/* The browser twin of ios/DefuseGame/App/Sources/Theme.swift.
   Ported from the approved design in design/prototypes/menu-demo (styles.css + dark.css): a bunker-dark
   field-operations interface — charcoal room, printed stationery, one emergency red.
   The fonts are self-hosted in ./fonts so the deployed game asks no CDN for anything. */

@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/barlow-condensed-500.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-600.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-700.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/dm-sans-400-700.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-400.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-500.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-mono-600.woff2) format('woff2'); }

:root {
  color-scheme: dark;
  --bg: #090b0c;
  --paper: #111516;
  --ink: #d8d9d4;
  --muted: #8c9391;
  --line: #2b3030;
  --orange: #d64a40;
  --olive: #9aa58c;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Barlow Condensed', 'Arial Narrow', Impact, sans-serif;
}

* { box-sizing: border-box; }
/* Beats the display rules below, so hiding anything is always just `element.hidden = true`. */
[hidden] { display: none !important; }
html { min-width: 320px; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(ellipse at 85% 0, #52242216, transparent 50%), var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  /* A game, not a document: a stray drag, double-click, long press or select-all highlights nothing.
     What a player genuinely copies or pastes — the invitation link — opts back in below. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input { -webkit-user-select: text; user-select: text; }
/* A fine paper tooth over the whole page, inverted for the dark room. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: .13;
  filter: invert(1);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23000' opacity='.13' filter='url(%23n)' d='M0 0h180v180H0z'/%3E%3C/svg%3E");
}
button, input { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .5; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }
::selection { background: #853b36; color: #fff; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }
button:focus-visible { outline: 3px solid var(--orange); outline-offset: 4px; }
/* Each new screen takes focus so screen readers announce it; that should not draw a ring. */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }
/* The round's readouts: off screen, and read by the tests alone. */
.round-readout { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.noscript { padding: 40px 22px; color: var(--muted); }

/* ─── Page scaffold ─────────────────────────────────────────────────────────────── */

.screen { display: block; }
/* `viewport-fit=cover` runs the page to the physical edges of the screen, so every gutter here
   clears the safe area: the notch and the Dynamic Island in portrait, the sensor housing in
   landscape, the home indicator, and the iPad's rounded corners. On a desktop every inset is 0,
   so the numbers below are exactly the ones the design asks for. */
.site-shell { max-width: 1160px; margin: auto; padding: 0 max(48px, env(safe-area-inset-right)) 0 max(48px, env(safe-area-inset-left)); min-height: 100svh; display: flex; flex-direction: column; }
.view { flex: 1; padding: calc(38px + env(safe-area-inset-top)) 0 calc(45px + env(safe-area-inset-bottom)); animation: arrive .4s ease both; }
@keyframes arrive { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
.view.settled { animation: none; }

.page-topline { display: flex; align-items: center; justify-content: space-between; margin: 0 0 37px; }
.back-link { display: flex; gap: 9px; align-items: center; min-height: 44px; padding: 6px 8px 6px 0; font: 10px var(--mono); letter-spacing: .5px; color: var(--muted); }
.back-link:hover { color: var(--orange); }
.edition { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0 0 8px; font: 9px var(--mono); letter-spacing: 4px; color: #90958c; }

.page-heading { text-align: center; margin-bottom: 45px; }
.page-heading h1 { font: 600 58px/.98 var(--display); letter-spacing: 1px; text-transform: uppercase; margin: 12px 0; }
.page-heading p { margin: 12px auto 0; max-width: 460px; color: var(--muted); font-size: 13px; line-height: 1.7; }

.eyebrow { display: flex; align-items: center; gap: 10px; font: 500 10px var(--mono); letter-spacing: 1.7px; text-transform: uppercase; }
.status-dot { display: inline-block; width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: #d35349; box-shadow: 0 0 8px #e1464560; }
.helper { margin-top: 12px; font-size: 11px; line-height: 1.7; color: var(--muted); }

.section-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 17px; }
.section-heading h2 { font-size: 12px; font-weight: 500; letter-spacing: .7px; }

/* ─── Start a game ──────────────────────────────────────────────────────────────── */

.workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(290px, 1fr); gap: 40px; align-items: start; }
.setup-form { border-top: 1px solid var(--line); }
.form-section { padding: 25px 0; border-bottom: 1px solid var(--line); }

.mission-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mission-option, .role-option {
  position: relative;
  text-align: left;
  border: 1px solid #303637;
  background: linear-gradient(145deg, #191d1e, #111415);
  transition: background .2s, border-color .2s;
}
.mission-option { min-height: 137px; padding: 15px 13px; }
.mission-option[data-selected="true"], .role-option[data-selected="true"] {
  background: linear-gradient(135deg, #2e2322, #1c1b1b);
  border-color: #9e4b40;
  box-shadow: inset 0 0 0 1px #9e4b4025, 0 0 24px #a0312708;
}
.choice-check { position: absolute; right: 11px; top: 12px; display: grid; place-items: center; width: 12px; height: 12px; font-size: 9px; border: 1px solid #59615c; border-radius: 50%; }
.choice-check:empty { background: transparent; }
.mission-option[data-selected="true"] .choice-check,
.role-option[data-selected="true"] .choice-check { background: #a84337; border-color: #a84337; color: #fff; }
.mission-icon { height: 30px; width: 40px; margin: 2px 0 11px; color: #a8b09f; }
.mission-option strong { display: block; font-size: 12px; font-weight: 650; }
.mission-option small { display: block; margin-top: 7px; font: 9px var(--mono); color: var(--muted); white-space: nowrap; }

.role-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* The expert's difficulty: a stepped slider, the level names under its stops, and what the level means. */
.difficulty-slider { display: block; width: 100%; height: 44px; margin: 0; accent-color: #c2503f; background: transparent; cursor: pointer; }
/* A native thumb's centre runs from half a thumb in from one end to half a thumb in from the other. */
.difficulty-names { position: relative; height: 13px; margin: 2px 8px 0; font: 9px var(--mono); letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.difficulty-names span { position: absolute; left: calc(var(--at) * 100%); transform: translateX(-50%); white-space: nowrap; }
.difficulty-names span:first-child { transform: translateX(-8px); }
.difficulty-names span:last-child { transform: translateX(calc(-100% + 8px)); }
.difficulty-names span[data-selected="true"] { color: #e6e7dd; }
.difficulty-caption { min-height: 19px; }
.role-option { display: flex; gap: 12px; align-items: center; padding: 18px 13px; }
.role-icon { width: 29px; height: 29px; flex-shrink: 0; color: #a8b09f; }
.role-option strong { display: block; font-size: 12px; }
.role-option small { display: block; margin-top: 4px; font-size: 10px; color: var(--muted); }


/* ─── Buttons ───────────────────────────────────────────────────────────────────── */

.button {
  display: inline-flex; justify-content: space-between; align-items: center; gap: 25px;
  min-height: 47px; padding: 0 19px;
  font-size: 12px; font-weight: 600; text-align: left;
  color: #daddd6; border: 1px solid #414846;
  transition: background .18s;
}
.button:hover { background: #272c2b; }
.button.primary {
  justify-content: center;
  color: #f3e6df;
  background: linear-gradient(#973b32, #752a25);
  border-color: #b55346;
  box-shadow: inset 0 1px 0 #ef99851a, 0 4px 20px #0003;
}
.button.primary:hover { background: #a64135; border-color: #e07561; }
.button.primary:disabled:hover { background: linear-gradient(#973b32, #752a25); border-color: #b55346; }
.button.full { width: 100%; }
.button.compact { min-height: 35px; padding: 0 11px; gap: 8px; font-size: 10px; }
.button > span.glyph { font-size: 21px; font-weight: 400; }
.button.compact > span.glyph { font-size: 14px; }

/* ─── Mission brief sidebar ─────────────────────────────────────────────────────── */

.mission-sidebar {
  position: relative;
  overflow: hidden;
  color: var(--ink);
  background: linear-gradient(155deg, #1b2020, #101415 65%);
  border: 1px solid #343b36;
  box-shadow: 0 16px 45px #0005;
}
.sidebar-top { display: flex; justify-content: space-between; align-items: center; padding: 25px 25px 0; color: #9da69b; }
.sidebar-top .eyebrow { font-size: 8px; letter-spacing: 1.2px; }
.sidebar-top > span { font: 8px var(--mono); }
.sidebar-art {
  position: relative;
  display: grid;
  place-items: center;
  height: 191px;
  margin: 12px 15px 0;
  background-image: radial-gradient(ellipse, #ab382017, transparent 68%), linear-gradient(#b7c0b009 1px, transparent 1px), linear-gradient(90deg, #b7c0b009 1px, transparent 1px);
  background-size: auto, 22px 22px, 22px 22px;
}
.sidebar-art img { height: 216px; width: 100%; padding: 14px 18px 4px; object-fit: contain; filter: drop-shadow(0 15px 15px #0009); }
.sidebar-art::before, .sidebar-art::after { position: absolute; content: "+"; font: 18px var(--mono); color: #5b675c; }
.sidebar-art::before { left: 4px; top: 10px; }
.sidebar-art::after { right: 4px; bottom: 10px; }
.sidebar-body { padding: 9px 23px 25px; }
.sidebar-body h2 { font: 500 30px var(--display); margin-bottom: 5px; }
.mission-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 21px 0; padding: 16px 0; border-top: 1px solid #363e38; border-bottom: 1px solid #363e38; }
.mission-stats div { padding-left: 15px; border-right: 1px solid #363e38; }
.mission-stats div:first-child { padding-left: 0; }
.mission-stats div:last-child { border: 0; }
.mission-stats strong { display: block; font: 500 21px var(--mono); color: #d4d6c9; }
.mission-stats div:first-child strong { color: #e27763; text-shadow: 0 0 16px #da493b30; }
.mission-stats small { display: block; margin-top: 6px; font: 7px var(--mono); letter-spacing: 1px; color: #9da69b; }
.invite-label { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font: 8px var(--mono); letter-spacing: 1.1px; color: #9da69b; }
/* The link itself stays on the page so it can always be copied by hand, but on one clipped line:
   the whole link is still the element's text, so select-all and the copy fallback take all of it,
   while the seed runs off the end instead of being set out where a player reads it. */
.invite-url { margin-bottom: 10px; padding: 9px 10px; background: #080b0c; border: 1px solid #333b38; font: 400 10px/1.5 var(--mono); color: #aeb5ad; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-user-select: all; user-select: all; }
.invite-tools { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.invite-tools .button { min-height: 44px; font-size: 10px; gap: 10px; }
.invite-tools .share-button { justify-content: center; width: 44px; padding: 0; font-size: 19px; }
.mission-sidebar .button:not(.primary) { border-color: #444d45; color: #d1d7c9; }
.mission-sidebar .button:not(.primary):hover { background: #2a322d; }
.mission-sidebar .button.primary { margin-top: 18px; }
.copied-note { margin-top: 10px; font-size: 10px; line-height: 1.6; color: #adb998; }

.input-caption { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font: 8px var(--mono); letter-spacing: .3px; color: var(--muted); }


/* ─── How to Play ───────────────────────────────────────────────────────────────── */

.manual-layout { max-width: 790px; margin: 0 auto; }
.manual-paper {
  padding: 28px;
  background: linear-gradient(125deg, #1c211f, #121716);
  border: 1px solid #3a4238;
  box-shadow: 5px 5px 0 #080c0a, 0 20px 50px #0004;
}
.manual-section { padding-top: 29px; }
.manual-section:first-child { padding-top: 0; }
.manual-section .section-heading h2 { font: 500 28px var(--display); letter-spacing: 0; }
.manual-section > p { max-width: 610px; font-size: 12px; line-height: 1.85; color: var(--muted); }

.manual-role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.manual-role { padding: 21px; background: #151b16; border: 1px solid #384232; }
.manual-role .role-icon { width: 35px; height: 35px; margin-bottom: 17px; }
.manual-role h2 { font: 500 27px var(--display); margin-bottom: 12px; }
.manual-role p { font-size: 11px; line-height: 1.8; color: var(--muted); }

.setup-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 15px 0 0; padding: 0; list-style: none; }
.setup-steps strong { display: block; margin-bottom: 6px; font-size: 11px; }
.setup-steps p { font-size: 10px; line-height: 1.8; color: var(--muted); }

.win-lose { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 16px; }
.condition { padding: 17px; background: #202a20; border-left: 3px solid #819570; }
.condition.danger { background: #2d201d; border-color: #ab5141; }
.condition strong { display: block; margin-bottom: 7px; font-size: 11px; }
.condition strong > span { margin-right: 7px; }
.condition p { font-size: 10px; line-height: 1.8; color: #a4ad9b; }


.guide-bottom { display: flex; justify-content: center; padding-top: 28px; }
.guide-bottom .button { min-width: 240px; }

/* ─── Start together / Result ───────────────────────────────────────────────────── */

.brief-sheet {
  max-width: 490px; margin: 0 auto; padding: 30px;
  background: linear-gradient(130deg, #1b2020, #111516);
  border: 1px solid #363c38;
  box-shadow: 5px 5px 0 #080a0a, 0 16px 45px #0004;
}
.detail { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 15px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.detail-label { color: var(--muted); text-transform: uppercase; letter-spacing: .8px; font: 8px var(--mono); }
.detail-value { font-size: 12px; }
.detail-value.mono { font: 500 12px var(--mono); letter-spacing: 1px; }
.countdown { padding: 12px 0; font: 500 96px/1 var(--mono); font-variant-numeric: tabular-nums; text-align: center; color: var(--orange); text-shadow: 0 0 40px #d64a4030; }
.center { text-align: center; }
.partner-state { display: inline-flex; align-items: center; gap: 8px; }
.partner-state .status-dot { width: 8px; height: 8px; }
.partner-state .status-dot[data-connected="true"] { background: #6fbf5b; box-shadow: 0 0 8px #6fbf5b80; }
.ready-invite { margin-top: 22px; }
.ready-invite .button:not(.primary) { border-color: #444d45; color: #d1d7c9; }
.ready-invite .button:not(.primary):hover { background: #2a322d; }
.lobby-line { min-height: 19px; }
.lobby-line[data-problem="true"] { color: var(--orange); }
.pointer-lock { pointer-events: none; }
.page-heading h1.headline { font: 600 72px/1 var(--display); letter-spacing: 4px; text-transform: uppercase; margin: 0; }
.page-heading h1.headline.won { color: #adb998; }
.page-heading h1.headline.lost { color: #e27763; }
.result-actions { display: grid; gap: 10px; margin-top: 26px; }

/* ─── The title screen ──────────────────────────────────────────────────────────── */

.screen.home { background: #0b1011; }
.title-screen { position: relative; min-height: 100svh; display: grid; place-items: center; isolation: isolate; overflow: hidden; background: #0d1213; }
.title-scenery { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.bunker-wall {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 46% 35%, #7184872f, transparent 48%),
    radial-gradient(ellipse at 10% 82%, #354d4829, transparent 40%),
    linear-gradient(105deg, #172022 0%, #111718 48%, #171416 100%);
}
.bunker-wall::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .62;
  background:
    linear-gradient(90deg, transparent 13.9%, #aab8b31d 14%, #05080830 14.15%, transparent 14.35%),
    linear-gradient(90deg, transparent 71.9%, #aab8b319 72%, #05080838 72.15%, transparent 72.35%),
    repeating-linear-gradient(0deg, transparent 0 207px, #a5b4ae12 208px, #02040440 209px, transparent 212px);
}
.bunker-wall::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .5;
  background:
    radial-gradient(circle at 14% 16%, #aab7b345 0 2px, transparent 2.5px),
    radial-gradient(circle at 72% 16%, #aab7b33d 0 2px, transparent 2.5px),
    radial-gradient(circle at 14% 67%, #aab7b338 0 2px, transparent 2.5px),
    radial-gradient(circle at 72% 67%, #aab7b332 0 2px, transparent 2.5px);
}
.emergency-light {
  position: absolute;
  width: 6px; height: 126px; right: 12.5%; top: 10%;
  background: linear-gradient(#ff8d69, #d34935 45%, #7d251d);
  border: 1px solid #ffb09270;
  box-shadow: 0 0 8px #ff6848, 0 0 38px 13px #dc3b2f57, 0 0 125px 70px #9f302837;
  transform: rotate(22deg);
  opacity: .82;
}
.light-spill {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 91% 13%, #b23d304c, transparent 39%),
    radial-gradient(ellipse at 4% 91%, #647d7040, transparent 43%),
    radial-gradient(ellipse at 50% 44%, #a7b5b00c, transparent 56%);
  animation: light-breathe 9s ease-in-out infinite alternate;
}
@keyframes light-breathe { from { opacity: .78; } to { opacity: 1; } }
.hanging-wires { position: absolute; inset: 0; width: 100%; height: 100%; stroke: #3a4141; stroke-width: 8; filter: drop-shadow(5px 5px 3px #0009); opacity: .78; }
.hanging-wires .red-wire { stroke: #7e3b31; stroke-width: 5; }
.shadow-device {
  position: absolute;
  width: min(59vw, 850px); bottom: -24%; left: -14%;
  transform: rotate(28deg);
  opacity: .72;
  filter: saturate(.42) brightness(.64) contrast(1.08) drop-shadow(18px 22px 24px #0008);
  mask-image: linear-gradient(90deg, #000 42%, #000d 68%, transparent 100%);
}
.shadow-device img { display: block; width: 100%; }
.floor-haze { position: absolute; inset: 50% -20% -10%; background: radial-gradient(ellipse at 31% 78%, #90a59b24, transparent 57%); filter: blur(24px); }
.scene-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 43%, transparent 17%, #03050520 62%, #0204049c 100%); }
.film-grain {
  position: absolute; inset: 0; opacity: .095;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23fff' opacity='.35' filter='url(%23n)' d='M0 0h200v200H0z'/%3E%3C/svg%3E");
}
.title-content { position: relative; width: 100%; text-align: center; padding: 60px max(24px, env(safe-area-inset-right)) 80px max(24px, env(safe-area-inset-left)); transform: translateY(-2vh); }
.game-title {
  display: inline-block;
  margin: 0 0 0 .15em;
  font: 600 clamp(90px, 11vw, 156px)/1 var(--display);
  letter-spacing: .15em;
  color: #c6c8c2;
  background: linear-gradient(170deg, #edece2 0%, #b3b7b0 47%, #858d87 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  mask-image: repeating-linear-gradient(0deg, #000 0 3px, #000b 3px 4px, #000 4px 7px);
}
.title-rule { width: 35px; height: 2px; margin: 29px auto 45px; background: #a54235; box-shadow: 0 0 15px #ac3c3140; }
.title-menu { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.title-option {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 310px; max-width: 100%; min-height: 57px;
  font: 450 14px var(--mono); letter-spacing: 2px;
  color: #969b96;
  transition: color .2s, text-shadow .2s, background .2s;
}
.title-option::before, .title-option::after {
  content: "";
  position: absolute;
  width: 15px; height: 1px;
  background: #ba5140;
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
.title-option::before { left: 22px; transform: translateX(-7px); }
.title-option::after { right: 22px; transform: translateX(7px); }
.title-option.selected { color: #e6e7dd; text-shadow: 0 0 20px #eae9c72b; background: linear-gradient(90deg, transparent, #b9b79a07, transparent); }
.title-option.selected::before, .title-option.selected::after { opacity: 1; transform: none; }
.title-option:focus-visible { outline: 1px solid #925244; outline-offset: 2px; }
/* Why an invitation that was opened could not be: the title screen is where a refused one lands. */
.title-notice { max-width: 310px; margin: 22px auto 0; font: 400 11px/1.6 var(--mono); letter-spacing: .3px; color: var(--orange); text-align: center; }
.title-version { position: absolute; left: 0; right: 0; bottom: calc(22px + env(safe-area-inset-bottom)); font: 400 8px var(--mono); letter-spacing: 1.6px; color: #5f6663; }

/* ─── Toast ─────────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; bottom: calc(28px + env(safe-area-inset-bottom)); left: 50%; z-index: 20;
  width: max-content; max-width: calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
  padding: 15px 24px;
  font-size: 12px;
  color: #e4e6d9; background: #252e27; border: 1px solid #526046;
  box-shadow: 0 12px 35px #0008;
  opacity: 0; pointer-events: none; transform: translate(-50%, 20px);
  transition: opacity .2s, transform .2s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
/* During a round the room fills the window and lines its own controls along the bottom edge, so a
   toast at 28px lands on top of them — on the expert's disk buttons in particular. It rides above
   the notice line instead, clearing the notice's own height. The ID beats the narrow-screen rule
   below on specificity, so a round toast keeps this offset at every size. */
#round:not([hidden]) ~ .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
#round:not([hidden]):has(.notice-wrap.expert) ~ .toast { bottom: calc(230px + env(safe-area-inset-bottom)); }

/* ─── The live round: the room fills the window with no HUD over it ─────────────── */

#round { position: fixed; inset: 0; background: #000; }
.room { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }
.notice-wrap { position: absolute; left: calc(16px + env(safe-area-inset-left)); right: calc(16px + env(safe-area-inset-right)); bottom: calc(104px + env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; }
/* The expert's office stacks more above the room's bottom buttons (disk readout over Insert disk), so its notice sits higher, as in ActiveRoundView. */
.notice-wrap.expert { bottom: calc(184px + env(safe-area-inset-bottom)); }
.notice { max-width: 100%; padding: 9px 14px; font-size: 14px; color: #a3aa9d; background: #202623e6; border-radius: 999px; transition: opacity .2s; }
.notice:empty { opacity: 0; }
/* A room error runs to 1500 characters. Centred and clipped, a long one lost both its title off
   the top and its tail off the bottom with nothing to scroll: `safe center` keeps the start of
   the message reachable, and `auto` lets the rest be scrolled to. */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  justify-content: center; justify-content: safe center;
  overflow: auto; overscroll-behavior: contain;
  padding: calc(28px + env(safe-area-inset-top)) calc(28px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(28px + env(safe-area-inset-left));
  text-align: center; background: var(--bg); transition: opacity .2s;
}
.overlay.error { gap: 10px; background: rgba(9, 11, 12, .94); }
.overlay-title { font: 600 26px var(--display); letter-spacing: 1px; text-transform: uppercase; }
/* A room error is whatever WebGL said, file names and URLs included: none of it may push the
   overlay sideways. */
.overlay .copy { font-size: 12px; line-height: 1.7; color: var(--muted); overflow-wrap: anywhere; }
/* Browser-only pause menu over the round. */
.pause {
  width: min(380px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto; overscroll-behavior: contain;
  padding: 28px; flex-direction: column; gap: 14px; color: var(--ink);
  background: linear-gradient(140deg, #222720, #111713); border: 1px solid #556148; box-shadow: 0 25px 100px #000b;
}
.pause[open] { display: flex; }
.pause::backdrop { background: #030605e0; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.pause h2 { font: 600 40px var(--display); letter-spacing: 1px; text-transform: uppercase; }
.pause p { font-size: 11px; line-height: 1.8; color: var(--muted); }
.pause .button { width: 100%; }
.spinner { width: 22px; height: 22px; border: 2px solid rgba(214, 74, 64, .25); border-top-color: var(--orange); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── The field report ──────────────────────────────────────────────────────────── */

/* Bottom right of the title screen and of both result screens, on the page rather than inside
   either — a screen is rebuilt on every render, and `.view` animates in on a transform, which
   would make it the thing a fixed child is positioned against. */
.corner-bar {
  position: fixed; z-index: 15; display: flex; gap: 8px;
  right: calc(20px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom));
}
.feedback-button {
  display: flex; text-decoration: none; align-items: center; gap: 9px;
  min-height: 42px; padding: 0 15px;
  font: 400 9px var(--mono); letter-spacing: 1.4px;
  color: #98a099; background: #141a1ad9; border: 1px solid #39423c;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: color .2s, background .2s, border-color .2s;
}
.feedback-button:hover { color: #e6e7dd; background: #1d2322e6; border-color: #8a4437; }
.feedback-button > .glyph { font-size: 14px; letter-spacing: 0; }
/* A screen carrying the button leaves room under itself, so it never sits on the last control. */
.has-feedback .view { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }

.feedback {
  width: min(420px, calc(100vw - 30px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: calc(100dvh - 30px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto; overscroll-behavior: contain;
  padding: 0; color: var(--ink); background: none; border: 0;
}
.feedback::backdrop { background: #030605e0; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.feedback-sheet {
  position: relative;
  display: flex; flex-direction: column; gap: 15px;
  padding: 26px;
  background: linear-gradient(130deg, #1b2020, #111516);
  border: 1px solid #363c38;
  box-shadow: 0 25px 100px #000b;
}
/* The same taped edge the other paper sheets carry: this is one more piece of stationery. */
.feedback-sheet::before { content: ""; position: absolute; top: -1px; left: 0; right: 0; height: 5px; background: repeating-linear-gradient(-45deg, #74443a 0 8px, #282423 8px 16px); }
.feedback-top { display: flex; justify-content: space-between; align-items: center; }
.feedback-close { padding: 2px 4px; font: 400 15px var(--mono); color: var(--muted); transition: color .2s; }
.feedback-close:hover { color: var(--ink); }
/* Inside the sheet the gap does the spacing, so nothing carries its own margin. */
.feedback-sheet .section-heading { margin: 0; }
.feedback-sheet .section-heading h2 { font: 500 26px var(--display); letter-spacing: .5px; }
.feedback-sheet .helper { margin: -6px 0 0; }
.feedback-field { display: grid; gap: 9px; }
.feedback-label { font: 500 8px var(--mono); letter-spacing: 1.1px; color: var(--muted); }

.stars { display: flex; gap: 4px; }
.star { padding: 3px; color: #4e574f; transition: color .15s; }
.star-icon { width: 31px; height: 31px; }
.star[data-on="true"] { color: #d8604d; }
.star[data-on="true"] .star-icon { fill: currentColor; }

/* The native control, drawn as the rest of the stationery is. The arrow is part of the field,
   because `appearance: none` takes the system one away. */
.feedback-select {
  width: 100%; padding: 13px 34px 13px 14px;
  font: 400 12px var(--sans); color: #e1d5bc;
  background: #090d0d; border: 1px solid #454d42; border-radius: 0;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #8b9488 50%), linear-gradient(135deg, #8b9488 50%, transparent 50%);
  background-position: calc(100% - 19px) center, calc(100% - 14px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.feedback-select option { color: #e1d5bc; background: #131817; }

.feedback-text {
  display: block; width: 100%; padding: 13px 14px; resize: vertical;
  font: 400 12px/1.7 var(--sans);
  color: #e1d5bc; background: #090d0d; border: 1px solid #454d42; border-radius: 0;
  caret-color: #e0745f;
  -webkit-user-select: text; user-select: text;
}
.feedback-text::placeholder { color: #67715f; }
.feedback-sheet .input-caption { margin: 0; }
.word-count[data-over="true"] { color: var(--orange); }
.feedback-error { font-size: 11px; line-height: 1.6; color: var(--orange); }
.feedback-error:empty { display: none; }
.feedback-sent { padding: 6px 0 2px; font: 400 42px var(--mono); color: #adb998; text-align: center; }

/* ─── Narrower rooms ────────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .site-shell { padding-right: max(36px, env(safe-area-inset-right)); padding-left: max(36px, env(safe-area-inset-left)); }
  .workspace { gap: 25px; }
  .mission-option { padding: 15px 9px; }
  .mission-option small { font-size: 8px; }
  .role-option { padding: 17px 10px; gap: 9px; }
  .role-icon { width: 24px; height: 24px; }
  .role-option small { font-size: 9px; }
  .manual-paper { padding: 25px; }
  .sidebar-top { padding: 22px 20px 0; }
  .sidebar-body { padding: 9px 20px 22px; }
}
@media (max-width: 760px) {
  .site-shell { padding-right: max(23px, env(safe-area-inset-right)); padding-left: max(23px, env(safe-area-inset-left)); }
  .view { padding-top: calc(25px + env(safe-area-inset-top)); }
  .page-topline { margin-bottom: 30px; }
  .page-heading { margin-bottom: 30px; }
  .page-heading h1 { font-size: 47px; }
  .page-heading p { font-size: 12px; max-width: 340px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .form-section { padding: 22px 0; }
  .mission-options { gap: 8px; }
  .mission-option { min-height: 122px; padding: 13px 10px; }
  .mission-option strong { font-size: 11px; }
  .mission-option small { font-size: 8px; letter-spacing: -.3px; }
  .mission-icon { width: 34px; }
  .role-option { padding: 18px 12px; gap: 10px; }
  .role-option strong { font-size: 11px; }
  .helper { font-size: 10px; }
  .sidebar-art { height: 180px; }
  .sidebar-art img { height: 207px; }
  .sidebar-body h2 { font-size: 28px; }
  .mission-stats { margin: 18px 0; }
  .manual-paper { padding: 20px 16px; }
  .manual-section .section-heading h2 { font-size: 26px; }
  .manual-role-grid { gap: 10px; }
  .manual-role { padding: 15px 12px; }
  .manual-role h2 { font-size: 23px; }
  .setup-steps { grid-template-columns: 1fr; gap: 16px; }
  .win-lose { grid-template-columns: 1fr; gap: 10px; }
  .brief-sheet { padding: 24px 18px; }
  .page-heading h1.headline { font-size: 58px; }
  .game-title { font-size: clamp(78px, 18vw, 126px); letter-spacing: .12em; margin-left: .12em; }
  .title-content { padding: 65px max(24px, env(safe-area-inset-right)) 65px max(24px, env(safe-area-inset-left)); transform: translateY(-3vh); }
  .title-rule { margin: 25px auto 36px; }
  .title-option { font-size: 13px; min-height: 58px; width: 285px; }
  .emergency-light { top: 9%; right: 8%; height: 72px; width: 3px; opacity: .4; }
  .shadow-device { width: 105vw; left: -47%; bottom: -6%; opacity: .38; }
  .hanging-wires { width: 160%; left: -52%; opacity: .3; }
  .toast { bottom: calc(15px + env(safe-area-inset-bottom)); font-size: 11px; padding: 14px 18px; }
  .corner-bar { right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); gap: 6px; }
  .feedback-button { min-height: 38px; padding: 0 12px; gap: 7px; font-size: 8px; }
  .feedback-button > .glyph { font-size: 12px; }
  .has-feedback .view { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
  .feedback-sheet { padding: 22px 18px; gap: 13px; }
}
/* Any short viewport, at any width. Gating this on a wide screen too left a small
   phone in landscape with the tall layout, which overflowed the clipped title screen. */
@media (max-height: 550px) {
  /* Bottom padding has to clear .title-version, which is pinned 22px up from the
     bottom of this box: at 28px all round the version line sat on the last menu item. */
  .title-content { padding: 28px max(28px, env(safe-area-inset-right)) 54px max(28px, env(safe-area-inset-left)); transform: none; }
  .game-title { font-size: 85px; }
  .title-rule { margin: 18px auto; }
  .title-option { min-height: 46px; }
  /* A phone held sideways is shorter than the pause menu was tall, so it opened scrolled. */
  .pause { padding: 18px; gap: 10px; }
  .pause h2 { font-size: 30px; }
  .feedback-sheet { padding: 18px; gap: 10px; }
  .feedback-sheet .section-heading h2 { font-size: 22px; }
  .star-icon { width: 26px; height: 26px; }
}
@media (max-width: 380px) {
  .site-shell { padding-right: max(18px, env(safe-area-inset-right)); padding-left: max(18px, env(safe-area-inset-left)); }
  .mission-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mission-option { padding: 12px 7px; }
  .mission-option strong { font-size: 10px; }
  .mission-option small { font-size: 7px; }
  .role-option { gap: 7px; padding: 19px 9px; }
  .role-option .role-icon { width: 21px; }
  .role-option small { font-size: 8px; }
  .page-heading h1 { font-size: 44px; }
}
