:root {
  color-scheme: dark;
  --bg: #0a0b0c;
  --ink: #ecedea;
  --soft: #a9aca9;
  --muted: #8e918f;
  --line: #ecedea1f;
  --cyan: #6ccff6;
  --red: #e5544b;
  --display: "DIN Condensed", "Bahnschrift", "Arial Narrow", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-press: cubic-bezier(0.2, 0, 0, 1);
  --gutter: clamp(24px, 6.6vw, 96px);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100svh; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .4; cursor: wait; }
:focus-visible { outline: 1px solid var(--cyan); outline-offset: 4px; }

/* Black Ops CRT: a fixed hairline raster over every screen. */
.scanlines { position: fixed; inset: 0; z-index: 10; pointer-events: none; background: repeating-linear-gradient(0deg, #00000026 0 1px, transparent 1px 3px); }
body.playing .scanlines { display: none; }

/* The shared display voice: condensed, uppercase, tight. DIN Condensed sits high, so labels get an optical nudge. */
.title, .menu-entry, .menu-action, .panel-heading h2, #status, .primary-action, #roster .name {
  font-family: var(--display);
  font-stretch: condensed;
  font-weight: 600;
  text-transform: uppercase;
}

/* Main menu */
#lobby { min-height: 100svh; display: flex; align-items: center; gap: 56px; padding: 48px var(--gutter); }
.menu-body { width: min(380px, 100%); flex-shrink: 0; }
#lobby { position: relative; overflow: hidden; isolation: isolate; }
#lobby > :not(.menu-backdrop) { position: relative; }

/* The fallen ring (ring.js): a dimmed, slowly turning, burning Halo behind the menu. */
.menu-backdrop { position: absolute; inset: 0; z-index: -1; pointer-events: none; transition: opacity 200ms ease; }
.menu-backdrop::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--bg) 0%, var(--bg) 30%, #0a0b0c99 55%, #0a0b0c33 100%); }
#ring { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 1200ms var(--ease-out); }
#ring.is-ready { opacity: 1; }
#lobby.panel-open .menu-backdrop { opacity: .45; }
.title { margin: 0; font-size: clamp(72px, 8vw, 112px); font-weight: 700; line-height: .86; letter-spacing: .01em; }
.main-menu { display: flex; flex-direction: column; margin-top: clamp(36px, 7vh, 64px); }
.menu-entry {
  display: flex; align-items: center; width: calc(100% + 16px); height: 52px; padding: 4px 16px 0; margin-left: -16px;
  border: 0; background: transparent; color: var(--soft); font-size: 30px; letter-spacing: .04em; text-align: left;
  transform-origin: left center;
  transition: background-color 120ms ease, color 120ms ease, transform 160ms var(--ease-press);
}
.menu-entry.is-current { background: var(--ink); color: var(--bg); }
.menu-entry:focus-visible { outline: none; }

/* One staged entrance, on load only. */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes appear { from { opacity: 0; } }
.title { animation: rise 500ms var(--ease-out) both; }
.menu-entry { animation: appear 400ms var(--ease-out) both; }
.menu-entry:nth-child(1) { animation-delay: 100ms; }
.menu-entry:nth-child(2) { animation-delay: 200ms; }
.menu-entry:nth-child(3) { animation-delay: 300ms; }
.menu-entry:nth-child(4) { animation-delay: 400ms; }

.context-panel { width: min(440px, 100%); max-height: calc(100svh - 96px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 4px 4px 4px 56px; border-left: 1px solid var(--line); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-heading h2 { margin: 0; font-size: 36px; letter-spacing: .04em; }
.back-button { height: 44px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 15px; transition: color 120ms ease; }
label { display: block; margin: 26px 0 0; font-size: 15px; color: var(--muted); }
input, select { display: block; width: 100%; min-width: 0; height: 48px; padding: 0; border: 0; border-bottom: 1px solid #ecedea66; border-radius: 0; background: transparent; color: var(--ink); font-size: 18px; outline: none; transition: border-color 120ms ease; }
input:focus-visible, select:focus-visible { outline: none; border-bottom-color: var(--cyan); }
input::placeholder { color: #6e716f; }
.code-input { height: 56px; font-family: var(--mono); font-size: 22px; letter-spacing: .02em; }
select { appearance: none; cursor: pointer; padding-right: 28px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a9aca9' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 4px center; }
select option { background: #15171a; color: var(--ink); }
.range-label { display: flex; justify-content: space-between; align-items: baseline; }
.range-label output { font-family: var(--mono); font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
input[type="range"] { height: 32px; border: 0; accent-color: var(--cyan); cursor: pointer; }
.field-note { margin: 18px 0 0; font-size: 14px; line-height: 1.6; color: var(--muted); }
.compact-note { margin-top: 8px; }
.panel-actions { display: flex; align-items: center; gap: 28px; margin-top: 32px; }
.primary-action { height: 52px; padding: 4px 40px 0; border: 0; background: var(--ink); color: var(--bg); font-size: 24px; letter-spacing: .06em; transition: transform 160ms var(--ease-press); }
.controls-help { margin-top: 28px; font-size: 14px; line-height: 1.7; color: var(--muted); }
.controls-help summary { cursor: pointer; padding-block: 10px; color: var(--ink); font-size: 15px; }
.controls-help p { margin: 10px 0; }

/* Game stage and its overlay: loading, waiting, paused, error. */
#stage { width: 100%; height: 100svh; background: var(--bg); position: relative; overflow: hidden; }
#game { display: block; width: 100%; height: 100%; object-fit: contain; outline: 0; }
#overlay { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 64px; padding: 48px var(--gutter); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; background: #0a0b0cf5; }
body.paused #overlay { background: linear-gradient(90deg, #0a0b0cf0 0%, #0a0b0cdb 45%, #0a0b0cb3 100%); }
.status-copy { min-width: 0; max-width: 620px; }
#status { margin: 0; font-size: clamp(56px, 7.5vw, 112px); font-weight: 700; line-height: .86; letter-spacing: .01em; overflow-wrap: break-word; }
/* Halo CE magazine: the download fills one round at a time. */
progress { display: block; width: min(537px, 100%); height: 26px; margin-top: 48px; border: 0; appearance: none; background: repeating-linear-gradient(90deg, #ecedea1f 0 6px, transparent 6px 9px); }
progress::-webkit-progress-bar { background: repeating-linear-gradient(90deg, #ecedea1f 0 6px, transparent 6px 9px); }
progress::-webkit-progress-value { background: repeating-linear-gradient(90deg, var(--cyan) 0 6px, transparent 6px 9px); }
progress::-moz-progress-bar { background: repeating-linear-gradient(90deg, var(--cyan) 0 6px, transparent 6px 9px); }
progress:indeterminate { animation: tick-wait 1.4s ease-in-out infinite alternate; }
@keyframes tick-wait { to { opacity: .35; } }
#detail { margin: 18px 0 0; min-height: 1.6em; font-size: 16px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#download-help { margin-top: 4px; font-size: 16px; }
.pause-actions { display: flex; flex-direction: column; align-items: stretch; width: min(360px, 100%); margin-top: 40px; }
.menu-action {
  display: flex; align-items: center; height: 52px; padding: 4px 16px 0; margin-left: -16px; border: 0; background: transparent; color: var(--soft);
  font-size: 30px; letter-spacing: .04em; text-align: left; transform-origin: left center;
  transition: background-color 120ms ease, color 120ms ease, transform 160ms var(--ease-press);
}
.menu-action.primary { background: var(--ink); color: var(--bg); }
.menu-action.quiet { margin-top: 20px; color: var(--red); }

#party { width: min(400px, 100%); align-self: center; }
#tracker { width: 240px; margin: 0 auto 36px; }
#tracker svg { display: block; width: 100%; height: auto; overflow: visible; }
.tracker-grid { fill: none; stroke: #ecedea22; }
.tracker-grid circle:first-child { stroke: #ecedea44; }
.tracker-pulse { fill: none; stroke: var(--cyan); stroke-opacity: .5; transform-box: fill-box; transform-origin: center; animation: tracker 2.4s linear infinite; }
@keyframes tracker { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.2); opacity: 0; } }
#tracker-dots circle { stroke-width: 2; transition: fill 120ms ease; }
#room-label { display: block; font-family: var(--mono); font-size: 15px; font-weight: 400; color: var(--soft); overflow-wrap: anywhere; }
#invite-link { margin-top: 10px; height: 40px; font-family: var(--mono); font-size: 13px; }
#roster { list-style: none; margin: 18px 0 0; padding: 0; border-top: 1px solid var(--line); }
#roster:empty { display: none; }
#roster li { display: flex; align-items: center; gap: 16px; min-height: 52px; border-bottom: 1px solid var(--line); }
#roster .swatch { width: 10px; height: 10px; flex-shrink: 0; border: 1px solid; }
#roster .swatch.solid { background: currentColor; }
#roster .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 24px; letter-spacing: .03em; }
#roster .open .name { color: #6e716f; }
#roster .state { font-size: 14px; color: var(--muted); white-space: nowrap; }
#roster .state.wait { color: var(--cyan); }
#roster .state.bad { color: var(--red); }
#roster .ping { width: 56px; text-align: right; font-family: var(--mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
#party-identity { margin-top: 8px; }
#party-identity label { margin-top: 18px; }
#notice { margin: 18px 0 0; font-size: 14px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; }
#notice:empty { display: none; }

#chat { position: absolute; left: 16px; bottom: 26%; z-index: 2; width: min(560px, calc(100% - 32px)); max-height: calc(74svh - 16px); display: flex; flex-direction: column; gap: 4px; pointer-events: none; font: 14px/1.45 var(--mono); }
#chat-log { display: flex; flex-direction: column; justify-content: safe flex-end; gap: 2px; min-height: 0; max-height: 40svh; overflow: hidden; }
#chat-log > div { align-self: flex-start; max-width: 100%; padding: 2px 8px; background: #0a0b0cb3; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; transition: opacity .4s ease; }
#chat-log > .chat-error { color: var(--red); }
#chat-log > .chat-stale { display: none; }
#chat.is-open #chat-log { overflow-y: auto; pointer-events: auto; scrollbar-width: thin; }
#chat.is-open #chat-log > .chat-stale { display: block; }
#chat-log > .chat-fading { opacity: 0; }
#chat.is-open #chat-log > .chat-fading { opacity: 1; }
body:not(.playing) #chat { display: none; }
#chat-suggestions { list-style: none; margin: 0; padding: 4px 0; align-self: flex-start; flex-shrink: 0; min-width: 200px; max-height: 40svh; overflow-y: auto; background: #0a0b0ce6; border-left: 2px solid var(--cyan); }
#chat-suggestions li { padding: 1px 10px; color: var(--soft); }
#chat-suggestions li.is-current { color: var(--cyan); }
#chat-suggestions li.chat-hint { color: var(--muted); }
#chat.is-open #chat-suggestions { pointer-events: auto; }
#chat-form { flex-shrink: 0; pointer-events: auto; }
#chat-input { width: 100%; height: 34px; margin: 0; padding: 0 10px; border: 0; border-radius: 0; background: #0a0b0cd9; color: var(--ink); font: inherit; outline: 1px solid var(--line); }
#chat-input:focus-visible { outline: 1px solid var(--cyan); }

@media (hover: hover) and (pointer: fine) {
  .menu-action:not(.primary):hover { color: var(--ink); }
  .menu-action.quiet:hover { color: #ff7a70; }
  .back-button:hover { color: var(--ink); }
}
.menu-entry:active:not(:disabled), .menu-action:active:not(:disabled), .primary-action:active:not(:disabled) { transform: scale(.96); }

@media (max-width: 860px) {
  #lobby { flex-direction: column; align-items: stretch; justify-content: center; gap: 40px; }
  #lobby.panel-open { justify-content: flex-start; }
  #lobby.panel-open .menu-body { display: none; }
  .menu-backdrop { opacity: .5; }
  .context-panel { width: 100%; max-height: none; overflow: visible; padding: 0; border-left: 0; }
  #overlay { grid-template-columns: minmax(0, 1fr); align-content: safe center; gap: 40px; }
  #party { width: 100%; }
  #tracker { margin-left: 0; width: 160px; }
}
@media (max-height: 680px) {
  #lobby { min-height: 680px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  .menu-entry:active, .menu-action:active, .primary-action:active { transform: none !important; }
}
