/* Block Lobbers: modern-retro look. Sizes use cqw (percent of the game's width)
   so the whole interface scales with the game. */
:root {
  --panel: rgba(12, 18, 34, 0.8);
  --panel-solid: rgba(12, 18, 34, 0.92);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --p1: #60a5fa;
  --p2: #fb923c;
  --accent: #facc15;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, ui-monospace, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: radial-gradient(ellipse at top, #1e293b, #0b1220 70%);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
}

.page {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 12px;
}

.stage {
  position: relative;
  width: min(100%, calc((100vh - 24px) * 16 / 9));
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 3px rgba(255, 255, 255, 0.08);
  font-size: 1.5cqw;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* Smooth layer for name tags, aim arrow and numbers, drawn on top of the pixel art. */
#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  image-rendering: auto;
}

[hidden] {
  display: none !important;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.3em;
  margin: 0 0.08em;
  border-radius: 0.3em;
  background: rgba(255, 255, 255, 0.14);
  border-bottom: 2px solid rgba(0, 0, 0, 0.35);
  font-family: var(--mono);
  font-size: 0.9em;
  text-align: center;
  line-height: 1.4;
}

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

.hud-top {
  position: absolute;
  top: 1.6%;
  left: 1.4%;
  right: 1.4%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.4cqw;
  align-items: start;
  pointer-events: none;
}

.player-card {
  max-width: 24em;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 0.8em;
  padding: 0.4em 0.7em 0.5em;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.player-card.p2 {
  justify-self: end;
  width: 100%;
}

.player-card.active.p1 {
  border-color: var(--p1);
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.35), 0 0 1.2em rgba(96, 165, 250, 0.5);
}

.player-card.active.p2 {
  border-color: var(--p2);
  box-shadow: 0 0 0 2px rgba(251, 146, 60, 0.35), 0 0 1.2em rgba(251, 146, 60, 0.5);
}

.pc-head {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.p2 .pc-head {
  flex-direction: row-reverse;
}

.swatch {
  width: 0.75em;
  height: 0.75em;
  border-radius: 2px;
  background: var(--p1);
}

.p2 .swatch {
  background: var(--p2);
}

.pc-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.p2 .pc-name {
  text-align: right;
}

.pc-life-num {
  font-variant-numeric: tabular-nums;
}

.life-bar {
  position: relative;
  height: 0.85em;
  margin-top: 0.3em;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.3em;
  overflow: hidden;
}

.life-chip,
.life-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
}

.p2 .life-chip,
.p2 .life-fill {
  left: auto;
  right: 0;
}

/* The pale "chip" lags behind so you can see how much was just lost. */
.life-chip {
  background: #fef3c7;
  transition: width 0.6s ease 0.4s;
}

.life-fill {
  background: linear-gradient(#4ade80, #16a34a);
  box-shadow: inset 0 0.18em 0 rgba(255, 255, 255, 0.35);
  transition: width 0.25s ease;
}

.life-fill.mid {
  background: linear-gradient(#fde047, #eab308);
}

.life-fill.low {
  background: linear-gradient(#f87171, #dc2626);
}

.hud-center {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 0.8em;
  padding: 0.4em 1em;
  text-align: center;
  font-family: var(--mono);
  backdrop-filter: blur(6px);
}

.terrain-name {
  font-size: 0.75em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.turn-label {
  font-weight: 700;
  white-space: nowrap;
}

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

.hud-bottom {
  position: absolute;
  left: 50%;
  bottom: 2%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.9em;
  align-items: center;
  white-space: nowrap;
  font-size: 0.88em;
  background: var(--panel);
  border: 2px solid var(--p1);
  border-radius: 0.8em;
  padding: 0.5em 0.8em;
  backdrop-filter: blur(6px);
}

.hud-bottom.p2-turn {
  border-color: var(--p2);
}

.weapon-btn {
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-width: 13em;
  padding: 0.25em 0.6em 0.25em 0.35em;
  font: inherit;
  color: var(--text);
  text-align: left;
  border: 2px solid var(--accent);
  border-radius: 0.5em;
  background: rgba(250, 204, 21, 0.14);
  cursor: pointer;
}

.weapon-btn:hover {
  background: rgba(250, 204, 21, 0.24);
}

.w-icon {
  width: 2.2em;
  height: 2.2em;
  image-rendering: pixelated;
}

.w-text {
  display: flex;
  flex-direction: column;
}

.w-name {
  font-family: var(--mono);
  font-weight: 700;
}

.w-ammo {
  margin-left: auto;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.caret {
  font-size: 0.6em;
  color: var(--accent);
}

.stat.dim {
  opacity: 0.35;
}

.aim {
  display: flex;
  gap: 1em;
  align-items: center;
  font-family: var(--mono);
}

.label {
  display: block;
  font-size: 0.68em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-value {
  display: inline-block;
  min-width: 3.4em;
  font-weight: 700;
  font-size: 1.15em;
  font-variant-numeric: tabular-nums;
}

.power-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.power-row .stat-value {
  min-width: 1.8em;
}

.power-bar {
  display: block;
  width: 6em;
  height: 0.8em;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.3em;
  overflow: hidden;
}

#power-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #facc15 55%, #ef4444) left / 6em 100% no-repeat;
}

.mute-btn {
  font: inherit;
  font-size: 0.75em;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.5em;
  padding: 0.3em 0.5em;
  cursor: pointer;
}

.mute-btn[aria-pressed="true"] {
  color: #fca5a5;
}

.info-btn {
  width: 1.9em;
  height: 1.9em;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font: 700 0.9em/1 Georgia, "Times New Roman", serif;
  font-style: italic;
  cursor: pointer;
  vertical-align: middle;
}

.info-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------- How-to-play dialog ---------- */

.help {
  width: min(92vw, 560px);
  max-height: 90vh;
  padding: 22px 26px;
  color: var(--text);
  background: var(--panel-solid);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 1em 3em rgba(0, 0, 0, 0.5);
  font-size: 15px;
  line-height: 1.5;
}

.help::backdrop {
  background: rgba(8, 12, 24, 0.6);
}

.help h2 {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 24px;
  color: var(--accent);
}

.keys {
  width: 100%;
  border-collapse: collapse;
}

.keys th,
.keys td {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  vertical-align: middle;
}

.keys th {
  width: 40%;
  font-weight: 400;
  white-space: nowrap;
}

.help .assist {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.assist-label {
  margin: 0 0 10px;
}

.help .chip span {
  padding: 0.4em 0.9em;
  white-space: nowrap;
}

.help .btn-primary {
  font-size: 18px;
}

/* ---------- Turn banner ---------- */

.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 36%;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  font-family: var(--mono);
}

.banner.show {
  animation: banner 1.8s ease forwards;
}

@keyframes banner {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  14% {
    opacity: 1;
    transform: scale(1.06);
  }
  24% {
    transform: scale(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-0.6em);
  }
}

.banner-title {
  font-size: 3.4em;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  text-shadow: 0.06em 0.06em 0 #1e4fd0, 0.12em 0.12em 0 rgba(0, 0, 0, 0.35);
}

.banner.p2 .banner-title {
  text-shadow: 0.06em 0.06em 0 #c2410c, 0.12em 0.12em 0 rgba(0, 0, 0, 0.35);
}

.banner-sub {
  display: inline-block;
  margin-top: 0.4em;
  padding: 0.2em 0.8em;
  border-radius: 999px;
  background: var(--panel);
  font-size: 1.1em;
  font-weight: 700;
}

/* ---------- Start and end screens ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 24, 0.45);
  backdrop-filter: blur(2px);
}

.panel {
  width: min(90%, 40em);
  padding: 1.4em 1.8em 1.2em;
  background: var(--panel-solid);
  border: 2px solid var(--panel-border);
  border-radius: 1em;
  box-shadow: 0 1em 3em rgba(0, 0, 0, 0.5);
}

.logo {
  margin: 0;
  font-family: var(--mono);
  font-size: 3.6em;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--p2);
  text-shadow: 0.05em 0.05em 0 #9a3412, 0.1em 0.1em 0 #431407, 0.1em 0.1em 0.4em rgba(0, 0, 0, 0.5);
}

.logo span {
  color: var(--p1);
  text-shadow: 0.05em 0.05em 0 #1e40af, 0.1em 0.1em 0 #172554, 0.1em 0.1em 0.4em rgba(0, 0, 0, 0.5);
}

.tagline {
  margin: 0.8em 0 0;
  text-align: center;
  color: var(--muted);
}

fieldset {
  margin: 1em 0 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.45em;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.names {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9em;
}

.name-field label {
  display: block;
  margin-bottom: 0.25em;
  font-weight: 700;
  color: var(--p1);
}

.name-field.p2 label {
  color: var(--p2);
}

.name-field input {
  width: 100%;
  padding: 0.4em 0.6em;
  font: inherit;
  font-size: 1.2em;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid var(--p1);
  border-radius: 0.45em;
}

.name-field.p2 input {
  border-color: var(--p2);
}

.name-field input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45em;
}

.chip {
  position: relative;
}

.chip input {
  position: absolute;
  opacity: 0;
}

.chip span {
  display: inline-block;
  padding: 0.35em 0.85em;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.chip span:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

.chip input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #1c1917;
  font-weight: 700;
}

.chip input:focus-visible + span {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.btn-primary,
.btn-secondary {
  font: inherit;
  font-family: var(--mono);
  font-weight: 800;
  text-transform: uppercase;
  border-radius: 0.55em;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 1.2em;
  padding: 0.55em;
  font-size: 1.3em;
  color: #1c1917;
  background: linear-gradient(#fde047, #eab308);
  border: 0;
  box-shadow: 0 0.22em 0 #a16207;
}

.btn-primary kbd,
.btn-secondary kbd {
  font-size: 0.6em;
  vertical-align: middle;
  text-transform: none;
}

.btn-primary kbd {
  background: rgba(0, 0, 0, 0.12);
}

.btn-primary:active {
  transform: translateY(0.15em);
  box-shadow: 0 0.07em 0 #a16207;
}

.btn-secondary {
  padding: 0.55em 1em;
  font-size: 1em;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.22);
}

.howto {
  margin: 1em 0 0;
  text-align: center;
  font-size: 0.8em;
  color: var(--muted);
}

.over-panel {
  width: min(80%, 30em);
  text-align: center;
  animation: pop 0.35s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
}

.over-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 2.8em;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0.06em 0.06em 0 #a16207, 0.1em 0.1em 0.3em rgba(0, 0, 0, 0.5);
  overflow-wrap: anywhere;
}

.over-detail {
  margin: 0.6em 0 0;
  color: var(--muted);
  font-size: 1.1em;
}

.over-buttons {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.6em;
}

.over-buttons .btn-primary {
  margin-top: 1.2em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Weapon menu ---------- */

.weapon-menu {
  width: min(94vw, 760px);
  max-height: 92vh;
  padding: 18px 22px;
  color: var(--text);
  background: var(--panel-solid);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 1em 3em rgba(0, 0, 0, 0.5);
  font-size: 14px;
}

.weapon-menu::backdrop {
  background: rgba(8, 12, 24, 0.5);
}

.weapon-menu h2 {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 22px;
  color: var(--accent);
}

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

.wm-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 6px 8px;
  font: inherit;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  cursor: pointer;
}

.wm-item:hover,
.wm-item:focus-visible {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.wm-item.selected {
  border-color: var(--accent);
  background: rgba(250, 204, 21, 0.16);
}

.wm-item.super {
  border-color: #f472b6;
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.18), rgba(250, 204, 21, 0.14));
}

.wm-item.super .wm-name {
  color: #f9a8d4;
}

.wm-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wm-item img {
  grid-row: 1 / 3;
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
}

.wm-name {
  font-family: var(--mono);
  font-weight: 700;
}

.wm-ammo {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--muted);
}

.wm-desc {
  grid-column: 2 / 4;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
}

.wm-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Character select ---------- */

.char-panel {
  width: min(94%, 62em);
}

.char-title {
  margin: 0 0 0.6em;
  font-family: var(--mono);
  color: var(--accent);
}

.char-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1em;
  margin-bottom: 1em;
}

.char-col legend {
  font-family: var(--mono);
  font-weight: 700;
}

.char-col.p1 legend {
  color: var(--p1);
}

.char-col.p2 legend {
  color: var(--p2);
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4em;
}

.char-card {
  position: relative;
  cursor: pointer;
}

.char-card input {
  position: absolute;
  opacity: 0;
}

.char-card span {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3em 0.2em;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.5em;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.72em;
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
}

.char-card img {
  width: 100%;
  max-width: 4.2em;
  image-rendering: pixelated;
}

.char-card span:hover {
  background: rgba(255, 255, 255, 0.1);
}

.char-col.p1 .char-card input:checked + span {
  border-color: var(--p1);
  background: rgba(59, 130, 246, 0.25);
}

.char-col.p2 .char-card input:checked + span {
  border-color: var(--p2);
  background: rgba(249, 115, 22, 0.25);
}

.char-card input:focus-visible + span {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------- Level chooser ---------- */

.level-btn {
  display: flex;
  align-items: center;
  gap: 0.8em;
  width: 100%;
  padding: 0.4em;
  font: inherit;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.6em;
  cursor: pointer;
}

.level-btn:hover,
.level-btn:focus-visible {
  border-color: var(--accent);
  background: rgba(250, 204, 21, 0.1);
  outline: none;
}

.lv-thumb {
  width: 7.5em;
  aspect-ratio: 16 / 9;
  border-radius: 0.35em;
  image-rendering: pixelated;
}

.lv-text {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  min-width: 0;
}

.lv-name {
  font-family: var(--mono);
  font-weight: 700;
}

.lv-desc {
  font-size: 0.85em;
  color: var(--muted);
}

.lv-change {
  margin-left: auto;
  padding-right: 0.4em;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.level-menu {
  width: min(94vw, 860px);
}

.lv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.lv-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  font: inherit;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  cursor: pointer;
}

.lv-item img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
}

.lv-item .lv-desc {
  font-size: 12px;
  line-height: 1.3;
}

.lv-item:hover,
.lv-item:focus-visible {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.lv-item.selected {
  border-color: var(--accent);
  background: rgba(250, 204, 21, 0.16);
}

/* ---------- Phones and tablets ---------- */

/* dvh = the visible screen height on phones (ignores the address bar). Older
   browsers skip this rule and keep the vh size above. */
.stage {
  width: min(100%, calc((100dvh - 24px) * 16 / 9));
}

/* Dragging on the game aims; don't scroll, zoom or select instead. */
#game {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.touch .page {
  padding: 0;
}

body.touch .stage {
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100vw, calc(100dvh * 16 / 9));
  border-radius: 0;
  box-shadow: none;
}

/* Keyboard hints mean nothing on a touch screen. */
body.touch kbd {
  display: none;
}

.touch-help,
body.touch .key-help {
  display: none;
}

body.touch .touch-help {
  display: table;
}

.fs-btn {
  width: 1.9em;
  height: 1.9em;
  padding: 0;
  border-radius: 0.4em;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font: 700 1em/1 var(--sans);
  cursor: pointer;
  vertical-align: middle;
}

.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

body:not(.touch) .touch-controls {
  display: none;
}

.touch-controls.waiting .tc-group {
  opacity: 0.35;
}

.tc-group {
  position: absolute;
  bottom: 3%;
  display: grid;
  gap: 0.8cqw;
  justify-items: center;
  align-items: center;
  pointer-events: auto;
  transition: opacity 0.2s;
}

.tc-left {
  left: 1.5%;
}

/* FIRE sits on the inside, the +/− buttons along the edge. */
.tc-right {
  right: 1.5%;
  grid-template-areas: "fire label" "fire up" "fire down";
  column-gap: 1.6cqw;
}

.tc-right .tc-label { grid-area: label; }
.tc-right [data-hold="powerUp"] { grid-area: up; }
.tc-right [data-hold="powerDown"] { grid-area: down; }
.tc-right .tc-fire { grid-area: fire; }

.tc-label {
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.tc-btn,
.tc-fire {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.tc-btn {
  width: 6.5cqw;
  height: 6.5cqw;
  border-radius: 1.2cqw;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: var(--panel);
  color: #fff;
  font: 900 2.8cqw/1 var(--sans);
}

.tc-btn.held {
  background: rgba(250, 204, 21, 0.4);
  border-color: var(--accent);
}

.tc-fire {
  width: 11cqw;
  height: 11cqw;
  border-radius: 50%;
  border: 0.4cqw solid #fecaca;
  background: radial-gradient(circle at 35% 30%, #fb7185, #dc2626 70%);
  color: #fff;
  font: 900 2.4cqw/1 var(--mono);
  letter-spacing: 0.05em;
  box-shadow: 0 0.5cqw 0 #7f1d1d, 0 0.8cqw 1.6cqw rgba(0, 0, 0, 0.4);
}

.tc-fire:active {
  transform: translateY(0.3cqw);
  box-shadow: 0 0.2cqw 0 #7f1d1d;
}

/* Short screens (phones on their side): tighter menus. */
@media (max-height: 520px) {
  .weapon-menu,
  .help {
    padding: 10px 14px;
    font-size: 12px;
  }

  .weapon-menu h2,
  .help h2 {
    font-size: 17px;
    margin-bottom: 8px;
  }

  .wm-desc {
    display: none;
  }

  .wm-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
  }

  .lv-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .lv-item .lv-desc {
    display: none;
  }
}

.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  place-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  font: 700 22px/1.3 var(--sans);
  background: radial-gradient(ellipse at top, #1e293b, #0b1220 70%);
}

.rotate-icon {
  font-size: 56px;
}

/* Set by main.js when a touch screen is taller than it is wide. Measured in
   JavaScript (not a CSS orientation query), so it updates reliably after turning,
   including in iPhone home-screen apps. */
body.portrait .rotate-hint {
  display: grid;
}

body.portrait .page {
  visibility: hidden;
}

.rotate-hint p {
  margin: 0;
}

.rotate-tip {
  max-width: 30em;
  font: 400 15px/1.4 var(--sans);
  color: var(--muted);
}

.rotate-hint .btn-secondary {
  justify-self: center;
  font-size: 15px;
}

/* Touch screens: a more compact bottom bar so it fits between the on-screen buttons. */
body.touch .hud-bottom {
  gap: 0.5em;
  padding: 0.35em 0.5em;
}

body.touch .weapon-btn {
  min-width: 9.5em;
}

body.touch .power-bar {
  width: 3.5em;
}

body.touch .stat-value {
  min-width: 2.6em;
}

body.touch .wm-hint {
  display: none;
}

.dlg-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font: 700 18px/1 var(--sans);
  cursor: pointer;
}

.dlg-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.weapon-menu {
  position: fixed;
}

.overlay {
  overflow: auto;
}

/* ---------- Short screens: start, character and end menus ---------- */
/* Phones held sideways in Safari keep the address bar, which can leave as little as
   ~260px of height for a 16:9 game. The menus switch to wider, flatter layouts so the
   main button stays on screen. */
@media (max-height: 430px) {
  /* Centered with auto margins rather than place-items, so a menu taller than the
     screen scrolls from its top instead of being cut off above. */
  .overlay {
    place-items: initial;
  }

  .overlay > .panel {
    margin: auto;
  }

  .panel {
    padding: 0.8em 1.2em 0.7em;
  }

  /* Start screen: title across the top, players and level side by side. */
  #start-form {
    width: min(96%, 64em);
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.2em;
    align-items: start;
  }

  #start-form .logo,
  #start-form .btn-primary,
  #start-form .howto {
    grid-column: 1 / -1;
  }

  #start-form .logo {
    font-size: 2.6em;
  }

  #start-form .tagline,
  #start-form .lv-desc {
    display: none;
  }

  #start-form fieldset {
    margin-top: 0.6em;
  }

  #start-form .btn-primary {
    margin-top: 0.8em;
  }

  #start-form .howto {
    margin-top: 0.5em;
  }

  /* Character select: smaller title, Back and Play side by side. */
  .char-panel {
    width: min(98%, 64em);
  }

  .char-title {
    margin-bottom: 0.3em;
    font-size: 1.2em;
  }

  .char-cols {
    margin-bottom: 0.5em;
  }

  .over-buttons {
    flex-direction: row;
  }

  .over-buttons > * {
    flex: 1;
  }

  .over-buttons .btn-primary {
    flex: 2;
    order: 2;
    margin-top: 0;
  }

  /* End screen */
  .over-panel {
    width: min(90%, 40em);
  }

  .over-title {
    font-size: 2.2em;
  }

  .over-panel .over-buttons {
    margin-top: 0.9em;
  }
}

/* ---------- MemoryLeak Games arcade link ---------- */
/* The studio's floating "back to the arcade" button (brand/arcade-bar.js) shows on the
   title screen only, so it never covers buttons on the other screens. During a game the
   small arcade button in the top-middle card (.arcade-btn) takes over: the bottom bar is
   already full on phones, between the angle buttons and FIRE. */
body:has(#title-screen[hidden]) .ml-arcade {
  display: none;
}

.hud-center {
  display: flex;
  align-items: center;
  gap: 0.7em;
}

.arcade-btn {
  pointer-events: auto;
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.9em;
  height: 1.9em;
  border-radius: 0.4em;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  vertical-align: middle;
}

.arcade-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.arcade-btn img {
  width: 1.2em;
  height: 1.2em;
  image-rendering: pixelated;
}
