:root {
  /* The site's palette (site/site.css); the red accent and good/bad stay the game's own. */
  --bg: var(--am-bg, #0b0d12);
  --panel: var(--am-panel, #161a22);
  --panel-2: var(--am-panel-2, #1f2530);
  --line: var(--am-line, #333c4a);
  --text: var(--am-text, #eef0f3);
  --muted: var(--am-muted, #a3abb8);
  --accent: #d8434b;
  --accent-2: var(--am-accent, #ffb547);
  --good: #6bd66b;
  --bad: #ff5a4a;
  --radius: 10px;
  --header-h: 48px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--am-font, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif);
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent-2);
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.site-logo {
  font-weight: 800;
  font-size: 20px;
  text-decoration: none;
  color: var(--text);
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.page {
  padding: 8px 8px 40px;
}

.game-root {
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: min(1280px, calc((100vh - var(--header-h) - 28px) * 1.7778));
  max-width: min(1280px, calc((100dvh - var(--header-h) - 28px) * 1.7778));
  min-width: min(100%, 300px);
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  container: stage / size;
}

.stage > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.stage.playing > canvas {
  cursor: crosshair;
}

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  font-size: 14px;
  text-shadow: 0 1px 2px #000;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.hud-row.bottom {
  align-items: flex-end;
}

.hud-box {
  background: rgba(8, 10, 14, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 5px 9px;
  min-width: 0;
}

.hud-box.center {
  text-align: center;
}

.hud-box.right {
  text-align: right;
}

.hud-wave,
.hud-weapon {
  font-weight: 700;
}

.hud-sub {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.hud-money {
  font-size: 20px;
  font-weight: 800;
  color: #9fe29a;
  font-variant-numeric: tabular-nums;
}

.hud-ammo {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hud-ammo .reserve {
  font-size: 14px;
  color: var(--muted);
}

.hud-ammo.low {
  color: #ff8a5a;
}

.hud-ammo.reloading {
  color: var(--accent-2);
}

.hud-buttons {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(22, 26, 34, 0.85);
  cursor: pointer;
  font-size: 15px;
}

.vitals {
  width: 170px;
}

.bar-label {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 9px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  overflow: hidden;
  margin: 2px 0 4px;
}

.bar.thin {
  height: 6px;
}

.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.15s linear;
}

.bar-fill.hp {
  background: linear-gradient(90deg, #c7353d, #e8575e);
}

.bar-fill.armor {
  background: linear-gradient(90deg, #4d7fbf, #79a7e0);
}

.segs {
  display: flex;
  gap: 3px;
  margin-top: 3px;
}

.seg {
  width: 22px;
  height: 10px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.seg > i {
  display: block;
  height: 100%;
  background: #c9b27a;
}

.seg.down > i {
  background: transparent;
}

.seg.down {
  outline: 1px solid #ff5a4a;
}

.flash-msg {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 0 2px 8px #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s;
  white-space: nowrap;
}

.flash-msg.show {
  opacity: 1;
}

.flash-msg small {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}

/* ---------- Overlays and cards ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  pointer-events: none;
}

.overlay:empty {
  display: none;
}

.overlay > * {
  pointer-events: auto;
}

.overlay.dim {
  background: rgba(4, 6, 10, 0.55);
}

.card {
  background: rgba(14, 17, 23, 0.94);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.card.wide {
  width: min(880px, 100%);
}

.card h2 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: 0.5px;
}

.card h3 {
  margin: 10px 0 6px;
  font-size: 15px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.card p {
  margin: 6px 0;
  line-height: 1.45;
}

.card .muted {
  color: var(--muted);
  font-size: 13px;
}

.title-card h2 {
  font-size: 34px;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.title-card .kicker {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* Without WebGL2 the title says why the night can't be drawn, in the
   story's place. */
.card p.view-notice {
  color: #f0c8c4;
}

.view-notice strong {
  color: var(--text);
}

.btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
}

.btn:hover,
.btn:focus-visible {
  border-color: #6d7990;
}

.btn.primary {
  background: var(--accent);
  border-color: #f06a71;
  color: #fff;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* "Take your post" while the view prepares: it fills with the share of the
   work done (src/3d/progress.js), and says it. */
.btn.primary.preparing {
  opacity: 1;
  color: rgba(255, 255, 255, 0.82);
  background: linear-gradient(90deg, var(--accent) var(--prep, 0%), #4a2a2e var(--prep, 0%));
}

.btn .pct {
  display: inline-block;
  min-width: 4.2ch;
  margin-left: 0.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
  margin: 10px 0;
}

.stat {
  background: var(--panel);
  border-radius: 8px;
  padding: 6px;
}

.stat b {
  display: block;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.stat span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------- Shop ---------- */

.shop {
  text-align: left;
}

.shop-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.shop-head h2 {
  margin: 0;
}

.wallet {
  font-size: 22px;
  font-weight: 800;
  color: #9fe29a;
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: flex;
  gap: 4px;
  margin: 10px 0 8px;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.tab[aria-selected='true'] {
  background: var(--panel-2);
  border-color: #6d7990;
}

.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item .name {
  font-weight: 800;
}

.item .desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  flex: 1;
}

.item .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

/* In the supply tent an item's row is as tall as its Buy button, which a
   purchase can take away ("Owned", "Full strength"): the item keeps its
   height, so nothing below it moves and a list scrolled to its end stays
   there (#935). The button is 32 px in every font. */
.shop .item .row {
  min-height: 32px;
}

.shop .item .btn {
  line-height: 20px;
}

/* What a purchase bought, said to screen readers only (#935). */
.shop .said {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.item .price {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.item .owned {
  font-size: 12px;
  color: var(--good);
}

.item .locked {
  font-size: 12px;
  color: var(--muted);
}

.item .btn {
  padding: 5px 12px;
  min-height: 32px;
}

/* A gun's card and a tier of armor's (#961): an "Owned" mark by the name,
   and what it holds where its price was. The mark keeps its room while
   hidden and the meter is one line in every state, so a purchase changes
   no card's height and nothing moves. The grenades and the medic count in
   a meter too. */
.item .head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.item .head .name {
  flex: 1;
  min-width: 0;
}

.item .mark {
  flex: none;
  margin-top: 1px;
  padding: 0 7px;
  border: 1px solid rgba(107, 214, 107, 0.5);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  color: var(--good);
  visibility: hidden;
}

.item .mark.owned {
  visibility: visible;
}

/* Positioned, so the words for screen readers in it (.sr) stay inside the
   card that scrolls, and scroll with it. */
.item .meter {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 20px;
  font-size: 12px;
  line-height: 20px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* The words give way before the bar does, in a card narrower than any
   layout makes. */
.item .meter > span:first-child {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item .meter .bar {
  flex: 1;
  min-width: 24px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.item .meter .bar i {
  display: block;
  height: 100%;
  background: var(--accent-2);
}

/* A gun's buttons start at the left, 8 px apart, so "+pack" stays put when
   "Fill" goes; unowned, its price sits left and Buy right, as elsewhere. */
.shop .item:is(.gun, .armor) .row {
  justify-content: flex-start;
  gap: 8px;
}

.shop .item:is(.gun, .armor) .row .price {
  margin-right: auto;
}

/* The longest pack and fill prices must fit together even in WebKit's
   wider system font on a tablet. Wrapping them grew the row after buying
   the heavy machine gun, moving its card and every row below it. */
.shop .item.gun .row .btn {
  padding-inline: 6px;
  white-space: nowrap;
  min-width: 44px;
}

/* A name or words that keep the room of the other thing a purchase can make
   them say (#961): both in one grid cell, the other hidden. */
.item .keep {
  display: grid;
}

.item .keep > span {
  grid-area: 1 / 1;
}

.item .keep > .alt {
  visibility: hidden;
}

.item .full {
  font-size: 12px;
  color: var(--good);
}

/* "Restock all" (#961), at the top of the Weapons tab. */
.shop .restock {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 8px;
}

.shop .restock .btn {
  padding: 5px 12px;
  min-height: 32px;
  line-height: 20px;
}

/* Words for screen readers only: what a meter holds, in full (#961). */
.shop .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.segrow {
  display: flex;
  gap: 4px;
  margin: 2px 0;
}

.segrow .seg {
  width: 100%;
  height: 8px;
}

/* ---------- Settings ---------- */

.settings {
  text-align: left;
}

.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.choice {
  display: flex;
  gap: 4px;
}

.choice .tab {
  min-width: 64px;
}

.setting input[type='range'] {
  width: 150px;
}

/* ---------- Page ---------- */

.ad-slot:empty {
  display: none;
}

.ad-slot {
  max-width: 970px;
  margin: 16px auto;
  min-height: 90px;
}

.about {
  max-width: 820px;
  margin: 20px auto;
  padding: 0 8px;
  line-height: 1.55;
}

.about h1 {
  margin-bottom: 4px;
}

.warning {
  background: #2a1214;
  border: 1px solid #5a2228;
  border-radius: 8px;
  padding: 8px 12px;
}

kbd {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

/* Upright screens get a tall game area rather than a 16:9 strip. */
@media (orientation: portrait) {
  .stage {
    aspect-ratio: 3 / 4;
    max-height: calc(100dvh - var(--header-h) - 40px);
  }
  .game-root {
    max-width: 100%;
  }
}

/* ---------- Small game areas ---------- */

@container stage (max-width: 520px) {
  .hud {
    font-size: 12px;
    padding: 5px;
  }
  .hud-money {
    font-size: 16px;
  }
  .hud-ammo {
    font-size: 18px;
  }
  .vitals {
    width: 118px;
  }
  .seg {
    width: 14px;
  }
  .hud-row.bottom {
    flex-wrap: wrap;
  }
  .barricades {
    order: -1;
    width: 100%;
  }
  .card {
    padding: 12px;
  }
  .card h2 {
    font-size: 21px;
  }
  .title-card h2 {
    font-size: 26px;
  }
  .items {
    grid-template-columns: 1fr;
  }
}

@container stage (max-height: 430px) {
  .hud {
    padding: 4px;
    font-size: 12px;
  }
  .hud-box {
    padding: 3px 7px;
  }
  .hud-money {
    font-size: 16px;
  }
  .hud-ammo {
    font-size: 17px;
  }
  .icon-btn {
    width: 30px;
    height: 30px;
  }
  .card {
    padding: 10px 14px;
  }
  .card h2 {
    font-size: 20px;
  }
  .title-card h2 {
    font-size: 24px;
  }
  .btn {
    min-height: 34px;
    padding: 6px 12px;
  }
  .flash-msg {
    font-size: 20px;
  }
}

@container stage (max-height: 300px) {
  .vitals {
    width: 110px;
  }
  .bar-label {
    font-size: 10px;
  }
  .hud-sub {
    font-size: 10px;
  }
}

.medal-note,
.card .medal-note {
  color: #d9b55e;
  font-weight: 600;
}

/* ---------- Platforms (DESIGN.md, "Platforms"): the layout of each format ---------- */

/* The safe-area insets, read by device.js. Tests set --sat, --sar, --sab and --sal. */
.safe-probe {
  position: fixed;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
  padding: var(--sat, env(safe-area-inset-top, 0px)) var(--sar, env(safe-area-inset-right, 0px)) var(--sab, env(safe-area-inset-bottom, 0px)) var(--sal, env(safe-area-inset-left, 0px));
}

/* No scrolling, zooming, selection or long-press menu on the stage. */
.v3d .stage {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

html.cd-night,
html.cd-night body {
  overscroll-behavior: none;
}

.v3d .stage.locked > canvas {
  cursor: none;
}

/* While the pointer is locked no cursor can reach the pause button, so it
   shows the key that pauses (#912). */
#btn-pause .ib-key {
  display: none;
}

.v3d .stage.locked #btn-pause {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 7px 0 9px;
}

.v3d .stage.locked #btn-pause .ib-key {
  display: inline-block;
  padding: 0 4px;
  font: 600 12px/18px system-ui, sans-serif;
  color: var(--text, #e8e2d4);
}

/* The HUD keeps to the edges, inside the safe area, at the class's scale. */
.v3d .hud {
  inset: 0 auto auto 0;
  width: calc(100% / var(--hud-k, 1));
  height: calc(100% / var(--hud-k, 1));
  transform: scale(var(--hud-k, 1));
  transform-origin: 0 0;
  padding: calc(var(--pt, 16px) / var(--hud-k, 1)) calc(var(--pr, 16px) / var(--hud-k, 1)) calc(var(--pb, 16px) / var(--hud-k, 1)) calc(var(--pl, 16px) / var(--hud-k, 1));
  font-size: max(var(--hud-text, 14px), 14px);
}

.v3d .hud .hud-sub,
.v3d .hud .bar-label,
.v3d .hud .hud-ammo .reserve {
  font-size: var(--hud-text, 14px);
}

.v3d .overlay {
  z-index: 3;
  padding: var(--pt, 16px) var(--pr, 16px) var(--pb, 16px) var(--pl, 16px);
}

/* With the touch controls, every read-out runs along the top edge: the
   thumbs own the bottom corners. Sound and Pause, 44 px, sit either side of
   the wave read-out. */
.v3d .stage.touch .hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px auto 44px minmax(0, 1fr);
  grid-template-rows: auto auto;
  grid-template-areas:
    'vitals mute wave pause weapon'
    'vitals info info info weapon';
  align-content: start;
  align-items: start;
  column-gap: 8px;
  row-gap: 4px;
}

.v3d .stage.touch .hud-row,
.v3d .stage.touch .hud-row.top > .hud-box.right,
.v3d .stage.touch .hud-buttons {
  display: contents;
}

.v3d .stage.touch .hud-row.top > .hud-box:first-child {
  grid-area: wave;
  text-align: center;
}

.v3d .stage.touch .hud-box.center {
  grid-area: info;
  justify-self: end;
  padding: 1px 8px;
}

.v3d .stage.touch #btn-mute {
  grid-area: mute;
}

.v3d .stage.touch #btn-pause {
  grid-area: pause;
}

.v3d .stage.touch .hud .icon-btn {
  width: 44px;
  height: 44px;
  pointer-events: auto;
}

.v3d .stage.touch .vitals {
  grid-area: vitals;
  justify-self: start;
  width: min(150px, 100%);
}

.v3d .stage.touch .barricades {
  grid-area: info;
  justify-self: start;
  order: 0;
  width: auto;
  padding: 4px 6px;
}

.v3d .stage.touch .barricades .bar-label {
  display: none;
}

.v3d .stage.touch .hud-box.weapon {
  grid-area: weapon;
  justify-self: end;
}

/* The thumb-placed buttons (touch.js places them; they take no events). */
.tc {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  display: none;
  transition: opacity 0.3s;
}

.stage.touch.playing .tc,
.stage.tc-editing .tc {
  display: block;
}

.stage.tc-faded:not(.tc-editing) .tc {
  opacity: 0;
}

.tc-btn {
  position: absolute;
  box-sizing: border-box;
  border-radius: 50%;
  border: 1.5px solid rgba(220, 224, 232, 0.55);
  background: rgba(10, 12, 16, 0.55);
  opacity: var(--tc-rest, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.06s, opacity 0.06s;
}

.tc-btn svg {
  width: 46%;
  height: 46%;
  fill: none;
  stroke: #e3e6ec;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tc-btn.down {
  opacity: 1;
  transform: scale(1.06);
  background: rgba(70, 76, 88, 0.75);
}

.tc-btn.off {
  opacity: calc(var(--tc-rest, 0.5) * 0.4);
}

.stage.tc-editing .tc-btn {
  opacity: 1;
  outline: 2px dashed rgba(220, 224, 232, 0.6);
  outline-offset: 3px;
}

/* The weapon strip (touch) along the left edge, and the wheel (the pad). */
.tc-strip {
  position: absolute;
  z-index: 4;
  left: var(--pl, 16px);
  top: var(--pt, 16px);
  bottom: var(--pb, 16px);
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  pointer-events: none;
}

/* The wheel is a ring round the view's centre, each gun where the stick
   points to pick it (controls.js sets --a, clockwise from the top; #576). */
.tc-strip.wheel {
  --ry: 34cqh;
  --rx: min(42cqw, 1.9 * var(--ry));
  left: 50%;
  top: 50%;
  bottom: auto;
  width: 0;
  height: 0;
  display: block;
}

.tc-strip.wheel .tc-gun {
  position: absolute;
  left: 0;
  top: 0;
  min-width: 128px;
  justify-content: center;
  white-space: nowrap;
  transform: translate(-50%, -50%) translate(calc(sin(var(--a, 0deg)) * var(--rx)), calc(cos(var(--a, 0deg)) * -1 * var(--ry)));
}

/* On a phone the ring sits below the read-outs along the top, so it never
   covers the pause button, and it is wide enough that its eleven names
   don't touch (#912). */
.game-root.v3d[data-class='phone'] .tc-strip.wheel {
  --top: calc(var(--pt, 16px) + 78px);
  --ry: max(80px, min(34cqh, (100cqh - var(--top) - var(--pb, 16px) - 44px) / 2));
  --rx: max(240px, min(42cqw, 50cqw - max(var(--pl, 16px), var(--pr, 16px)) - 70px));
  top: calc(var(--top) + 22px + var(--ry));
}

.game-root.v3d[data-class='phone'] .tc-strip.wheel .tc-gun {
  min-width: 112px;
  padding: 0 8px;
}

.tc-gun {
  min-height: 44px;
  min-width: 140px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(10, 12, 16, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 14px;
  font-weight: 700;
}

.tc-gun.on {
  border-color: #d9d2c2;
  background: rgba(60, 64, 72, 0.9);
}

/* Edit layout: the view stays frozen under the buttons. */
.overlay.passthrough {
  align-items: flex-start;
  pointer-events: none;
  background: none;
}

.edit-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(14, 17, 23, 0.94);
  border: 1px solid var(--line);
  font-size: 14px;
}

/* The rotate prompt: a phone turning on its side. */
.card.rotate h2 {
  margin-top: 8px;
}

.rotate-phone {
  width: 34px;
  height: 58px;
  margin: 4px auto 0;
  border: 3px solid #d9d2c2;
  border-radius: 7px;
  animation: cd-turn 2.2s ease-in-out infinite;
}

@keyframes cd-turn {
  0%,
  25% {
    transform: rotate(0deg);
  }
  60%,
  100% {
    transform: rotate(-90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-phone {
    animation: none;
    transform: rotate(-90deg);
  }
}

.overlay.rotate-hold {
  background: rgba(4, 6, 10, 0.9);
}

/* The prompt has no buttons: it lets touches through, and the held night ignores them. */
.overlay.rotate-hold > .card.rotate {
  pointer-events: none;
}

/* The home-screen card: inside the menu's card, or over the view in a night. */
.hint-card {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #d9d2c2;
  border-radius: 10px;
  background: rgba(30, 34, 42, 0.95);
  text-align: left;
}

.hint-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.hint-card p {
  margin: 0 0 8px;
  font-size: 14px;
}

.overlay > .hint-card {
  width: min(440px, 100%);
}

.sound-hint {
  font-size: 13px;
}

.controls-card {
  text-align: left;
}

.controls-card .controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 16px;
}

.row.wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

/* "How it plays" on the Controls screen: each kind of control's defaults. */
.how-scheme {
  margin: 4px 0;
  text-align: left;
}
.how-scheme summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}
.how-scheme summary::-webkit-details-marker {
  display: none;
}
.how-scheme summary::before {
  content: "\25B8";
  display: inline-block;
  transition: transform 0.15s;
}
.how-scheme[open] summary::before {
  transform: rotate(90deg);
}
@media (prefers-reduced-motion: reduce) {
  .how-scheme summary::before {
    transition: none;
  }
}
.how-scheme dl {
  display: grid;
  grid-template-columns: minmax(8em, max-content) 1fr;
  gap: 4px 12px;
  margin: 0 0 8px;
}
.how-scheme dt {
  color: var(--muted, #aab);
}
.how-scheme dd {
  margin: 0;
}
@container stage (max-width: 520px) {
  .how-scheme dl {
    grid-template-columns: 1fr;
  }
  .how-scheme dd {
    margin-bottom: 4px;
  }
}

.binds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 4px 16px;
}

.bind {
  display: grid;
  grid-template-columns: 1fr 96px 96px;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.bind .btn {
  min-height: 32px;
  padding: 4px 6px;
}

/* Fullscreen: the game root fills the screen, and the site header is hidden. */
.game-root.v3d:fullscreen {
  max-width: none;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.game-root.v3d:-webkit-full-screen {
  max-width: none;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.game-root.v3d:fullscreen .stage {
  aspect-ratio: auto;
  height: 100%;
  max-height: none;
}

.game-root.v3d:-webkit-full-screen .stage {
  aspect-ratio: auto;
  height: 100%;
  max-height: none;
}

/* Phones: in a night the game fills the viewport, and the site header hides
   (docs/ADDING-A-GAME.md allows it); the menus show it again. */
html.cd-phone.cd-night {
  overflow: hidden;
}

html.cd-phone.cd-night .site-header {
  display: none;
}

html.cd-phone.cd-night .game-root.v3d {
  position: fixed;
  inset: 0;
  z-index: 50;
  max-width: none;
  width: auto;
  height: 100vh;
  height: 100dvh;
  border: 0;
  border-radius: 0;
}

html.cd-phone.cd-night .game-root.v3d .stage {
  aspect-ratio: auto;
  height: 100%;
  max-height: none;
}

/* ---------- Every format plays and reads well (#576; DESIGN.md, "Play pass as built (#576)") ---------- */

/* The smallest text on every screen is the class's (DESIGN.md, "Layout"):
   13 CSS px on phones, 15 on tablets and 14 on desktops, in the menus as in
   the HUD. */
.game-root.v3d {
  --min-text: 14px;
}

.game-root.v3d[data-class='phone'] {
  --min-text: 13px;
}

.game-root.v3d[data-class='tablet'] {
  --min-text: 15px;
}

.v3d .title-card .kicker,
.v3d .stat span,
.v3d .item .desc,
.v3d .item .owned,
.v3d .item .mark,
.v3d .item .meter,
.v3d .item .full,
.v3d .item .locked,
.v3d .card .muted,
.v3d .tab,
.v3d .sound-hint {
  font-size: var(--min-text);
}

.v3d .flash-msg small,
.v3d .bind,
.v3d .edit-bar,
.v3d .hint-card p,
.v3d .tc-gun {
  font-size: max(14px, var(--min-text));
}

/* On phones and tablets, and wherever the touch controls show, every
   button, tab and slider in the menus is at least 44 CSS px tall, and so
   is a supply tent item's row, with or without its Buy button (#935). */
.game-root.v3d:is([data-class='phone'], [data-class='tablet']) :is(.btn, .tab),
.v3d .stage.touch :is(.btn, .tab),
.game-root.v3d:is([data-class='phone'], [data-class='tablet']) .shop .item .row,
.v3d .stage.touch .shop .item .row {
  min-height: 44px;
}

.game-root.v3d:is([data-class='phone'], [data-class='tablet']) input[type='range'],
.v3d .stage.touch input[type='range'] {
  height: 44px;
}

/* Phones: the menus get the whole width and the height below the site's
   header (a night already fills the screen). */
html.cd-phone .page {
  padding: 0 0 40px;
}

html.cd-phone .game-root.v3d {
  max-width: none;
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  border-width: 0 0 1px;
  border-radius: 0;
}

html.cd-phone .game-root.v3d .stage {
  aspect-ratio: auto;
  height: 100%;
  max-height: none;
}

/* A card's buttons stay in view while the rest of it scrolls; a focused
   item scrolls clear of them. The card's bottom padding moves into the
   buttons' row, so they sit on the card's edge (Firefox before 121, without
   :has(), keeps the padding under them). */
.v3d .card {
  --card-pb: 16px;
  --card-px: 20px;
  scroll-padding-bottom: 84px;
}

.v3d .card:has(> .btns:last-child) {
  padding-bottom: 0;
}

.v3d .card > .btns:last-child {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin: 10px calc(-1 * var(--card-px)) 0;
  padding: 10px var(--card-px) var(--card-pb);
  background: rgb(14, 17, 23);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.06);
}

/* Short game areas (phones held sideways): compact cards that fit. */
@container stage (max-height: 430px) {
  .v3d .card {
    --card-pb: 10px;
    --card-px: 14px;
    padding: 10px 14px;
  }
  .v3d .card h2 {
    font-size: 20px;
    margin-bottom: 2px;
  }
  .v3d .title-card h2 {
    font-size: 22px;
  }
  .v3d .card p {
    margin: 4px 0;
    line-height: 1.35;
  }
  .v3d .btns {
    margin-top: 6px;
  }
  .v3d .card > .btns:last-child {
    margin-top: 6px;
    padding-top: 8px;
  }
  .v3d .stats {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 14px;
    margin: 6px 0;
  }
  .v3d .stat {
    background: none;
    padding: 0;
  }
  .v3d .stat b {
    display: inline;
    font-size: 16px;
  }
  .v3d .stat span {
    margin-left: 5px;
    text-transform: none;
    letter-spacing: 0;
  }
  .v3d .tabs {
    margin: 6px 0;
  }
  .v3d .shop-head h2,
  .v3d .wallet {
    font-size: 19px;
  }
  .v3d .hint-card {
    padding: 6px 10px;
    margin: 8px 0 0;
  }
  .v3d .hint-card h3 {
    display: none;
  }
  .v3d .hint-card p {
    margin: 0 0 6px;
  }
}

@container stage (max-height: 430px) and (min-width: 600px) {
  .v3d .card {
    width: min(720px, 100%);
  }
}

/* Desktops: the menus, the wave's announcements and the pad's wheel grow
   with the HUD's scale (the game area's height over 720, 1 to 3), so a full
   screen 1080p or 4K desktop reads them as a 720p window does (#576). */
.game-root.v3d[data-class='desktop'] .overlay {
  inset: 0 auto auto 0;
  width: calc(100% / var(--hud-k, 1));
  height: calc(100% / var(--hud-k, 1));
  transform: scale(var(--hud-k, 1));
  transform-origin: 0 0;
  padding: calc(var(--pt, 16px) / var(--hud-k, 1)) calc(var(--pr, 16px) / var(--hud-k, 1)) calc(var(--pb, 16px) / var(--hud-k, 1)) calc(var(--pl, 16px) / var(--hud-k, 1));
}

.game-root.v3d[data-class='desktop'] .flash-msg {
  transform: translateX(-50%) scale(var(--hud-k, 1));
  transform-origin: 50% 0;
}

.game-root.v3d[data-class='desktop'] .tc-strip.wheel .tc-gun {
  transform: translate(-50%, -50%) translate(calc(sin(var(--a, 0deg)) * var(--rx)), calc(cos(var(--a, 0deg)) * -1 * var(--ry))) scale(var(--hud-k, 1));
}

/* The walk stick on his feet (#938): a ring where the left thumb landed,
   its knob following the thumb; past the rim it runs. */
.tc-stick {
  position: absolute;
  box-sizing: border-box;
  border-radius: 50%;
  border: 1.5px solid rgba(220, 224, 232, 0.5);
  background: rgba(10, 12, 16, 0.3);
  opacity: var(--tc-rest, 0.5);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tc-stick > i {
  width: 44%;
  height: 44%;
  border-radius: 50%;
  background: rgba(220, 224, 232, 0.55);
}

.tc-stick.run {
  border-color: rgba(236, 240, 230, 0.9);
}

.tc-gun.off {
  opacity: 0.45;
}

.tc-stick[hidden] {
  display: none;
}

/* ?perf is an opt-in, collapsible report below the HUD and site exit. */
.perf-panel { position: absolute; z-index: 30; top: max(calc(var(--sat, 0px) + 90px), var(--perf-top, 90px)); left: calc(var(--sal, 0px) + 8px); max-width: calc(100% - var(--sal, 0px) - var(--sar, 0px) - 16px); color: #fff; background: #111e; border: 1px solid #aaa; border-radius: 6px; font: 13px/1.4 monospace; max-height: calc(100% - max(calc(var(--sat, 0px) + 90px), var(--perf-top, 90px)) - var(--sab, 0px) - 8px); overflow: auto; }
.perf-panel summary { min-height: 44px; padding: 10px; cursor: pointer; box-sizing: border-box; }
.perf-panel button { min-height: 44px; min-width: 110px; margin: 4px 8px; }
.perf-panel pre { margin: 8px; max-height: min(40dvh, 360px); max-width: min(700px, 85vw); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.stage.touch .perf-panel { max-width: calc(45% - 8px); max-height: min(34dvh, calc(100% - var(--perf-top, 90px) - var(--sab, 0px) - 8px)); }
