:root {
  --bg: #0b0d12;
  --panel: #151922;
  --panel-edge: #262c3a;
  --text: #e8ebf2;
  --muted: #9aa3b5;
  --accent: #7fd1ff;
  --accent-strong: #3fb4f2;
  --danger: #ff6b6b;
  --ok: #7be38c;
  --warn: #ffd166;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body.playing {
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: none;
  background: #000;
  object-fit: contain;
  image-rendering: auto;
}

body.playing #screen { display: block; }
body.playing #launcher { display: none; }

#launcher {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.panel {
  width: 100%;
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 20px;
}

.panel.wide { max-width: 900px; }

h1 { margin: 0; font-size: 28px; letter-spacing: 0.02em; }
h1 span { color: var(--accent); font-weight: 500; }
h2 { font-size: 17px; margin: 18px 0 6px; }
.subtitle { color: var(--muted); margin: 4px 0 12px; }
.small { color: var(--muted); font-size: 13px; }
.legal { color: var(--muted); font-size: 12px; margin: 18px 0 0; }
code { background: #0e1117; padding: 1px 5px; border-radius: 4px; }

.checks { display: grid; gap: 4px; margin: 8px 0; font-size: 14px; }
.check::before { content: "✓ "; color: var(--ok); }
.check.bad::before { content: "✕ "; color: var(--danger); }
.check.warn::before { content: "! "; color: var(--warn); }

.hint {
  background: #10202b;
  border: 1px solid #1f4058;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 14px;
}

.share-glyph { display: inline-block; font-weight: 700; color: var(--accent); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: #1d2330;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.button.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #04121c; }
.button.danger { color: var(--danger); }
.button:disabled { opacity: 0.5; }
#play { width: 100%; font-size: 18px; min-height: 52px; margin-top: 12px; }

.progress { margin-top: 12px; }
.bar { height: 8px; background: #0e1117; border-radius: 4px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--accent-strong); transition: width 0.2s; }

.online { margin-top: 18px; border-top: 1px solid var(--panel-edge); padding-top: 4px; }
.online input[type=text] {
  flex: 1;
  min-width: 120px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-edge);
  background: #0e1117;
  color: var(--text);
  font: inherit;
}
.room-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0 4px; }
.room-line strong { font-size: 20px; letter-spacing: 0.12em; color: var(--accent); }
.small-button { min-height: 34px; padding: 0 12px; font-size: 13px; }
.settings input[type=text], .settings input[type=password], .settings select {
  flex: 1;
  min-width: 120px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--panel-edge);
  background: #0e1117;
  color: var(--text);
  font: inherit;
}
.controller-status { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.controller-status.ready { color: #9fe870; }
.games { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.game {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.03);
}
.game.chosen { border-color: var(--accent); background: rgba(255, 255, 255, 0.07); }
.game-pick { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.game-pick input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.game-pick span { display: flex; flex-direction: column; min-width: 0; }
.game-pick strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-pick small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings { margin-top: 16px; border-top: 1px solid var(--panel-edge); padding-top: 10px; }
.settings summary { cursor: pointer; color: var(--muted); min-height: 32px; }
.row { display: flex; gap: 10px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.row input[type=range] { flex: 1; min-width: 120px; }
.row.buttons .button { flex: 1 1 auto; }

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 9, 0.92);
  z-index: 20;
  padding: 16px;
  text-align: center;
}

.overlay[hidden] { display: none; }
.overlay pre {
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow: auto;
  font-size: 12px;
  background: #0e1117;
  padding: 10px;
  border-radius: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  top: max(12px, env(safe-area-inset-top));
  transform: translateX(-50%);
  background: rgba(21, 25, 34, 0.95);
  border: 1px solid var(--panel-edge);
  padding: 8px 14px;
  border-radius: 10px;
  z-index: 30;
  font-size: 14px;
  max-width: calc(100vw - 32px);
}

/* ---------- touch controls

Laid out like the original Xbox controller (the Controller S): A, B, X and Y
as green, red, blue and yellow translucent gems in a diamond, the white and
black buttons below them, the L and R triggers above each side, back and
start between the thumbs, a round d-pad under the left thumb, and the left
stick where the left thumb lands. */

.touch-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  touch-action: none;
  --edge-left: env(safe-area-inset-left);
  --edge-right: env(safe-area-inset-right);
  --edge-bottom: env(safe-area-inset-bottom);
  --face: 56px;
  --gap: 5px;
  /* the controller's charcoal body */
  --body: rgba(28, 30, 28, 0.5);
  --rim: rgba(160, 170, 160, 0.45);
}

body.has-controller .touch-layer { display: none; }

.touch-button {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(235, 240, 235, 0.95);
  background: var(--body);
  border: 1.5px solid var(--rim);
  -webkit-user-select: none;
  user-select: none;
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  transition: transform 0.06s, filter 0.06s;
}

.touch-button.pressed { transform: scale(0.92); filter: brightness(1.45); }

.touch-button .glyph { font-weight: 900; line-height: 1; }
.touch-button .caption {
  position: absolute;
  top: 100%;
  margin-top: 3px;
  font: 700 9px/1 -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* A, B, X and Y: domed translucent gems, their letters embossed */
.touch-button.face {
  width: var(--face);
  height: var(--face);
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.35), inset 0 5px 8px rgba(255, 255, 255, 0.35),
    0 3px 6px rgba(0, 0, 0, 0.45);
  --diamond-right: calc(46px + var(--edge-right));
  --diamond-bottom: calc(96px + var(--edge-bottom));
}

.touch-button.face .glyph {
  font-size: 22px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.35), 0 1px 1px rgba(255, 255, 255, 0.4);
}

.face-a { background: radial-gradient(circle at 38% 30%, rgba(160, 235, 120, 0.85), rgba(40, 150, 40, 0.72) 60%, rgba(15, 80, 20, 0.8)); }
.face-b { background: radial-gradient(circle at 38% 30%, rgba(255, 150, 150, 0.85), rgba(210, 30, 35, 0.72) 60%, rgba(110, 10, 15, 0.8)); }
.face-x { background: radial-gradient(circle at 38% 30%, rgba(150, 200, 255, 0.85), rgba(30, 90, 210, 0.72) 60%, rgba(10, 40, 120, 0.8)); }
.face-y { background: radial-gradient(circle at 38% 30%, rgba(255, 240, 150, 0.9), rgba(235, 190, 20, 0.75) 60%, rgba(140, 100, 0, 0.8)); }
.face-y .glyph { color: rgba(70, 50, 0, 0.85); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); }

.face-a { right: calc(var(--diamond-right) + var(--face) + var(--gap)); bottom: var(--diamond-bottom); }
.face-b { right: var(--diamond-right); bottom: calc(var(--diamond-bottom) + var(--face) + var(--gap)); }
.face-x { right: calc(var(--diamond-right) + 2 * (var(--face) + var(--gap))); bottom: calc(var(--diamond-bottom) + var(--face) + var(--gap)); }
.face-y { right: calc(var(--diamond-right) + var(--face) + var(--gap)); bottom: calc(var(--diamond-bottom) + 2 * (var(--face) + var(--gap))); }

/* white and black: smaller gems below the diamond, towards the edge */
.touch-button.duo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  bottom: calc(22px + var(--edge-bottom));
  box-shadow: inset 0 -5px 8px rgba(0, 0, 0, 0.35), inset 0 4px 6px rgba(255, 255, 255, 0.3), 0 3px 6px rgba(0, 0, 0, 0.45);
}

.duo-white {
  right: calc(76px + var(--edge-right));
  background: radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.95), rgba(215, 220, 215, 0.85) 60%, rgba(150, 155, 150, 0.85));
  border-color: rgba(255, 255, 255, 0.7);
}

.duo-black {
  right: calc(24px + var(--edge-right));
  background: radial-gradient(circle at 38% 30%, rgba(110, 110, 110, 0.95), rgba(30, 30, 30, 0.9) 60%, rgba(5, 5, 5, 0.9));
  border-color: rgba(150, 150, 150, 0.6);
}

/* the triggers: the controller's curved L and R above each side */
.touch-button.trigger {
  width: 96px;
  height: 52px;
  top: calc(56px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(90, 95, 90, 0.6), rgba(30, 32, 30, 0.6));
}

.touch-button.trigger .glyph { font-size: 22px; }
.touch-button.trigger.left-side { left: calc(26px + var(--edge-left)); border-radius: 30px 14px 10px 22px; }
.touch-button.trigger.right-side { right: calc(26px + var(--edge-right)); border-radius: 14px 30px 22px 10px; }

/* the stick clicks: pressing a thumbstick, which a touch screen cannot do */
.touch-button.stick-click {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(60, 64, 60, 0.6) 35%, rgba(25, 27, 25, 0.6) 36%);
}

.touch-button.left-click { left: calc(200px + var(--edge-left)); bottom: calc(var(--edge-bottom) + 176px); }
.touch-button.right-click { right: calc(236px + var(--edge-right)); bottom: calc(var(--edge-bottom) + 176px); }

/* back and start: the small black buttons between the thumbs */
.touch-button.system {
  width: 54px;
  height: 26px;
  border-radius: 13px;
  bottom: calc(24px + var(--edge-bottom));
  background: rgba(15, 15, 15, 0.65);
}

.touch-button.system .glyph { font: 800 9px/1 -apple-system, BlinkMacSystemFont, Roboto, sans-serif; letter-spacing: 0.08em; }
.touch-button.back { left: calc(50% - 62px); }
.touch-button.start { left: calc(50% + 8px); }

/* the d-pad: a round plate with a cross, each arm a button */
.touch-dpad {
  position: absolute;
  left: calc(190px + var(--edge-left));
  bottom: calc(var(--edge-bottom) + 14px);
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(80, 84, 80, 0.5), rgba(25, 27, 25, 0.55));
  border: 1.5px solid var(--rim);
}

.touch-dpad .touch-button {
  width: 38px;
  height: 36px;
  border-radius: 4px;
  background: rgba(20, 21, 20, 0.7);
  border-color: rgba(120, 125, 120, 0.4);
}

/* the arms meet at the centre without overlapping (the plate is 124 wide,
its border inside) */
.touch-dpad .up { left: 42px; top: 7px; }
.touch-dpad .down { left: 42px; top: 79px; }
.touch-dpad .left { left: 7px; top: 43px; width: 35px; height: 36px; }
.touch-dpad .right { left: 80px; top: 43px; width: 35px; height: 36px; }

.touch-dpad .touch-button::after {
  content: "";
  width: 0;
  height: 0;
  border: 6px solid transparent;
}

.touch-dpad .up::after { border-bottom-color: rgba(220, 225, 220, 0.8); transform: translateY(-3px); }
.touch-dpad .down::after { border-top-color: rgba(220, 225, 220, 0.8); transform: translateY(3px); }
.touch-dpad .left::after { border-right-color: rgba(220, 225, 220, 0.8); transform: translateX(-3px); }
.touch-dpad .right::after { border-left-color: rgba(220, 225, 220, 0.8); transform: translateX(3px); }

/* the left stick: a concave black thumbstick where the thumb lands */
.touch-stick {
  position: absolute;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 1.5px solid var(--rim);
  background: radial-gradient(circle, rgba(28, 30, 28, 0.2) 0%, rgba(28, 30, 28, 0.5) 100%);
  left: calc(34px + var(--edge-left));
  bottom: calc(46px + var(--edge-bottom));
  pointer-events: none;
  opacity: 0.65;
  transition: opacity 0.1s;
}

.touch-stick.active { opacity: 1; }

.touch-knob {
  position: absolute;
  left: 32px;
  top: 32px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(18, 18, 18, 0.95) 38%, rgba(55, 58, 55, 0.95) 40%,
    rgba(30, 32, 30, 0.95) 70%);
  border: 1.5px solid rgba(140, 145, 140, 0.6);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.55);
}

/* smaller phones in landscape */
@media (max-height: 380px) {
  .touch-layer { --face: 50px; }
  .touch-button.face { --diamond-bottom: calc(86px + var(--edge-bottom)); }
  .touch-button.trigger { top: calc(46px + env(safe-area-inset-top)); height: 46px; width: 86px; }
  .touch-button.left-click, .touch-button.right-click { bottom: calc(var(--edge-bottom) + 158px); }
  .touch-button.right-click { right: calc(210px + var(--edge-right)); }
}

/* ---------- touch controls: the modern layout

As in a modern mobile shooter: a large fire button under the right thumb,
which also aims while held, the actions around it as white line icons on dark
glass, a second fire button for the left thumb, pause and score at the top,
and a floating stick anywhere on the left half. Sizes are in --u, which
shrinks on small phones. */

.touch-layer.modern { --u: 1px; }

.touch-layer.modern .touch-button {
  width: calc(54 * var(--u));
  height: calc(54 * var(--u));
  border-radius: 50%;
  background: rgba(8, 10, 14, 0.36);
  border: 2px solid rgba(255, 255, 255, 0.6);
  color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

.touch-layer.modern .touch-button.pressed {
  transform: scale(0.92);
  filter: none;
  background: rgba(255, 255, 255, 0.88);
  color: rgba(10, 12, 16, 0.95);
  border-color: #fff;
}

.touch-layer.modern .touch-button .glyph { display: flex; width: 52%; height: 52%; }
.touch-layer.modern .touch-button .glyph svg { width: 100%; height: 100%; }

.touch-layer.modern .touch-button .caption {
  margin-top: calc(2 * var(--u));
  font-size: calc(8 * var(--u));
  color: rgba(255, 255, 255, 0.75);
}

/* the Xbox button each one is, for the menus */
.touch-layer.modern .badge {
  position: absolute;
  top: calc(-4 * var(--u));
  right: calc(-4 * var(--u));
  width: calc(17 * var(--u));
  height: calc(17 * var(--u));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 800 calc(10 * var(--u))/1 -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.touch-layer.modern .badge-a { background: #2f9a2f; }
.touch-layer.modern .badge-b { background: #c8262c; }
.touch-layer.modern .badge-x { background: #2860c8; }
.touch-layer.modern .badge-y { background: #d8a800; color: #2a2000; }

/* right thumb */
.touch-layer.modern .m-fire {
  width: calc(86 * var(--u));
  height: calc(86 * var(--u));
  right: calc(40 * var(--u) + var(--edge-right));
  bottom: calc(96 * var(--u) + var(--edge-bottom));
  border-width: 2.5px;
  background: rgba(8, 10, 14, 0.42);
}

.touch-layer.modern .m-fire .glyph { width: 46%; height: 46%; }

.touch-layer.modern .m-zoom { right: calc(146 * var(--u) + var(--edge-right)); bottom: calc(168 * var(--u) + var(--edge-bottom)); }
.touch-layer.modern .m-melee { right: calc(150 * var(--u) + var(--edge-right)); bottom: calc(86 * var(--u) + var(--edge-bottom)); }
.touch-layer.modern .m-reload {
  width: calc(50 * var(--u));
  height: calc(50 * var(--u));
  right: calc(58 * var(--u) + var(--edge-right));
  bottom: calc(206 * var(--u) + var(--edge-bottom));
}
.touch-layer.modern .m-jump {
  width: calc(60 * var(--u));
  height: calc(60 * var(--u));
  right: calc(22 * var(--u) + var(--edge-right));
  bottom: calc(14 * var(--u) + var(--edge-bottom));
}
.touch-layer.modern .m-crouch { right: calc(104 * var(--u) + var(--edge-right)); bottom: calc(14 * var(--u) + var(--edge-bottom)); }
.touch-layer.modern .m-grenade {
  width: calc(50 * var(--u));
  height: calc(50 * var(--u));
  right: calc(142 * var(--u) + var(--edge-right));
  bottom: calc(246 * var(--u) + var(--edge-bottom));
}
.touch-layer.modern .m-grenade-type {
  width: calc(40 * var(--u));
  height: calc(40 * var(--u));
  right: calc(214 * var(--u) + var(--edge-right));
  bottom: calc(262 * var(--u) + var(--edge-bottom));
}
.touch-layer.modern .m-light {
  width: calc(40 * var(--u));
  height: calc(40 * var(--u));
  right: calc(22 * var(--u) + var(--edge-right));
  bottom: calc(276 * var(--u) + var(--edge-bottom));
}

/* weapon swap: a wide pill beside crouch, as a weapon slot */
.touch-layer.modern .m-swap {
  width: calc(76 * var(--u));
  height: calc(42 * var(--u));
  border-radius: calc(21 * var(--u));
  right: calc(178 * var(--u) + var(--edge-right));
  bottom: calc(20 * var(--u) + var(--edge-bottom));
}
.touch-layer.modern .m-swap .glyph { width: 34%; height: 62%; }

/* left thumb: a second fire button above the stick */
.touch-layer.modern .m-fire2 {
  width: calc(60 * var(--u));
  height: calc(60 * var(--u));
  left: calc(36 * var(--u) + var(--edge-left));
  bottom: calc(212 * var(--u) + var(--edge-bottom));
}

/* pause and score in the top corners */
.touch-layer.modern .m-top {
  width: calc(44 * var(--u));
  height: calc(32 * var(--u));
  border-radius: calc(16 * var(--u));
  top: calc(8 * var(--u) + env(safe-area-inset-top));
}
.touch-layer.modern .m-top .glyph { width: 40%; height: 56%; }
.touch-layer.modern .m-top .caption { display: none; }
.touch-layer.modern .m-score { left: calc(50% - 52 * var(--u)); }
.touch-layer.modern .m-pause { left: calc(50% + 8 * var(--u)); }

/* the stick: a ring of glass that appears where the thumb lands */
.touch-layer.modern .touch-stick {
  width: 120px;
  height: 120px;
  left: calc(56 * var(--u) + var(--edge-left));
  bottom: calc(40 * var(--u) + var(--edge-bottom));
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(8, 10, 14, 0.22);
  opacity: 0.7;
}

.touch-layer.modern .touch-knob {
  left: 34px;
  top: 34px;
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

@media (max-height: 400px) {
  .touch-layer.modern { --u: 0.88px; }
}

@media (max-height: 340px) {
  .touch-layer.modern { --u: 0.76px; }
}

/* Settings: "Show the frame rate" */
.fps {
  position: fixed;
  top: max(6px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  z-index: 30;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #9fe870;
  font: 600 12px/1.4 ui-monospace, Menlo, monospace;
  white-space: pre;
  pointer-events: none;
}

/* ---------- the in-game menu */

.menu-button {
  position: fixed;
  z-index: 15;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  width: 36px;
  height: 32px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  background: rgba(8, 10, 14, 0.35);
  color: rgba(255, 255, 255, 0.9);
}
.menu-button svg { width: 100%; height: 100%; display: block; }
body:not(.playing) .menu-button { display: none; }

.game-menu { z-index: 25; background: rgba(5, 6, 9, 0.8); }
.game-menu .panel { max-height: 92vh; overflow: auto; }
.game-menu select { min-height: 36px; border-radius: 8px; border: 1px solid var(--panel-edge); background: #0e1117; color: var(--text); padding: 0 8px; flex: 1; min-width: 120px; }

/* ---------- the touch layout editor */

.layout-editor {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 55, 80, 0.55), rgba(5, 6, 9, 0.9));
  touch-action: none;
}
body.playing .layout-editor { background: rgba(5, 6, 9, 0.45); }
.layout-editor .touch-layer { display: block !important; }
.layout-editor .touch-stick { pointer-events: auto; opacity: 0.9; }
.layout-editor [data-control] { cursor: grab; }
.layout-editor .editing { outline: 2px dashed #7fd1ff; outline-offset: 4px; }
.touch-dpad.editing { border-radius: 50%; }
.editor-bar {
  position: absolute;
  z-index: 40;
  left: 50%;
  top: calc(8px + env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: min(94vw, 720px);
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(14, 17, 23, 0.92);
  border: 1px solid var(--panel-edge);
  color: var(--text);
  font-size: 13px;
}
.editor-bar label { display: flex; align-items: center; gap: 6px; }
.editor-bar input[type=range] { width: 110px; }
.editor-hint { color: var(--muted); }
/* the layout is for the screen held sideways */
@media (orientation: portrait) {
  .layout-editor::before {
    content: "Turn your device sideways to edit the layout.";
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    background: rgba(5, 6, 9, 0.95);
    color: var(--text);
    font-size: 17px;
  }
}
/* on the start page, nothing shows through */
body:not(.playing) .layout-editor { background: radial-gradient(ellipse at 50% 40%, #1c2536, #06070a); }

/* ---------- the theme: a UNSC terminal over a starfield

Orbitron for titles and Rajdhani for labels and buttons (fonts/, SIL Open
Font License). The backdrop is art/ring.jpg, the ring of Halo's main menu
(a frame of the game's own scene, used under Microsoft's Game Content Usage
Rules), or once the player's own game has run, a frame of its main menu
(app.js, captureBackdrop), kept on the device only. */

@font-face {
  font-family: "Orbitron";
  font-weight: 700 900;
  font-display: swap;
  src: url("fonts/orbitron-900.woff2") format("woff2");
}
@font-face {
  font-family: "Rajdhani";
  font-weight: 500;
  font-display: swap;
  src: url("fonts/rajdhani-500.woff2") format("woff2");
}
@font-face {
  font-family: "Rajdhani";
  font-weight: 700;
  font-display: swap;
  src: url("fonts/rajdhani-700.woff2") format("woff2");
}

:root {
  --bg: #04070c;
  --panel: rgba(9, 15, 25, 0.8);
  --panel-edge: rgba(127, 209, 255, 0.22);
  --accent: #7fd6ff;
  --accent-strong: #36b6f0;
  --glow: rgba(95, 200, 255, 0.45);
  --ui-font: "Rajdhani", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --title-font: "Orbitron", "Rajdhani", -apple-system, sans-serif;
}

html, body { background: var(--bg); }

.backdrop {
  position: fixed;
  inset: -12px;
  z-index: -1;
  filter: brightness(0.6);
  background: url("art/ring.jpg") 62% center / cover no-repeat, var(--bg);
}
body.has-backdrop .backdrop {
  background-size: cover;
  background-position: center;
  filter: blur(3px) brightness(0.45) saturate(1.15);
  transform: scale(1.03);
}
body.playing .backdrop { display: none; }

#launcher { background: transparent; }

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 20px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(127, 209, 255, 0.12);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
/* corner brackets */
#launcher > .panel::before, #launcher > .panel::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  pointer-events: none;
}
#launcher > .panel::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
#launcher > .panel::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }

.title {
  margin: 0;
  font-family: var(--title-font);
  font-weight: 900;
  font-size: 30px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 0%, #d7ecfb 45%, #86b9df 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(95, 200, 255, 0.35));
}
.title span {
  font-weight: 700;
  font-size: 0.55em;
  letter-spacing: 0.35em;
  margin-left: 0.3em;
  vertical-align: 0.35em;
  background: none;
  -webkit-text-fill-color: var(--accent);
  color: var(--accent);
}

.subtitle { font-family: var(--ui-font); font-size: 17px; font-weight: 500; }

h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--ui-font);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--panel-edge), transparent); }

.button {
  font-family: var(--ui-font);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 3px;
  background: rgba(20, 32, 48, 0.85);
  border: 1px solid rgba(127, 209, 255, 0.28);
  transition: background 0.15s, box-shadow 0.15s;
}
.button:hover { background: rgba(30, 48, 70, 0.95); }
.button.primary {
  background: linear-gradient(180deg, #6fd6ff 0%, #2f9fdc 100%);
  border-color: #9fe2ff;
  color: #03111b;
  box-shadow: 0 0 18px var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.button.danger { color: #ff8a8a; }
.small-button { font-size: 13px; }

#play {
  font-family: var(--title-font);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.35em;
  min-height: 58px;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}

.checks { font-family: var(--ui-font); font-size: 15px; font-weight: 500; }
.hint { background: rgba(16, 40, 58, 0.7); border-color: rgba(127, 209, 255, 0.3); border-radius: 3px; }
.game { border-radius: 3px; background: rgba(12, 22, 34, 0.7); }
.game.chosen { box-shadow: 0 0 14px rgba(95, 200, 255, 0.25); }
.game-pick strong { font-family: var(--ui-font); font-size: 17px; letter-spacing: 0.03em; }
.settings summary { font-family: var(--ui-font); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; font-size: 14px; }

/* ---------- installation guides */

.sheet {
  position: fixed;
  z-index: 45;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(92vw, 460px);
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 18px 20px 20px;
  background: rgba(9, 15, 25, 0.96);
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.6), 0 0 24px rgba(95, 200, 255, 0.12);
  text-align: left;
}
.sheet h2 { margin-top: 0; }
.sheet .button { width: 100%; margin-top: 8px; }
.steps { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 14px; counter-reset: step; }
.steps li { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.step-icon {
  flex: none;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(127, 209, 255, 0.5);
  background: rgba(20, 40, 60, 0.8);
  color: var(--accent);
}
.step-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.checks-ok summary { cursor: pointer; color: var(--ok); font-weight: 700; list-style: none; }
.checks-ok summary::before { content: "✓ "; }
.checks-ok summary::-webkit-details-marker { display: none; }
.checks-ok[open] summary { margin-bottom: 4px; }
/* the page's body lets the backdrop (behind it) show; html keeps the colour */
body { background: transparent; }
body.playing { background: #000; }
.legal a { color: var(--accent); }
.legal.credits { margin-top: 14px; }
.legal.credits strong { color: var(--text); }

/* ---------- matchmaking: open games */

.lobby { margin-top: 14px; }
.lobby h3 { margin: 0 0 6px; font: 700 14px var(--ui-font); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text); }
.lobby-list { display: flex; flex-direction: column; gap: 6px; }
.lobby-room {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 3px;
  border: 1px solid var(--panel-edge);
  background: rgba(12, 22, 34, 0.7);
}
.lobby-room .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lobby-room strong { font: 700 16px var(--ui-font); letter-spacing: 0.03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-room small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-room .count { font: 700 15px var(--ui-font); color: var(--accent); white-space: nowrap; }
.lobby-room.other-maps { opacity: 0.55; }
.lobby-room.mine { border-color: var(--accent); }
#quick-match { min-width: 160px; }

/* ---------- text chat */

.menu-button { overflow: visible; }
.unread {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #e0443c;
  color: #fff;
  font: 700 11px/18px -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  text-align: center;
}

/* new messages over the game, for a few seconds */
.chat-feed {
  position: fixed;
  z-index: 14;
  top: calc(48px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  max-width: min(46vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}
body:not(.playing) .chat-feed { display: none; }
.chat-line {
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(4, 7, 12, 0.6);
  color: #e8eef6;
  font: 500 14px/1.3 var(--ui-font);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  overflow-wrap: anywhere;
  transition: opacity 0.6s;
}
.chat-line b { color: var(--accent); font-weight: 700; margin-right: 6px; }
.chat-line.self b { color: #9fe870; }
.chat-line.fading { opacity: 0; }

/* the chat panel */
.chat {
  position: fixed;
  z-index: 28;
  left: 50%;
  top: max(8px, env(safe-area-inset-top));
  bottom: max(8px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(94vw, 520px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-edge);
  background: rgba(9, 15, 25, 0.95);
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
}
.chat-head { display: flex; align-items: center; gap: 8px; font-family: var(--ui-font); }
.chat-head strong { font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.chat-head .button { margin-left: auto; }
.chat-log {
  flex: 1;
  min-height: 60px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
}
.chat-log .chat-line { background: none; padding: 1px 2px; }
.chat-log .empty { color: var(--muted); font-size: 13px; margin: auto; text-align: center; }
.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-quick .button { min-height: 32px; padding: 0 10px; font-size: 13px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid var(--panel-edge);
  background: #0e1117;
  color: var(--text);
  font: 16px -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}
