:root {
  --ink: #27343a;
  --yellow: #ffd166;
  --coral: #e56b55;
  --blue: #61b7d8;
  --green: #66bf74;
  --font-display: 'Fredoka', 'Arial Rounded MT Bold', sans-serif;
  --font-body: 'Nunito', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: #dceff5; color: var(--ink); font-family: var(--font-body); user-select: none; -webkit-user-select: none; }
button { font: inherit; -webkit-tap-highlight-color: transparent; }

.game-shell { background: #fff; box-shadow: 0 0 44px rgba(24, 65, 82, .18); inset: 0; margin: 0 auto; max-width: 1280px; overflow: hidden; position: fixed; }
.topbar { align-items: center; background: rgba(255,255,255,.96); border-bottom: 2px solid #dbe9ed; display: grid; gap: 18px; grid-template-columns: 1fr auto auto auto; height: 68px; padding: 0 22px; position: relative; z-index: 30; }
.brand { align-items: center; color: #d75c48; display: flex; font-family: var(--font-display); font-size: 23px; font-weight: 700; gap: 9px; }
.brand-mark { align-items: center; background: var(--yellow); border-radius: 8px; display: flex; height: 40px; justify-content: center; width: 40px; }
.hud-progress, .hud-score { align-items: center; background: #fff; border: 2px solid #dbe6e9; border-radius: 999px; display: flex; font-size: 16px; font-weight: 900; gap: 8px; min-height: 43px; padding: 5px 14px; }
.hud-progress strong { color: #16806f; font-size: 18px; }
.hud-score { background: #313d42; border-color: #313d42; color: #fff; }
.language { background: #fff; border: 2px solid #d9e3e5; border-radius: 999px; color: #657176; cursor: pointer; min-height: 44px; min-width: 103px; }
.language strong { color: var(--ink); }
.language.is-zh strong { color: #657176; }
.language.is-zh span:last-child { color: var(--ink); font-weight: 900; }

.board { background: linear-gradient(#7fd1ed 0 68%, #8bd47f 68% 100%); height: calc(100% - 68px); overflow: hidden; position: relative; touch-action: none; transition: background 360ms ease; }
.board::after { background: repeating-linear-gradient(90deg, transparent 0 80px, rgba(255,255,255,.15) 80px 82px); bottom: 0; content: ''; height: 32%; left: 0; pointer-events: none; position: absolute; right: 0; z-index: 0; }
.board[data-stage="fruits"] { background: linear-gradient(#ffd6a0 0 68%, #89c96f 68% 100%); }
.board[data-stage="veggies"] { background: linear-gradient(#a7dfbf 0 68%, #70bd66 68% 100%); }
.board[data-stage="ocean"] { background: linear-gradient(#58bfe2 0 68%, #2389ad 68% 100%); }
.board[data-stage="ocean"]::after { background: repeating-radial-gradient(ellipse at bottom, rgba(255,255,255,.18) 0 5px, transparent 6px 44px); }
.board[data-stage="vehicles"] { background: linear-gradient(#f6b8c5 0 68%, #68777c 68% 100%); }
.board[data-stage="vehicles"]::after { background: repeating-linear-gradient(90deg, transparent 0 110px, rgba(255,255,255,.72) 110px 158px, transparent 158px 230px); height: 8px; bottom: 15%; }
.sky-decoration { pointer-events: none; position: absolute; z-index: 1; }
.sun { font-size: 74px; right: 5%; top: 6%; animation: spin 16s linear infinite; }
.cloud { font-size: 64px; opacity: .92; }
.cloud-one { top: 12%; animation: cloudTravel 22s linear infinite; }
.cloud-two { top: 33%; animation: cloudTravel 29s linear infinite -11s; }

.stage-label { background: rgba(255,255,255,.93); border: 0; border-radius: 8px; box-shadow: 0 6px 16px rgba(29,77,93,.15); color: var(--ink); cursor: pointer; left: 18px; padding: 10px 15px; position: absolute; text-align: left; top: 16px; z-index: 12; }
.stage-label span { display: block; font-family: var(--font-display); font-size: 22px; }
.stage-label small { align-items: center; color: #557078; display: flex; font-size: 13px; font-weight: 900; gap: 7px; margin-top: 1px; }
.stage-label small b { background: #e7f1f2; border-radius: 999px; color: #16806f; padding: 1px 6px; }
.stage-label small i { font-style: normal; }

.hero { align-items: center; background: linear-gradient(135deg, #fff1d9, #ffb8c4); border: 5px solid #fff; border-radius: 50%; box-shadow: 0 7px 0 rgba(167,84,98,.36), 0 12px 24px rgba(47,62,68,.24); cursor: grab; display: flex; font-size: 53px; height: 88px; justify-content: center; left: 50%; padding: 0; position: absolute; top: 55%; transform: translate(-50%, -50%); transition: transform 120ms ease; width: 88px; z-index: 15; animation: heroBounce .62s ease-in-out infinite; }
.hero.is-moving { animation-duration: .28s; }
.hero.is-hit { animation: hitGlow .48s ease; }

.target { background: transparent; border: 0; cursor: pointer; height: 132px; padding: 0; position: absolute; width: 126px; z-index: 8; }
.target-card { background: #fff; border: 5px solid #fff; border-radius: 18px; box-shadow: 0 7px 16px rgba(31,72,82,.22); height: 104px; overflow: hidden; position: relative; transition: border-color 160ms ease, transform 160ms ease; width: 126px; }
.target.is-near .target-card { border-color: var(--yellow); transform: scale(1.08); }
.target-card img { height: 100%; object-fit: cover; pointer-events: none; width: 100%; }
.target[data-item-id="dog"] img { object-position: 72% center; }
.target-name { background: rgba(255,255,255,.96); border-radius: 999px; bottom: 0; box-shadow: 0 3px 8px rgba(34,63,70,.18); color: var(--ink); display: flex; font-size: 14px; font-weight: 900; gap: 5px; justify-content: center; left: 50%; min-width: 94px; padding: 4px 9px; position: absolute; transform: translateX(-50%); white-space: nowrap; }
.target-bob { animation: targetBob 2.4s ease-in-out infinite; height: 100%; width: 100%; }

.control-dock { bottom: 18px; display: grid; gap: 4px; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 58px); position: absolute; right: 20px; z-index: 20; }
.control { background: rgba(255,255,255,.96); border: 3px solid #fff; border-radius: 15px; box-shadow: 0 5px 0 rgba(36,73,83,.26); color: #2a5966; cursor: pointer; font-size: 25px; font-weight: 900; touch-action: none; }
.control:active, .control.is-active { background: var(--yellow); transform: translateY(3px); box-shadow: 0 2px 0 rgba(36,73,83,.26); }
.control.up { grid-column: 2; grid-row: 1; }
.control.left { grid-column: 1; grid-row: 2; }
.control.right { grid-column: 3; grid-row: 2; }
.control.down { grid-column: 2; grid-row: 3; }
.control-center { align-items: center; background: rgba(45,61,67,.82); border-radius: 15px; color: #fff; display: flex; font-size: 28px; grid-column: 2; grid-row: 2; justify-content: center; }
.help { background: rgba(255,255,255,.96); border: 3px solid #fff; border-radius: 50%; bottom: 20px; box-shadow: 0 5px 12px rgba(42,69,77,.22); color: #276473; cursor: pointer; font-family: var(--font-display); font-size: 24px; height: 54px; left: 20px; position: absolute; width: 54px; z-index: 20; }

.word-toast { align-items: center; background: rgba(255,255,255,.97); border: 4px solid var(--yellow); border-radius: 8px; box-shadow: 0 12px 30px rgba(36,61,68,.28); display: flex; gap: 12px; left: 50%; opacity: 0; padding: 9px 14px; pointer-events: none; position: absolute; top: 18%; transform: translate(-50%, -18px) scale(.9); transition: opacity 160ms ease, transform 160ms ease; z-index: 25; }
.word-toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.word-toast img { border-radius: 5px; height: 66px; object-fit: cover; width: 82px; }
.word-toast strong { display: block; font-family: var(--font-display); font-size: 25px; }
.word-toast span { display: block; font-size: 19px; font-weight: 900; }
.particle { animation: particleBurst 850ms ease-out forwards; font-size: 30px; pointer-events: none; position: absolute; z-index: 24; }

.overlay { align-items: center; background: rgba(29,52,58,.66); display: none; inset: 0; justify-content: center; padding: 20px; position: absolute; z-index: 50; }
.overlay.visible { display: flex; }
.start-panel, .instructions-panel, .complete-panel { background: #fff; border: 5px solid var(--yellow); border-radius: 8px; box-shadow: 0 18px 50px rgba(16,41,48,.35); max-width: 520px; padding: 24px; text-align: center; width: 100%; }
.start-panel { max-width: 650px; }
.eyebrow { color: #16806f; font-size: 12px; font-weight: 900; margin: 0 0 4px; }
.start-panel h1, .instructions-panel h2, .complete-panel h2 { font-family: var(--font-display); font-size: 34px; margin: 0 0 15px; }
.hero-choices { display: grid; gap: 10px; grid-template-columns: repeat(5, 1fr); }
.hero-choice { background: #eef7f8; border: 3px solid transparent; border-radius: 8px; cursor: pointer; font-size: 43px; height: 74px; padding: 0; }
.hero-choice.selected { background: #fff4cf; border-color: var(--yellow); transform: translateY(-3px); }
.start-copy { color: #52676d; font-size: 17px; font-weight: 800; margin: 12px auto; }
.level-heading { align-items: center; color: #16806f; display: flex; font-size: 12px; justify-content: space-between; margin: 0 1px 7px; }
.level-heading span { background: #e8f2f4; border-radius: 999px; color: #52676d; font-weight: 900; padding: 2px 8px; }
.stage-choices { display: grid; gap: 7px; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 14px; }
.stage-choice { background: #eef7f8; border: 3px solid transparent; border-radius: 8px; color: var(--ink); cursor: pointer; height: 86px; min-width: 0; padding: 5px 3px; position: relative; }
.stage-choice.selected { background: #fff4cf; border-color: var(--yellow); }
.stage-choice.completed { background: #e5f6e7; }
.stage-choice.selected.completed { background: #fff4cf; }
.stage-choice:disabled { cursor: not-allowed; filter: grayscale(.45); opacity: .58; }
.stage-choice .stage-badge { display: block; font-size: 30px; line-height: 34px; }
.stage-choice small { color: #6b777a; display: block; font-size: 10px; font-weight: 900; }
.stage-choice strong { display: block; font-size: 11px; line-height: 12px; margin-top: 1px; overflow-wrap: anywhere; }
.stage-choice i { align-items: center; background: #16806f; border-radius: 50%; color: #fff; display: flex; font-size: 10px; font-style: normal; height: 18px; justify-content: center; position: absolute; right: 3px; top: 3px; width: 18px; }
.stage-choice i:empty { display: none; }
.primary-action, .secondary-action { border: 0; border-radius: 8px; cursor: pointer; font-size: 19px; font-weight: 900; min-height: 54px; padding: 8px 20px; }
.primary-action { background: var(--coral); color: #fff; min-width: 190px; }
.secondary-action { background: #e8f2f4; color: var(--ink); margin-left: 8px; }
.instruction-row { align-items: center; background: #eef7f8; border-radius: 8px; display: flex; gap: 14px; margin: 8px 0; padding: 10px 14px; text-align: left; }
.instruction-row span { font-size: 28px; }
.instruction-row p { font-size: 16px; font-weight: 900; margin: 0; }
.credits-link { color: #557078; display: block; font-size: 12px; font-weight: 900; margin-top: 12px; }
.complete-stars { font-size: 44px; }
.complete-panel p { color: #52676d; font-size: 18px; font-weight: 800; }
.earned-badges { display: flex; gap: 8px; justify-content: center; margin: 15px 0; }
.earned-badges span { align-items: center; background: #e8eef0; border-radius: 50%; display: flex; filter: grayscale(1); font-size: 25px; height: 44px; justify-content: center; opacity: .35; width: 44px; }
.earned-badges span.earned { background: #fff1b8; filter: none; opacity: 1; }

@keyframes cloudTravel { from { left: -100px; } to { left: calc(100% + 100px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes heroBounce { 50% { transform: translate(-50%, -50%) scale(1.07); } }
@keyframes hitGlow { 35% { filter: drop-shadow(0 0 18px #fff) drop-shadow(0 0 24px var(--yellow)); transform: translate(-50%, -50%) scale(1.28); } }
@keyframes targetBob { 50% { transform: translateY(-12px) rotate(2deg); } }
@keyframes particleBurst { to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(180deg) scale(.5); } }

@media (max-width: 680px) {
  .topbar { gap: 6px; grid-template-columns: 1fr auto auto; height: 60px; padding: 0 9px; }
  .brand { font-size: 17px; gap: 6px; }
  .brand-mark { height: 32px; width: 32px; }
  .hud-progress span { display: none; }
  .hud-progress, .hud-score { font-size: 14px; min-height: 38px; padding: 4px 9px; }
  .hud-score { display: none; }
  .language { min-height: 39px; min-width: 79px; }
  .board { height: calc(100% - 60px); }
  .stage-label { left: 10px; padding: 7px 10px; top: 10px; }
  .stage-label span { font-size: 18px; }
  .stage-label small { font-size: 11px; }
  .sun { font-size: 54px; }
  .target { height: 112px; width: 100px; }
  .target-card { height: 84px; width: 100px; }
  .target-name { font-size: 12px; min-width: 84px; }
  .hero { font-size: 45px; height: 76px; width: 76px; }
  .control-dock { bottom: 12px; gap: 3px; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 50px); right: 12px; }
  .control { border-radius: 12px; font-size: 21px; }
  .control-center { border-radius: 12px; font-size: 24px; }
  .help { bottom: 14px; height: 48px; left: 12px; width: 48px; }
  .start-panel, .instructions-panel, .complete-panel { padding: 16px 12px; }
  .start-panel h1, .instructions-panel h2, .complete-panel h2 { font-size: 28px; }
  .hero-choices { gap: 5px; }
  .hero-choice { font-size: 32px; height: 56px; }
  .start-copy { font-size: 14px; margin: 8px auto; }
  .stage-choices { gap: 4px; margin-bottom: 10px; }
  .stage-choice { height: 78px; padding: 3px 1px; }
  .stage-choice .stage-badge { font-size: 26px; line-height: 30px; }
  .stage-choice strong { font-size: 10px; line-height: 11px; }
  .word-toast { top: 12%; }
}

@media (max-width: 380px) {
  .brand span:last-child { display: none; }
  .secondary-action { display: block; margin: 8px auto 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .sun, .hero, .target-bob { animation: none; }
}
