@font-face {
  font-family: "Kusa Digits";
  src: url(https://fonts.gstatic.com/s/jersey10/v4/GftH7vZKsggXMf9n_J5n_5jh.woff2) format("woff2");
  unicode-range: U+0030-0039;
  font-weight: 100 900;
  font-display: swap;
  size-adjust: 116%;
}
:root {
  --sky1: #ffe4ee; --sky2: #ffc6da; --sky3: #f7a8c4;
  --pink: #ff8fb8; --rose: #e85d8f; --berry: #b23a6a;
  --mint: #9be3c9; --mintd: #3f9e7f; --butter: #ffe08a; --lilac: #c9b6ff;
  --cream: #fff6f9; --ink: #5a3446; --ink2: #7d5468; --line: #e9b3c8;
  --fh: "Kusa Digits", "Pixelify Sans"; --fb: "VT323";
  color-scheme: light;
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { margin: 0; color: var(--ink); font: 21px/1.3 var(--fb), ui-monospace, monospace; background: var(--sky2); }
h1, h2, h3, .fh { font-family: var(--fh), ui-monospace, monospace; font-weight: 700; line-height: 1.15; margin: 0; }
h2 { font: 400 32px/1 var(--fb); margin-bottom: 8px; }
p { margin: 0 0 10px; }
[hidden] { display: none !important; }
kbd { font: 15px var(--fb); background: var(--cream); color: var(--ink); border: 2px solid var(--ink); border-bottom-width: 3px; padding: 0 5px; margin: 0 1px; }
.tiny-text { font-size: 17px; color: var(--ink2); }

#scene { position: fixed; left: 0; top: 0; opacity: 0; transition: opacity .9s; z-index: 0; }
body.playing #scene { opacity: 1; }
.bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; background: linear-gradient(180deg, var(--sky3) 0%, var(--sky2) 45%, var(--sky1) 85%); transition: opacity .9s; }
body.playing .bg { opacity: 0; }
.layer { position: absolute; inset: 0; }
.cloud { position: absolute; animation: drift linear infinite; }
@keyframes drift { from { transform: translateX(-30vw); } to { transform: translateX(130vw); } }
.spark { position: absolute; bottom: -10px; width: 6px; height: 6px; background: var(--cream); animation: rise linear infinite; }
.spark.s { width: 4px; height: 4px; background: var(--butter); }
@keyframes rise { from { transform: translateY(0); opacity: 0; } 10% { opacity: 1; } to { transform: translateY(-90vh); opacity: 0; } }
.pano { position: absolute; left: 0; bottom: 0; height: 150px; display: flex; width: max-content; animation: pan 150s linear infinite; }
.pano svg { height: 150px; width: auto; flex: none; display: block; }
@keyframes pan { to { transform: translateX(-50%); } }

.crt-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 50; display: none; }
.crt-overlay.on { display: block; }
.crt-overlay::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(180deg, rgba(90, 52, 70, .05) 0 1px, transparent 1px 3px), radial-gradient(ellipse at center, transparent 70%, rgba(178, 58, 106, .18) 100%);
  animation: flick 6s steps(1) infinite;
}
.crt-overlay::before {
  content: ""; position: absolute; left: 0; right: 0; height: 120px; top: -120px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .14), transparent);
  animation: roll 9s linear infinite;
}
@keyframes flick { 0%, 100% { opacity: 1; } 47% { opacity: .9; } 48% { opacity: 1; } 83% { opacity: .95; } }
@keyframes roll { to { top: 110%; } }

.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px max(2vw, 10px); pointer-events: none; }
.topbar > * { pointer-events: auto; }
.mini-logo { font: 700 26px var(--fh); color: var(--cream); letter-spacing: .06em; text-shadow: -2px 0 var(--mint), 2px 0 var(--rose), 0 3px 0 var(--berry); background: none; border: 0; cursor: pointer; padding: 4px; }
.hud { display: flex; align-items: center; gap: 14px; }
.tools { display: flex; gap: 8px; }
main { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.view { position: absolute; inset: 0; }
.view > * { pointer-events: auto; }

#title { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding-bottom: 120px; }
.logo { font: 700 clamp(64px, 16vh, 130px) var(--fh); color: var(--cream); letter-spacing: .04em; text-shadow: -3px 0 0 var(--mint), 3px 0 0 var(--rose), 0 6px 0 var(--berry); animation: flk 5s steps(1) infinite; line-height: 1; display: flex; margin: 0; }
.logo span { display: inline-block; animation: wave 3.2s ease-in-out infinite; }
@keyframes wave { 50% { transform: translateY(-9px); } }
@keyframes flk { 0%, 92%, 100% { opacity: 1; } 93% { opacity: .7; } 94% { opacity: .95; } 95% { opacity: .6; } 96% { opacity: 1; } }
.sub { font-size: 20px; color: var(--berry); letter-spacing: .25em; }
.rules { font-size: 21px; background: rgba(255, 246, 249, .8); padding: 2px 10px; max-width: 36ch; margin: 0; }
.keyhint { font-size: 17px; color: var(--ink2); margin: 0; }
.hero-buddy { position: absolute; left: 14%; top: 16%; width: 28px; animation: wander 26s cubic-bezier(.65, 0, .35, 1) infinite; }
.hero-buddy .sway { animation: sway 2.6s cubic-bezier(.65, 0, .35, 1) infinite; filter: drop-shadow(0 0 5px rgba(255, 224, 138, .95)) drop-shadow(0 0 12px rgba(255, 246, 249, .8)); }
.hero-buddy svg { width: 100%; height: auto; display: block; }
@keyframes wander { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(60px, -30px); } 50% { transform: translate(20px, 24px); } 75% { transform: translate(-30px, -12px); } }
@keyframes sway { 0%, 100% { transform: translateY(0) rotate(-4deg) scale(1, 1); } 25% { transform: translateY(-7px) rotate(2deg) scale(.96, 1.04); } 50% { transform: translateY(-2px) rotate(5deg) scale(1, 1); } 75% { transform: translateY(-9px) rotate(-2deg) scale(.97, 1.03); } }

.btn { font: 700 18px var(--fh), monospace; letter-spacing: .08em; min-height: 46px; padding: 8px 22px; border: 3px solid var(--ink); background: var(--pink); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); cursor: pointer; transition: transform .06s; }
.btn:hover { background: #ffa3c6; }
.btn:active { transform: translate(4px, 4px); box-shadow: none; }
.btn:focus-visible, .field:focus-visible, .mini-logo:focus-visible { outline: 3px dashed var(--berry); outline-offset: 3px; }
.btn.big { font-size: 22px; padding: 14px 40px; animation: btnbob 1.9s cubic-bezier(.65, 0, .35, 1) infinite; }
.btn.big:active { animation: none; }
@keyframes btnbob { 50% { transform: translateY(5px); } }
.btn.mint { background: var(--mint); }
.btn.ghost { background: var(--cream); }
.btn.sm { font-size: 14px; min-height: 40px; padding: 4px 10px; box-shadow: 3px 3px 0 var(--ink); }
.btn kbd { font-size: 13px; padding: 0 3px; margin-left: 4px; }

.card { background: var(--cream); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 14px 18px; }
.label { font: 17px var(--fb); letter-spacing: .08em; color: var(--rose); }
.chip { background: var(--cream); border: 3px solid var(--ink); padding: 2px 12px; min-width: 84px; box-shadow: 3px 3px 0 var(--ink); }
.chip small { display: block; font-size: 15px; color: var(--ink2); line-height: 1; }
.chip b { font: 700 22px var(--fh); color: var(--rose); }
.chip.bump { animation: bump .4s; }
@keyframes bump { 30% { transform: scale(1.25); } }
.pips { display: flex; gap: 5px; justify-content: center; }
.pip { width: 15px; height: 15px; border: 2px solid var(--ink); background: var(--cream); }
.pip.done { background: var(--butter); }
.pip.now { background: var(--rose); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .4; } }
.hud .tiny-text { text-align: center; text-shadow: 0 1px 0 var(--cream); }

.qcard, .banner { position: absolute; top: 72px; left: 50%; transform: translateX(-50%); width: min(760px, 94vw); }
.qcard.away { animation: away .35s forwards; }
@keyframes away { to { transform: translate(-50%, -30px); opacity: 0; visibility: hidden; } }
.qhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.q { font: clamp(24px, 3.6vh, 30px)/1.15 var(--fb); margin: 4px 0 10px; }
.answer { display: flex; gap: 10px; align-items: center; }
.timer { --left: 100%; flex: none; width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--ink); background: conic-gradient(var(--mint) 0 var(--left), var(--cream) 0); display: grid; place-items: center; font: 700 22px var(--fh); }
.timer.low { background: conic-gradient(var(--rose) 0 var(--left), var(--cream) 0); color: var(--cream); text-shadow: 0 2px 0 var(--ink); }
.field-wrap { position: relative; flex: 1 1 auto; }
.field { width: 100%; font: 24px var(--fb); min-height: 50px; padding: 6px 14px; border: 3px solid var(--ink); background: #fff; color: var(--ink); border-radius: 0; }
.field::placeholder { color: #b88aa0; }
.field.nope { animation: nope .32s; }
@keyframes nope { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.toast { display: inline-block; margin-top: 10px; background: var(--butter); border: 3px solid var(--ink); padding: 2px 12px; font-size: 19px; }
.toast.pop { animation: pop .25s steps(3); }
@keyframes pop { from { transform: scale(.85); } to { transform: scale(1); } }

.banner { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; animation: drop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes drop { from { transform: translate(-50%, -40px); opacity: 0; } }
.banner .rev-icon { width: 56px; height: 56px; }
.banner .rank { font: 700 34px/1 var(--fh); text-shadow: 3px 3px 0 var(--ink); letter-spacing: .03em; }
.banner .said { font-size: 23px; }
.banner .meta { font-size: 17px; color: var(--ink2); }
.banner .gain { font: 700 20px var(--fh); color: var(--rose); }
.rev-icon, .icon-sm { filter: drop-shadow(1px 0 0 var(--ink)) drop-shadow(-1px 0 0 var(--ink)) drop-shadow(0 1px 0 var(--ink)) drop-shadow(0 -1px 0 var(--ink)); }
.miss { opacity: .45; }

.depth { position: absolute; right: max(4vw, 14px); top: 42%; text-align: right; color: var(--cream); text-shadow: 3px 3px 0 var(--ink); }
.depth b { font: 700 clamp(56px, 11vh, 96px)/1 var(--fh); }
.depth span { font: 700 28px var(--fh); margin-left: 4px; }
.depth em { display: block; font: 400 26px var(--fb); font-style: normal; letter-spacing: .2em; color: var(--butter); min-height: 1.2em; }
.depth em.flash { animation: layer .5s steps(4); }
@keyframes layer { from { transform: translateX(-12px) scale(1.3); opacity: 0; } }
.depth.final b { color: var(--butter); animation: bump .45s; }

.slam { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none !important; font: 700 clamp(48px, 12vh, 120px)/1 var(--fh); letter-spacing: .04em; color: var(--cream); opacity: 0; }
.slam.go { animation: slam 1.5s cubic-bezier(.2, 1.2, .3, 1) forwards; }
@keyframes slam { 0% { transform: scale(2.6); opacity: 0; } 14% { transform: scale(.94); opacity: 1; } 22% { transform: scale(1.04); } 30%, 75% { transform: scale(1); opacity: 1; } 100% { transform: scale(1) translateY(-20px); opacity: 0; } }

.unlock { position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--butter); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 4px 16px; font-size: 21px; white-space: nowrap; animation: drop .4s cubic-bezier(.2, 1.4, .4, 1); }
.unlock b { font: 700 18px var(--fh); color: var(--berry); margin-right: 8px; }
.skiphint { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); margin: 0; font-size: 16px; color: var(--ink); text-shadow: 0 1px 0 var(--cream); }

.endcard { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -46%); width: min(720px, 94vw); max-height: calc(100vh - 90px); display: flex; flex-direction: column; overflow: hidden; }
#endPage { flex: 1 1 auto; overflow: hidden; }
.endhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.big-score { font-size: clamp(48px, 9vh, 72px); color: var(--rose); text-shadow: 3px 3px 0 var(--ink); }
.log { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: clamp(90px, 18vh, 150px); border-bottom: 3px solid var(--ink); margin: 10px 0; }
.log div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.log span { width: 3px; background: var(--line); }
.log svg { width: 26px; height: 26px; }
.log em { font-style: normal; font-size: 17px; color: var(--ink2); }
.end-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.countdown { font: 700 18px var(--fh); color: var(--mintd); margin: 10px 0 0; }
.endnav { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 10px; }
.endcard .keyhint { text-align: center; margin-top: 6px; }
.qpage .q { margin-bottom: 6px; }
.mine-row { font-size: 21px; margin-bottom: 8px; }
.ranks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.ranks li { display: grid; grid-template-columns: 26px 118px 1fr; gap: 8px; align-items: start; font-size: 20px; line-height: 1.15; }
.ranks svg { width: 22px; height: 22px; }
.ranks b { font: 700 16px var(--fh); padding-top: 2px; text-shadow: 1px 1px 0 var(--ink); }
.ranks .mine { background: var(--butter); padding: 0 3px; outline: 2px solid var(--ink); }

dialog { border: 0; padding: 0; background: transparent; max-width: min(560px, 94vw); max-height: 94vh; }
dialog::backdrop { background: rgba(90, 52, 70, .4); }
dialog .card { max-height: 90vh; overflow: hidden; }
.ladder { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 10px; }
.tier { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 3px solid var(--ink); padding: 3px 10px; }
.tier svg { width: 30px; height: 30px; }
.tier b { font: 700 18px var(--fh); text-shadow: 2px 2px 0 var(--ink); }
.tier .pts { font: 700 18px var(--fh); white-space: nowrap; }
.tier p { margin: 0; font-size: 16px; color: var(--ink2); line-height: 1.1; }

@media (max-width: 600px), (max-height: 640px) {
  body { font-size: 19px; }
  .pano, .pano svg { height: 90px; }
  .qcard, .banner { top: 58px; padding: 10px 12px; }
  .tools .btn kbd, .qhead .tiny-text, body.playing .mini-logo { display: none; }
  .topbar { padding: 8px; }
  .tools { gap: 6px; }
  .tools .btn.sm { font-size: 12px; min-height: 34px; padding: 2px 6px; box-shadow: 2px 2px 0 var(--ink); }
  .chip { min-width: 60px; padding: 1px 8px; }
  .chip b { font-size: 19px; }
  .pip { width: 12px; height: 12px; }
  .pips { gap: 3px; }
  .answer { flex-wrap: wrap; }
  .answer .field-wrap { flex: 1 1 60%; }
  .answer .btn { flex: 1 1 100%; }
  .banner { grid-template-columns: auto 1fr; }
  .banner .btn { grid-column: 1 / -1; }
  .ranks li { grid-template-columns: 22px 92px 1fr; font-size: 18px; }
  .hero-buddy { left: 6%; top: 10%; }
  .slam { font-size: 44px; top: 34%; }
  .unlock { white-space: normal; width: 92vw; text-align: center; font-size: 18px; }
  .depth b { font-size: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  .cloud, .spark, .hero-buddy, .hero-buddy .sway, .logo, .logo span, .btn.big, .crt-overlay::after, .crt-overlay::before, .pip.now, .pano, .field.nope, .toast.pop, .banner, .unlock, .slam.go, .chip.bump, .depth em.flash, .depth.final b { animation: none !important; }
  .slam.go { opacity: 1; }
}
