/* ---------- tokens ---------- */
:root {
  --bg: #0a0c11;
  --bg-2: #0e1116;
  --panel: #161a22;
  --panel-2: #1c212b;
  --line: rgba(255, 255, 255, 0.07);
  --text: #e9edf6;
  --muted: #8992a6;
  --lime: #b6ff2e;
  --cyan: #35c9ff;
  --pink: #ff44b7;
  --red: #ff4757;
  --yellow: #ffd21f;
  --violet: #9d6bff;
  --display: "Segoe UI Black", "Arial Black", "Helvetica Neue", system-ui, sans-serif;
  --ui: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  --r: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  /* A steer gesture must not scroll the page, rubber-band it, flash a tap highlight
     or start a text selection. */
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
/* The dynamic viewport unit tracks a collapsing URL bar; 100% is the fallback. */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

#app { height: 100%; position: relative; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: clamp(14px, 2.2vh, 30px) clamp(16px, 3vw, 54px);
  overflow: auto;
}
.screen.active { display: flex; }
.hidden { display: none !important; }

.title {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(26px, 3.4vw, 44px);
  letter-spacing: 0.02em;
  margin: 0;
  text-transform: uppercase;
}
.subtitle { color: var(--muted); margin: 6px 0 0; font-size: 15px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--display);
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 17px;
  padding: 15px 30px 17px;
  border: 0;
  border-radius: 10px;
  color: #08090c;
  cursor: pointer;
  position: relative;
  transition: transform .08s ease, filter .15s ease, box-shadow .15s ease;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45), 0 12px 30px rgba(0, 0, 0, 0.4);
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); }
.btn-primary {
  background: linear-gradient(180deg, #c9ff54 0%, var(--lime) 55%, #86d400 100%);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 5px 0 rgba(0,0,0,.45), 0 0 34px rgba(182, 255, 46, 0.35); }
.btn-ghost {
  background: linear-gradient(180deg, var(--panel-2), #141821);
  color: var(--text);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--line);
}
.btn-ghost:hover { color: #fff; box-shadow: 0 5px 0 rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.18); }
.btn:disabled { cursor: not-allowed; background: #171b23; color: #4d5566; text-shadow: none;
  box-shadow: 0 4px 0 rgba(0,0,0,.4), inset 0 0 0 1px var(--line); filter: none; }
.btn:disabled:hover { filter: none; box-shadow: 0 4px 0 rgba(0,0,0,.4), inset 0 0 0 1px var(--line); }
.mini {
  font: 700 10px/1 var(--ui);
  letter-spacing: .08em;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
  float: right;
}
.mini:hover { color: var(--text); }

/* ---------- menu ---------- */
#screen-menu { align-items: center; justify-content: center; text-align: center; gap: 26px; }
.menu-glow {
  /* Fixed, not absolute: at 900px square this decoration is larger than a phone screen,
     and as a child of the scrolling .screen its overhang counted towards the scrollable
     area - several hundred pixels of empty space below the menu. Fixed positioning keeps
     it centred on the viewport and out of the scroll extent entirely. */
  position: fixed;
  top: 50%; left: 50%; margin: -450px 0 0 -450px;
  width: 900px; height: 900px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(53, 201, 255, .09), transparent 62%);
  filter: blur(20px);
  pointer-events: none;
  animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translate(-8%, -6%); } to { transform: translate(8%, 6%); } }
.brand { position: relative; }
/* Sized so the mark's 2:1 box stands as tall as the wordmark beside it: at 200px wide
   it is 100px high against a 104px cap height. Below that it read as a bullet point. */
.brand-mark svg { width: 200px; filter: drop-shadow(0 8px 28px rgba(0, 0, 0, .6)); }
.brand-name {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(44px, 8vw, 104px);
  margin: 4px 0 0;
  letter-spacing: -0.01em;
  line-height: .95;
  background: linear-gradient(180deg, #fff, #9fb0cc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 14px 40px rgba(0, 0, 0, .6);
}
.brand-name span { color: transparent; background: linear-gradient(180deg, var(--lime), #6fbe00); -webkit-background-clip: text; background-clip: text; }
.brand-tag { color: var(--muted); margin: 10px 0 0; font-size: 16px; letter-spacing: .02em; }
.menu-actions { display: flex; flex-direction: column; gap: 12px; width: min(360px, 80vw); position: relative; }
.menu-foot { color: #5b6376; font-size: 12px; position: absolute; bottom: 18px; }
.howto { max-width: 900px; }
.howto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; text-align: left; }
.howto-grid > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.howto-grid h3 { font-family: var(--display); font-style: italic; margin: 0 0 6px; font-size: 15px; letter-spacing: .04em; color: var(--lime); }
.howto-grid p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.k-self { color: var(--lime); font-weight: 700; }
.k-others { color: var(--red); font-weight: 700; }
.k-all { color: var(--cyan); font-weight: 700; }

/* ---------- setup ---------- */
.setup-head { margin-bottom: 16px; }
.you-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 18px 16px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px 16px;
}
.you-label {
  font-family: var(--display); font-style: italic; font-size: 15px; letter-spacing: .06em;
}
.you-colors { display: flex; flex-wrap: wrap; gap: 10px; }
.you-chip {
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer;
  opacity: .5;
  transition: opacity .14s ease, transform .1s ease;
}
.you-chip:hover { opacity: .85; transform: translateY(-2px); }
.you-chip.on { opacity: 1; }
.you-keys { grid-column: 2; margin: 0; font-size: 12.5px; color: var(--muted); letter-spacing: .02em; }
.you-keys b { color: var(--lime); }
.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.slot {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color .18s ease, transform .12s ease, box-shadow .18s ease;
  min-height: 82px;
}
.slot.joined { transform: translateY(-2px); }
.slot .swatch {
  width: 34px; height: 34px; border-radius: 50%;
  flex: none;
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .18);
}
.slot .who { font-family: var(--display); font-style: italic; font-size: 15px; letter-spacing: .03em; }
.slot .binds { display: flex; gap: 6px; margin-top: 6px; }
.key {
  font: 700 11px/1 var(--ui);
  letter-spacing: .06em;
  background: #0e1219;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--muted);
  cursor: pointer;
  min-width: 34px;
  text-align: center;
}
.key:hover { color: var(--text); border-color: rgba(255,255,255,.25); }
.key.static { cursor: default; color: var(--lime); border-color: rgba(182,255,46,.28); }
.slot { flex-wrap: wrap; padding-bottom: 30px; }
.slot .status { margin-left: auto; align-self: flex-start; font: 800 10px/1.3 var(--ui); letter-spacing: .12em;
  color: var(--muted); text-align: right; max-width: 92px;
  background: none; border: 0; padding: 0; cursor: pointer; }
.slot.joined .status { color: var(--lime); }
.slot .bot-toggle {
  position: absolute; right: 10px; bottom: 10px;
  font: 700 9px/1 var(--ui); letter-spacing: .1em;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 5px; padding: 4px 6px; cursor: pointer;
}
.slot .bot-toggle.on { color: var(--cyan); border-color: rgba(53,201,255,.5); }

.bind-msg { min-height: 18px; margin: -8px 0 12px; font-size: 12.5px; color: var(--muted); letter-spacing: .02em; }
.bind-msg.bad { color: var(--red); }
.setup-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.panel-wide { grid-column: 1 / -1; }
.panel-title { font-family: var(--display); font-style: italic; font-size: 13px; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
.field { display: grid; grid-template-columns: 1fr 130px 34px; align-items: center; gap: 10px; font-size: 13.5px; margin-bottom: 10px; }
.field b { text-align: right; color: var(--lime); font-family: var(--display); font-style: italic; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 5px; border-radius: 3px; background: #262c37; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--lime); cursor: pointer; box-shadow: 0 0 12px rgba(182,255,46,.6); }
.field-hint { margin: 2px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; margin-bottom: 9px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--lime); }

.powerup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.pw {
  background: #10141b; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 6px 8px; text-align: center; cursor: pointer; opacity: .35;
  transition: opacity .14s ease, border-color .14s ease, transform .1s ease;
}
.pw.on { opacity: 1; }
.pw:hover { transform: translateY(-2px); }
.pw img { width: 26px; height: 26px; display: block; margin: 0 auto 5px; }
.pw span { font: 700 9px/1.25 var(--ui); letter-spacing: .04em; color: var(--muted); display: block; }
.pw.on.self { border-color: rgba(143, 240, 58, .45); }
.pw.on.others { border-color: rgba(255, 71, 87, .45); }
.pw.on.all { border-color: rgba(53, 201, 255, .45); }
.setup-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 18px; }

/* ---------- online ---------- */
.online-gate { max-width: 560px; }
.field-text { grid-template-columns: 1fr; gap: 6px; margin-bottom: 16px; }
.field-text span { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
#net-name, .code-input {
  font: 800 18px/1 var(--display);
  letter-spacing: .12em;
  background: #0e1219;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  text-transform: uppercase;
  outline: none;
  width: 100%;
}
#net-name:focus, .code-input:focus { border-color: rgba(182,255,46,.5); }
.gate-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.join-row { display: flex; gap: 8px; align-items: center; }
.code-input { width: 132px; text-align: center; letter-spacing: .3em; }
.room-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 14px; }
.room-code { font: 800 13px/1 var(--ui); letter-spacing: .14em; color: var(--muted); }
.room-code b {
  font-family: var(--display); font-style: italic; font-size: 30px; letter-spacing: .22em;
  color: var(--lime); text-shadow: 0 0 26px rgba(182,255,46,.45); margin-left: 8px;
}
.room-ping { margin-left: auto; font: 700 11px/1 var(--ui); letter-spacing: .1em; color: var(--muted); }
.key.static.dim { color: var(--muted); border-color: var(--line); }
.slot.mine { border-color: rgba(182,255,46,.55) !important; }
.slot.mine .status { color: var(--lime); }

/* An online match cannot pause for one player, so its hint stays off screen. */
#screen-game.net .hint[data-key="KeyP"] { display: none; }

/* ---------- game ---------- */
#screen-game { padding: 0; overflow: hidden; }
.game-wrap { display: grid; grid-template-columns: 1fr 290px; height: 100%; min-height: 0; gap: 0; overflow: hidden; }
.arena-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px 12px 8px 16px; }
.arena-top, .arena-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 4px 2px 10px; }
.arena-bottom { padding-top: 8px; color: var(--muted); font-size: 11.5px; letter-spacing: .04em; }
.for-touch { display: none; }
.hint { background: none; border: 0; padding: 0; margin: 0; color: inherit; font: inherit;
  letter-spacing: inherit; cursor: pointer; }
button.hint:hover b { border-color: rgba(255,255,255,.3); color: #fff; }
.hint b { color: var(--text); background: #161b24; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; margin-right: 4px; font-size: 10.5px; }
.fps { margin-left: auto; font-variant-numeric: tabular-nums; }
.pill {
  font: 800 11px/1 var(--ui); letter-spacing: .12em; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
}
.pill b { color: var(--lime); font-family: var(--display); font-style: italic; font-size: 15px; margin-left: 6px; }
.global-effects { display: flex; gap: 6px; }
.match-point {
  font-family: var(--display); font-style: italic; font-size: 13px; letter-spacing: .06em;
  margin: 0 auto 0 12px; padding: 7px 14px; border-radius: 999px;
  background: rgba(255, 210, 31, .1); border: 1px solid currentColor;
  animation: mpPulse 1.1s ease-in-out infinite alternate;
}
@keyframes mpPulse { from { opacity: .55; } to { opacity: 1; } }
.pill-note { font-style: normal; font-size: 10px; letter-spacing: .12em; color: #79839a; margin-left: 7px; font-weight: 800; }
.global-chip {
  font: 800 10px/1 var(--ui); letter-spacing: .1em; color: #06212c;
  background: linear-gradient(180deg, #5fd8ff, var(--cyan));
  border-radius: 6px; padding: 6px 10px;
  animation: chipIn .25s ease;
}
@keyframes chipIn { from { transform: translateY(-6px); opacity: 0; } }

/* The canvas is taken out of flow: its intrinsic size must not feed back into layout. */
.arena-holder { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; }
#arena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.countdown {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none; text-align: center;
}
.count-main {
  font-family: var(--display); font-style: italic;
  font-size: clamp(70px, 13vw, 190px); line-height: .9;
  color: var(--lime);
  -webkit-text-stroke: 2px rgba(10, 12, 17, .9);
  text-shadow: 0 6px 0 rgba(10,12,17,.85), 0 18px 44px rgba(0,0,0,.8);
}
.count-sub { font: 800 13px/1 var(--ui); letter-spacing: .3em; color: var(--muted); margin-top: 14px; }
.countdown.pop .count-main { animation: countPop .45s cubic-bezier(.2,1.5,.4,1); }
@keyframes countPop { from { transform: scale(1.9); opacity: 0; } }

/* The banner scrims the arena so the result reads over a busy trail field. */
.banner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(4,5,9,.72) 0%, rgba(4,5,9,.86) 70%, rgba(4,5,9,.92) 100%);
  animation: scrimIn .22s ease;
}
@keyframes scrimIn { from { opacity: 0; } }
.banner .big {
  font-family: var(--display); font-style: italic; font-size: clamp(30px, 5vw, 62px);
  text-shadow: 0 12px 40px rgba(0,0,0,.8);
  animation: countPop .4s cubic-bezier(.2,1.4,.4,1);
}
.banner .small { font: 800 12px/1 var(--ui); letter-spacing: .3em; color: var(--muted); margin-top: 10px; }

.feed { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column-reverse; gap: 6px; pointer-events: none; }
.feed-item {
  display: flex; align-items: center; gap: 8px;
  background: rgba(10, 12, 17, .72);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 8px; padding: 7px 12px 7px 10px;
  font-size: 12.5px; color: var(--muted);
  backdrop-filter: blur(6px);
  animation: feedIn .22s ease;
  transition: opacity .6s ease, transform .6s ease;
}
.feed-item img { width: 17px; height: 17px; }
.feed-item.fade { opacity: 0; transform: translateX(-14px); }
.feed-who { font-weight: 800; }
.feed-self { border-left-color: var(--lime); }
.feed-others { border-left-color: var(--red); }
.feed-all { border-left-color: var(--cyan); }
.feed-death { border-left-color: #55607a; }
.feed-skull { width: 15px; height: 15px; border-radius: 50%; border: 2px solid #55607a; position: relative; }
.feed-skull::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: #55607a; }
@keyframes feedIn { from { transform: translateX(-16px); opacity: 0; } }

/* sidebar */
.side { background: var(--bg-2); border-left: 1px solid var(--line); padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: auto; }
.side-title {
  font-family: var(--display); font-style: italic; font-size: 22px; letter-spacing: .02em;
  color: var(--lime); margin: 0 0 2px; text-transform: uppercase;
}
.standings { display: flex; flex-direction: column; gap: 7px; }
.row {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; overflow: hidden;
  transition: opacity .2s ease, transform .2s ease;
}
.row-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; opacity: .16; transition: width .35s cubic-bezier(.2,.8,.3,1); }
.row-edge { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.row-main { position: relative; display: flex; align-items: center; gap: 9px; }
.row .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.row .rank { font-family: var(--display); font-style: italic; font-size: 12px; color: #5c6577; width: 14px; flex: none; }
.row .name { font-family: var(--display); font-style: italic; font-size: 14.5px; letter-spacing: .02em; }
.row .keys { font: 700 9px/1 var(--ui); letter-spacing: .1em; color: #6b7488;
  background: #0e1219; border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; }
.row .keys.is-bot { color: var(--cyan); background: transparent; border-color: transparent; padding: 0; }
.row .score { margin-left: auto; font-family: var(--display); font-style: italic; font-size: 19px; font-variant-numeric: tabular-nums; }
.row.dead { opacity: .55; }
.row.dead .keys { color: #7c8598; }
.row.dead .name { text-decoration: line-through; text-decoration-thickness: 2px; }
.row.leader { border-color: transparent; box-shadow: inset 0 0 0 2px currentColor, 0 0 24px -6px currentColor; }
.row.leader .rank { color: currentColor; }
.row.leader .name { color: #fff; }
.row.leader .score { color: currentColor; }
.row.leader .row-bar { opacity: .3; }
.row-effects { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; position: relative; }
.row-effects:empty { display: none; }
.chip { font: 800 9px/1 var(--ui); letter-spacing: .08em; padding: 4px 6px; border-radius: 5px; }
.chip-good { background: rgba(143, 240, 58, .16); color: var(--lime); }
.chip-bad { background: rgba(255, 71, 87, .16); color: var(--red); }
.chip-neutral { background: rgba(53, 201, 255, .16); color: var(--cyan); }
.side-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.side-card-label { font: 800 10.5px/1 var(--ui); letter-spacing: .16em; color: #79839a; display: block; margin-bottom: 9px; }
.side-card-body { font-family: var(--display); font-style: italic; font-size: 14px; }
.match-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.match-stats b { font-family: var(--display); font-style: italic; font-size: 21px; display: block; line-height: 1; }
.match-stats span { font: 800 10px/1 var(--ui); letter-spacing: .12em; color: #79839a; }
.side-log { flex: 1; min-height: 90px; display: flex; flex-direction: column; }
.round-log { display: flex; flex-direction: column; gap: 5px; overflow: auto; flex: 1; }
.log-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,.04); }
.log-row:last-child { border-bottom: 0; }
.log-n { font: 800 10px/1 var(--ui); letter-spacing: .1em; color: #5c6577; min-width: 22px; }
.log-who { font-family: var(--display); font-style: italic; font-size: 13px; }
.log-empty { color: #5c6577; font-size: 12px; font-style: italic; }
.side-foot { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.legend { display: flex; align-items: center; gap: 8px; font: 800 10.5px/1.3 var(--ui); letter-spacing: .09em; text-transform: uppercase; color: #98a1b4; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg.self { background: var(--lime); }
.lg.others { background: var(--red); }
.lg.all { background: var(--cyan); }

/* ---------- results ---------- */
/* Centred with margin:auto on the card, never justify-content:center on the scroller.
   A centred flex container pushes its overflow above its own start edge, where no
   amount of scrolling reaches it - that is what hid the winner's name on a phone. */
#screen-results { align-items: center; }
.results-card { margin: auto 0; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 36px 40px; width: min(620px, 92vw); box-shadow: 0 40px 90px rgba(0,0,0,.6); }
.results-meta { color: var(--muted); font-size: 13px; margin: 8px 0 0; letter-spacing: .04em; }
.btn-key { font: 800 9px/1 var(--ui); letter-spacing: .12em; background: rgba(0,0,0,.22); border-radius: 4px; padding: 4px 6px; margin-left: 8px; vertical-align: middle; }
.results-list { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 6px; }
.result-row { display: flex; align-items: center; gap: 12px; background: #10141b; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.result-row .rank { font-family: var(--display); font-style: italic; color: var(--muted); width: 26px; }
.result-row.first { border-color: rgba(255, 210, 31, .5); box-shadow: 0 0 30px rgba(255, 210, 31, .12); }
.result-row.first .rank { color: var(--yellow); }
.result-row .name { font-family: var(--display); font-style: italic; }
.result-row .pts { margin-left: auto; font-family: var(--display); font-style: italic; font-size: 18px; }
.result-row .dot, .result-member .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
/* A team match is won on the team total, so the board is sides first and players
   underneath them: the big number is the one the match was decided on, and a player's
   own score reads as their share of it rather than as a standing of its own. */
.result-team { display: flex; flex-direction: column; gap: 0; }
.result-row.team { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.result-row.team .name { font-size: 17px; letter-spacing: .03em; color: currentColor; }
.result-row.team .pts { font-size: 26px; color: currentColor; }
.result-team.first .result-row.team { background: #141a23; }
.result-members {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 10px 10px; padding: 4px 14px 6px 40px;
  background: rgba(255, 255, 255, .014);
}
.result-member {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; font-size: 13px; color: var(--muted);
}
.result-member .name { font-family: var(--display); font-style: italic; }
.result-member .pts {
  margin-left: auto; font-family: var(--display); font-style: italic;
  font-size: 14px; font-variant-numeric: tabular-nums;
}

/* ---------- touch controls ---------- */
/* Full-height edge zones: the thumb rests at the screen edge, off the play area.
   Hidden until a coarse pointer is present so a desktop mouse never sees them. */
.steer {
  position: absolute; top: 0; bottom: 0; width: 16%;
  display: none;
  align-items: center;
  pointer-events: none;              /* the holder owns the pointer, not the chevron */
  color: rgba(255, 255, 255, .22);
  font-size: 22px;
  transition: background .12s ease, color .12s ease;
}
.steer-l { left: 0; justify-content: flex-start; padding-left: calc(6px + env(safe-area-inset-left)); }
.steer-r { right: 0; justify-content: flex-end; padding-right: calc(6px + env(safe-area-inset-right)); }
.steer-l { background: linear-gradient(90deg, rgba(182,255,46,.05), transparent); }
.steer-r { background: linear-gradient(270deg, rgba(182,255,46,.05), transparent); }
.steer.on { color: var(--lime); }
.steer-l.on { background: linear-gradient(90deg, rgba(182,255,46,.20), transparent); }
.steer-r.on { background: linear-gradient(270deg, rgba(182,255,46,.20), transparent); }

/* Compact score strip: what replaces the 290px sidebar when there is no room for it. */
.mini-standings {
  position: absolute; top: 0; left: 0; right: 0;
  display: none;
  gap: 8px; padding: 6px 10px;
  justify-content: center; align-items: center; flex-wrap: wrap;
  pointer-events: none;
}
.mini-pip {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(10, 12, 17, .66);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 9px 3px 6px;
}
.mini-pip .mini-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mini-pip .mini-score { font-family: var(--display); font-style: italic; font-size: 14px; }
.mini-pip.dead { opacity: .4; }
.mini-pip.leader { border-color: currentColor; }

/* Buttons inside a banner: the banner itself is click-through, these are not. */
.prompt-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; pointer-events: auto; }
.prompt-actions .btn { font-size: 15px; padding: 13px 24px 15px; }

/* ---------- rotate gate ---------- */
.rotate-gate {
  position: absolute; inset: 0; z-index: 30;
  display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--bg);
  text-align: center;
}
/* Drawn rather than a glyph: a phone-shaped box is the only thing whose rotation
   actually reads as a rotation. */
.rotate-icon {
  width: 40px; height: 68px;
  border: 3px solid var(--lime);
  border-radius: 8px;
  box-shadow: 0 0 26px rgba(182, 255, 46, .35);
  animation: rotateHint 2.4s ease-in-out infinite;
}
@keyframes rotateHint { 0%, 35% { transform: rotate(0deg); } 65%, 100% { transform: rotate(90deg); } }
.rotate-big { font-family: var(--display); font-style: italic; font-size: clamp(20px, 6vw, 34px); }
.rotate-small { font: 800 11px/1 var(--ui); letter-spacing: .24em; color: var(--muted); }

/* ---------- narrow screens: portrait phones, menu and lobby ---------- */
@media (max-width: 720px) {
  .screen { padding: clamp(12px, 2vh, 20px) 14px; }
  .menu-actions { width: min(420px, 100%); }
  .setup-columns { grid-template-columns: 1fr; }
  .slots { grid-template-columns: 1fr; }
  .setup-actions { justify-content: stretch; }
  .setup-actions .btn { flex: 1; }
  .results-card { padding: 24px 18px; }
  .menu-foot { display: none; }
}

/* ---------- coarse pointer: hit targets and the steer zones ---------- */
@media (pointer: coarse) {
  .steer { display: flex; }
  /* Nothing should advertise a key on a device that has none. */
  .for-keys { display: none; }
  .for-touch { display: inline; }
  .hint b { display: none; }
  .hint .for-touch { font: 800 11px/1 var(--ui); letter-spacing: .14em; color: var(--text);
    background: #161b24; border: 1px solid var(--line); border-bottom-width: 2px;
    border-radius: 6px; padding: 9px 13px; display: inline-block; }
  /* 44px is the smallest target a thumb hits reliably; every one of these was
     built for a mouse and sat well under it. */
  .btn { padding: 17px 30px 19px; }
  .key { min-height: 34px; min-width: 44px; padding: 9px 12px; font-size: 13px; }
  .you-chip { width: 40px; height: 40px; }
  .you-colors { gap: 12px; }
  .slot { min-height: 96px; padding-bottom: 34px; }
  .slot .status { font-size: 11.5px; max-width: none; padding: 8px 4px; }
  .slot .bot-toggle { font-size: 11px; padding: 9px 12px; right: 8px; bottom: 8px; }
  .mini { font-size: 12px; padding: 10px 14px; }
  input[type=range] { height: 22px; background-clip: content-box; padding: 8px 0; }
  input[type=range]::-webkit-slider-thumb { width: 26px; height: 26px; }
  .check { min-height: 44px; margin-bottom: 4px; }
  .check input { width: 22px; height: 22px; }
  .field { grid-template-columns: 1fr 40% 34px; }
  .hint { padding: 8px 2px; }
  .hint b { font-size: 12px; padding: 4px 8px; }
  .row .keys { font-size: 11px; }
}

/* ---------- short landscape: the phone-in-hand play posture ----------
   The sidebar is 290px of chrome this viewport cannot spare, so the game screen
   takes the whole thing and the scores move on top of the arena. */
@media (max-height: 560px) and (orientation: landscape) {
  .game-wrap { grid-template-columns: 1fr; }
  .side { display: none; }
  .arena-col {
    padding: 0;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .arena-top {
    position: absolute; z-index: 6; top: 0; left: 0; right: 0;
    padding: 4px 10px; gap: 6px;
    justify-content: space-between;
    pointer-events: none;
  }
  .arena-top .pill { font-size: 9.5px; padding: 5px 10px; background: rgba(10,12,17,.66); }
  .arena-top .pill b { font-size: 12px; }
  .arena-bottom {
    position: absolute; z-index: 6; bottom: 0; left: 0; right: 0;
    padding: 2px 10px calc(2px + env(safe-area-inset-bottom));
    justify-content: flex-end; gap: 14px;
  }
  .mini-standings { display: flex; top: 30px; }
  /* Hard against the left edge, not 18% in: that inset was meant to clear the steer
     zone but put the feed adrift in the middle of the play area. Bottom-left keeps the
     desktop reading position and sits above the button row. */
  .feed { left: calc(6px + env(safe-area-inset-left)); bottom: 46px; gap: 4px; }
  .feed-item { font-size: 11px; padding: 5px 9px 5px 7px; backdrop-filter: none; }
  /* Five entries is a tall stack on a 390px-high screen. Newest is first in the DOM,
     so this drops the oldest and keeps the column short. */
  .feed-item:nth-child(n+4) { display: none; }
  /* Same for the result card: eight standings rows plus a title do not fit 390px of
     height stacked, so they go two-up and the rest tightens. Who won is the one thing
     that must be legible the moment the match ends, with no scrolling. */
  .results-card { padding: 14px 16px; width: min(760px, 96vw); }
  #results-title { font-size: clamp(19px, 4.6vh, 28px); }
  .results-meta { font-size: 10.5px; margin-top: 3px; }
  .results-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 4px; }
  /* Two sides sit side by side here; each block keeps its own players under it. */
  .result-members { padding: 3px 10px 4px 28px; }
  .result-member { padding: 3px 0; font-size: 12px; }
  .result-row.team .pts { font-size: 20px; }
  .result-row { padding: 7px 10px; gap: 8px; }
  .result-row .rank { width: 18px; }
  .result-row .pts { font-size: 15px; }
  #screen-results .setup-actions .btn { padding: 11px 20px 12px; min-height: 44px; }

  /* The menu has several flow children, so it cannot lean on the card's margin:auto
     trick. Top-align it instead: centred content taller than the screen overflows past
     the scroller's start edge, and the brand mark up there becomes unreachable. */
  #screen-menu { justify-content: flex-start; gap: 14px; }
  /* Pinned to the bottom of the visible box, so once the menu scrolls it sits on top of
     the buttons. A 390px-high screen has no room for a tagline anyway. */
  .menu-foot { display: none; }
  /* With the branding sized for a desktop hero the four buttons ran 100px past the
     bottom. Scrolling works now, but a main menu should not need it. So the mark grows
     here too, but by 11px of height rather than matching the desktop ratio. */
  .brand-mark svg { width: 96px; }
  .brand-name { font-size: clamp(30px, 6.4vw, 52px); }
  .brand-tag { font-size: 12px; margin-top: 5px; }
  #screen-menu .btn { padding: 12px 26px 13px; min-height: 44px; }

  /* Landscape lobby is short: shrink the cards so START is reachable without a scroll. */
  #screen-setup { padding: 10px 14px; }
  .setup-head { margin-bottom: 8px; }
  #screen-setup .title { font-size: 22px; }
  #screen-setup .subtitle { font-size: 12px; margin: 2px 0 0; }
  .slots { gap: 8px; margin-bottom: 10px; }
  .slot { min-height: 0; padding: 10px 12px 26px; }
  .bind-msg { min-height: 0; margin: 0 0 6px; }
  .count-main { font-size: clamp(48px, 16vh, 90px); }
  .banner .big { font-size: clamp(26px, 9vh, 44px); }
}

/* Portrait on a touchscreen is not a play posture for a 16:9 arena, so gate it
   rather than shipping a letterboxed strip. Menu and lobby stay usable. */
@media (orientation: portrait) and (pointer: coarse) {
  #screen-game.active .rotate-gate { display: flex; }
}

/* ---------- narrow desktop windows: keep the old stacking behaviour ---------- */
@media (max-width: 900px) and (min-height: 561px) {
  .game-wrap { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { border-left: 0; border-top: 1px solid var(--line); flex-direction: row; overflow-x: auto; }
  .standings { flex-direction: row; }
  .side-title, .side-foot { display: none; }
}

/* ---- team play ---------------------------------------------------------- */
/* Team totals sit above the player rail. The rail answers "who is playing well",
   this answers "who is winning", and in team play those are different questions. */
.team-strip {
  display: flex; flex-direction: column; gap: 4px;
  margin: 0 0 10px; padding: 8px 10px;
  background: rgba(255, 255, 255, .028);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 10px;
}
.team-row {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--display); font-size: 13px; letter-spacing: .04em;
  opacity: .82; transition: opacity .18s ease;
}
.team-row.leader { opacity: 1; }
.team-row.dead { opacity: .38; }
/* My side, tagged. The arena rings my teammates; the strip says which of these two
   rows those rings belong to, so neither view has to be learned from the other. */
.team-row.is-yours { opacity: 1; }
.team-you {
  font: 800 8.5px/1 var(--ui); letter-spacing: .12em; flex: 0 0 auto;
  padding: 2px 4px 3px; border: 1px solid currentColor; border-radius: 4px; opacity: .9;
}
.team-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.team-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-score { font-size: 16px; font-variant-numeric: tabular-nums; }
/* A player on my side: a heavier edge and a lifted ground, which survives .leader and
   .dead being toggled over the top of it. */
.row.is-ally { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .2); }
.row.is-ally .row-edge { width: 7px; box-shadow: 0 0 14px -2px currentColor; }
.row.is-ally .row-side { opacity: 1; }
/* The side a player plays for, on their own row. */
.row-side {
  font-size: 9px; letter-spacing: .1em; padding: 1px 5px 2px;
  border: 1px solid; border-radius: 5px; opacity: .85; white-space: nowrap;
}
/* A rule that has nothing to mean yet - friendly fire without teams - is shown but
   inert, rather than vanishing and reflowing the panel every time teams change. */
.check.disabled { opacity: .38; pointer-events: none; }

/* ---- replay ------------------------------------------------------------- */
.replay-bar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-radius: 11px;
  background: rgba(8, 10, 16, .86); border: 1px solid rgba(255, 255, 255, .1);
  backdrop-filter: blur(6px); z-index: 6;
}
.replay-tag {
  font-family: var(--display); font-size: 11px; letter-spacing: .16em;
  color: #ffd21f; padding: 2px 7px 3px; border: 1px solid rgba(255, 210, 31, .5);
  border-radius: 5px;
}
.replay-what { font-size: 11.5px; opacity: .7; margin-right: 4px; white-space: nowrap; }
.replay-btn {
  font: inherit; font-size: 11px; letter-spacing: .06em;
  padding: 4px 9px 5px; border-radius: 6px; cursor: pointer;
  color: #cfd6e6; background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
}
.replay-btn:hover { color: #fff; border-color: rgba(255, 255, 255, .3); }
.replay-btn.on { color: #0a0c11; background: var(--lime); border-color: var(--lime); }
