*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
/* Layout: one narrow column of cloud-white cards over a drifting daytime sky. The sky view on top runs from
   the ground to space, with a balloon for each answer at the height it reached. */
:root {
  color-scheme: light;
  --sky-top: #4fb0f2;
  --sky-mid: #8fd2fb;
  --sky-low: #dff3ff;
  --card: rgba(255, 255, 255, 0.88);
  --card-solid: #ffffff;
  --line: rgba(21, 48, 77, 0.12);
  --ink: #15304d;
  --dim: #48647f;
  --faint: #7f95aa;
  --sun: #ffc83d;
  --sun-hover: #ffd466;
  --sun-ink: #3b2a00;
  --blue: #2c74e0;
  --coral: #ff5d6c;
  --coral-ink: #b3222f;
  --coral-soft: #ffe4e6;
  /* heights */
  --t-ground: #8a6d4b;
  --t-trees: #2f8a49;
  --t-cloud: #1c86ad;
  --t-jet: #2160cf;
  --t-strato: #7444e0;
  --t-space: #0d1440;
  --display: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}
html, body { min-height: 100%; }
body {
  background:
    radial-gradient(60vmax 60vmax at 88% -8%, rgba(255, 236, 170, 0.9) 0%, rgba(255, 236, 170, 0.35) 22%, rgba(255, 236, 170, 0) 45%) fixed,
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-low) 100%) fixed,
    var(--sky-mid);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.app { position: relative; z-index: 1; max-width: 580px; margin: 0 auto; padding-block: 18px 40px; display: flex; flex-direction: column; gap: 16px; }

header.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 1.5rem; background: rgba(255, 255, 255, 0.8); border: 0; border-radius: 999px; color: var(--ink); cursor: pointer; padding: 2px 14px; }
.wordmark span { color: var(--blue); }
.linkish { background: rgba(255, 255, 255, 0.8); border: 0; border-radius: 999px; color: var(--ink); font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; padding: 6px 14px; }
.linkish:hover { background: #fff; }
.bar-right { display: flex; gap: 8px; align-items: center; }
.linkish.icon { width: 38px; height: 34px; padding: 0; font-size: 1rem; line-height: 1; }

.chart { position: relative; border-radius: 22px; overflow: hidden; background: #8fd2ff; box-shadow: 0 10px 30px rgba(21, 70, 120, 0.22), inset 0 0 0 3px rgba(255, 255, 255, 0.7); }
.chart canvas { display: block; width: 100%; height: 240px; }
.chart .chart-cap { position: absolute; left: 12px; top: 10px; right: 12px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.chart .chart-cap span { background: rgba(255, 255, 255, 0.85); color: var(--ink); border-radius: 999px; padding: 2px 10px; font-family: var(--display); font-weight: 600; font-size: 0.8rem; }
.chart .chart-cap span:empty { display: none; }

.panel { background: var(--card); border-radius: 24px; padding: 22px 20px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 12px 34px rgba(21, 70, 120, 0.16); display: flex; flex-direction: column; gap: 16px; }
.eyebrow { font-family: var(--display); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.02em; color: var(--blue); }
.eyebrow.soft { color: var(--faint); font-weight: 500; }
h1.title { font-family: var(--display); font-weight: 700; font-size: clamp(3rem, 14vw, 4.6rem); line-height: 0.95; margin: 0; color: var(--ink); }
h1.title em { font-style: normal; color: var(--blue); }
.lede { margin: 0; color: var(--dim); max-width: 48ch; }
.lede strong { color: var(--ink); }

.btn { font: inherit; font-family: var(--display); font-weight: 600; font-size: 1.05rem; border-radius: 999px; padding: 11px 20px; cursor: pointer; border: 2px solid var(--line); background: #fff; color: var(--ink); transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s; }
.btn:hover { border-color: rgba(21, 48, 77, 0.3); }
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--sun); border-color: var(--sun); color: var(--sun-ink); box-shadow: 0 4px 0 #e0a514; }
.btn.primary:hover { background: var(--sun-hover); }
.btn.primary:active { box-shadow: 0 2px 0 #e0a514; }
.btn:focus-visible, .linkish:focus-visible, .wordmark:focus-visible, input:focus-visible, .row-btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row .btn { flex: 1 1 auto; }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 18px; background: rgba(143, 210, 251, 0.18); }
.mode small { font-family: var(--body); font-weight: 400; color: var(--dim); font-size: 0.8rem; line-height: 1.3; }
@media (max-width: 460px) { .modes { grid-template-columns: 1fr; } }

.stats { display: flex; gap: 22px; flex-wrap: wrap; font-size: 0.85rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.stats b { display: block; font-family: var(--display); font-size: 1.7rem; font-weight: 600; color: var(--ink); line-height: 1.1; }
.fineprint { font-size: 0.82rem; color: var(--faint); margin: 0; }

/* round */
.round-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.timer { position: relative; width: 60px; height: 60px; flex: none; }
.timer svg { width: 60px; height: 60px; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 5; }
.timer .track { stroke: rgba(44, 116, 224, 0.12); }
.timer .arc { stroke: var(--blue); stroke-linecap: round; transition: stroke 0.3s; }
.timer.low .arc { stroke: var(--coral); }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-weight: 600; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.timer.low span { color: var(--coral-ink); }
.prompt { font-family: var(--display); font-weight: 600; font-size: clamp(1.8rem, 7vw, 2.5rem); line-height: 1.1; margin: 0; text-wrap: balance; }
form.answer { display: flex; gap: 10px; flex-wrap: wrap; }
form.answer input { flex: 1 1 200px; min-width: 0; font: inherit; font-size: 1.15rem; padding: 12px 18px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); }
form.answer input::placeholder { color: var(--faint); }

/* lives: three balloons, popped one at a time */
.lives { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 18px; background: var(--coral-soft); }
.lives-row { display: flex; gap: 6px; }
.lives-label { font-family: var(--display); font-weight: 600; color: var(--coral-ink); font-size: 1.05rem; }
.life { display: block; width: 30px; height: 50px; color: var(--coral); transform-origin: 50% 30%; }
.life svg { width: 100%; height: 100%; display: block; overflow: visible; }
.life .bb { transform-origin: 12px 13px; transform-box: view-box; }
.life:not(.gone):not(.popping) { animation: bob 2.4s ease-in-out infinite; }
.life:nth-child(2) { animation-delay: -0.8s !important; }
.life:nth-child(3) { animation-delay: -1.6s !important; }
.life.gone .bb { opacity: 0; }
.life.gone .str { opacity: 0.25; }
.life.popping .bb { animation: popit 0.4s ease-out forwards; }
.life.popping .str { animation: dropstr 0.6s ease-in forwards; }
.lives.last { background: #ffd2d6; }
.lives.last .life:not(.gone):not(.popping) { animation: wobble 0.9s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes popit { 40% { transform: scale(1.35); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes dropstr { to { opacity: 0.25; transform: translateY(6px); } }
.life-msg { margin: 0; padding: 10px 14px; border-radius: 14px; background: var(--coral-soft); color: var(--coral-ink); font-weight: 700; }
.life-msg b { font-family: var(--display); font-size: 1.15rem; margin-right: 4px; }

.reveal { display: flex; flex-direction: column; gap: 14px; animation: rise 0.35s ease-out; }
@keyframes rise { from { transform: translateY(6px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.verdict { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.verdict .ans { font-family: var(--display); font-weight: 600; font-size: 2.1rem; line-height: 1.1; overflow-wrap: anywhere; min-width: 0; }
.verdict .pts { font-family: var(--display); font-weight: 600; font-size: 1.25rem; color: var(--blue); font-variant-numeric: tabular-nums; white-space: nowrap; }
.verdict.miss .ans { color: var(--coral-ink); }
.verdict.miss .pts { color: var(--faint); }
.verdict.trees .ans { color: var(--t-trees); }
.verdict.cloud .ans { color: var(--t-cloud); }
.verdict.jet .ans { color: var(--t-jet); }
.verdict.strato .ans { color: var(--t-strato); }
.verdict.space .ans { color: var(--t-space); }
.meta { font-size: 0.9rem; color: var(--dim); margin: 0; }
.others { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 0.92rem; margin: 0; }
.others dt { color: var(--faint); font-family: var(--display); font-weight: 600; font-size: 0.85rem; padding-top: 1px; }
.others dd { margin: 0; min-width: 0; }

/* summary */
.const-name { font-family: var(--display); font-weight: 700; font-size: clamp(2.2rem, 9vw, 3.2rem); line-height: 1; margin: 0; overflow-wrap: anywhere; color: var(--blue); }
.score-line { display: flex; gap: 18px; flex-wrap: wrap; align-items: baseline; }
.score-line .big { font-family: var(--display); font-weight: 600; font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.score-line .big small { font-size: 1rem; color: var(--dim); font-family: var(--body); font-weight: 400; }
.best-line { margin: 0; color: var(--dim); }
table.log { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.log td { padding: 9px 6px; border-top: 2px solid var(--line); vertical-align: top; }
table.log td:first-child { padding-left: 0; color: var(--dim); }
table.log td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 0; }
table.log td.height { color: var(--dim); white-space: nowrap; }
table.log td.ans { font-weight: 700; overflow-wrap: anywhere; }
table.log td.ans.miss { color: var(--coral-ink); font-weight: 400; }
.sharebox { width: 100%; font: inherit; font-size: 0.9rem; background: rgba(143, 210, 251, 0.15); color: var(--ink); border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; resize: none; }

/* lists */
.list { display: flex; flex-direction: column; }
.row-btn { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 6px; background: none; border: 0; border-top: 2px solid var(--line); color: var(--ink); font: inherit; text-align: left; cursor: pointer; border-radius: 10px; }
.row-btn:hover { background: rgba(143, 210, 251, 0.18); }
.row-btn .r-main { display: flex; flex-direction: column; min-width: 0; font-family: var(--display); font-weight: 600; }
.row-btn .r-main small { font-family: var(--body); font-weight: 400; color: var(--dim); font-size: 0.82rem; }
.row-btn .r-side { font-size: 0.9rem; color: var(--blue); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-btn .r-side.todo { color: var(--faint); }
h2.sec { font-family: var(--display); font-weight: 700; font-size: 2rem; margin: 0; line-height: 1.1; }

.howto ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 8px; }
.howto li::marker { color: var(--blue); font-family: var(--display); font-weight: 600; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; font-size: 0.78rem; text-align: center; }
.scale div { border-radius: 12px; padding: 8px 4px; color: #fff; }
.scale b { display: block; font-family: var(--display); font-weight: 600; font-size: 0.9rem; line-height: 1.2; }
.scale .trees { background: var(--t-trees); }
.scale .cloud { background: var(--t-cloud); }
.scale .jet { background: var(--t-jet); }
.scale .strato { background: var(--t-strato); }
.scale .space { background: var(--t-space); color: #ffd75e; }
@media (max-width: 460px) { .scale { grid-template-columns: repeat(2, 1fr); } .scale .space { grid-column: span 2; } }

/* judging and the height reveal */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }
.judging { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 0.95rem; min-height: 48px; }
.judging .scope { width: 26px; height: 26px; flex: none; border-radius: 50%; border: 3px solid var(--blue); border-right-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.retry-msg { margin: 0; color: var(--coral-ink); }
.retry-msg b { color: var(--ink); }
.suggest-btn { font: inherit; font-family: var(--display); font-weight: 600; color: #fff; background: var(--blue); border: 0; border-radius: 999px; padding: 2px 12px; margin: 0 2px; cursor: pointer; }
.suggest-btn:hover { background: #1f63c9; }
.suggest-btn:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
form.answer input.nope { border-color: var(--coral); animation: nudge 0.35s; }
@keyframes nudge { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.tier { align-self: flex-start; font-family: var(--display); font-weight: 600; font-size: 0.95rem; padding: 5px 14px; border-radius: 999px; color: #fff; opacity: 0; }
.tier.on { opacity: 1; animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
.tier.ground { background: var(--t-ground); }
.tier.trees { background: var(--t-trees); }
.tier.cloud { background: var(--t-cloud); }
.tier.jet { background: var(--t-jet); }
.tier.strato { background: linear-gradient(100deg, #5b33c9, #8a5cf0); box-shadow: 0 0 18px rgba(138, 92, 240, 0.45); }
.tier.space { color: #ffd75e; background: linear-gradient(100deg, #0d1440, #26307a 45%, #0d1440 60%); background-size: 200% 100%; box-shadow: 0 0 24px rgba(255, 200, 61, 0.55); font-size: 1.05rem; }
.tier.space.on { animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1), shimmer 1.6s linear infinite; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shimmer { to { background-position: -200% 0; } }
.note { margin: 0; color: var(--faint); font-style: italic; font-size: 0.9rem; }
.panel.shake { animation: shake 0.5s; }
@keyframes shake { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, -1px); } 80% { transform: translate(2px, 1px); } }

@media (prefers-reduced-motion: reduce) {
  .reveal, .tier.on, .tier.space.on, .panel.shake, .judging .scope, form.answer input.nope, .life, .life .bb, .life .str { animation: none !important; }
  .life.popping .bb { opacity: 0; }
  .btn { transition: none; }
}
