:root {
  --bg: #FFFFFF;
  --surface: #F5F7FA;
  --primary: #1CB0F6;
  --success: #58CC02;
  --error: #FF4B4B;
  --reward: #FFC800;
  --cta: #FF9600;
  --text: #4B4B4B;
  --radius: 22px;
  --tap: 64px;
  --card-shadow: 0 8px 20px rgba(70, 110, 160, 0.14);
  --font-en: 'Andika', system-ui, sans-serif;
  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-th: 'Noto Sans Thai', system-ui, sans-serif;
}

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

html, body {
  margin: 0; padding: 0; min-height: 100%;
  color: var(--text);
  font-family: var(--font-th);
  font-size: 20px;
  overscroll-behavior: none;
}

/* Soft Storybook Sky — atmosphere instead of a flat white page */
body {
  background:
    radial-gradient(circle at 50% -8%, #FFF7D6 0%, rgba(255, 247, 214, 0) 42%),
    linear-gradient(180deg, #BCE6FF 0%, #D6F2EA 48%, #FFF7E8 100%);
  background-attachment: fixed;
}
/* Drifting clouds, kept faint so words stay the hero */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(70px 44px at 14% 18%, rgba(255,255,255,.75), transparent 72%),
    radial-gradient(96px 56px at 82% 12%, rgba(255,255,255,.6), transparent 72%),
    radial-gradient(80px 50px at 72% 64%, rgba(255,255,255,.45), transparent 72%),
    radial-gradient(60px 38px at 24% 80%, rgba(255,255,255,.5), transparent 72%);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translateY(0) translateX(0); }
  to   { transform: translateY(-14px) translateX(10px); }
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

.screen {
  position: relative;
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center;            /* center short screens; kills the empty-bottom look */
  padding: 24px 16px; gap: 22px; max-width: 760px; margin: 0 auto; width: 100%;
  animation: screenIn .42s cubic-bezier(.2,.8,.3,1.2) both;
}
/* The stage path is taller than the viewport — pin to top and clear the floating bar */
.screen:has(.path) { justify-content: flex-start; padding-top: 92px; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.title {
  font-family: var(--font-display); font-size: 30px; font-weight: 700;
  margin: 0; text-align: center; color: #2b3a55;
  text-shadow: 0 2px 0 rgba(255,255,255,.6);
}
.word-en { font-family: var(--font-en); font-size: 42px; font-weight: 700; color: #2b3a55; }
.word-th { font-family: var(--font-th); font-size: 28px; line-height: 1.7; color: #41506b; }
.emoji-big { font-size: 104px; line-height: 1.1; filter: drop-shadow(0 6px 10px rgba(70,110,160,.22)); }
.game-area .emoji-big { animation: floaty 3.4s ease-in-out infinite; }
@keyframes floaty {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-12px); }
}

/* Buttons: pill, 3D pressable */
.btn {
  font-family: var(--font-display); font-size: 22px; font-weight: 700;
  min-height: var(--tap); min-width: var(--tap);
  padding: 14px 30px; border: none; border-radius: var(--radius);
  background: var(--primary); color: #fff; cursor: pointer;
  box-shadow: 0 5px 0 #128fcb, var(--card-shadow);
  transition: transform .05s, box-shadow .05s; touch-action: manipulation;
}
.btn:active { transform: translateY(5px); box-shadow: 0 0 0 #128fcb, var(--card-shadow); }
.btn--cta { background: var(--cta); box-shadow: 0 5px 0 #d97e00, var(--card-shadow); }
.btn--cta:active { box-shadow: 0 0 0 #d97e00, var(--card-shadow); }
.btn--success { background: var(--success); box-shadow: 0 5px 0 #469e00, var(--card-shadow); }
.btn--success:active { box-shadow: 0 0 0 #469e00, var(--card-shadow); }
.btn--ghost { background: #fff; color: var(--text); box-shadow: 0 5px 0 #d8dee6, var(--card-shadow); }
.btn--ghost:active { box-shadow: 0 0 0 #d8dee6, var(--card-shadow); }

/* Cards */
.card {
  background: #fff; border-radius: var(--radius);
  padding: 20px; min-height: var(--tap); display: flex;
  align-items: center; justify-content: center; cursor: pointer;
  border: 3px solid transparent; box-shadow: var(--card-shadow);
  transition: transform .08s, border-color .12s, background .12s, box-shadow .12s;
  user-select: none; touch-action: manipulation;
}
.card:active { transform: scale(0.96); }
.card.correct { border-color: var(--success); background: #eaffd6; box-shadow: 0 0 0 4px rgba(88,204,2,.25), var(--card-shadow); }
.card.wrong { border-color: var(--error); background: #ffe5e5; animation: shake .3s; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
@keyframes bounce {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.bounce { animation: bounce .3s; }

/* Grids */
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; width: 100%; }
.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; width: 100%; margin: auto 0; }
/* Staggered entrance for the world cards */
.world-grid > * { animation: popIn .4s cubic-bezier(.2,.8,.3,1.3) both; }
.world-grid > *:nth-child(1) { animation-delay: .05s; }
.world-grid > *:nth-child(2) { animation-delay: .12s; }
.world-grid > *:nth-child(3) { animation-delay: .19s; }
.world-grid > *:nth-child(4) { animation-delay: .26s; }
.world-grid > *:nth-child(5) { animation-delay: .33s; }
.world-grid > *:nth-child(6) { animation-delay: .40s; }
@keyframes popIn {
  from { opacity: 0; transform: scale(.8) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Top bar — floats at the top so the game can centre in the space below */
.topbar {
  position: absolute; top: 16px; left: 16px; right: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; z-index: 5;
}
.progress-dots { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 2px rgba(70,110,160,.18); transition: background .2s; }
.dot.done { background: var(--success); box-shadow: none; }
.icon-btn {
  font-size: 28px; background: #fff; border: none; border-radius: 50%;
  width: var(--tap); height: var(--tap); cursor: pointer;
  box-shadow: 0 4px 0 #d8dee6, var(--card-shadow); transition: transform .05s, box-shadow .05s;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 #d8dee6, var(--card-shadow); }
/* The speak button matters most for pre-readers — make it pop */
.icon-btn--speak {
  background: var(--primary); color: #fff; width: 72px; height: 72px; font-size: 32px;
  box-shadow: 0 5px 0 #128fcb, var(--card-shadow);
  animation: pulse 2.2s ease-in-out infinite;
}
.icon-btn--speak:active { transform: translateY(5px); box-shadow: 0 0 0 #128fcb, var(--card-shadow); animation: none; }
@keyframes pulse {
  0%,100% { box-shadow: 0 5px 0 #128fcb, 0 0 0 0 rgba(28,176,246,.45); }
  50%     { box-shadow: 0 5px 0 #128fcb, 0 0 0 14px rgba(28,176,246,0); }
}

/* World card */
.world-card {
  position: relative; overflow: hidden;
  flex-direction: column; gap: 6px; min-height: 184px; padding: 22px 16px 18px;
  color: #fff; font-family: var(--font-display);
  text-shadow: 0 2px 4px rgba(0,0,0,.18);
}
.world-card .emoji-big { font-size: 58px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.2)); }
.world-card__name { font-size: 18px; opacity: .95; }
.world-card .word-th { color: #fff; font-weight: 700; line-height: 1.4; }
.world-card.locked { cursor: not-allowed; }
.world-card.locked::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: rgba(255,255,255,.5);
}
.world-card.locked .emoji-big { opacity: .85; }
.world-card__lock { position: absolute; top: 10px; right: 12px; font-size: 26px; z-index: 2; filter: drop-shadow(0 2px 3px rgba(0,0,0,.2)); }
.stars { color: #fff; font-size: 22px; letter-spacing: 1px; font-weight: 700; }

/* Stage path */
.path { display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 12px 0 40px; width: 100%; }
.node {
  width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-family: var(--font-display); font-size: 30px; color: #fff;
  background: var(--primary); box-shadow: 0 6px 0 #128fcb, var(--card-shadow); cursor: pointer; border: none;
}
.node.cleared { background: var(--reward); box-shadow: 0 6px 0 #d9a800, var(--card-shadow); }
.node.locked { background: #fff; color: #b7c0cc; box-shadow: 0 6px 0 #d8dee6, var(--card-shadow); cursor: not-allowed; }
.node.current { animation: nodepop 1.1s ease-in-out infinite; }
@keyframes nodepop {
  0%,100% { transform: scale(1) translateY(0); }
  50%     { transform: scale(1.08) translateY(-4px); }
}
.node.boss { width: 100px; height: 100px; font-size: 40px; }
.node:nth-child(even) { align-self: flex-end; margin-right: 20%; }
.node:nth-child(odd)  { align-self: flex-start; margin-left: 20%; }

/* Word Build */
.slots { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.slot {
  width: 68px; height: 80px; border-radius: 16px; border: 3px dashed #b9c4d4;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-en); font-size: 38px; font-weight: 700; color: #2b3a55;
  background: rgba(255,255,255,.7);
}
.slot.filled { border-style: solid; border-color: var(--primary); background: #fff; }
.slot.correct { border-color: var(--success); background: #eaffd6; }
.slot.wrong { border-color: var(--error); background: #ffe5e5; animation: shake .3s; }
.tiles { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 24px; min-height: 86px; touch-action: none; }
.tile {
  width: 68px; height: 80px; border-radius: 16px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-en); font-size: 38px; font-weight: 700; cursor: grab;
  box-shadow: 0 5px 0 #128fcb, var(--card-shadow); user-select: none; touch-action: none;
}
.tile.dragging { opacity: .9; cursor: grabbing; transform: scale(1.08); }
.game-area { touch-action: none; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* Result */
.result-stars { font-size: 72px; color: var(--reward); filter: drop-shadow(0 4px 6px rgba(217,168,0,.4)); animation: bounce .6s ease; }
.celebrate { font-family: var(--font-display); font-size: 34px; font-weight: 700; color: var(--success); }

/* Error screen */
.error-box { background: #fff; border-radius: var(--radius); padding: 28px; text-align: center; box-shadow: var(--card-shadow); }
