:root {
  --ink: #1d2340;
  --ink-soft: #5a6185;
  --card: #ffffff;
  --accent: #ff7a1a;
  --accent-dark: #d95a00;
  --good: #2eb872;
  --bad: #e5484d;
  --radius: 18px;
  --font: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: #0b1030; overflow: hidden; }
button, input { font: inherit; }
[hidden] { display: none !important; }

#app { position: relative; height: 100dvh; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; overflow: hidden; }

.topbar { position: relative; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
.brand { background: none; border: 0; color: #fff; font-size: 1.25rem; font-weight: 700; cursor: pointer; padding: 4px 0; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.streak { color: #fff; font-weight: 600; background: rgba(0,0,0,.3); padding: 4px 10px; border-radius: 99px; }
.icon-btn { background: rgba(0,0,0,.3); border: 0; border-radius: 99px; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; }

.scene { position: absolute; inset: 0; z-index: 0; overflow: hidden; }

.screen { position: relative; z-index: 3; flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* Menu */
.menu { justify-content: flex-end; padding: 16px; }
.menu-card { background: var(--card); border-radius: var(--radius); padding: 22px 20px; box-shadow: 0 10px 30px rgba(0,0,0,.25); text-align: center; }
.menu-card h1 { margin: 0 0 6px; font-size: 1.7rem; }
.menu-card p { margin: 0 0 16px; color: var(--ink-soft); }
.menu-card .small { font-size: .9rem; margin: 10px 0 0; }
.big-btn { display: block; width: 100%; padding: 14px; margin-top: 10px; border-radius: 14px; border: 2px solid var(--ink); background: #fff; color: var(--ink); font-size: 1.15rem; font-weight: 600; cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.big-btn.primary { background: var(--accent); color: #fff; }
.big-btn:disabled { opacity: .5; cursor: default; }

/* Game */
.game { justify-content: flex-start; }
.game .controls { margin-top: auto; }
.question-bar { margin: 4px 14px 0; background: rgba(255,255,255,.95); border-radius: var(--radius); padding: 10px 14px; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.mode-tag { font-size: .8rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.question-bar h2 { margin: 2px 0 0; font-size: 1.45rem; }

.popup { align-self: center; margin-top: 10px; text-align: center; background: rgba(255,255,255,.95); border-radius: 16px; padding: 10px 18px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: pop .35s cubic-bezier(.2,1.6,.4,1); }
.popup-level { font-size: 1.4rem; font-weight: 700; }
.popup-word { color: var(--ink-soft); font-weight: 600; }
.popup.miss .popup-level { color: var(--bad); }
.popup.top .popup-level { color: var(--accent-dark); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.controls { margin: 0 14px 6px; background: rgba(255,255,255,.95); border-radius: var(--radius); padding: 12px; box-shadow: 0 -4px 20px rgba(0,0,0,.15); }
.tries { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; flex-wrap: wrap; }
.try { min-width: 30px; height: 30px; padding: 0 10px; border-radius: 99px; background: #e6e9f5; display: grid; place-items: center; font-size: .85rem; font-weight: 600; }
.try.hit { background: var(--good); color: #fff; }
.try.miss { background: var(--bad); color: #fff; }
.answer-form { display: flex; gap: 8px; }
.answer-form input { flex: 1; min-width: 0; padding: 12px 14px; border: 2px solid #cfd4ea; border-radius: 12px; font-size: 1.1rem; background: #fff; color: var(--ink); }
.answer-form input:focus { outline: none; border-color: var(--accent); }
.answer-form button { padding: 0 20px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; font-size: 1.1rem; cursor: pointer; }
.answer-form button:disabled { background: #c9cde0; cursor: default; }
.msg { min-height: 1.3em; margin: 8px 0 0; text-align: center; font-size: .95rem; color: var(--ink-soft); }
.msg.error { color: var(--bad); }

/* Result */
.result { justify-content: flex-end; }
.sheet { background: var(--card); border-radius: var(--radius) var(--radius) 0 0; padding: 18px 18px 12px; max-height: 80dvh; overflow-y: auto; box-shadow: 0 -10px 30px rgba(0,0,0,.3); animation: up .35s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.result-label { margin: 0; color: var(--ink-soft); text-align: center; }
.sheet h2 { margin: 0; text-align: center; font-size: 1.8rem; }
.result-word { margin: 0 0 10px; text-align: center; font-weight: 600; color: var(--accent-dark); }
.result-list { list-style: none; padding: 0; margin: 0 0 10px; }
.result-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #f3f5fc; margin-bottom: 6px; }
.result-list .lvl { color: var(--ink-soft); font-size: .9rem; text-align: right; }
.result-list .miss { color: var(--bad); }
.reveal { font-size: .95rem; color: var(--ink-soft); text-align: center; margin-bottom: 4px; }
.reveal strong { color: var(--ink); }
.result-actions { display: flex; gap: 10px; }
.result-actions .big-btn { flex: 1; }
.countdown { text-align: center; color: var(--ink-soft); margin: 10px 0 0; }
.report { margin-top: 12px; }
.report summary { cursor: pointer; color: var(--ink-soft); text-align: center; }
.report .answer-form { margin-top: 8px; }

.ad-banner { position: relative; z-index: 3; }
.footer { position: relative; z-index: 3; text-align: center; font-size: .8rem; padding: 2px 0 6px; }
.footer a { color: rgba(255,255,255,.85); }
.result:not([hidden]) ~ .footer, .result:not([hidden]) ~ .ad-banner { background: #fff; }
.result:not([hidden]) ~ .footer a { color: var(--ink-soft); }

@media (min-width: 700px) {
  .question-bar h2 { font-size: 1.7rem; }
}

/* ===== About / Privacy pages ===== */
body.page { overflow: auto; background: linear-gradient(#5ab4f0, #2a6cb8 60%, #0d1640); min-height: 100%; padding: 16px; }
.page-card { max-width: 640px; margin: 0 auto; background: #fff; border-radius: var(--radius); padding: 22px 22px 10px; line-height: 1.55; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.page-card h1 { margin: 8px 0 10px; font-size: 1.8rem; }
.page-card h2 { margin: 22px 0 6px; font-size: 1.2rem; }
.page-card p, .page-card li { color: #343a5c; }
.page-card ul { padding-left: 20px; }
.page-card a { color: var(--accent-dark); }
.back { font-weight: 600; text-decoration: none; }

/* ===== Scene ===== */
.world {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--band, 400px) * 20);
  background: linear-gradient(to top,
    #8fd3ff 0%, #7cc6f7 12%, #5ab4f0 22%, #3f95dc 32%, #2a6cb8 38%,
    #18306b 44%, #0d1640 50%, #070b24 70%, #120a2e 90%, #2a0f45 100%);
  will-change: transform;
}
.world::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 120vh; background: #4caf50; }
.stars {
  position: absolute; left: 0; right: 0; top: 0; height: 58%; pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 80px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 160px 40px, #cfe2ff, transparent),
    radial-gradient(1px 1px at 230px 120px, #fff, transparent),
    radial-gradient(2px 2px at 300px 60px, #fff, transparent),
    radial-gradient(1px 1px at 60px 150px, #ffe9c4, transparent);
  background-size: 340px 170px;
  -webkit-mask-image: linear-gradient(to top, transparent, #000 15%);
          mask-image: linear-gradient(to top, transparent, #000 15%);
}
.band { position: absolute; left: 0; right: 0; height: var(--band); bottom: calc(var(--i) * var(--band)); overflow: hidden; }
.band-label {
  position: absolute; right: 10px; bottom: 8px; font-size: .75rem; font-weight: 600;
  color: rgba(255,255,255,.75); letter-spacing: .04em; text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.man { position: absolute; left: 50%; width: 76px; margin-left: -38px; z-index: 2; bottom: 0; }
.man-svg { width: 76px; height: 114px; display: block; filter: drop-shadow(0 4px 4px rgba(0,0,0,.25)); }
.man .flame { transform-origin: 40px 78px; transform: scaleY(.35); opacity: .7; transition: transform .3s; }
.man.flying .flame { transform: scaleY(var(--boost, 1.2)); opacity: 1; animation: flicker .12s infinite alternate; }
.man.flying .man-svg { animation: wobble .5s ease-in-out infinite alternate; }
@keyframes flicker { from { opacity: .85; } to { opacity: 1; } }
@keyframes wobble { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
.man.sputter .man-svg { animation: shake .12s linear 5; }
.man.sputter::after {
  content: ""; position: absolute; left: 50%; top: 80%; width: 34px; height: 34px; margin-left: -17px;
  border-radius: 50%; background: radial-gradient(circle, rgba(120,120,130,.8), rgba(120,120,130,0) 70%);
  animation: puff .7s ease-out forwards;
}
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px) rotate(-4deg); } 75% { transform: translateX(4px) rotate(4deg); } }
@keyframes puff { from { transform: scale(.4); opacity: 1; } to { transform: scale(2.2) translateY(18px); opacity: 0; } }

/* level decorations */
.ground { position: absolute; left: 0; right: 0; bottom: 0; height: 12%; background: #4caf50; border-top: 4px solid #3a8f3e; }
.house { position: absolute; bottom: 12%; width: 70px; height: 60px; background: #f2c38a; border: 3px solid #1d2340; }
.house::before { content: ""; position: absolute; left: -10px; right: -10px; top: -32px; height: 30px; background: #d9534f; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.house.h1 { left: 6%; } .house.h2 { right: 8%; height: 80px; }
.rooftop { position: absolute; bottom: -20px; width: 110px; height: 70px; border: 3px solid #1d2340; border-radius: 6px 6px 0 0;
  background: repeating-linear-gradient(90deg, transparent 0 16px, #ffe9a8 16px 30px) 0 18px / 100% 20px no-repeat, #c9d3ea; }
.rooftop.r1 { left: -10px; } .rooftop.r2 { right: 4%; height: 110px; }
.tree { position: absolute; bottom: -10px; width: 60px; height: 70px; background: #2e9b4f; border: 3px solid #1d2340; border-radius: 50% 50% 45% 45%; }
.tree.t1 { left: 4%; } .tree.t2 { right: 6%; height: 90px; width: 70px; } .tree.t3 { left: 28%; height: 50px; width: 45px; }
.bird { position: absolute; color: #1d2340; font-size: 1.2rem; font-weight: 700; }
.bird.b1 { left: 12%; top: 30%; } .bird.b2 { right: 16%; top: 50%; } .bird.b3 { left: 30%; top: 70%; font-size: .9rem; }
.cloud { position: absolute; fill: #fff; opacity: .95; }
.cloud.c1 { left: -10px; top: 25%; } .cloud.c2 { right: 6%; top: 55%; }
.cloud.storm { fill: #5d6787; }
.cloud.s1 { right: -20px; top: 20%; } .cloud.s2 { left: 4%; top: 58%; }
.deco-at { position: absolute; }
.haze { position: absolute; inset: 0; background: linear-gradient(to top, rgba(255,255,255,.12), transparent); }
.curve { position: absolute; left: -30%; right: -30%; bottom: -160%; height: 200%; border-radius: 50%; border-top: 6px solid rgba(140,200,255,.45); box-shadow: 0 -10px 40px rgba(120,190,255,.35); }
.planet { position: absolute; border-radius: 50%; border: 3px solid rgba(0,0,0,.35); }
.moon { width: 90px; height: 90px; left: 10%; top: 20%; background: radial-gradient(circle at 35% 35%, #f4f4f0, #b9b9b4); box-shadow: inset -12px -8px 0 rgba(0,0,0,.12); }
.mars { width: 80px; height: 80px; right: 12%; top: 30%; background: radial-gradient(circle at 35% 35%, #f08a5d, #b8432a); }
.rock { position: absolute; background: #8c8072; border: 3px solid #3c342d; border-radius: 40% 55% 45% 60%; }
.rock.k1 { width: 34px; height: 26px; left: 10%; top: 20%; } .rock.k2 { width: 22px; height: 18px; left: 34%; top: 60%; }
.rock.k3 { width: 40px; height: 30px; right: 12%; top: 40%; } .rock.k4 { width: 16px; height: 14px; right: 30%; top: 75%; }
.jupiter { width: 130px; height: 130px; left: -20px; top: 15%; background: repeating-linear-gradient(10deg, #e6c49a 0 14px, #c98d5b 14px 24px, #f1dcc0 24px 34px); }
.saturn { width: 90px; height: 90px; right: 14%; top: 25%; background: radial-gradient(circle at 35% 35%, #f6e2a8, #c9a45a); }
.saturn .ring { position: absolute; left: -38px; right: -38px; top: 36px; height: 18px; border-radius: 50%; border: 5px solid rgba(233,210,150,.9); transform: rotate(-14deg); }
.pluto { width: 40px; height: 40px; left: 18%; top: 40%; background: radial-gradient(circle at 35% 35%, #e8d8c8, #9b8574); }
.sun-far { position: absolute; left: 20%; bottom: 10%; width: 22px; height: 22px; border-radius: 50%; background: #ffe680; box-shadow: 0 0 30px 12px rgba(255,220,100,.5); }
.star-big { position: absolute; width: 10px; height: 10px; background: #fff; border-radius: 50%; box-shadow: 0 0 16px 6px rgba(200,220,255,.7); }
.star-big.s1 { left: 15%; top: 25%; } .star-big.s2 { right: 18%; top: 55%; background: #ffd9a0; } .star-big.s3 { left: 40%; top: 75%; width: 6px; height: 6px; }
.galaxy { position: absolute; left: 50%; top: 45%; width: 240px; height: 110px; margin: -55px 0 0 -120px; border-radius: 50%;
  background: radial-gradient(ellipse, #fff 0 6%, #f5c6ff 12%, rgba(160,90,255,.6) 35%, rgba(60,40,160,0) 70%); transform: rotate(-20deg); }
.nebula { position: absolute; inset: 0; background:
  radial-gradient(circle at 30% 40%, rgba(255,90,170,.45), transparent 45%),
  radial-gradient(circle at 70% 60%, rgba(80,200,255,.4), transparent 45%),
  radial-gradient(circle at 50% 20%, rgba(255,210,90,.35), transparent 40%); }

@media (prefers-reduced-motion: reduce) {
  .man.flying .man-svg, .man.sputter .man-svg, .man.flying .flame { animation: none; }
}
