:root {
  color-scheme: dark;
  --bg: #111218;
  --panel: #1b1c26;
  --ink: #f8f8fc;
  --muted: #a1a3b7;
  --accent: #f540d5;
  --gold: #ffc857;
  --line: rgba(255, 255, 255, .12);
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: radial-gradient(ellipse at 50% 0, #242035, var(--bg) 65%); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
button, svg, img, canvas { -webkit-user-select: none; user-select: none; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.hidden { display: none !important; }
.arcade { width: min(1440px, calc(100% - 64px), calc((100svh - 136px) * var(--world-aspect, 1.777778))); margin: 0 auto; padding-top: max(12px, env(safe-area-inset-top)); }
.arcade-header { height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 23px; font-weight: 650; letter-spacing: -.8px; }
.brand img { width: 32px; height: 32px; filter: invert(1); }
.brand b { font-size: 18px; font-style: italic; letter-spacing: .5px; }
.brand-divider { margin: 0 13px; font-weight: 400; color: #737386; }
.catalog-link { color: var(--muted); font-size: 14px; text-decoration: none; white-space: nowrap; }
.catalog-link:hover { color: var(--ink); }
.edition { color: var(--muted); font-size: 12px; letter-spacing: .22em; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.sound-label { font-size: 14px; color: var(--muted); }
.icon-button { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; background: rgba(255,255,255,.06); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; transition: background .15s; }
.icon-button:hover { background: rgba(255,255,255,.16); }
#stage { position: relative; width: 100%; aspect-ratio: var(--world-aspect, 1.777778); overflow: hidden; border: 1px solid #494252; border-radius: 20px; background: #69a7e4; box-shadow: 0 28px 80px #0005; isolation: isolate; container-type: inline-size; }
#game { display: block; width: 100%; height: 100%; touch-action: none; }
#hud { position: absolute; inset: 0; z-index: 2; pointer-events: none; padding: 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.hud-goal, .hud-center, .hud-right { display: flex; align-items: center; min-height: 64px; padding: 10px 14px; background: #181b2ae8; border: 1px solid #ffffff21; border-radius: 14px; box-shadow: 0 4px 14px #15223920; }
.hud-goal { gap: 9px; min-width: 162px; }
.hud-coin { width: 39px; height: 39px; object-fit: contain; }
.goal-content { flex: 1; }
.stat-label { display: block; color: #b6b9ce; font-size: 10px; font-weight: 600; letter-spacing: .13em; }
.goal-value { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.goal-value b { font-size: 20px; line-height: 1.1; color: var(--gold); }
.goal-value > span { color: #b6b9ce; font-size: 12px; white-space: nowrap; }
.goal-track { height: 3px; background: #ffffff23; margin-top: 6px; border-radius: 4px; overflow: hidden; }
.goal-track i { display: block; width: 0; height: 100%; background: var(--gold); transition: width .2s; }
.hud-center { gap: 24px; text-align: center; }
.stat b { display: block; margin-top: 3px; font-size: 22px; line-height: 1.1; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.stat.record { border-left: 1px solid var(--line); padding-left: 24px; }
.record b { color: #b6b9ce; }
.hud-right { gap: 15px; padding: 9px 10px 9px 14px; }
.hearts { display: flex; align-items: center; gap: 4px; }
.hearts img { width: 24px; height: 23px; object-fit: contain; }
.hud-right .icon-button { pointer-events: auto; width: 36px; height: 36px; border-radius: 9px; }
.hud-fx { position: absolute; top: 98px; right: 22px; display: flex; gap: 8px; }
.fx { position: relative; width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: #181b2ae8; overflow: hidden; }
.fx img { width: 31px; height: 31px; object-fit: contain; }
.fx i { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--accent); }
.milestone { position: absolute; top: 98px; left: 22px; display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: #181b2aeb; border: 1px solid #ffc85755; border-radius: 12px; font-size: 13px; }
.milestone b { font-weight: 650; }
.milestone span { color: var(--gold); font-variant-numeric: tabular-nums; }
.overlay { position: absolute; inset: 0; z-index: 3; display: flex; justify-content: center; align-items: center; padding: 28px; overflow-y: auto; background: #10121bc9; backdrop-filter: blur(6px); }
.menu-overlay { background: linear-gradient(90deg, #11131feb, #151728b5 65%, #14162588); backdrop-filter: none; }
.menu-layout { width: min(870px, 100%); display: grid; grid-template-columns: 1.4fr 1fr; align-items: center; gap: 26px 70px; }
.eyebrow { display: block; font-size: 11px; font-weight: 650; letter-spacing: .17em; color: var(--muted); }
h1 { font-size: clamp(22px, 3.5vw, 43px); font-weight: 850; letter-spacing: -.04em; line-height: 1; margin: 18px 0 21px; }
h1 > span { display: block; font-size: clamp(62px, 8.6vw, 110px); font-weight: 900; font-style: italic; letter-spacing: -.07em; margin-left: -5px; }
.title-dot { color: var(--accent); }
.lead { font-size: 16px; line-height: 1.65; color: #c0c2d1; margin: 0 0 25px; }
.lead b { color: white; font-weight: 600; }
.btn { width: 100%; border: 1px solid transparent; border-radius: 12px; padding: 17px 22px; font-size: 16px; font-weight: 750; display: flex; align-items: center; justify-content: space-between; gap: 16px; transition: background .15s, transform .15s; }
.btn-start { background: var(--accent); color: #1e1021; box-shadow: 0 4px 22px #f540d520; }
.btn-start:hover:not(:disabled) { background: #ff6ae2; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.menu-copy .btn { max-width: 320px; }
.menu-record { font-size: 12px; color: var(--muted); margin: 16px 0 0; }
.menu-record b { margin-left: 12px; font-variant-numeric: tabular-nums; font-weight: 550; color: #e1e1eb; letter-spacing: .1em; }
.runner-card { padding: 22px 25px; text-align: center; border: 1px solid #ffffff26; border-radius: 18px; background: linear-gradient(145deg, #ffffff0c, #171b2f80); }
.runner-tag { display: block; font-size: 10px; letter-spacing: .17em; color: #bec2d7; }
.runner-art { position: relative; height: 220px; overflow: hidden; margin: 10px 0; background: radial-gradient(ellipse, #b1b2ee22, transparent 68%); mask-image: linear-gradient(#000 84%, transparent); }
.runner-art img { position: absolute; display: block; top: 0; left: 50%; width: auto; height: 235%; max-width: none; transform: translateX(-50%); }
.runner-name b { display: block; font-size: 21px; letter-spacing: -.02em; }
.runner-name > span { display: block; margin-top: 7px; font-size: 12px; color: #c2c5d6; }
.runner-name i, .status-dot { display: inline-block; width: 6px; height: 6px; background: #70dfa5; border-radius: 100%; margin-right: 5px; }
.runner-lives { display: flex; align-items: center; justify-content: center; gap: 3px; border-top: 1px solid var(--line); padding-top: 17px; margin-top: 21px; }
.runner-lives img { width: 17px; height: 16px; object-fit: contain; }
.runner-lives span { margin-left: 7px; font-size: 11px; color: #bec2d7; }
.menu-controls { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); padding-top: 20px; color: #c2c4d3; font-size: 12px; }
.menu-controls > span { display: flex; align-items: center; gap: 7px; }
kbd { font: inherit; font-size: 10px; color: #d2d3df; border: 1px solid #ffffff24; border-bottom-width: 2px; border-radius: 5px; padding: 4px 6px; white-space: nowrap; }
.menu-controls .touch-tip { display: none; }
.panel { width: min(420px, 100%); text-align: center; padding: 36px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 64px #0004; }
h2 { font-size: 34px; font-weight: 750; letter-spacing: -.04em; line-height: 1.15; margin: 16px 0; }
.panel .btn { margin-top: 24px; }
.btn-ghost { border: 0; background: none; color: #babccc; padding: 14px; margin-top: 8px; font-size: 14px; }
.btn-ghost:hover { color: white; }
.result-stats { display: flex; justify-content: center; gap: 32px; margin: 28px 0; }
.result-stats > div { display: flex; flex-direction: column; gap: 8px; }
.result-stats > div > span { font-size: 10px; color: var(--muted); letter-spacing: .14em; }
.result-stats b { font-size: 27px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--gold); }
.result-record { margin: 0; color: var(--muted); font-size: 13px; }
.result-record b { margin-left: 8px; color: var(--ink); font-variant-numeric: tabular-nums; }
.result-message { margin: 10px 0 0; color: #c0c2d1; font-size: 13px; line-height: 1.5; }
.arcade-footer { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #979aaf; font-size: 11px; }
.desktop-controls { display: flex; align-items: center; gap: 5px; }
.desktop-controls kbd { border: 0; padding: 0; }
.footer-separator { color: #53566b; margin: 0 10px; }
.footer-brand { color: #797c94; }
.touch-controls { display: none; gap: 12px; padding: 10px 0 max(18px, env(safe-area-inset-bottom)); }
.touch-controls button { flex: 1; min-height: 54px; background: #242532; color: #eeeef6; border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 10px; touch-action: none; }
.touch-controls button:active { background: #494052; }
@media (pointer: coarse) { .touch-controls:not(.hidden) { display: flex; } .desktop-controls { display: none; } }
@media (max-width: 1000px), (max-height: 760px) {
  .arcade { width: min(calc(100% - 40px), calc((100svh - 114px) * var(--world-aspect, 1.777778))); }
  .arcade-header { height: 58px; }
  .menu-layout { width: min(770px, 100%); gap: 20px 45px; }
  h1 { font-size: 30px; margin: 13px 0 16px; }
  h1 > span { font-size: 82px; }
  .runner-art { height: 165px; }
  .runner-card { padding: 18px; }
  .runner-lives { margin-top: 16px; padding-top: 14px; }
  .lead { font-size: 14px; margin-bottom: 20px; }
  .btn { padding: 14px 18px; }
  .menu-controls { padding-top: 15px; }
}
@media (max-width: 680px) {
  .arcade { width: calc(100% - 24px); padding-top: max(8px, env(safe-area-inset-top)); }
  .arcade-header { height: 62px; gap: 12px; }
  .catalog-link { font-size: 12px; margin-left: auto; }
  .brand { font-size: 20px; gap: 8px; }
  .brand img { width: 26px; height: 26px; }
  .brand b { font-size: 16px; }
  .brand-divider { margin: 0 9px; }
  .edition, .sound-label, .footer-brand { display: none; }
  #stage { border-radius: 14px; }
  .overlay { padding: 20px; }
  .menu-overlay { position: absolute; min-height: 100%; }
  #stage:has(.menu-overlay:not(.hidden)) { min-height: 610px; background: #111a2b; }
  #stage:has(.menu-overlay:not(.hidden)) #game { visibility: hidden; }
  #stage:has(#screen-over:not(.hidden)) { min-height: 380px; }
  .menu-overlay { background: linear-gradient(180deg, #111423 0%, #111423 58%, #111423bb 100%), url("assets/bg/bg_0.png") center bottom / auto 45% no-repeat; }
  .menu-layout { display: grid; grid-template-columns: 1fr; gap: 18px; text-align: center; }
  .menu-copy { order: 1; }
  .menu-copy .btn { max-width: none; }
  h1 { margin: 12px 0 16px; font-size: 29px; }
  h1 > span { font-size: 80px; }
  .menu-record { margin-top: 12px; }
  .runner-card { order: 2; display: flex; align-items: center; gap: 17px; text-align: left; padding: 11px 17px; }
  .runner-tag, .runner-lives { display: none; }
  .runner-art { height: 66px; width: 65px; flex-shrink: 0; margin: 0; }
  .runner-art img { height: 290%; }
  .runner-name b { font-size: 18px; }
  .menu-controls { order: 3; justify-content: center; flex-wrap: wrap; gap: 12px; padding-top: 14px; font-size: 11px; }
  .menu-controls > span { display: none; }
  .menu-controls .touch-tip { display: block; line-height: 1.5; }
  .arcade-footer { min-height: 40px; font-size: 10px; }
  .desktop-controls { display: none; }
  .touch-controls:not(.hidden) { display: flex; }
  .panel { padding: 21px; }
  h2 { font-size: 26px; margin: 12px 0; }
  .panel .lead { margin-bottom: 10px; }
  .panel .btn { margin-top: 14px; }
  .result-stats { margin: 16px 0; }
}
@media (max-height: 540px) and (min-width: 681px) {
  .arcade { width: min(calc(100% - 28px), calc((100svh - 60px) * var(--world-aspect, 1.777778))); padding-top: 0; }
  .arcade-header { height: 38px; }
  .brand { font-size: 16px; }
  .brand img { width: 23px; height: 23px; }
  .header-actions .icon-button { height: 28px; width: 32px; }
  .arcade-footer { min-height: 22px; font-size: 9px; }
  .overlay { padding: 18px 30px; }
  .menu-layout { gap: 12px 35px; }
  .eyebrow { font-size: 9px; }
  h1 { font-size: 22px; margin: 8px 0; }
  h1 > span { font-size: 58px; }
  .lead { font-size: 12px; margin-bottom: 12px; }
  .btn { padding: 11px 16px; font-size: 14px; }
  .menu-record { margin-top: 9px; font-size: 10px; }
  .runner-art { height: 110px; }
  .runner-name b { font-size: 16px; }
  .runner-lives, .menu-controls { display: none; }
  .runner-card { padding: 14px; }
  .panel { padding: 22px; }
  h2 { font-size: 26px; }
  #hud { padding: 10px; }
  .hud-goal, .hud-center, .hud-right { min-height: 48px; padding-top: 6px; padding-bottom: 6px; }
  .hud-fx { top: 68px; right: 10px; }
  .touch-controls { padding: 0 0 8px; }
  .touch-controls button { min-height: 38px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@container (max-width: 680px) {
  #hud { padding: 10px; gap: 7px; }
  .hud-goal, .hud-center, .hud-right { min-height: 47px; border-radius: 9px; padding: 7px 9px; }
  .hud-goal { min-width: 101px; gap: 5px; }
  .hud-coin { width: 25px; height: 25px; }
  .stat-label { font-size: 8px; }
  .goal-value b, .stat b { font-size: 16px; }
  .goal-value > span { font-size: 10px; }
  .stat.record { display: none; }
  .hud-right { gap: 7px; padding: 7px; }
  .hearts { gap: 2px; }
  .hearts img { width: 16px; height: 16px; }
  .hud-right .icon-button { width: 28px; height: 28px; border-radius: 6px; }
  .hud-right .icon { width: 16px; height: 16px; }
  .hud-fx { top: 67px; right: 10px; max-width: calc(100% - 150px); flex-wrap: wrap; justify-content: flex-end; }
  .milestone { top: 67px; left: 10px; max-width: 125px; flex-direction: column; align-items: flex-start; gap: 3px; padding: 8px 10px; border-radius: 9px; font-size: 11px; }
  .fx { width: 30px; height: 30px; border-radius: 7px; }
  .fx img { width: 23px; height: 23px; }
}
@container (max-width: 340px) {
  #hud { padding: 8px; gap: 4px; }
  .hud-goal { min-width: 89px; padding: 7px 6px; }
  .hud-coin { width: 21px; height: 21px; }
  .goal-value > span { display: none; }
  .hud-center { padding: 7px; }
  .stat b { font-size: 14px; }
  .hud-right { padding: 7px 5px; gap: 4px; }
  .hearts img { width: 14px; height: 14px; }
}

@media (pointer: coarse) and (max-height: 540px) and (min-width: 681px) {
  .arcade { width: min(calc(100% - 28px), calc((100svh - 110px) * var(--world-aspect, 1.777778))); }
}

@media (max-width: 360px) {
  .arcade-header { gap: 8px; }
  .brand { font-size: 18px; gap: 5px; }
  .brand-divider { margin: 0 5px; }
  .header-actions .icon-button { width: 36px; height: 36px; }
}
