/* Tablet shell: pinned chrome, flexible play area, deliberately contained lists. */
:root {
  --ink: #203c46;
  --muted: #526e76;
  --aqua: #68d9c3;
  --violet: #6854b8;
  --coral: #e97965;
  --sun: #f5ca67;
  --paper: #fffdf7;
  --lav: #ece9f6;
}
html,
body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: #e8f2ef;
  color: var(--ink);
}
button,
a,
input {
  touch-action: manipulation;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #187d72;
  outline-offset: 3px;
}
.shell {
  height: 100dvh;
  max-width: 1440px;
  padding: max(16px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  gap: 16px;
}
.topbar {
  margin: 0;
  min-height: 54px;
}
.brand-name,
.brand small,
.progress-meta {
  color: var(--ink);
}
.brand-mark {
  background: #237e73;
  box-shadow: none;
  color: white;
  border-radius: 18px;
}
.top-actions {
  gap: 8px;
}
.icon-btn,
.player-chip {
  background: #fffdf7;
  color: var(--ink);
  box-shadow: 0 2px 0 #c6d9d4;
}
.icon-btn {
  min-width: 44px;
  min-height: 44px;
}
.track {
  background: #cbded8;
}
.track-fill {
  background: #278779;
}
.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  min-height: 0;
  gap: 16px;
}
.main-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: 24px;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #d3e2db;
  background: #fffdf7;
  border-radius: 28px;
  box-shadow: 0 5px 0 #cfdfd8;
}
.question-zone {
  align-self: center;
  padding: 12px 0;
  text-align: center;
}
.question {
  font-size: clamp(36px, 5vw, 60px);
  line-height: 1.15;
  margin: 12px 0;
  color: var(--ink);
}
.question.word {
  font-size: clamp(25px, 3.6vw, 38px);
  max-width: 680px;
  margin: 10px auto;
}
.question-kicker {
  color: #54717a;
}
.question-sub {
  font-size: 13px;
  margin: 8px 0;
  color: var(--muted);
}
.question-visual:empty {
  display: none;
}
.question-visual svg {
  display: block;
  width: min(320px, 100%);
  height: 118px;
  margin: 8px auto;
  overflow: visible;
}
.question-visual rect,
.question-visual circle {
  fill: #e8f4f0;
  stroke: #278779;
  stroke-width: 2;
}
.question-visual .shaded {
  fill: #68d9c3;
}
.question-visual .tick {
  fill: #203c46;
  stroke: none;
}
.question-visual text {
  font: 600 16px system-ui;
  fill: var(--ink);
  text-anchor: middle;
}
.question-visual path {
  fill: none;
  stroke: #203c46;
  stroke-width: 3;
  stroke-linecap: round;
}
.answer-mode {
  margin: 0 0 12px;
  padding: 5px;
  border-radius: 18px;
  background: #ecf1ed;
}
.mode-btn {
  min-height: 46px;
  color: #426069;
}
.mode-btn.active {
  background: #237e73;
  color: white;
  box-shadow: none;
}
.choices {
  gap: 12px;
}
.choice {
  min-height: 76px;
  border-radius: 20px;
  background: #edeaf8;
  color: #43377b;
  box-shadow: 0 4px 0 #d5cee9;
  border: 1px solid #dcd5ee;
}
.choice:nth-child(2) {
  background: #e0f2ec;
  color: #236356;
  box-shadow: 0 4px 0 #bfded2;
}
.choice:nth-child(3) {
  background: #fcf0d6;
  color: #765b22;
  box-shadow: 0 4px 0 #e8d6ac;
}
.choice:nth-child(4) {
  background: #fae8e0;
  color: #854c39;
  box-shadow: 0 4px 0 #e9cabc;
}
.feedback {
  min-height: 30px;
  margin: 12px 0 0;
  font-size: 14px;
}
.keypad-view.show {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 1.3fr);
  gap: 16px;
}
.input-well {
  min-height: 0;
  background: #edf3ef;
  box-shadow: none;
  border: 1px solid #d2e1d9;
}
.answer-input {
  color: var(--ink);
  font-size: 40px;
  min-width: 0;
  width: 100%;
}
.number-pad {
  gap: 7px;
  max-width: none;
}
.num {
  min-height: 44px;
  height: 44px;
  background: #eeeaf6;
  color: #43377b;
  box-shadow: 0 2px 0 #d4cce5;
}
.num.go {
  background: #237e73;
  color: white;
  box-shadow: 0 2px 0 #175b53;
}
.side {
  overflow: auto;
  overscroll-behavior: contain;
  align-content: start;
}
.panel {
  background: #fffdf7;
  color: var(--ink);
  border: 1px solid #d3e2db;
  box-shadow: none;
  border-radius: 22px;
}
.panel-title {
  color: var(--ink);
}
.home-modal {
  background: #e8f2ef;
  padding: 20px;
}
.home-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 16px;
  width: min(1160px, 100%);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.home-top {
  padding: 0;
  min-height: 52px;
}
.home-hero {
  padding: 18px 24px;
  grid-template-columns: minmax(0, 1fr) 180px;
  background: #d4e9e1;
  border-radius: 28px;
  gap: 18px;
}
.home-copy h1 {
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.02;
  color: #203c46;
  margin: 8px 0;
}
.home-copy > p {
  color: #42636a;
  font-size: 14px;
  max-width: 520px;
  margin: 10px 0;
}
.home-orbit {
  min-height: 180px;
}
.home-planet {
  width: 140px;
  height: 140px;
  font-size: 66px;
  box-shadow: 0 8px 0 #d2a54d;
}
.orbit-chip {
  font-size: 10px;
}
.home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.home-action {
  min-height: 66px;
  padding: 12px;
  border-radius: 16px;
  box-shadow: 0 3px 0 #bccfc7;
}
.home-action strong {
  font-size: 16px;
}
.home-action.arcade {
  grid-column: auto;
}
.coin-vault {
  padding: 6px 12px 6px 6px;
  grid-template-columns: 38px auto;
  box-shadow: none;
}
.coin-orb {
  width: 38px;
  height: 38px;
  font-size: 24px;
}
.coin-vault b {
  font-size: 24px;
}
.home-dashboard {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.home-card {
  background: #fffdf7;
  color: var(--ink);
  padding: 18px;
  border-radius: 24px;
  box-shadow: none;
  border: 1px solid #d3e2db;
}
.home-card h2 {
  font-size: 23px;
}
.home-card > p,
.collection-head p {
  color: var(--muted);
  font-size: 12px;
}
.skill-map {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.skill-chip {
  padding: 8px 4px;
  background: #edf3ef;
  color: var(--ink);
}
.skill-chip small {
  font-size: 10px;
}
.home-note {
  font-size: 11px;
  color: var(--muted);
}
.collection-card {
  grid-column: 1/-1;
  display: block;
}
.buddy-shelf {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.buddy-slot {
  padding: 10px 4px;
  min-height: 90px;
  background: #edf3ef;
}
.buddy-slot .collectable-portrait {
  width: 64px;
  height: 64px;
}
.buddy-slot small {
  display: block;
}
.collection-open {
  min-height: 44px;
  margin-top: 10px;
}
.home-collection-top {
  min-height: 44px;
}
.intro,
.lesson-modal,
.finish-modal,
.switch-modal,
.bonus-modal,
.collection-modal,
.arcade-modal {
  overscroll-behavior: none;
}
.intro-card,
.modal-card,
.theme-card,
.bonus-card {
  max-height: calc(100dvh - 40px);
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 8px 0 #162f3433;
  border-radius: 28px;
}
.intro-form {
  background: #fffdf7;
}
.skill-btn {
  min-height: 80px;
}
.collection-shell {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.collection-grid {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.collection-detail-card {
  overscroll-behavior: contain;
}
.lesson-options button {
  min-height: 52px;
}
.lesson-visual svg {
  height: 100px;
}
.arcade-shell {
  overflow: auto;
  overscroll-behavior: contain;
}
.arcade-modal {
  background: #e8f2ef;
}
[data-theme="dark"] body {
  background: #142c32;
  color: #edf6f2;
}
[data-theme="dark"] .home-modal,
[data-theme="dark"] .arcade-modal {
  background: #142c32;
}
[data-theme="dark"] .main-card,
[data-theme="dark"] .panel,
[data-theme="dark"] .home-card {
  background: #203c43;
  color: #edf6f2;
  border-color: #3b5960;
}
[data-theme="dark"] .home-hero {
  background: #294c50;
}
[data-theme="dark"] .question,
[data-theme="dark"] .home-copy h1,
[data-theme="dark"] .brand-name,
[data-theme="dark"] .brand small,
[data-theme="dark"] .progress-meta,
[data-theme="dark"] .panel-title {
  color: #edf6f2;
}
[data-theme="dark"] .question-sub,
[data-theme="dark"] .question-kicker,
[data-theme="dark"] .home-copy > p,
[data-theme="dark"] .home-card > p,
[data-theme="dark"] .collection-head p,
[data-theme="dark"] .home-note {
  color: #bdd4d2;
}
[data-theme="dark"] .question-visual text {
  fill: #edf6f2;
}
@media (orientation: portrait) {
  .topbar {
    flex-wrap: wrap;
  }
  .run-progress {
    order: 3;
    flex: 0 0 100%;
    max-width: none;
  }
  .game-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .side {
    display: grid;
    grid-template-columns: 1fr;
    overflow: hidden;
  }
  .side > .panel:not(:first-child) {
    display: none;
  }
  .side > .panel:first-child {
    padding: 10px 16px;
  }
  .side > .panel:first-child .panel-title {
    display: none;
  }
  .stat-row {
    gap: 12px;
  }
  .stat {
    padding: 6px;
  }
  .main-card {
    padding: 22px;
  }
  .home-hero {
    grid-template-columns: 1fr;
  }
  .home-orbit {
    display: none;
  }
  .home-dashboard {
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .home-copy h1 {
    font-size: 48px;
  }
  .home-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }
}
@media (max-width: 600px), (max-height: 720px) {
  .shell,
  .home-modal {
    padding: 10px;
    gap: 8px;
  }
  .main-card {
    padding: 14px;
  }
  .question {
    font-size: 32px;
  }
  .question.word {
    font-size: 22px;
  }
  .question-visual svg {
    height: 80px;
  }
  .question-sub {
    display: none;
  }
  .choice {
    min-height: 54px;
  }
  .question-zone {
    padding: 4px 0;
  }
  .home-shell {
    gap: 8px;
  }
  .home-hero {
    padding: 12px;
  }
  .home-copy h1 {
    font-size: 34px;
  }
  .home-copy > p {
    display: none;
  }
  .home-card {
    padding: 10px;
  }
  .home-dashboard {
    gap: 8px;
  }
  .home-card h2 {
    font-size: 18px;
  }
  .buddy-slot .collectable-portrait {
    width: 40px;
    height: 40px;
  }
  .buddy-slot {
    min-height: 64px;
    padding: 5px 2px;
  }
  .buddy-slot small {
    display: none;
  }
  .home-actions {
    gap: 6px;
  }
  .home-action {
    padding: 8px;
    min-height: 52px;
  }
  .home-action strong {
    font-size: 13px;
  }
  .home-action small {
    font-size: 9px;
  }
  .skill-chip {
    padding: 5px 2px;
  }
  .home-note {
    display: none;
  }
  .keypad-view.show {
    grid-template-columns: 100px 1fr;
  }
  .num {
    height: 38px;
    min-height: 38px;
  }
  .feedback {
    font-size: 12px;
    min-height: 22px;
  }
  .answer-mode {
    margin-bottom: 8px;
  }
  .mode-btn {
    min-height: 40px;
  }
}
.home-dashboard {
  height: 100%;
  margin: 0;
  align-self: stretch;
  grid-template-rows: auto auto;
}
.home-copy h1 span,
.brand-name span {
  color: #237e73;
}
.home-action.maths {
  background: #237e73;
  color: white;
}
.home-action.quick {
  background: #f5ca67;
}
.home-action.arcade,
.arcade-btn {
  background: #6854b8;
}
.home-stat b {
  color: #237e73;
}
.home-stat small {
  color: #526e76;
}
.home-note {
  color: #526e76;
}
.orb {
  display: none;
}
body {
  background-image: none;
}
.answer-mode {
  width: 100%;
  max-width: none;
}
.main-card:before,
.main-card:after {
  display: none;
}
[data-theme="light"] body {
  background: #e8f2ef;
}
[data-theme="dark"] .home-copy h1 span,
[data-theme="dark"] .brand-name span,
[data-theme="dark"] .home-stat b {
  color: #68d9c3;
}
[data-theme="dark"] .home-stat small {
  color: #bdd4d2;
}
body,
button,
input,
.display,
.home-action strong,
.home-stat b,
.choice,
.num {
  font-family: "Space Grotesk", "Avenir Next", system-ui, sans-serif;
}
.buddy-slot.locked {
  opacity: 0.65;
}
.home-copy > p {
  font-size: 14px;
}
.collection-detail-card,
.bonus-card,
.theme-card {
  background: #fffdf7;
  color: #203c46;
}
.lesson-modal .modal-card {
  background: #fffdf7;
  color: #203c46;
}
.lesson-body {
  color: #526e76;
}
.finish-modal .modal-card {
  overflow: auto;
  overscroll-behavior: contain;
}
.intro {
  background: #d4e9e1;
}
.intro-art {
  background: #237e73;
}
.intro-form h1,
.intro-form h2 {
  color: #203c46;
}
.primary-btn {
  background: #237e73;
  color: white;
  box-shadow: 0 4px 0 #195c54;
}
.start-btn {
  background: #237e73;
  box-shadow: 0 4px 0 #195c54;
}
.skill-btn.active {
  background: #e0f2ec;
  border-color: #237e73;
  box-shadow: 0 4px 0 #b8d8cd;
}
.skill-btn.active:after {
  background: #237e73;
  color: white;
}
.intro-form a {
  color: #55429c;
}
.arcade-hero h1 span {
  color: #237e73;
}
.game-tile.maze {
  background: #d9eee6;
}
.game-tile.jump {
  background: #e7e2f5;
}
.game-tile.blast {
  background: #f8e3da;
}
.game-tile {
  box-shadow: 0 5px 0 #c6d9d4;
  border: 1px solid #d0dfd8;
}
.game-tile h3 {
  color: #203c46;
  font-size: 26px;
}
.game-tile p {
  color: #42636a;
  font-size: 13px;
}
.game-meta span {
  background: #ffffff90;
  color: #334f57;
}
.play-game {
  background: #237e73;
  color: white;
  min-height: 52px;
  box-shadow: 0 3px 0 #195c54;
}
.collection-modal {
  background: #142c32b8;
}
.collection-panel {
  background: #fffdf7;
  color: #203c46;
  box-shadow: 0 5px 0 #162f3433;
}
.collection-panel-head p,
.collection-summary {
  color: #526e76;
}
.collection-summary strong {
  color: #237e73;
}
.collection-tab {
  min-height: 44px;
  background: #edf3ef;
  color: #334f57;
  border-color: #d3e2db;
}
.collection-tab.active {
  background: #237e73;
  color: white;
  border-color: #237e73;
  box-shadow: none;
}
.collection-close {
  background: #edf3ef;
  color: #203c46;
}
.collection-card-item {
  background: #edf3ef;
  border-color: #d3e2db;
  min-height: 135px;
}
.collection-card-item.locked {
  opacity: 0.7;
}
.collection-card-item strong {
  color: #203c46;
}
.collection-card-item small {
  color: #526e76;
}
.collection-detail-card {
  box-shadow: 0 5px 0 #162f3433;
}
.collection-detail-card > p:not(.collection-detail-rarity) {
  color: #526e76;
}
@media (orientation: portrait) and (min-width: 600px) {
  .collection-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
  .collection-card-item .collectable-portrait {
    width: 82px;
    height: 82px;
  }
  .collection-card-item strong {
    font-size: 13px;
  }
}
[data-theme="dark"] .collection-panel {
  background: #203c43;
  color: #edf6f2;
}
[data-theme="dark"] .collection-panel-head p,
[data-theme="dark"] .collection-summary {
  color: #bdd4d2;
}
[data-theme="dark"] .collection-summary strong,
[data-theme="dark"] .arcade-hero h1 span {
  color: #68d9c3;
}
.app {
  background: #e8f2ef;
}
.app::before {
  display: none;
}
[data-theme="dark"] .app {
  background: #142c32;
}
.theme-fab {
  position: static;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  font-size: 20px;
  border-radius: 14px;
  box-shadow: 0 2px 0 #c6d9d4;
}
.intro-form > .theme-fab {
  margin-left: auto;
}

/* Cabinet controls stay above the scrolling shelf. */
.home-dashboard {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(140px, 1fr);
}
.collection-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.collection-head {
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 10px;
}
.collection-head .collection-open {
  width: auto;
  margin: 0 0 0 auto;
  flex-shrink: 0;
  min-height: 48px;
}
.collection-card .buddy-shelf {
  overflow: auto;
  min-height: 0;
}
.home-collection-top {
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.collection-detail-modal {
  padding: 0;
}
.collection-detail-modal .collection-detail-card {
  width: 100%;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  box-shadow: none;
  isolation: isolate;
}
.collection-detail-card .collection-detail-art,
.collection-detail-card .collection-detail-art.has-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}
.collection-detail-art .collectable-character {
  inset: 5% 38% 5% 2%;
  width: 60%;
  height: 90%;
  animation: collectable-drift 7s ease-in-out infinite;
  filter: drop-shadow(0 20px 20px #102a3440);
}
.collection-detail-card .collection-detail-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 48px;
  height: 48px;
  z-index: 5;
  background: #fffdf7;
  color: #203c46;
}
.collection-detail-info {
  position: absolute;
  right: max(24px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  width: min(360px, 35%);
  max-height: calc(100dvh - 150px);
  overflow: auto;
  padding: 24px;
  border-radius: 24px;
  background: #fffdf7ed;
  color: #203c46;
  box-shadow: 0 12px 40px #102a3433;
  backdrop-filter: blur(16px);
  z-index: 3;
}
.collection-detail-info > p:not(.collection-detail-rarity) {
  font-size: 14px;
  line-height: 1.5;
  margin: 12px 0;
  color: #526e76;
}
.collection-detail-info > strong {
  display: block;
  margin-top: 12px;
}
.collection-detail-info .collection-trade {
  margin-top: 12px;
}
@keyframes collectable-drift {
  0%,
  100% {
    transform: translateY(0) rotate(-0.6deg);
  }
  50% {
    transform: translateY(-10px) rotate(0.6deg);
  }
}
@media (max-width: 700px), (orientation: portrait) {
  .collection-detail-art .collectable-character {
    inset: 4% 5% auto;
    width: 90%;
    height: 54%;
  }
  .collection-detail-info {
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 16px;
    left: 16px;
    width: auto;
    max-height: 40dvh;
    transform: none;
    padding: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .collection-detail-art .collectable-character {
    animation: none;
  }
}
