:root {
  --bg: #0f131a;
  --panel: #171d27;
  --panel-border: #2b3547;
  --text: #e6edf7;
  --muted: #8b9bb4;
  --accent: #3ddc84;
  --accent-2: #f7931a;
  --danger: #ff4d5a;
  --blue: #4ea8ff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 2px solid var(--panel-border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.logo {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 2px 2px 0 #082918;
}

.subtitle {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1px;
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

select, input[type="text"], input[type="number"] {
  background: #0c1016;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 12px;
}

.btn {
  background: #232c3b;
  color: var(--text);
  border: 1px solid #39465e;
  border-radius: 4px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s, transform 0.05s;
}

.btn:hover {
  background: #2f3b4f;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary:hover {
  background: #258553;
}

.btn-primary.active, .btn-secondary.active {
  box-shadow: 0 0 0 2px rgba(61, 220, 132, 0.45);
}

.btn-secondary.active {
  background: #25588a;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(78, 168, 255, 0.45);
}

.btn-danger {
  background: #6b1d24;
  border-color: var(--danger);
}

.btn-sm {
  padding: 4px 7px;
  font-size: 11px;
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.hud-item {
  background: #0c1016;
  border: 1px solid var(--panel-border);
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.hero-badge {
  background: #1a3b2c;
  border-color: var(--accent);
  color: var(--accent);
  min-width: 90px;
  text-align: center;
}

.btc {
  color: var(--accent-2);
  border-color: #6b4512;
}

.vault {
  color: var(--accent);
  border-color: #166534;
}

/* Wallet + vault: two chips side by side; on a phone one chip (see the 560px media query) */
.hud-money {
  display: contents;
}

.map-screen {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.world-map-canvas {
  width: min(100vw, 100vh * 16 / 9);
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  cursor: pointer;
  touch-action: none;
}

#workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.editor-panel {
  width: 265px;
  background: var(--panel);
  border-right: 2px solid var(--panel-border);
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.editor-panel.hidden {
  display: none;
}

.panel-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 6px;
}

.panel-section input[type="text"],
.panel-section select {
  width: 100%;
  margin-bottom: 6px;
}

.size-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 3x3 grid: the side(s) where the level grows or shrinks (the selects behind it hold the value) */
.anchor-grid {
  display: grid;
  grid-template-columns: repeat(3, 18px);
  gap: 2px;
}
.anchor-grid button {
  width: 18px;
  height: 18px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
}
.anchor-grid button[aria-pressed="true"] {
  background: #3ddc84;
  color: #0b1220;
}

.size-row input {
  width: 56px;
}

.size-row .btn {
  margin: 0 0 0 auto;
}

.row {
  margin-bottom: 6px;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.hint {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

.palette-group {
  margin-bottom: 10px;
}

.palette-group-title {
  font-size: 10px;
  color: var(--blue);
  text-transform: uppercase;
  margin-bottom: 4px;
  letter-spacing: 0.8px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* long labels wrap instead of widening the panel (no sideways scrollbar) */
  gap: 4px;
}

.palette-item {
  min-width: 0;
  hyphens: auto; /* Dutch hyphenation (html lang="nl") where the browser has a dictionary; otherwise a plain break */
  overflow-wrap: anywhere; /* lets a long label shrink the column instead of widening the panel */
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  background: #0e131b;
  border: 1px solid #283345;
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.palette-item:hover {
  border-color: #51668a;
}

.palette-item.selected {
  border-color: var(--accent);
  background: #173025;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

#stageWrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #080b10;
  padding: 10px;
  min-width: 0;
}

#gameCanvas {
  width: 100%;
  max-width: 1120px;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 115px);
  background: #101824;
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  cursor: default;
  touch-action: none;
}

/* Immersive play mode: the game fills the whole window (16:9 = 480x270 view), HUD floats on top */
body.immersive #topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 15;
  padding: 8px 12px;
  background: transparent;
  border-bottom: none;
  pointer-events: none;
}
body.immersive .brand,
body.immersive .controls-bar,
body.immersive .controls-help {
  display: none;
}
body.immersive .hud {
  flex-wrap: wrap;
}
body.immersive .hud-item {
  background: rgba(8, 11, 16, 0.62);
  border-color: rgba(255, 255, 255, 0.18);
}
body.immersive #stageWrap {
  padding: 0;
  background: #000;
}
body.immersive #gameCanvas {
  width: min(100vw, 100vh * 16 / 9);
  max-width: none;
  max-height: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

#gameCanvas.edit-mode {
  cursor: crosshair;
}

.banner {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 14, 22, 0.9);
  border: 2px solid var(--accent);
  padding: 12px 26px;
  border-radius: 6px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
  text-align: center;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
  z-index: 10;
}

.banner small {
  display: block;
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
  letter-spacing: 1px;
}

.hidden {
  display: none !important;
}

.full-width {
  width: 100%;
}

.pad-badge.connected {
  border-color: var(--accent);
  color: var(--accent);
}

.ed-validation {
  background: rgba(255, 77, 90, 0.16);
  border: 1px solid var(--danger);
  color: #fecdd3;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 4px;
  margin-top: 4px;
}

.overlay-modal {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 15, 0.86);
  display: flex;
  align-items: center;
  align-items: safe center; /* too-tall cards (e.g. phone landscape) start at the top instead of being cut off */
  justify-content: center;
  overflow-y: auto;
  z-index: 20;
  padding: 16px;
}

.menu-card, .pause-card, .splash-card {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 20px 24px;
  max-width: 640px;
  width: 100%;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.78);
}

.pause-card {
  max-width: 340px;
}

.menu-sub, .pause-sub {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0 14px;
  letter-spacing: 1px;
}

.pixel-icon {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.pixel-icon-lg {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}

.menu-section-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--blue);
  margin: 10px 0 6px;
  font-weight: 700;
}

.menu-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-lg {
  padding: 9px 16px;
  font-size: 13px;
}

.splash-tag {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent-2);
  margin-bottom: 4px;
}

/* Level intro: floats over the running game while the hero drops in (no pause, no clicks) */
.overlay-modal.intro-banner {
  background: transparent;
  pointer-events: none;
  align-items: flex-start;
  padding-top: 5%;
}

.intro-banner .splash-card {
  background: rgba(6, 9, 15, 0.72);
  max-width: 340px;
  padding: 8px 14px;
}

.intro-banner h2 {
  font-size: 15px;
  margin: 2px 0;
}

.intro-banner p {
  font-size: 11px;
  margin: 2px 0;
}

.intro-banner .splash-hero-row {
  margin: 6px 0 0;
  font-size: 11px;
}

.intro-banner .pixel-icon-lg {
  width: 24px;
  height: 24px;
}

.intro-level-num {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 4px;
}

.splash-hero-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 10px;
  font-weight: 700;
  color: var(--accent);
}

.victory-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 18px;
  margin: 10px 0 6px;
  font-size: 13px;
}

.victory-unlock {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
}


.campaign-end-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 12px;
}

.campaign-hero-lineup {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 10px 0 14px;
}

.campaign-hero-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(10, 14, 22, 0.65);
  border: 1px solid rgba(46, 204, 113, 0.4);
  font-size: 10px;
  font-weight: 700;
  color: #e5e7eb;
}

.campaign-hero-chip.locked {
  opacity: 0.45;
  border-style: dashed;
}

/* Finale parade: the heroes walk once across the bottom of the screen (main.js renderHeroParade), over nothing clickable */
.hero-parade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  height: 36px;
  overflow: hidden;
  pointer-events: none;
}
.parade-walker {
  position: absolute;
  bottom: 0;
  left: -40px;
  animation: parade-walk 6s linear both;
}
.parade-walker img {
  display: block;
  animation: parade-step 0.3s steps(2) infinite;
}
@keyframes parade-walk {
  from { left: -40px; }
  to { left: 100%; }
}
@keyframes parade-step {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

.campaign-hero-chip small {
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
}
.settings-heroes-wrap {
  margin-bottom: 12px;
}

.settings-hero-lineup {
  margin: 6px 0 4px;
  gap: 8px;
}

.settings-hero-lineup .pixel-icon-lg {
  width: 28px;
  height: 28px;
}

.btc-text {
  color: var(--accent-2);
}

.victory-parade {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  max-height: 150px;
  overflow-y: auto;
  background: #0b0f16;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 16px;
}

.parade-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 9px;
  color: var(--muted);
  animation: popIn 0.2s ease-out;
}

.parade-item.boss {
  color: var(--danger);
  font-weight: 900;
}

@keyframes popIn {
  from { transform: scale(0.3) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* Virtual Touch Controls for Mobile & Tablet */
.touch-controls {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 15;
}

.touch-dpad, .touch-actions {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  touch-action: none;
}

.touch-dpad-mid, .touch-row {
  display: flex;
  gap: 8px;
}

.tbtn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(23, 29, 39, 0.72);
  border: 2px solid rgba(148, 163, 184, 0.55);
  color: #fff;
  font-family: inherit;
  font-weight: 900;
  font-size: 13px;
  touch-action: none;
  user-select: none;
}

.tbtn:active, .tbtn.pressed {
  background: rgba(61, 220, 132, 0.65);
  border-color: var(--accent);
}

.tbtn-sm {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

.tbtn-shoot {
  background: rgba(239, 68, 68, 0.68);
  border-color: #f87171;
}

.tbtn-jump {
  background: rgba(29, 107, 66, 0.75);
  border-color: var(--accent);
}

.tbtn-spec {
  background: rgba(247, 147, 26, 0.68);
  border-color: var(--accent-2);
}

@media (max-width: 820px) {
  .subtitle, .controls-help {
    display: none;
  }
  #topbar {
    padding: 5px 8px;
    gap: 6px;
  }
  .hud {
    gap: 4px;
    font-size: 11px;
  }
  .hud-item {
    padding: 2px 5px;
  }
  .help-grid {
    grid-template-columns: 1fr;
  }
  .editor-panel {
    width: 210px;
  }
}

/* Phone width: the HUD stays on (about) one row: no controller counter, tighter chips */
@media (max-width: 560px) {
  .hud {
    gap: 3px;
    font-size: 10px;
  }
  .hud-item {
    padding: 2px 3px;
  }
  .hero-badge {
    min-width: 0;
  }
  #hudPads {
    display: none;
  }
  /* Wallet and vault share one chip (never split over two rows) */
  .hud-money {
    display: flex;
    gap: 5px;
    padding: 2px 3px;
    border: 1px solid #6b4512;
    border-radius: 4px;
    background: #0c1016;
  }
  body.immersive .hud-money {
    background: rgba(8, 11, 16, 0.62);
    border-color: rgba(255, 255, 255, 0.18);
  }
  .hud-money .hud-item,
  body.immersive .hud-money .hud-item {
    padding: 0;
    border: none;
    background: none;
  }
}

.help-modal {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 15, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.help-card {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 16px 20px;
  max-width: 680px;
  width: 100%;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7);
}
.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  font-size: 12px;
  line-height: 1.55;
}

.help-grid h4 {
  color: var(--blue);
  margin-bottom: 6px;
  font-size: 12px;
}

.help-grid ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.help-tip {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
  font-size: 11px;
  color: var(--muted);
}

.controls-help {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}

.controls-help b {
  color: var(--text);
  background: #1b2330;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid #303c52;
}

/* Loading splash, title menu */
.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #05080d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.boot-bar {
  width: min(320px, 60vw);
  height: 8px;
  border: 2px solid var(--panel-border);
  overflow: hidden;
}
.boot-bar-fill {
  width: 35%;
  height: 100%;
  background: var(--accent);
  animation: boot-slide 1.1s ease-in-out infinite alternate;
}
@keyframes boot-slide {
  from { transform: translateX(0); }
  to { transform: translateX(185%); }
}
.boot-text {
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--muted);
}

body.prestart #topbar {
  display: none;
}

.title-screen {
  flex-direction: column;
  gap: 36px;
  background: radial-gradient(ellipse at center, #0e1826, #04060a);
}
.title-logo {
  font-size: clamp(48px, 9vw, 110px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-shadow: 4px 4px 0 #072916;
}
.title-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.title-btn {
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(26px, 4.4vw, 52px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 24px;
  cursor: pointer;
  position: relative;
}
.title-btn small {
  position: absolute;
  left: 100%;
  bottom: 14px;
  font-size: 0.32em;
  letter-spacing: 0.1em;
  white-space: nowrap;
  color: var(--muted);
}
/* One source of truth: only the focused button is highlighted. The mouse moves the focus (see main.js), so a
   hovered button and a keyboard/controller-selected one can never both show an arrow. */
.title-btn:focus,
.title-btn:focus-visible {
  color: var(--accent);
  outline: none;
}
.title-btn:focus::before,
.title-btn:focus-visible::before {
  content: '▶ ';
}

.overlay-modal .btn:focus,
.overlay-modal .btn:focus-visible {
  outline: 2px solid #facc15;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.25);
}
.title-btn:disabled {
  color: #4a566b;
  cursor: default;
}
.title-btn-gap {
  margin-top: 28px;
}

/* Visually hidden but read by screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Calm mode: main.js sets body.reduced-motion from Settings (AUTO follows the OS, AAN/UIT override it).
   Only the loading bar listens to the OS directly: it runs before main.js (and the Settings choice) exists. */
@media (prefers-reduced-motion: reduce) {
  .boot-bar-fill { animation: none; }
}
body.reduced-motion .parade-item,
body.reduced-motion .boot-bar-fill {
  animation: none;
}
body.reduced-motion .hero-parade { display: none; } /* calm mode: no walking heroes, just the lineup */

/* Pause menu: the title-menu look over the (dimmed) running level; Settings and Help open on top of it */
.pause-screen {
  background: rgba(4, 6, 10, 0.86);
  gap: 20px;
}
.pause-screen .title-logo {
  font-size: clamp(26px, min(5.5vw, 9vh), 64px); /* also scale with height: fits low/landscape screens */
}
.pause-screen .title-btn {
  font-size: clamp(16px, min(3.2vw, 5.5vh), 36px);
}
#settingsModal { z-index: 30; }
#helpModal { z-index: 31; }

/* Goodbye screen after "Afsluiten": calmer than the UNPLUG! logo */
#exitScreen .title-logo {
  font-size: clamp(26px, min(6vw, 10vh), 64px);
  text-align: center;
}

/* Result & campaign-finale screens: the title-menu look (big title, ▶ title buttons) over the dimmed level */
.result-screen {
  background: rgba(4, 6, 10, 0.88);
  gap: 12px;
}
/* Low screens (laptop with a short window, phone landscape): the campaign finale fits without scrolling */
@media (max-height: 480px) {
  .result-screen { gap: 5px; }
  .result-screen .campaign-hero-lineup .pixel-icon-lg { width: 24px; height: 24px; }
  .result-screen .hero-parade { bottom: 2px; height: 26px; }
  .result-screen .hero-parade .pixel-icon-lg { width: 24px; height: 24px; } /* walks below the buttons */
  .result-screen .campaign-end-sub { margin: 0; }
  .result-screen .scoreboard { padding: 4px 10px; }
  .result-screen .result-nav .title-btn { font-size: clamp(13px, 4vh, 24px); padding-top: 0; padding-bottom: 0; }
  .pause-screen .pause-sub { display: none; } /* the Esc hint: no room on a phone in landscape (and no Esc key there) */
}
.result-tag {
  font-size: clamp(11px, min(1.6vw, 2.6vh), 16px);
}
.result-title {
  font-size: clamp(24px, min(5vw, 8vh), 60px);
  text-align: center;
}
.scoreboard {
  font-size: clamp(12px, min(1.8vw, 3vh), 20px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 2px solid var(--accent);
  border-radius: 4px;
  padding: 8px 16px;
  background: rgba(7, 41, 22, 0.35);
}
.scoreboard b {
  color: var(--accent);
  margin-left: 4px;
}
.result-nav {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 10px;
}
.result-nav .title-btn {
  font-size: clamp(16px, min(2.8vw, 5vh), 34px);
}

/* Settings in the title-menu look (7 options + hero lineup: a bit smaller than the title menu so it fits) */
.settings-screen {
  /* opaque (the title-screen gradient): Settings opens over the title menu, whose text must not shine through */
  gap: 12px;
}
.settings-screen .title-logo {
  font-size: clamp(26px, min(5.5vw, 9vh), 64px);
}
.settings-screen .title-btn {
  font-size: clamp(15px, min(2.6vw, 4.4vh), 30px);
}
.settings-screen .settings-heroes-wrap {
  margin-bottom: 0;
  text-align: center;
}
.title-btn.danger {
  color: #f87171;
}
.title-btn.danger:hover:not(:disabled),
.title-btn.danger:focus,
.title-btn.danger:focus-visible {
  color: #ef4444;
}

/* Low screens (phone landscape, small laptops): tighten Settings so title, heroes and all options fit without scrolling */
@media (max-height: 480px) {
  .settings-screen { gap: 4px; }
  .settings-screen .title-btn { padding-top: 1px; padding-bottom: 1px; font-size: clamp(14px, 4vh, 30px); }
  .settings-screen .title-btn-gap { margin-top: 6px; }
  .settings-screen .pause-sub { display: none; }
}
/* Low but wide (laptop with a short window, phone landscape): the ten options in two columns (top-to-bottom, so the
   menu order stays the reading order), "Terug" centred below, so everything fits without scrolling */
@media (max-height: 480px) and (min-width: 700px) {
  .settings-screen .title-nav {
    display: grid;
    grid-template-rows: repeat(5, auto);
    grid-template-columns: auto auto;
    grid-auto-flow: column;
    column-gap: 32px;
    justify-items: center;
  }
  .settings-screen .title-nav .title-btn-gap { grid-row: 6; grid-column: 1 / -1; }
}

/* Help (Besturing) in the title-menu look: big title, two readable columns, a "Terug" title button */
.help-screen .help-card {
  background: none;
  border: none;
  box-shadow: none;
  max-width: 920px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.help-screen .title-logo {
  font-size: clamp(26px, min(5.5vw, 9vh), 64px);
}
.help-screen .help-grid {
  font-size: clamp(11px, min(1.5vw, 2.7vh), 16px);
  border: 2px solid var(--accent);
  border-radius: 4px;
  padding: 10px 16px;
  background: rgba(7, 41, 22, 0.35);
}
.help-screen .help-grid h4 {
  font-size: 1em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.help-screen .title-btn {
  font-size: clamp(16px, min(2.8vw, 5vh), 34px);
}

/* Help per input device: small tabs, then rows of button icons (drawn in CSS) + the action */
.help-tabs {
  display: flex;
  gap: 8px;
}
.help-tab {
  font: inherit;
  font-size: clamp(12px, min(1.6vw, 3vh), 16px);
  font-weight: 700;
  color: var(--muted);
  background: rgba(7, 41, 22, 0.35);
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
}
.help-tab[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}
.help-tab:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
.help-screen .help-controls {
  grid-template-columns: auto 1fr auto 1fr; /* two columns of [buttons | action]; the buttons line up per column */
  align-items: center;
  column-gap: 0.6em;
  row-gap: 0.4em;
  font-size: clamp(12px, min(1.9vw, 3.4vh), 20px);
  line-height: 1.2;
}
.help-row {
  display: contents;
}
.help-action {
  padding-right: 0.8em;
}
.help-keys {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25em;
  white-space: nowrap;
}
.help-sep {
  color: var(--muted);
}
.kc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75em;
  height: 1.75em;
  padding: 0 0.35em;
  border: 1px solid #94a3b8;
  border-bottom-width: 3px;
  border-radius: 0.3em;
  background: #1e293b;
  color: #f8fafc;
  font-weight: 700;
}
/* Controller: coloured round face buttons, shoulder buttons, Start, stick and D-pad */
.kc.pad-a, .kc.pad-b, .kc.pad-x, .kc.pad-y {
  width: 1.75em;
  padding: 0;
  border: 2px solid rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  color: #0b1220;
}
.kc.pad-a { background: #22c55e; }
.kc.pad-b { background: #ef4444; }
.kc.pad-x { background: #3b82f6; }
.kc.pad-y { background: #eab308; }
.kc.pad-sh {
  border-width: 1px;
  border-radius: 0.8em 0.8em 0.3em 0.3em;
  background: #334155;
}
.kc.pad-start {
  border-width: 1px;
  border-radius: 1em;
  background: #334155;
}
.kc.pad-stick {
  width: 1.75em;
  padding: 0;
  border: 2px solid #64748b;
  border-radius: 50%;
  background: radial-gradient(circle, #475569 45%, #1e293b 50%);
}
.kc.pad-dpad {
  border: none;
  background: none;
  font-size: 1.3em;
  min-width: 1.35em;
  height: 1.35em;
}
/* Touch: the round on-screen buttons */
.kc.tc {
  border: 2px solid rgba(148, 163, 184, 0.7);
  border-radius: 1em;
  background: rgba(23, 29, 39, 0.85);
}
.kc.tc-jump { background: rgba(29, 107, 66, 0.9); border-color: var(--accent); }
.kc.tc-fire { background: rgba(239, 68, 68, 0.8); border-color: #f87171; }
.kc.tc-spec { background: rgba(247, 147, 26, 0.8); border-color: var(--accent-2); }
/* Low screens (phone in landscape): no tip, so the controls fit without scrolling */
@media (max-height: 600px) {
  .help-screen .help-tip { display: none; }
  .help-screen .help-card { gap: 8px; }
}
@media (max-height: 400px) {
  .help-screen .help-card { gap: 6px; }
  .help-screen .help-controls { row-gap: 0.2em; padding: 6px 14px; }
}
/* Narrow portrait phone: one column (may scroll) */
@media (max-width: 520px) {
  .help-screen .help-controls { grid-template-columns: auto 1fr; }
}

/* Community maps: a scrollable list of title buttons with the author in small print */
.community-screen {
  gap: 10px;
}
.community-screen .title-logo {
  font-size: clamp(26px, min(5.5vw, 9vh), 64px);
}
.community-list {
  max-height: 46vh;
  overflow-y: auto;
  padding: 4px 24px;
}
.community-list .title-btn {
  font-size: clamp(16px, min(2.8vw, 5vh), 34px);
}
.community-list .title-btn small {
  position: static;
  margin-left: 12px;
  font-size: 0.4em;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* World map on touch devices: menu / overview / shoot buttons at the right edge */
.map-touch-bar {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 21;
}
.map-touch-bar.hidden {
  display: none;
}
.map-touch-bar .btn {
  width: 52px;
  height: 52px;
  font-size: 22px;
  padding: 0;
  border-radius: 50%;
  background: rgba(9, 13, 22, 0.78);
}
