:root {
  --bg: #101713;
  --surface: #18231d;
  --surface-raised: #223129;
  --surface-soft: #2b3a31;
  --line: #425449;
  --text: #f5f0df;
  --muted: #b7b9aa;
  --accent: #e5b95c;
  --accent-strong: #f2cf7b;
  --good: #7bd3a0;
  --bad: #ee846f;
  --cell-empty: #26352d;
  --cell-gap: clamp(2px, 0.6vw, 5px);
  --board-size: min(72vh, 88vw, 610px);
  --radius: 18px;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 8%, rgba(122, 153, 102, 0.13), transparent 28rem),
    radial-gradient(circle at 90% 80%, rgba(229, 185, 92, 0.08), transparent 26rem),
    var(--bg);
  font-family: ui-rounded, "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.mode-selection {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.mode-selection[hidden] {
  display: none;
}

.mode-selection-card {
  width: min(100%, 620px);
  padding: clamp(28px, 6vw, 56px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(36, 52, 43, 0.98), rgba(21, 31, 26, 0.98));
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
  text-align: center;
}

.mode-selection-card h1 {
  margin: 8px 0 32px;
  color: var(--text);
  font-size: clamp(2rem, 8vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
}

.mode-options {
  display: grid;
  gap: 16px;
}

.mode-option {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(239, 231, 202, 0.07);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.mode-option:hover,
.mode-option:focus-visible {
  border-color: var(--accent);
  background: rgba(229, 185, 92, 0.12);
  outline: none;
}

.mode-option strong {
  font-size: 1.05rem;
  letter-spacing: 0.08em;
}

.mode-option span {
  color: var(--muted);
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 3px;
}

.game-shell {
  width: min(100% - 28px, 980px);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px) 0 44px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--board-size);
  margin: 0 auto 14px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.brand-mark,
.mushroom-symbol {
  position: relative;
  display: block;
  width: 35px;
  height: 18px;
  border-radius: 22px 22px 8px 8px;
  background: var(--accent);
}

.brand-mark::after,
.mushroom-symbol::after {
  position: absolute;
  top: 14px;
  left: 13px;
  width: 9px;
  height: 13px;
  border-radius: 3px 3px 7px 7px;
  background: var(--text);
  content: "";
}

.brand h1 {
  margin: 0;
  font-size: clamp(1rem, 3vw, 1.45rem);
  line-height: 1;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: clamp(0.63rem, 2vw, 0.78rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.hud-card {
  position: relative;
  min-width: 76px;
  padding: 8px 12px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(34, 49, 41, 0.86);
  text-align: right;
}

.hud-label {
  display: block;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 0.67rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.hud-value {
  font-size: clamp(1rem, 4vw, 1.35rem);
  font-variant-numeric: tabular-nums;
}

.timer-warning {
  color: var(--bad);
}

.score-deltas {
  position: absolute;
  z-index: 3;
  right: 8px;
  bottom: -4px;
  pointer-events: none;
}

.score-delta {
  position: absolute;
  right: 0;
  bottom: 0;
  color: var(--accent-strong);
  font-weight: 800;
  white-space: nowrap;
  animation: score-rise 850ms ease-out forwards;
}

@keyframes score-rise {
  from { opacity: 0; transform: translateY(0) scale(0.85); }
  20% { opacity: 1; }
  to { opacity: 0; transform: translateY(-42px) scale(1.05); }
}

.play-area {
  width: var(--board-size);
  margin: auto;
}

.board-frame {
  padding: clamp(8px, 1.6vw, 13px);
  border: 1px solid #53675a;
  border-radius: calc(var(--radius) + 5px);
  background: linear-gradient(145deg, #304238, #1d2b24);
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.08);
}

.board {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--cell-gap);
  padding: var(--cell-gap);
  overflow: hidden;
  border-radius: var(--radius);
  background: #132019;
  touch-action: none;
  user-select: none;
}

.board-cell {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.035);
  border-radius: clamp(3px, 0.8vw, 7px);
  background: var(--cell-empty);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.035);
}

.board-cell.occupied {
  border-color: rgba(255, 255, 255, 0.19);
  background: var(--piece-color, #72a579);
  box-shadow:
    inset 0 2px rgba(255, 255, 255, 0.18),
    inset 0 -2px rgba(0, 0, 0, 0.14);
}

.board-cell.occupied::after {
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  content: "";
}

.board-cell.ghost-valid {
  outline: 3px solid var(--good);
  outline-offset: -3px;
  background:
    repeating-linear-gradient(135deg, rgba(123, 211, 160, 0.35) 0 5px, rgba(123, 211, 160, 0.12) 5px 10px),
    var(--cell-empty);
}

.board-cell.ghost-invalid {
  outline: 3px dashed var(--bad);
  outline-offset: -3px;
  background:
    repeating-linear-gradient(135deg, rgba(238, 132, 111, 0.36) 0 4px, rgba(238, 132, 111, 0.08) 4px 9px),
    var(--cell-empty);
}

.board-cell.ghost-invalid::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffd8cf;
  content: "×";
  font-size: clamp(0.7rem, 3vw, 1.4rem);
  font-weight: 900;
}

.board-cell.clearing {
  z-index: 2;
  animation: clear-flash 270ms ease-in-out forwards;
}

.board.bomb-targeting .board-cell {
  cursor: crosshair;
  touch-action: manipulation;
}

.board-cell.bomb-preview {
  border-color: var(--accent-strong);
  background: #5e5734;
  box-shadow:
    inset 0 0 0 3px rgba(242, 207, 123, 0.46),
    0 0 8px rgba(229, 185, 92, 0.4);
}

.board-cell.occupied.bomb-preview::after {
  opacity: 0.46;
}

.board.bomb-combo-targeting .board-cell.bomb-preview {
  border-color: #ffad5c;
  background: #68442d;
  box-shadow:
    inset 0 0 0 3px rgba(255, 173, 92, 0.5),
    0 0 9px rgba(255, 126, 68, 0.44);
}

.board.bomb-super-combo-targeting .board-cell.bomb-preview {
  border-color: #ff6e5c;
  background: #6b3030;
  box-shadow:
    inset 0 0 0 3px rgba(255, 110, 92, 0.56),
    0 0 10px rgba(255, 80, 65, 0.5);
}

.board-cell.bomb-target {
  border-color: #fff0b5;
  outline: 3px solid var(--bad);
  outline-offset: -4px;
}

.board-cell.bomb-hover-target {
  outline: 2px dashed rgba(255, 240, 181, 0.78);
  outline-offset: -4px;
}

.board.bomb-target-locked .board-cell.bomb-target {
  box-shadow:
    inset 0 0 0 3px rgba(255, 240, 181, 0.66),
    0 0 11px rgba(238, 132, 111, 0.62);
}

.board-cell.embedded-object::after {
  position: absolute;
  z-index: 3;
  inset: 10%;
  display: grid;
  place-items: center;
  border: 2px solid var(--embedded-border, #a7b8ad);
  border-radius: 44%;
  background: var(--embedded-background, #263529);
  color: var(--embedded-color, #ffffff);
  content: var(--embedded-marker, "?");
  font-size: clamp(0.62rem, 2.4vw, 1rem);
  line-height: 1;
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(17, 27, 21, 0.42);
}

.board-cell.embedded-tommy-gun::after {
  position: absolute;
  z-index: 3;
  inset: 10%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 221, 130, 0.78);
  border-radius: 50%;
  background: #263529;
  color: #fff2c4;
  content: "🍄";
  font-size: clamp(0.62rem, 2.4vw, 1rem);
  line-height: 1;
  opacity: 1;
  filter: saturate(0.75);
  box-shadow: 0 0 0 2px rgba(17, 27, 21, 0.42);
}

.board-cell.embedded-bomb-mushroom::after,
.board-cell.embedded-bomb-origin::after {
  position: absolute;
  z-index: 3;
  inset: 9%;
  display: grid;
  place-items: center;
  border: 2px solid #ff806f;
  border-radius: 42% 42% 48% 48%;
  background: #261a1a;
  color: #ffd0b9;
  content: "\1F4A3";
  font-size: clamp(0.62rem, 2.4vw, 1rem);
  line-height: 1;
  opacity: 1;
  box-shadow:
    0 0 0 2px rgba(58, 15, 15, 0.52),
    inset 0 0 7px rgba(255, 90, 68, 0.3);
}

.board-cell.embedded-queued::after {
  border-color: var(--bad);
  box-shadow: 0 0 8px rgba(238, 132, 111, 0.7);
}

.board-cell.embedded-firing {
  z-index: 4;
  outline: 3px solid #ffcf65;
  outline-offset: -3px;
}

.board-cell.embedded-firing::after {
  animation: tommy-firing 180ms ease-in-out infinite alternate;
}

.board-cell.embedded-detonating {
  z-index: 5;
  outline: 3px solid #ff6e5c;
  outline-offset: -3px;
}

.board-cell.embedded-bomb-origin {
  z-index: 5;
  outline: 3px solid #ff6e5c;
  outline-offset: -3px;
}

.board-cell.embedded-bomb-origin::after {
  animation: bomb-armed 140ms ease-in-out infinite alternate;
}

.board-cell.embedded-detonating::after {
  animation: bomb-armed 140ms ease-in-out infinite alternate;
}

.board-cell.embedded-activating {
  z-index: 4;
  outline: 3px solid var(--embedded-border, #d9bc64);
  outline-offset: -3px;
}

.board-cell.embedded-activating::after {
  animation: embedded-object-active 150ms ease-in-out infinite alternate;
}

.board-cell.tommy-shot {
  z-index: 3;
  animation: tommy-shot 160ms ease-out;
}

.board-cell.embedded-bomb-blast {
  z-index: 3;
  animation: embedded-bomb-blast 190ms ease-out;
}

.board-cell.embedded-effect-drill {
  z-index: 3;
  animation: drill-sweep 190ms ease-out;
}

.board-cell.embedded-effect-grid {
  z-index: 3;
  animation: grid-flash 190ms ease-out;
}

@keyframes clear-flash {
  0%, 100% { filter: brightness(1); transform: scale(1); }
  50% { filter: brightness(1.8); transform: scale(0.72); background: var(--accent-strong); }
  100% { opacity: 0; }
}

@keyframes tommy-firing {
  from { transform: scale(0.86) rotate(-5deg); filter: brightness(1); }
  to { transform: scale(1.12) rotate(5deg); filter: brightness(1.55); }
}

@keyframes tommy-shot {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 231, 142, 0.92); }
  100% { box-shadow: inset 0 0 0 20px rgba(255, 231, 142, 0); }
}

@keyframes bomb-armed {
  from { transform: scale(0.88); filter: brightness(1); }
  to { transform: scale(1.14); filter: brightness(1.8); }
}

@keyframes embedded-bomb-blast {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 91, 69, 0.92); }
  100% { box-shadow: inset 0 0 0 22px rgba(255, 91, 69, 0); }
}

@keyframes embedded-object-active {
  from { transform: scale(0.9); filter: brightness(1); }
  to { transform: scale(1.1); filter: brightness(1.6); }
}

@keyframes drill-sweep {
  0% { box-shadow: inset 0 0 0 0 rgba(235, 198, 93, 0.9); }
  100% { box-shadow: inset 0 0 0 22px rgba(235, 198, 93, 0); }
}

@keyframes grid-flash {
  0% { box-shadow: inset 0 0 0 0 rgba(103, 188, 231, 0.9); }
  100% { box-shadow: inset 0 0 0 22px rgba(103, 188, 231, 0); }
}


.tray-section {
  margin-top: 15px;
}

.tray-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px 8px;
  gap: 12px;
}

.tray-heading h2 {
  margin: 0;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tray-heading span {
  color: var(--muted);
  font-size: 0.76rem;
}

.tray {
  display: grid;
  min-height: clamp(105px, 19vw, 138px);
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.tray-slot {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(34, 49, 41, 0.86);
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.tray-slot:hover {
  border-color: #718a79;
  background: #293a30;
}

.tray-slot.used {
  cursor: default;
  opacity: 0.32;
}

.tray-slot.used::after {
  color: var(--muted);
  content: "Placed";
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.piece-grid {
  display: grid;
  grid-template-columns: repeat(var(--piece-width), var(--piece-cell));
  grid-template-rows: repeat(var(--piece-height), var(--piece-cell));
  gap: max(2px, calc(var(--piece-cell) * 0.09));
  pointer-events: none;
}

.piece-cell {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: max(3px, calc(var(--piece-cell) * 0.18));
  background: var(--piece-color);
  box-shadow:
    inset 0 2px rgba(255, 255, 255, 0.2),
    inset 0 -2px rgba(0, 0, 0, 0.15);
}

.piece-cell.piece-embedded-object::after,
.board-cell.ghost-embedded-object::after {
  position: absolute;
  z-index: 4;
  inset: 9%;
  display: grid;
  place-items: center;
  border: 2px solid var(--embedded-border, #a7b8ad);
  border-radius: 44%;
  background: var(--embedded-background, #263529);
  color: var(--embedded-color, #ffffff);
  content: var(--embedded-marker, "?");
  font-size: max(0.58rem, calc(var(--piece-cell, 28px) * 0.54));
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(17, 27, 21, 0.42);
}

.piece-cell.piece-embedded-tommy::after,
.board-cell.ghost-embedded-tommy::after {
  position: absolute;
  z-index: 4;
  inset: 10%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 221, 130, 0.86);
  border-radius: 50%;
  background: #263529;
  color: #fff2c4;
  content: "\1F344";
  font-size: max(0.58rem, calc(var(--piece-cell, 28px) * 0.54));
  line-height: 1;
  filter: saturate(0.75);
  box-shadow: 0 0 0 2px rgba(17, 27, 21, 0.42);
}

.piece-cell.piece-embedded-bomb::after,
.board-cell.ghost-embedded-bomb::after {
  position: absolute;
  z-index: 4;
  inset: 8%;
  display: grid;
  place-items: center;
  border: 2px solid #ff806f;
  border-radius: 42% 42% 48% 48%;
  background: #261a1a;
  color: #ffd0b9;
  content: "\1F4A3";
  font-size: max(0.58rem, calc(var(--piece-cell, 28px) * 0.54));
  line-height: 1;
  box-shadow:
    0 0 0 2px rgba(58, 15, 15, 0.52),
    inset 0 0 6px rgba(255, 90, 68, 0.3);
}

.board-cell.ghost-embedded-tommy::after {
  font-size: clamp(0.62rem, 2.4vw, 1rem);
}

.board-cell.ghost-embedded-bomb::after {
  font-size: clamp(0.62rem, 2.4vw, 1rem);
}

.drag-piece {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  filter: drop-shadow(0 12px 12px rgba(0, 0, 0, 0.34));
  opacity: 0.95;
}

.drag-piece.invalid {
  filter: saturate(0.5) drop-shadow(0 0 7px var(--bad));
}

.controls {
  display: flex;
  justify-content: center;
  margin-top: 14px;
  gap: 8px;
}

.gangster-tools {
  display: grid;
  width: var(--board-size);
  margin: 14px auto 0;
  padding: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #6d6544;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(229, 185, 92, 0.09), transparent 55%),
    rgba(24, 35, 29, 0.95);
}

.gangster-inventory {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.inventory-slot {
  display: grid;
  min-width: 0;
  padding: 8px 10px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: #1b2922;
  text-align: left;
  cursor: pointer;
}

.inventory-slot.is-empty {
  opacity: 0.62;
}

.inventory-slot.is-available {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(229, 185, 92, 0.18);
}

.inventory-slot.is-targeting {
  border-color: var(--bad);
  background: rgba(149, 73, 61, 0.23);
  box-shadow:
    inset 0 0 0 1px rgba(238, 132, 111, 0.38),
    0 0 14px rgba(238, 132, 111, 0.18);
}

.inventory-slot.is-rescue {
  border-color: #ffcf65;
  box-shadow:
    inset 0 0 0 1px rgba(255, 207, 101, 0.35),
    0 0 16px rgba(255, 207, 101, 0.2);
}

.inventory-slot.is-combo {
  border-color: #ffad5c;
  background: rgba(140, 74, 40, 0.3);
}

.inventory-slot.is-super-combo {
  border-color: #ff6e5c;
  background: rgba(142, 49, 45, 0.36);
  box-shadow:
    inset 0 0 0 1px rgba(255, 110, 92, 0.42),
    0 0 16px rgba(255, 80, 65, 0.24);
}

.inventory-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgba(229, 185, 92, 0.14);
  font-size: 1.2rem;
}

.inventory-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.inventory-copy strong {
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-copy > span {
  color: var(--muted);
  font-size: 0.65rem;
}

.inventory-count {
  min-width: 30px;
  color: var(--accent-strong);
  font-size: 1.35rem;
  font-weight: 900;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.gangster-reward {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.gangster-reward .button {
  min-width: 132px;
}

.gangster-feedback {
  min-height: 1em;
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: right;
}

.gangster-rescue {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 207, 101, 0.72);
  border-radius: 12px;
  background:
    linear-gradient(120deg, rgba(229, 185, 92, 0.18), transparent),
    #202b23;
}

.gangster-rescue h3,
.gangster-rescue p {
  margin: 0;
}

.gangster-rescue h3 {
  margin-top: 2px;
  color: #ffcf65;
  font-size: 1rem;
}

.gangster-rescue p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.gangster-rescue.is-targeting {
  border-color: var(--bad);
}

.gangster-debug-scenarios {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.bomb-target-controls {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(229, 185, 92, 0.24);
}

.bomb-target-controls p {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 750;
}

.bomb-target-actions {
  display: flex;
  gap: 8px;
}

.bomb-target-actions .button {
  min-width: 116px;
}

.button {
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid #5e7365;
  border-radius: 999px;
  background: #2b3c32;
  font-weight: 750;
  cursor: pointer;
}

.button:hover {
  background: #354a3c;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  min-width: 150px;
  border-color: var(--accent);
  color: #1a211b;
  background: var(--accent);
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-quiet {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.button-small {
  min-height: 38px;
  border-radius: 10px;
  font-size: 0.83rem;
}

.button-danger {
  border-color: #955c51;
  color: #ffd2c8;
}

.debug-panel {
  width: min(var(--board-size), 610px);
  margin: 18px auto 0;
  padding: 18px;
  border: 1px dashed #66796d;
  border-radius: 16px;
  background: rgba(24, 35, 29, 0.94);
}

.debug-heading,
.debug-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.debug-heading h2 {
  margin: 2px 0 0;
  font-size: 1rem;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.seed-display {
  color: var(--muted);
  font: 0.75rem ui-monospace, monospace;
}

.debug-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr auto;
  align-items: end;
  gap: 10px;
  margin: 16px 0 12px;
}

.debug-grid label {
  display: grid;
  color: var(--muted);
  font-size: 0.72rem;
  gap: 5px;
}

.debug-grid select,
.debug-grid input {
  width: 100%;
  min-height: 38px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #101813;
}

.debug-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.debug-legal {
  display: grid;
  margin-top: 13px;
  color: var(--muted);
  font: 0.75rem ui-monospace, monospace;
  gap: 4px;
}

.debug-note {
  margin: 11px 0 0;
  color: #8f988f;
  font-size: 0.72rem;
}

.overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 13, 10, 0.84);
  backdrop-filter: blur(7px);
}

.overlay[hidden],
[hidden] {
  display: none !important;
}

.dialog-card {
  width: min(100%, 430px);
  padding: clamp(24px, 6vw, 38px);
  border: 1px solid #52695a;
  border-radius: 24px;
  background: linear-gradient(145deg, #24342b, #17231c);
  box-shadow: var(--shadow);
  text-align: center;
}

.dialog-symbol {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 50%;
  color: #1a211b;
  background: var(--accent);
  font-size: 1.25rem;
  font-weight: 900;
}

.dialog-symbol.mushroom-symbol {
  width: 56px;
  height: 28px;
  margin-bottom: 29px;
  border-radius: 34px 34px 12px 12px;
}

.dialog-symbol.mushroom-symbol::after {
  top: 22px;
  left: 21px;
  width: 14px;
  height: 20px;
}

.dialog-card h2 {
  margin: 6px 0 8px;
  font-size: clamp(1.6rem, 7vw, 2.35rem);
}

.dialog-card > p:not(.eyebrow) {
  margin: 0 0 22px;
  color: var(--muted);
}

.fake-ad-card {
  width: min(100%, 470px);
  border-color: #8b7847;
}

.fake-ad-card h2 {
  font-size: clamp(1.45rem, 7vw, 2.25rem);
}

.fake-ad-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.fake-ad-actions .button {
  flex: 1 1 145px;
}

.final-score {
  display: grid;
  margin: 0 auto 19px;
  gap: 2px;
}

.final-score span {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.final-score strong {
  color: var(--accent-strong);
  font-size: 2.5rem;
  font-variant-numeric: tabular-nums;
}

.round-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 0 0 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.round-stats div {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.round-stats div:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.round-stats div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.round-stats dt {
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.round-stats dd {
  margin: 2px 0 0;
  font-weight: 800;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.dragging,
body.dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}

@media (max-width: 580px) {
  :root {
    --board-size: min(91vw, 66vh, 500px);
  }

  .game-shell {
    width: 100%;
    padding-top: max(11px, env(safe-area-inset-top));
  }

  .game-header {
    gap: 8px;
  }

  .brand-mark {
    display: none;
  }

  .hud-card {
    min-width: 65px;
    padding: 6px 9px;
  }

  .tray {
    min-height: 105px;
  }

  .tray-heading span {
    font-size: 0.68rem;
  }

  .gangster-tools {
    padding: 10px;
    grid-template-columns: 1fr;
  }

  .gangster-reward {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-items: start;
  }

  .gangster-feedback {
    text-align: left;
  }

  .bomb-target-controls {
    grid-template-columns: 1fr;
  }

  .gangster-rescue {
    grid-template-columns: 1fr;
  }

  .gangster-rescue .button {
    width: 100%;
  }

  .bomb-target-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .bomb-target-actions .button {
    width: 100%;
    min-width: 0;
  }

  .debug-grid {
    grid-template-columns: 1fr 1fr;
  }

  .debug-grid .button {
    align-self: end;
  }
}

@media (max-height: 690px) and (orientation: landscape) {
  :root {
    --board-size: min(60vh, 75vw, 480px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
