:root {
  --text: #f2f2f5;
  --muted: #a8a8b8;
  --panel: rgba(14, 14, 22, 0.92);
  --accent: #ff3a5c;
  --ok: #4ade80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--text); font: 14px/1.4 system-ui, sans-serif; }
#view, #view canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#fade, #flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; }
#flash { background: radial-gradient(transparent 40%, rgba(255, 0, 0, 0.6)); }
#flash.on { animation: flash 0.4s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

#crosshair { position: fixed; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; background: #7dff7d; border-radius: 50%; pointer-events: none; }

#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 1px 2px #000; }
body:not(.playing) #hud, body:not(.playing) #crosshair { display: none; }
#stats { position: absolute; left: 16px; bottom: 14px; display: flex; gap: 18px; font-size: 15px; padding: 4px 12px; border-radius: 8px; background: rgba(0, 0, 0, 0.5); }
#stats b { font-size: 22px; font-variant-numeric: tabular-nums; }
#seed { color: var(--muted); align-self: end; }
#chat { position: absolute; left: 16px; bottom: 60px; max-width: min(640px, 80vw); display: flex; flex-direction: column; gap: 2px; }
#chat div { background: rgba(0, 0, 0, 0.35); padding: 2px 8px; border-radius: 4px; transition: opacity 1s; }
#chat div.old { opacity: 0; }
#center { position: absolute; top: 28%; width: 100%; text-align: center; font-size: 24px; font-weight: 700; }
#hint { position: absolute; top: 12%; width: 100%; text-align: center; font-size: 18px; }

#banner { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); text-align: center; padding: 18px 30px; background: var(--panel); border-radius: 10px; pointer-events: none; }
#banner h2 { margin: 0 0 6px; font-size: 30px; }
#banner.dead h2 { color: var(--accent); }
#banner.won h2 { color: var(--ok); }
#banner p { margin: 0; color: var(--muted); }

#status { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 12px 18px; background: var(--panel); border-radius: 8px; }
#status:empty, #status[hidden] { display: none; }

#menu { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); padding: 16px; }
#menu[hidden] { display: none; }
.panel { width: min(560px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border-radius: 12px; padding: 22px 24px; }
.panel h1 { margin: 0; font-size: 24px; }
.mappick { display: flex; align-items: center; gap: 10px; margin: 6px 0 16px; color: var(--muted); }
.mappick select { flex: 1; font: inherit; padding: 6px 8px; border-radius: 6px; border: 1px solid #33334a; background: #111119; color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }
.primary, .scenario { width: 100%; text-align: left; border: 1px solid #33334a; background: #1c1c2c; border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.primary { background: var(--accent); border-color: var(--accent); text-align: center; font-weight: 700; }
.scenario strong { display: block; }
.scenario span { color: var(--muted); font-size: 13px; }
.scenario:hover { border-color: var(--accent); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 14px 0; }
.settings label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.settings label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.settings input[type=number], .settings select { font: inherit; padding: 6px 8px; border-radius: 6px; border: 1px solid #33334a; background: #111119; color: var(--text); }
.settings input[type=range] { accent-color: var(--accent); }
.secondary { align-self: center; justify-self: start; border: 1px solid #33334a; background: #1c1c2c; border-radius: 6px; padding: 6px 14px; }
.secondary:hover { border-color: var(--accent); }
.keys { margin: 8px 0 4px; }
.note { margin: 0; color: var(--muted); font-size: 12px; }
@media (max-width: 520px) { .settings { grid-template-columns: 1fr; } }
