@font-face {
  font-family: 'Orbitron';
  src: url('fonts/orbitron.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}
:root { --red: #ff2a3a; --ink: #fff; --muted: rgba(255,255,255,.62); --card: rgba(8,8,12,.86); --line: rgba(255,255,255,.14); }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #000;
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
/* The 9:16 portrait stage; game.js sizes and centers it, the page around it stays black */
#stage { position: fixed; overflow: hidden; background: #07070b; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#mute, #pause-btn {
  position: absolute; z-index: 3; top: 12px;
  width: 44px; height: 44px; border-radius: 50%; padding: 0;
  border: 1px solid var(--line); background: rgba(10,10,14,.55);
  color: #fff; cursor: pointer; display: grid; place-items: center;
}
#mute { right: 12px; }
#pause-btn { left: 12px; }
#pause-btn[hidden] { display: none; }
#mute svg, #pause-btn svg { width: 20px; height: 20px; }

/* Menus */
#ui { position: absolute; inset: 0; z-index: 2; pointer-events: none; font-family: Orbitron, system-ui, sans-serif; color: var(--ink); }
#ui .backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); pointer-events: auto; }
#ui .card {
  pointer-events: auto; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(380px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; box-sizing: border-box;
  padding: 22px 20px 18px; background: var(--card); border-top: 3px solid var(--red); border-radius: 6px;
  display: flex; flex-direction: column; gap: 10px; text-align: center;
  -webkit-user-select: text; user-select: text; touch-action: auto;
}
#ui .menu { background: rgba(8,8,12,.72); }
#ui h1 { margin: 0; font-size: 48px; font-weight: 800; letter-spacing: .02em; }
#ui h2 { margin: 0; font-size: 26px; font-weight: 800; }
#ui .bar { width: 96px; height: 3px; background: var(--red); margin: -2px auto 4px; }
#ui p { margin: 0; }
#ui .label { font-size: 11px; color: var(--muted); letter-spacing: .12em; }
#ui .score { font-size: 48px; font-weight: 800; line-height: 1; }
#ui .saves { color: #ff6b78; font-size: 12px; font-weight: 800; letter-spacing: .06em; }
#ui .best { font-size: 12px; color: var(--muted); letter-spacing: .08em; }
#ui .newbest { color: var(--red); font-size: 13px; font-weight: 800; letter-spacing: .1em; }
#ui .fine, #ui .account { font-family: system-ui, sans-serif; font-size: 12px; color: var(--muted); line-height: 1.4; }
#ui .fine a { color: #fff; }
#ui .msg { font-family: system-ui, sans-serif; font-size: 13px; color: #ff8a94; }
#ui .help { text-align: left; font-family: system-ui, sans-serif; font-size: 13px; line-height: 1.45; color: rgba(255,255,255,.85); display: grid; gap: 8px; }
#ui .row { display: flex; gap: 10px; justify-content: center; align-items: center; }
#ui .row > button { flex: 1; }
#ui .restarts { justify-content: space-between; font-size: 11px; letter-spacing: .06em; color: var(--muted); text-align: left; }
#ui .restarts b { color: #fff; }
#ui button {
  font: 800 15px/1.1 Orbitron, system-ui, sans-serif; letter-spacing: .04em; color: #fff;
  min-height: 46px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255,255,255,.08); cursor: pointer;
}
#ui button small { display: block; margin-top: 4px; font-size: 10px; font-weight: 500; letter-spacing: .06em; opacity: .85; }
#ui button.primary { background: var(--red); border-color: var(--red); }
#ui button.small { min-height: 34px; padding: 6px 12px; font-size: 11px; flex: none; background: var(--red); border-color: var(--red); }
#ui button.ghost { background: transparent; color: var(--muted); font-size: 12px; min-height: 36px; }
#ui button.ghost.warn { color: #ff8a94; border-color: #ff8a94; }
#ui button.link { background: none; border: 0; min-height: 0; padding: 0; font: inherit; color: #fff; text-decoration: underline; }
#ui button:disabled { opacity: .5; cursor: default; }
#ui button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
#ui input {
  font: 16px system-ui, sans-serif; color: #fff; background: rgba(255,255,255,.08); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px; text-align: center; -webkit-user-select: text; user-select: text;
}
#ui input#si-code { font: 800 24px Orbitron, monospace; letter-spacing: .3em; }
#ui .back { font-size: 11px; color: var(--muted); letter-spacing: .12em; text-decoration: none; margin-top: 2px; }
#ui .back::before { content: '\2190  '; }
#toast {
  position: absolute; z-index: 4; left: 50%; bottom: 20px; transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 999px; background: rgba(8,8,12,.92); border: 1px solid var(--line);
  font: 600 13px system-ui, sans-serif; color: #fff; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  white-space: nowrap;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Small stages (short phones, small windows): tighter menus so everything fits without scrolling */
#stage.compact #ui .card { width: min(420px, calc(100% - 24px)); max-height: calc(100% - 16px); padding: 12px 16px 10px; gap: 6px; }
#stage.compact #ui h1 { font-size: 30px; }
#stage.compact #ui h2 { font-size: 20px; }
#stage.compact #ui .score { font-size: 34px; }
#stage.compact #ui .bar { margin: -2px auto 0; }
#stage.compact #ui button { min-height: 38px; padding: 7px 12px; font-size: 13px; }
#stage.compact #ui button small { margin-top: 2px; }
#stage.compact #ui button.small { min-height: 30px; padding: 4px 10px; font-size: 10px; }
#stage.compact #ui button.ghost { min-height: 30px; }
#stage.compact #ui input { padding: 8px; }
#stage.compact #mute, #stage.compact #pause-btn { top: 8px; width: 38px; height: 38px; }
#stage.compact #mute { right: 8px; }
#stage.compact #pause-btn { left: 8px; }

/* Phones held sideways */
#rotate {
  position: fixed; inset: 0; z-index: 10; background: #000; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  font-family: Orbitron, system-ui, sans-serif; text-align: center; padding: 24px;
}
#rotate[hidden] { display: none; }
#rotate svg { width: 96px; height: 96px; fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
#rotate .phone { stroke: var(--red); transform-origin: 32px 28px; animation: car-hop-turn 2.4s ease-in-out infinite; }
#rotate p { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: .08em; }
#rotate small { font: 14px system-ui, sans-serif; color: var(--muted); }
@keyframes car-hop-turn { 0%, 25% { transform: rotate(-90deg); } 55%, 100% { transform: rotate(0deg); } }
@media (prefers-reduced-motion: reduce) { #rotate .phone { animation: none; transform: rotate(0deg); } }
