:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #edf4ff;
  background: #101a2d;
  --edge: #344765;
  --gold: #ffe08a;
  --game-size: min(650px, calc(100vw - 32px), calc(100vh - 258px));
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at top, #223750, #101a2d 68%); min-height: 100vh; }
button, a { -webkit-tap-highlight-color: transparent; }
button {
  font: inherit; color: inherit; border: 1px solid var(--edge); border-radius: 12px;
  background: #23334e; cursor: pointer; padding: .65rem .9rem; min-height: 42px;
  touch-action: manipulation;
}
button:hover:not(:disabled) { background: #344967; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
button:disabled { opacity: .4; cursor: default; }
button.primary { color: #192638; background: var(--gold); border-color: #ffebad; font-weight: 750; }
button.primary:hover { background: #ffecb2; }
[hidden] { display: none !important; }
.app { max-width: 1040px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.app:fullscreen { max-width: none; width: 100%; height: 100%; overflow: auto; background: #101a2d; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
h1 { font-size: clamp(1.2rem, 3.5vw, 1.7rem); letter-spacing: -.04em; margin: 0; }
.badge { font-size: .6rem; letter-spacing: .12em; color: var(--gold); vertical-align: middle; padding-left: .6rem; }
.tagline { color: #aebfd8; font-size: .8rem; margin: 4px 0 0; }
.toolbar { display: flex; gap: 6px; }
.toolbar button { padding: .5rem .65rem; font-size: .8rem; border-radius: 10px; }
.play-layout { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.game-frame {
  position: relative; width: max(260px, var(--game-size)); aspect-ratio: 1;
  border: 4px solid #40536e; border-radius: 10px; background: #000;
  box-shadow: 0 16px 48px #0005; overflow: hidden;
}
#game { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; background: #07101aa8; overflow: auto; }
.menu-card { padding: clamp(14px, 3vw, 26px); width: min(100%, 390px); max-height: 100%; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #647284 transparent; border: 1px solid #647284; border-radius: 18px; background: #17243cee; text-align: center; box-shadow: 0 8px 30px #0007; }
.menu-card h2 { font-size: clamp(1.2rem, 4vw, 1.7rem); margin: .35rem 0 .5rem; }
.menu-card p { line-height: 1.45; margin: .6rem 0; font-size: .9rem; }
.menu-card .eyebrow { font-size: .58rem; color: var(--gold); letter-spacing: .12em; }
.menu-card .small { font-size: .7rem; color: #b4c5dc; }
.menu-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
progress { width: 100%; height: 10px; border: 0; border-radius: 5px; accent-color: var(--gold); margin: 14px 0; }
.touch-controls { display: flex; width: max(260px, var(--game-size)); justify-content: space-between; gap: 12px; user-select: none; -webkit-user-select: none; }
.movement, .actions { display: flex; gap: 7px; min-width: 0; }
.movement { flex: 1; }
.actions { flex: 2; }
.actions button { flex: 1; min-width: 0; }
.touch-controls button { touch-action: none; min-height: 62px; padding: .5rem .8rem; font-size: .9rem; box-shadow: 0 4px 0 #070f1d; }
.movement button { flex: 1; min-width: 0; font-size: 1.4rem; }
.touch-controls span { display: block; margin-top: 5px; font-size: .55rem; color: #bed1e8; }
.touch-controls .fire { background: #67465f; border-color: #ae739c; }
.touch-controls .jump { background: #255962; border-color: #4d9da8; }
.touch-controls .cycle { padding-inline: .55rem; }
.touch-controls button.held { background: var(--gold); color: #15233a; transform: translateY(3px); box-shadow: 0 1px 0 #070f1d; }
.touch-controls button.held span { color: #344765; }
.statusbar { max-width: 650px; margin: 14px auto 0; font-size: .72rem; color: #b3c6df; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.notice { max-width: 650px; margin: 12px auto 0; border-left: 3px solid var(--gold); padding: 8px 12px; color: #ffe8a7; background: #302e32; font-size: .8rem; }
.instructions { max-width: 750px; margin: 20px auto; border: 1px solid var(--edge); background: #17243c; border-radius: 16px; padding: 22px; line-height: 1.55; }
.instructions h2 { margin-top: 0; }
.instructions p, dd { font-size: .9rem; }
dt { color: var(--gold); font-weight: 650; margin-top: 12px; }
dd { margin: 4px 0 0; }
footer { margin: 22px 0 0; color: #90a6c3; text-align: center; font-size: .65rem; line-height: 1.6; display: grid; gap: 4px; }
a { color: #cee4ff; }
@supports (height: 100svh) { :root { --game-size: min(650px, calc(100vw - 32px), calc(100svh - 258px)); } }
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
  .toolbar { margin-left: auto; }
  .toolbar button { min-height: 36px; }
  .tagline { font-size: .7rem; }
  .touch-controls { gap: 6px; }
  .movement, .actions { gap: 5px; }
  .movement button { min-width: 40px; padding: .4rem .55rem; }
  .touch-controls button { font-size: .8rem; padding: .4rem .5rem; }
  .touch-controls span { font-size: .49rem; }
  .menu-card { padding: 12px; border-radius: 12px; }
  .menu-card p { font-size: .8rem; }
  .menu-actions { margin-top: 10px; gap: 6px; }
  .menu-actions button { min-height: 36px; padding: .45rem; font-size: .85rem; }
  .statusbar { font-size: .65rem; }
}
@media (max-height: 700px) {
  .menu-card { padding: 12px; }
  .menu-card h2 { font-size: 1.15rem; }
  .menu-card p { font-size: .8rem; }
  .menu-card .eyebrow { display: none; }
  .menu-actions { gap: 6px; margin-top: 10px; }
  .menu-actions button { min-height: 36px; padding: .45rem; font-size: .85rem; }
}
@media (orientation: landscape) and (max-height: 560px) {
  :root { --game-size: min(650px, calc(100vh - 85px), calc(100vw - 255px)); }
  .app { max-width: 1100px; padding-top: 8px; }
  .topbar { margin-bottom: 8px; flex-wrap: nowrap; }
  .tagline { display: none; }
  .play-layout { flex-direction: row; justify-content: center; align-items: center; }
  .game-frame { width: var(--game-size); min-width: 200px; }
  .touch-controls { width: 190px; flex-direction: column; gap: 12px; }
  .movement { justify-content: center; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .actions .fire { grid-column: span 2; }
  .menu-card { padding: 10px; }
  .menu-card .eyebrow, .menu-card .small { display: none; }
  .menu-card h2 { font-size: 1rem; }
  .menu-card p { font-size: .7rem; }
  .menu-actions { margin-top: 8px; gap: 4px; }
  .menu-actions button { padding: .35rem; min-height: 30px; font-size: .8rem; }
  .statusbar { margin-top: 7px; }
  footer { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
