: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, #lag { color: var(--muted); align-self: end; }
#lag:empty { display: none; }
#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; }
#menu { user-select: none; transition: background-color 0.15s; }
.panel, .panel > *, .settings > * { transition: opacity 0.15s, background-color 0.15s, box-shadow 0.15s; }
/* moving a FOV slider fades everything but that slider, so the view behind shows the result */
body.fov-preview #menu, body.fov-preview .panel { background: transparent; }
body.fov-preview .panel > :not(.settings), body.fov-preview .settings > :not(.previewing) { opacity: 0; pointer-events: none; }
body.fov-preview .settings > .previewing { background: var(--panel); box-shadow: 0 0 0 8px var(--panel); border-radius: 2px; }
body.fov-preview #crosshair { display: block; }
.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); }
button { font: inherit; color: inherit; cursor: pointer; }

/* map dropdown (src/mappicker.js) */
.mp { position: relative; flex: 1; min-width: 0; }
.mp-button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px 6px 6px; text-align: left;
  border: 1px solid #33334a; border-radius: 8px; background: #111119; }
.mp-button:hover, .mp-button[aria-expanded=true] { border-color: var(--accent); }
.mp-button:focus-visible, .mp-list:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mp-thumb { flex: none; width: 64px; aspect-ratio: 16 / 9; border-radius: 4px; background: #1d1d2a center / cover no-repeat; }
.mp-thumb.none { display: grid; place-items: center; color: #3b3b52; font-size: 10px; }
.mp-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mp-name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-sub { color: var(--muted); font-size: 12px; }
.mp-chevron { flex: none; width: 8px; height: 8px; margin: 0 4px 4px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform 0.15s; }
.mp-button[aria-expanded=true] .mp-chevron { transform: translateY(4px) rotate(-135deg); }
.mp-list { position: absolute; z-index: 1; left: 0; right: 0; top: calc(100% + 4px); max-height: min(340px, 60vh); overflow: auto;
  margin: 0; padding: 4px; list-style: none; border: 1px solid #33334a; border-radius: 8px; background: #111119;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); }
.mp-list[hidden] { display: none; }
.mp-option { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.mp-option.active { background: #1c1c2c; }
.mp-option[aria-selected=true] .mp-name { color: var(--accent); }
.empty { margin: 0 0 8px; padding: 12px 14px; border: 1px dashed #33334a; border-radius: 8px; color: var(--muted); }
.empty a { color: var(--accent); }
.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=checkbox] { accent-color: var(--accent); }
.settings output { position: absolute; right: 0; top: 0; color: var(--text); font-variant-numeric: tabular-nums; }

/* sliders: a slim track filled up to the thumb; --fill (0..1) comes from main.js, Firefox fills it natively */
.settings input[type=range] { --thumb: 16px; --track: 6px; -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; }
.settings input[type=range]:focus-visible { outline: none; }
.settings input[type=range]::-webkit-slider-runnable-track { height: var(--track); border-radius: var(--track);
  background: linear-gradient(to right, var(--accent) calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--fill, 0)), #2a2a3d 0); }
.settings input[type=range]::-moz-range-track { height: var(--track); border-radius: var(--track); background: #2a2a3d; }
.settings input[type=range]::-moz-range-progress { height: var(--track); border-radius: var(--track); background: var(--accent); }
.settings input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
  width: var(--thumb); height: var(--thumb); margin-top: calc((var(--track) - var(--thumb)) / 2); border: 0; border-radius: 50%;
  background: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); transition: box-shadow 0.15s, transform 0.15s; }
.settings input[type=range]::-moz-range-thumb { width: var(--thumb); height: var(--thumb); border: 0; border-radius: 50%;
  background: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); transition: box-shadow 0.15s, transform 0.15s; }
.settings input[type=range]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgba(255, 58, 92, 0.22); }
.settings input[type=range]:hover::-moz-range-thumb { box-shadow: 0 0 0 6px rgba(255, 58, 92, 0.22); }
.settings input[type=range]:active::-webkit-slider-thumb { box-shadow: 0 0 0 8px rgba(255, 58, 92, 0.3); transform: scale(1.12); }
.settings input[type=range]:active::-moz-range-thumb { box-shadow: 0 0 0 8px rgba(255, 58, 92, 0.3); transform: scale(1.12); }
.settings input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px #0e0e16, 0 0 0 5px var(--accent); }
.settings input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px #0e0e16, 0 0 0 5px var(--accent); }
.settings label:has(output) { position: relative; }
.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; }

/* bug reports and ideas (src/contact.js); selectable, unlike the rest of the menu */
.contact { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid #262636; color: var(--muted); font-size: 13px; user-select: text; }
.contact a { color: var(--text); text-underline-offset: 2px; }
.contact a:hover { color: var(--accent); }
.contact button { padding: 0 6px; border: 1px solid #33334a; border-radius: 4px; background: #1c1c2c; color: var(--text); }
.contact button:hover { border-color: var(--accent); }
.contact button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.contact button.copied { border-color: var(--ok); color: var(--ok); }
@media (max-width: 520px) { .settings { grid-template-columns: 1fr; } }
