:root {
  --hud: #7dffb0;
  --hud-dim: rgba(125, 255, 176, 0.55);
  --warn: #ff4d4d;
  --ink: #e9f1f7;
  --panel: rgba(8, 16, 26, 0.82);
  --accent: #ffcf4a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1420; color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
canvas#game, canvas#hud { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#hud { pointer-events: none; }
.hidden { display: none !important; }

.attribution { position: fixed; left: calc(8px + var(--safe-l)); bottom: calc(6px + var(--safe-b)); z-index: 30;
  display: flex; align-items: flex-end; gap: 8px; max-width: 70vw; pointer-events: none;
  font-size: 11px; line-height: 1.25; color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.attribution img { height: 18px; width: auto; flex: none; }

.status { position: fixed; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 25;
  background: var(--panel); padding: 6px 12px; border-radius: 6px; font-size: 13px; }

.overlay { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; padding: 24px calc(16px + var(--safe-r)) 24px calc(16px + var(--safe-l));
  background: linear-gradient(180deg, rgba(5, 10, 18, 0.55), rgba(5, 10, 18, 0.9)); text-align: center; overflow-y: auto; }
.logo { margin: 0; font-size: clamp(34px, 9vw, 72px); letter-spacing: 0.06em; line-height: 0.95; color: var(--accent);
  font-weight: 900; font-style: italic; text-shadow: 0 3px 0 #6b3d00, 0 0 24px rgba(255, 207, 74, 0.35); }
.tagline { margin: 0; font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.85; }
.brief { max-width: 34em; margin: 4px 0; font-size: 14px; opacity: 0.9; }
.keys, .fine { font-size: 12px; opacity: 0.65; margin: 2px 0; }
.opts { display: flex; flex-wrap: wrap; gap: 12px 18px; justify-content: center; font-size: 14px; }
.opts label, .key-box label { display: flex; align-items: center; gap: 6px; }
select, input[type=password] { font: inherit; color: var(--ink); background: #132233; border: 1px solid #35516b; border-radius: 6px; padding: 6px 8px; }
.key-box { display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: min(420px, 100%); background: var(--panel);
  border: 1px solid #35516b; border-radius: 10px; padding: 12px; text-align: left; font-size: 13px; }
.key-box input[type=password] { width: 100%; }
.check { font-size: 13px; }
button { font: inherit; cursor: pointer; }
.big { background: var(--accent); color: #1b1200; border: none; border-radius: 999px; padding: 14px 38px; font-size: 18px;
  font-weight: 800; letter-spacing: 0.08em; box-shadow: 0 4px 0 #8a5a00; }
.big:active { transform: translateY(2px); box-shadow: 0 2px 0 #8a5a00; }
.link { background: none; border: none; color: var(--ink); opacity: 0.75; text-decoration: underline; }
h2 { margin: 0; font-size: 34px; letter-spacing: 0.08em; color: var(--accent); }
#result-text { white-space: pre-line; font-size: 15px; max-width: 30em; }

.top-buttons { position: fixed; top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); z-index: 30; display: flex; gap: 8px; }
.round { min-width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--hud-dim); background: rgba(0, 0, 0, 0.35);
  color: var(--hud); font-weight: 700; font-size: 13px; padding: 0 10px; }

.touch { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.stick-zone { position: absolute; left: 0; top: 0; bottom: 0; width: 55%; pointer-events: auto; }
.stick-base { position: absolute; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%;
  border: 2px solid var(--hud-dim); background: rgba(0, 0, 0, 0.18); }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: rgba(125, 255, 176, 0.35); border: 2px solid var(--hud); }
.right-controls { position: absolute; right: calc(12px + var(--safe-r)); bottom: calc(40px + var(--safe-b)); display: flex;
  align-items: flex-end; gap: 14px; pointer-events: auto; }
.throttle { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--hud); font-size: 11px; font-weight: 700; }
.throttle input { writing-mode: vertical-lr; direction: rtl; width: 44px; height: 150px; accent-color: var(--hud); }
.fire { width: 88px; height: 88px; border-radius: 50%; border: 3px solid var(--warn); background: rgba(255, 77, 77, 0.25);
  color: #fff; font-weight: 900; font-size: 16px; letter-spacing: 0.08em; }
.fire.on { background: rgba(255, 77, 77, 0.6); }

.fatal { position: fixed; left: 0; right: 0; bottom: 0; z-index: 99; background: #b00020; color: #fff; padding: 10px 14px;
  font-size: 14px; white-space: pre-wrap; }
