/* Let’s Learn — calm, high-contrast, large-touch kiosk UI
   Tuned for a 10" 1800×1200 Surface Go. No flashing, no tight timers. */

:root {
  --bg: #EFE6D6;
  --bg-deep: #E4D8C4;
  --paper: #FFFBF3;
  --ink: #1E2A22;
  --ink-soft: #3A4A40;
  --line: #D4C6AE;
  --teal: #2E7868;
  --teal-deep: #21564B;
  --blue: #3D6E96;
  --blue-deep: #2B516F;
  --apricot: #C67A3A;
  --apricot-deep: #8F5424;
  --plum: #6B5B8F;
  --plum-deep: #4C3F68;
  --sage: #3E7A4C;
  --amber: #A56B1F;
  --quiet: #8A7B68;
  --shadow: 0 8px 0 rgba(30, 42, 34, 0.12);
  --radius: 28px;
  --tap: 96px;
  --header-h: 108px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Segoe UI Historic", Arial, sans-serif;
  font-weight: 600;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: default;
}

button {
  font-family: inherit;
  font-weight: 700;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px 20px 16px;
  max-width: 1800px;
  margin: 0 auto;
}

.topbar {
  height: var(--header-h);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 8px 18px;
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--teal-deep);
}

.icon-btn svg { width: 48px; height: 48px; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 4px 0 rgba(30, 42, 34, 0.12); }

.titles { flex: 1; text-align: center; }
.titles h1 {
  margin: 0;
  font-size: 42px;
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: var(--ink);
}
.titles p {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-soft);
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome, .prompt {
  margin: 4px 0 16px;
  font-size: 32px;
  color: var(--ink-soft);
  font-weight: 700;
}

.tiles {
  width: 100%;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 22px;
  padding: 4px 8px 12px;
}

.tile {
  background: var(--paper);
  border-radius: 36px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 160px;
  padding: 16px;
  border: 6px solid transparent;
}

.tile:active { transform: translateY(4px); box-shadow: 0 4px 0 rgba(30, 42, 34, 0.12); }

.tile-art {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  margin-bottom: 8px;
}
.tile-abc { border-color: var(--teal); color: var(--teal-deep); }
.tile-find { border-color: var(--blue); color: var(--blue-deep); }
.tile-count { border-color: var(--apricot); color: var(--apricot-deep); }
.tile-order { border-color: var(--plum); color: var(--plum-deep); }

.tile-art-find { display: flex; gap: 14px; align-items: center; }
.tile-art-find .dot {
  width: 70px; height: 70px; border-radius: 50%;
  background: #E8F0F6; display: flex; align-items: center; justify-content: center;
  font-size: 48px;
}
.tile-art-count { display: flex; gap: 16px; }
.tile-art-count .dot {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--apricot);
}
.tile-name { font-size: 34px; line-height: 1.1; }
.tile-hint { font-size: 22px; font-weight: 600; color: var(--ink-soft); }

/* ABC */
.stage {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-height: 0;
}
.nav-arrow {
  width: 100px;
  min-width: 100px;
  height: 160px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 80px;
  line-height: 1;
  color: var(--teal-deep);
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-arrow:active { transform: translateY(3px); }
.abc-focus {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}
.giant-glyph {
  font-size: 240px;
  font-weight: 800;
  line-height: 1;
  color: var(--teal-deep);
  min-width: 0.7em;
  text-align: center;
}
.picture-card {
  background: var(--paper);
  border-radius: 32px;
  box-shadow: var(--shadow);
  min-width: 280px;
  min-height: 280px;
  padding: 16px 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.picture-card:active { transform: translateY(3px); }
.picture-art { width: 200px; height: 200px; }
.picture-art svg { width: 100%; height: 100%; }
.picture-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 16px;
  display: block;
  pointer-events: none;
}
.picture-word {
  margin-top: 8px;
  font-size: 42px;
  line-height: 1.15;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.letter-board {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 8px;
  padding: 10px 0 4px;
  flex-shrink: 0;
}
.letter-key {
  min-height: 72px;
  height: 76px;
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(30, 42, 34, 0.10);
  font-size: 28px;
  font-weight: 800;
  color: var(--teal-deep);
}
.letter-key.current {
  background: var(--teal);
  color: #FFFBF3;
}
.letter-key:active { transform: translateY(2px); }

/* Find / feedback */
.target-card {
  width: min(320px, 40vw);
  height: 200px;
  border-radius: 32px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 150px;
  font-weight: 800;
  color: var(--blue-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  line-height: 1;
}
.choices {
  display: flex;
  gap: 24px;
  justify-content: center;
  width: 100%;
  flex-wrap: wrap;
}
.choice {
  width: 200px;
  height: 200px;
  min-width: 160px;
  border-radius: 32px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 120px;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.choice:active { transform: translateY(4px); }
.choice.correct {
  background: #E4F0E4;
  color: var(--sage);
  box-shadow: 0 8px 0 rgba(62, 122, 76, 0.25);
}
.choice.try-again {
  background: #F4EBDD;
  color: var(--amber);
}

.feedback {
  min-height: 56px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.feedback .mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 800;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 160ms ease, transform 160ms ease;
}
.feedback.show .mark { opacity: 1; transform: scale(1); }
.feedback.ok .mark { background: #E4F0E4; color: var(--sage); }
.feedback.again .mark { background: #F4EBDD; color: var(--amber); }

/* Count */
.count-scene {
  width: 100%;
  flex: 1;
  min-height: 200px;
  background: var(--paper);
  border-radius: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 12px 16px;
  padding: 16px 24px;
  margin-bottom: 16px;
}
.count-scene .obj { width: 92px; height: 92px; }
.count-scene .obj svg,
.count-scene .obj img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
  padding-bottom: 6px;
}
.num-key {
  min-height: 100px;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 40px;
  font-weight: 800;
  color: var(--apricot-deep);
}
.num-key:active { transform: translateY(3px); }
.num-key.correct {
  background: #E4F0E4;
  color: var(--sage);
}
.num-key.try-again {
  background: #F4EBDD;
  color: var(--amber);
}

/* Order */
.order-path {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 92px;
  margin-bottom: 16px;
}
.path-slot {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: var(--bg-deep);
  border: 4px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 800;
  color: var(--quiet);
}
.path-slot.filled {
  background: #E4F0E4;
  border-style: solid;
  border-color: var(--sage);
  color: var(--sage);
}
.order-pool {
  flex: 1;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 18px;
  min-height: 0;
}
.order-tile {
  width: 140px;
  height: 140px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 64px;
  font-weight: 800;
  color: var(--plum-deep);
  display: flex;
  align-items: center;
  justify-content: center;
}
.order-tile:active { transform: translateY(3px); }
.order-tile.used {
  visibility: hidden;
  pointer-events: none;
}
.order-tile.try-again {
  background: #F4EBDD;
  color: var(--amber);
}

/* Hidden parent-exit corner — dull, no icon */
#exit-corner {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 88px;
  height: 88px;
  background: transparent;
  z-index: 40;
  cursor: default;
}

/* PIN overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 42, 34, 0.45);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pin-card {
  background: var(--paper);
  border-radius: 32px;
  box-shadow: 0 16px 40px rgba(30, 42, 34, 0.25);
  padding: 28px 32px 20px;
  width: min(480px, 92vw);
  text-align: center;
}
.pin-card h2 { margin: 0 0 6px; font-size: 32px; }
.pin-card p { margin: 0 0 16px; font-size: 22px; color: var(--ink-soft); font-weight: 600; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin-bottom: 18px; }
.pin-dots span {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--teal);
  background: transparent;
}
.pin-dots span.on { background: var(--teal); }
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pin-key {
  min-height: 76px;
  border-radius: 18px;
  background: var(--bg);
  font-size: 32px;
  font-weight: 800;
  color: var(--ink);
}
.pin-key:active { background: var(--bg-deep); }
.pin-key.wide { grid-column: span 1; }
.pin-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.pin-action {
  min-height: 76px;
  border-radius: 20px;
  background: var(--bg);
  font-size: 26px;
  color: var(--ink);
}
.pin-action.primary { background: var(--teal); color: #FFFBF3; }
.pin-action.quiet { background: transparent; min-height: 56px; color: var(--ink-soft); font-size: 22px; }
.pin-cancel-link {
  margin-top: 14px;
  font-size: 22px;
  color: var(--ink-soft);
  min-height: 48px;
}
.pin-card.shake { animation: softnudge 280ms ease; }
@keyframes softnudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@media (max-width: 1200px) {
  .giant-glyph { font-size: 180px; }
  .picture-card { min-width: 220px; min-height: 220px; }
  .picture-art { width: 160px; height: 160px; }
  .letter-board { grid-template-columns: repeat(13, 1fr); }
  .number-pad { grid-template-columns: repeat(5, 1fr); }
  .num-key { min-height: 88px; }
  .choice { width: 160px; height: 160px; font-size: 100px; }
}
@media (max-width: 900px) {
  :root { --header-h: 96px; --tap: 84px; }
  .titles h1 { font-size: 32px; }
  .tile-name { font-size: 26px; }
  .letter-board { grid-template-columns: repeat(7, 1fr); }
  .giant-glyph { font-size: 140px; }
  .abc-focus { flex-direction: column; gap: 8px; }
  .nav-arrow { width: 72px; min-width: 72px; height: 120px; font-size: 60px; }
}

/* Parent settings */
#settings-overlay { z-index: 90; align-items: flex-start; overflow: auto; padding: 24px 16px; }
.settings-card {
  background: var(--paper);
  border-radius: 32px;
  box-shadow: 0 16px 40px rgba(30, 42, 34, 0.25);
  padding: 24px 28px 20px;
  width: min(860px, 96vw);
  margin: auto;
  text-align: left;
}
.settings-card h2 { margin: 0 0 18px; font-size: 32px; text-align: center; }
.settings-card h2 span { display: block; font-size: 18px; font-weight: 600; color: var(--ink-soft); margin-top: 2px; }
.set-label { display: block; font-size: 22px; font-weight: 800; margin: 12px 0 8px; }
.set-label span { font-size: 16px; font-weight: 600; color: var(--ink-soft); }
#set-playlist {
  width: 100%;
  min-height: 72px;
  border-radius: 18px;
  border: 3px solid var(--line);
  background: var(--bg);
  font-size: 22px;
  font-family: inherit;
  font-weight: 600;
  padding: 12px 16px;
  color: var(--ink);
}
#set-playlist:focus { outline: 3px solid var(--teal); border-color: var(--teal); }
.set-row { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 8px; }
.set-field { flex: 1 1 280px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.step-btn {
  min-width: 72px;
  min-height: 72px;
  border-radius: 18px;
  background: var(--bg);
  font-size: 36px;
  font-weight: 800;
  color: var(--teal-deep);
  box-shadow: var(--shadow);
}
.step-btn:active { transform: translateY(3px); }
.step-value {
  flex: 1;
  min-height: 72px;
  border-radius: 18px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
}
.set-status { min-height: 32px; font-size: 20px; font-weight: 700; color: var(--sage); text-align: center; }
.settings-card .pin-action { width: 100%; margin-top: 10px; }
.settings-card .pin-action.quiet { min-height: 64px; }

/* Reward */
.reward-play {
  width: min(280px, 70vw);
  height: min(280px, 70vw);
  border-radius: 50%;
  background: var(--paper);
  color: var(--teal-deep);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: auto;
}
.reward-play svg { width: 70%; height: 70%; }
.reward-play:active { transform: translateY(4px); }
.reward-stage { width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.reward-frame-wrap { flex: 1; min-height: 240px; background: #111; border-radius: 20px; overflow: hidden; }
.reward-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.reward-progress { height: 10px; margin-top: 12px; background: var(--bg-deep); border-radius: 999px; overflow: hidden; }
#reward-bar { height: 100%; width: 100%; background: var(--teal); transform-origin: left center; }
