:root {
  color-scheme: dark;
  --bg: #10130f;
  --panel: #181d18;
  --panel-2: #20261f;
  --ink: #f4f0de;
  --muted: #aab3a3;
  --line: #394135;
  --accent: #f2b84b;
  --accent-2: #69d2c1;
  --danger: #e4543f;
  --safe: #75c95b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(105, 210, 193, 0.12), transparent 34%),
    radial-gradient(circle at 78% 20%, rgba(242, 184, 75, 0.12), transparent 28%),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.command-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 96px;
  padding-bottom: 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark {
  width: 44px;
  height: 44px;
  border: 2px solid var(--accent);
  background:
    linear-gradient(90deg, transparent 47%, rgba(242, 184, 75, 0.5) 48% 52%, transparent 53%),
    linear-gradient(0deg, transparent 47%, rgba(242, 184, 75, 0.5) 48% 52%, transparent 53%),
    #1d221c;
  box-shadow: inset 0 0 0 8px rgba(105, 210, 193, 0.08);
  transform: rotate(3deg);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.88;
}

.brand-lockup p,
.notes,
.stat-label {
  color: var(--muted);
}

.run-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 8px;
  width: min(620px, 100%);
}

.run-stats > div,
.tuner-panel,
.board-zone {
  border: 1px solid var(--line);
  background: rgba(24, 29, 24, 0.92);
  box-shadow: var(--shadow);
}

.run-stats > div {
  min-height: 62px;
  padding: 10px 12px;
  border-radius: 8px;
}

.stat-label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.run-stats strong {
  font-size: 1.15rem;
}

.play-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tuner-panel,
.board-zone {
  border-radius: 8px;
}

.tuner-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.panel-header,
.header-actions,
.board-toolbar,
.mode-row,
.notes div {
  display: flex;
  align-items: center;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 18px;
}

.header-actions {
  gap: 8px;
}

.panel-header h2 {
  font-size: 1.35rem;
}

.icon-command,
.tool-button,
.mode-pill {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel-2);
  cursor: pointer;
}

.icon-command,
.tool-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-size: 1.15rem;
}

.icon-command.primary {
  border-color: rgba(242, 184, 75, 0.65);
  background: #312619;
}

.icon-command.pending {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(242, 184, 75, 0.16);
}

.control-grid {
  display: grid;
  gap: 16px;
}

.knob {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  align-items: center;
}

.knob span {
  font-size: 0.9rem;
  color: var(--muted);
}

.knob output {
  color: var(--ink);
  font-weight: 700;
}

.knob input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

.mode-row {
  gap: 8px;
  margin: 20px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121611;
}

.mode-pill {
  flex: 1;
  min-height: 38px;
  border-radius: 6px;
}

.mode-pill.active,
.tool-button.active {
  border-color: var(--accent-2);
  color: #081311;
  background: var(--accent-2);
}

.notes {
  display: grid;
  gap: 10px;
  font-size: 0.9rem;
}

.notes div {
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.safe {
  background: var(--safe);
}

.dot.delay {
  background: var(--danger);
}

.board-zone {
  min-height: 680px;
  padding: 14px;
}

.board-toolbar {
  gap: 8px;
  margin-bottom: 12px;
}

.lock-meter {
  flex: 1;
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #111610;
}

.lock-meter span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--danger), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(24px, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(24px, 1fr));
  gap: 4px;
  width: 100%;
  aspect-ratio: var(--columns) / var(--rows);
  max-height: calc(100vh - 190px);
  margin: 0 auto;
}

.tile {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 1px solid #30382f;
  border-radius: 5px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 48%),
    #222a20;
  color: var(--ink);
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.tile:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.tile.revealed {
  background: #121611;
  border-color: #252c24;
}

.tile.flagged {
  color: var(--accent);
  background: #2d2619;
}

.tile.bomb {
  color: #fff3ea;
  border-color: rgba(228, 84, 63, 0.8);
  background: radial-gradient(circle, #e4543f, #6c2118);
}

.tile[data-nearby="1"] {
  color: #69d2c1;
}

.tile[data-nearby="2"] {
  color: #75c95b;
}

.tile[data-nearby="3"] {
  color: #f2b84b;
}

.tile[data-nearby="4"],
.tile[data-nearby="5"],
.tile[data-nearby="6"],
.tile[data-nearby="7"],
.tile[data-nearby="8"] {
  color: #f17c60;
}

.board.locked .tile {
  filter: saturate(0.75) brightness(0.82);
}

.board.sample .tile {
  cursor: default;
}

.board.sample .tile.revealed:not(.bomb) {
  background: #151b15;
}

.board.previewing .tile.hidden[data-nearby="0"] {
  box-shadow: inset 0 0 0 999px rgba(117, 201, 91, 0.1);
}

.board.previewing .tile.hidden[data-nearby="1"],
.board.previewing .tile.hidden[data-nearby="2"] {
  box-shadow: inset 0 0 0 999px rgba(105, 210, 193, 0.12);
}

.board.previewing .tile.hidden[data-nearby="3"],
.board.previewing .tile.hidden[data-nearby="4"] {
  box-shadow: inset 0 0 0 999px rgba(242, 184, 75, 0.15);
}

.board.previewing .tile.hidden[data-nearby="5"],
.board.previewing .tile.hidden[data-nearby="6"],
.board.previewing .tile.hidden[data-nearby="7"],
.board.previewing .tile.hidden[data-nearby="8"] {
  box-shadow: inset 0 0 0 999px rgba(228, 84, 63, 0.16);
}

@media (max-width: 980px) {
  .command-strip,
  .play-layout {
    grid-template-columns: 1fr;
  }

  .command-strip {
    display: grid;
  }

  .play-layout {
    display: grid;
  }

  .tuner-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 18px, 1480px);
    padding-top: 12px;
  }

  .run-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .board-zone {
    min-height: auto;
    padding: 10px;
  }

  .board {
    gap: 3px;
    max-height: none;
  }

  .tile {
    border-radius: 4px;
    font-size: 0.75rem;
  }
}
