/* Crash Test Dummy: Comic Neon. A cel-shaded comic book at night: thick ink outlines, halftone dots, speed lines,
   neon orange and electric blue, comic lettering (Luckiest Guy, SIL OFL). Its own look: games.css loads first only for
   the shared rules (no selectable text, the back button's pop-up); everything you see is set here. */
@font-face { font-family: 'Luckiest Guy'; src: url(/fonts/luckiest-guy.woff2) format('woff2'); font-display: swap; }
:root {
  --ink: #0a0a14; --night: #0b0f33; --night2: #1b1052; --orange: #ff7a1a; --blue: #19c8ff; --pink: #ff3df2;
  --yellow: #ffd21f; --lime: #9bff3a; --paper: #fff8ea; --panel: #151a4a;
}
* { box-sizing: border-box; }
html, body.ctd { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body.ctd { background: var(--night); color: var(--paper); font: 600 17px/1.35 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
.ctd #app { position: fixed; inset: 0; }
.ctd .hidden { display: none !important; }
.ctd .muted { color: #b9c2ff; }

/* comic lettering */
.ctd h1, .ctd h2, .ctd .logo, .ctd .big, .ctd .chip, .ctd .pad, .ctd .banner, .ctd .meter label, .ctd .level-grid b { font-family: 'Luckiest Guy', Impact, 'Arial Black', sans-serif; font-weight: 400; letter-spacing: .02em; }
.ctd h1, .ctd h2 { margin: 0; }

/* buttons: ink outline, a hard shadow, a slight tilt */
.ctd button { font: inherit; color: var(--ink); cursor: pointer; border: 3px solid var(--ink); border-radius: 14px; background: var(--paper); padding: 8px 14px; min-height: 46px; box-shadow: 0 4px 0 var(--ink); touch-action: manipulation; transition: transform .07s, box-shadow .07s; }
.ctd button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.ctd button:focus-visible, .ctd a:focus-visible { outline: 4px dashed var(--lime); outline-offset: 3px; }
.ctd button:disabled { opacity: .5; cursor: default; }
.ctd button.big { width: 100%; font-size: 26px; min-height: 60px; background: var(--orange); transform: rotate(-.6deg); }
.ctd button.big small { display: block; font: 700 13px/1.1 Inter, system-ui, sans-serif; letter-spacing: 0; opacity: .85; margin-top: 2px; }
.ctd button.big:active:not(:disabled) { transform: translateY(3px) rotate(-.6deg); }
.ctd button.soft { background: var(--blue); font-size: 18px; letter-spacing: .02em; font-family: 'Luckiest Guy', Impact, sans-serif; font-weight: 400; }
.ctd button.icon { min-width: 44px; min-height: 44px; padding: 2px 8px; font-size: 20px; border-radius: 50%; }
.ctd a { color: var(--yellow); }

/* top bar */
.ctd-top { position: absolute; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); pointer-events: none; }
.ctd-top > * { pointer-events: auto; }
#back-slot:empty { display: none; }
.ctd button.back, .ctd button.back.quiet { color: var(--ink); background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); min-height: 44px; min-width: 44px; padding: 6px 14px 6px 10px; display: inline-flex; align-items: center; gap: 6px; font: 800 16px Inter, system-ui, sans-serif; }
.playing button.back { font-size: 0; gap: 0; padding: 6px; justify-content: center; }
.playing button.back span { font-size: 22px; }
.ctd-top #sound { margin-left: auto; }
.hud { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 12px; background: #0a0a14cc; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 12px; box-shadow: 0 0 0 2px var(--blue); font-family: 'Luckiest Guy', Impact, sans-serif; letter-spacing: .03em; }
.hud b { font-weight: 400; color: var(--yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud .tries { color: #b9c2ff; font-size: 15px; white-space: nowrap; }
.coins { display: inline-flex; gap: 4px; }
.coins i { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--ink); background: #3a3f78; display: inline-block; }
.coins i.on { background: radial-gradient(circle at 35% 30%, #fff3a8, #ffcf1f 60%); box-shadow: 0 0 8px var(--yellow); }

#stage { position: absolute; inset: 0; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.playing .page { display: none; }

/* a big comic word over the picture */
.banner { position: absolute; left: 50%; top: 26%; transform: translate(-50%, 0) rotate(-3deg); z-index: 12; pointer-events: none; font-size: clamp(30px, 8vw, 58px); color: var(--yellow); -webkit-text-stroke: 2px var(--ink); text-shadow: 3px 4px 0 var(--ink); text-align: center; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.banner small { display: block; font: 700 16px/1.2 Inter, system-ui, sans-serif; color: var(--paper); -webkit-text-stroke: 0; text-shadow: 0 2px 0 var(--ink); margin-top: 6px; }
@keyframes pop { from { transform: translate(-50%, 8px) rotate(-3deg) scale(.3); opacity: 0; } to { transform: translate(-50%, 0) rotate(-3deg) scale(1); opacity: 1; } }

/* pages: comic panels */
.page { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 64px 14px 14px; background: radial-gradient(ellipse at 50% 40%, #0b0f3322, #0b0f33cc 78%); overflow-y: auto; }
.card { width: min(430px, 100%); background: var(--panel); border: 4px solid var(--ink); border-radius: 18px; padding: 18px; box-shadow: 0 0 0 3px var(--blue), 8px 9px 0 var(--ink); position: relative; overflow: hidden; }
.card.wide { width: min(640px, 100%); }
.card::before { content: ''; position: absolute; right: -28px; top: -28px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, #ff7a1a55 2.2px, transparent 2.6px) 0 0 / 11px 11px; pointer-events: none; }
.card > * { position: relative; }
.card > * + * { margin-top: 12px; }
.logo { font-size: clamp(38px, 11vw, 56px); line-height: .95; color: var(--paper); text-shadow: 3px 4px 0 var(--ink); transform: rotate(-2deg); }
.logo span { color: var(--orange); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.logo em { font-style: normal; color: var(--yellow); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.tag { margin: 0; color: #dfe5ff; }
.stars-total { font: 400 20px 'Luckiest Guy', Impact, sans-serif; color: var(--yellow); }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ctd .chip { min-height: 44px; font-size: 19px; padding: 4px 8px; background: #2a2f78; color: var(--paper); border-color: var(--ink); }
.ctd .chip[aria-pressed="true"] { background: var(--lime); color: var(--ink); box-shadow: 0 4px 0 var(--ink), 0 0 0 3px var(--yellow); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.links { margin: 0; text-align: center; }
.card h2 { font-size: 34px; color: var(--yellow); text-shadow: 2px 3px 0 var(--ink); }
.card ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.card ul b { color: var(--yellow); }

/* levels */
.level-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; }
.level-grid li { margin: 0; }
.level-grid button { width: 100%; min-height: 84px; text-align: left; display: grid; gap: 2px; background: var(--paper); padding: 8px 10px; }
.level-grid button[disabled] { background: #3a3f78; color: #9aa3e6; }
.level-grid .n { font: 700 12px Inter, system-ui, sans-serif; opacity: .7; }
.level-grid b { font-size: 18px; line-height: 1.05; }
.level-grid .st { color: #c98a00; font-size: 18px; letter-spacing: 2px; }
.level-grid button[disabled] .st { color: #6b73b8; }

/* aim meters */
.meters { position: absolute; z-index: 12; left: 0; right: 0; bottom: 0; padding: 8px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px 12px; align-items: end; background: linear-gradient(to top, #0b0f33f0 60%, transparent); }
.meter label { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; color: var(--paper); text-shadow: 2px 2px 0 var(--ink); margin-bottom: 3px; }
.meter label b { font-weight: 400; color: var(--yellow); }
.meter .bar { position: relative; height: 26px; border: 3px solid var(--ink); border-radius: 13px; background: #1c2160; overflow: hidden; box-shadow: 0 0 0 2px var(--blue); }
.meter .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, var(--blue), var(--orange)); }
.meter .bar u { position: absolute; top: -2px; bottom: -2px; width: 8px; margin-left: -4px; left: 0; background: var(--paper); border: 2px solid var(--ink); border-radius: 4px; text-decoration: none; }
.meter.locked .bar i { background: var(--lime); }
.meter.idle { opacity: .55; }
.meters button.big { width: auto; min-width: 170px; font-size: 22px; }
.meters .keys { grid-column: 1 / -1; margin: 0; text-align: center; font-size: 13px; color: #b9c2ff; }
@media (max-width: 600px) and (orientation: portrait) {
  .meters { grid-template-columns: 1fr 1fr; }
  .meters button.big { grid-column: 1 / -1; width: 100%; }
}
@media (pointer: coarse) { .meters .keys { display: none; } }

/* steering pads */
.pads { position: absolute; z-index: 12; left: 0; right: 0; bottom: 0; padding: 0 max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); pointer-events: none; }
.pads > * { pointer-events: auto; }
.glide { position: relative; height: 18px; width: min(280px, 56%); margin: 0 auto 8px; border: 3px solid var(--ink); border-radius: 10px; background: #1c2160; overflow: hidden; box-shadow: 0 0 0 2px var(--blue); pointer-events: none; }
.glide i { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, var(--pink), var(--yellow)); }
.glide span { position: absolute; inset: 0; display: grid; place-items: center; font: 400 11px 'Luckiest Guy', Impact, sans-serif; color: var(--ink); letter-spacing: .1em; }
.pad-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.pad-left, .pad-right { display: flex; gap: 10px; }
.ctd button.pad { min-width: 76px; min-height: 76px; border-radius: 22px; background: var(--blue); font-size: 15px; display: grid; place-items: center; align-content: center; padding: 4px 8px; user-select: none; touch-action: none; }
.ctd button.pad span { font-size: 26px; line-height: 1; font-family: Inter, system-ui, sans-serif; }
.ctd button.pad.star { background: var(--pink); min-width: 92px; }
.ctd button.pad.tuck { background: var(--yellow); }
.ctd button.pad.down { transform: translateY(3px) scale(.97); box-shadow: 0 1px 0 var(--ink), 0 0 14px var(--lime); background: var(--lime); }
.pads .keys { display: none; margin: 6px 0 0; text-align: center; font-size: 13px; color: #b9c2ff; }
@media (pointer: fine) { .pad-row { display: none; } .pads .keys { display: block; } }
@media (pointer: coarse) and (max-height: 460px) { .ctd button.pad { min-width: 64px; min-height: 64px; } .ctd button.pad.star { min-width: 78px; } }

/* result */
.end-stars { display: flex; justify-content: center; gap: 8px; font-size: 54px; line-height: 1; }
.end-stars i { font-style: normal; color: #3a3f78; text-shadow: 0 3px 0 var(--ink); -webkit-text-stroke: 2px var(--ink); }
.end-stars i.on { color: var(--yellow); animation: pop2 .5s cubic-bezier(.2, 1.7, .4, 1) both; }
.end-stars i.on:nth-child(2) { animation-delay: .15s; }
.end-stars i.on:nth-child(3) { animation-delay: .3s; }
@keyframes pop2 { from { transform: scale(.2) rotate(-40deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sub { margin: 0; text-align: center; color: #dfe5ff; }
.parts { list-style: none; padding: 0 !important; margin: 0; display: grid; gap: 4px !important; }
.parts li { display: flex; justify-content: space-between; border-bottom: 2px dotted #3a3f78; padding: 3px 0; }
.parts b { color: var(--yellow); }
.new { margin: 0; text-align: center; font: 400 22px 'Luckiest Guy', Impact, sans-serif; color: var(--lime); transform: rotate(-2deg); }

@media (max-height: 460px) {
  .page { padding-top: 56px; place-items: start center; }
  .card { padding: 12px; }
  .card > * + * { margin-top: 8px; }
  .logo { font-size: 38px; }
  .ctd button.big { min-height: 52px; font-size: 22px; }
  .end-stars { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .banner, .end-stars i.on { animation: none; }
  .ctd button { transition: none; }
}

@media (max-width: 430px) {
  .hud { gap: 6px; padding: 4px 6px; }
  .hud b { font-size: 15px; }
  .coins { gap: 3px; }
  .coins i { width: 16px; height: 16px; }
  .hud .tries { font-size: 13px; }
}
