:root {
  --ink: #1a1b1f;
  --paper: #f3f2ef;
  --accent-1: #d63a35;
  --accent-2: #b52c28;
  --accent-3: #2c2f33;
  --accent-4: #4b4f56;
  --board-dark: #5c5f63;
  --board-light: #6d7075;
  --barrier: #d63a35;
  --glow: rgba(214, 58, 53, 0.35);
  --tray: #1c1f24;
  --tray-edge: #30343a;
  --container-dark: #15181d;
  --container-light: rgba(255, 255, 255, 0.85);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Gill Sans", "Trebuchet MS", "Century Gothic", sans-serif;
  background: radial-gradient(circle at top, #f9f7f3, #e5e2dc 55%, #bcb7b0 100%);
  color: var(--ink);
  min-height: 100vh;
  transition: background 0.3s ease;
}

body.dark-mode {
  background: radial-gradient(circle at top, #0a0b0d, #12141a 55%, #1a1d24 100%);
  color: #f3f4f6;
}

body:not(.dark-mode) .player-box {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  color: var(--ink);
}

body:not(.dark-mode) .player-box.is-active {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 20px var(--glow), inset 0 0 0 1px var(--glow);
  border-color: var(--accent-1);
}

body:not(.dark-mode) .player-label {
  color: rgba(0, 0, 0, 0.5);
}

body:not(.dark-mode) .player-name {
  color: var(--ink);
}

body:not(.dark-mode) .board-wrap {
  background: var(--container-light);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

body:not(.dark-mode) .board-wrap::after {
  background: none;
}

body:not(.dark-mode) .board-wrap::before {
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

body:not(.dark-mode) .status-panel {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

body:not(.dark-mode) .status-row .label {
  color: rgba(0, 0, 0, 0.5);
}

body:not(.dark-mode) .status-row .value {
  color: var(--ink);
}

body:not(.dark-mode) .player-time {
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--ink);
}

body:not(.dark-mode) .player-score {
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--ink);
}

body:not(.dark-mode) .player-edit {
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
}

body:not(.dark-mode) .player-edit:hover {
  background: rgba(0, 0, 0, 0.15);
}

body:not(.dark-mode) .player-input {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.2);
  color: var(--ink);
}

body:not(.dark-mode) .player-input:focus {
  border-color: var(--accent-1);
  background: rgba(255, 255, 255, 1);
}

body:not(.dark-mode) .help-button {
  background: rgba(0, 0, 0, 0.1);
  color: var(--ink);
}

body:not(.dark-mode) .help-button:hover {
  background: rgba(0, 0, 0, 0.15);
}

body:not(.dark-mode) .top-bar {
  background: var(--container-light);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

body:not(.dark-mode) h1 {
  color: var(--ink);
}

body:not(.dark-mode) .help-modal {
  background: rgba(0, 0, 0, 0.4);
}

body:not(.dark-mode) .help-content {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

body:not(.dark-mode) .help-close {
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
}

body:not(.dark-mode) .help-close:hover {
  background: rgba(0, 0, 0, 0.15);
}

body:not(.dark-mode) .help-subtitle {
  color: var(--ink);
}

body:not(.dark-mode) .settings-option {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--ink);
}

body:not(.dark-mode) .settings-option:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: var(--glow);
}

body:not(.dark-mode) .settings-option.active {
  background: var(--accent-1);
  border-color: var(--accent-1);
  color: #ffffff;
}

body:not(.dark-mode) .settings-audio-label {
  color: var(--ink);
}

body:not(.dark-mode) .settings-audio-button {
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--ink);
}

body:not(.dark-mode) .settings-audio-button:hover {
  background: rgba(0, 0, 0, 0.12);
  border-color: var(--glow);
}

body:not(.dark-mode) .help-footer {
  border-top-color: rgba(0, 0, 0, 0.15);
}

body:not(.dark-mode) .cell:not(.barrier) {
  background: #c9c5c0;
}

body:not(.dark-mode) .cell.dark:not(.barrier) {
  background: #c9c5c0;
}

body:not(.dark-mode) .cell.center::after {
  background: rgba(80, 75, 70, 0.85);
  box-shadow: 0 0 0 2px rgba(60, 55, 50, 0.4);
}

body:not(.dark-mode) .board {
  background: #a8a49f;
  box-shadow: 0 0 0 8px #6d7075;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 24px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  min-height: 100vh;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: space-between;
  align-items: center;
  background: var(--container-dark);
  color: #f2f3f5;
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
  width: min(92vw, 860px);
  justify-self: center;
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 18px;
}

.brand {
  max-width: 520px;
}

.eyebrow {
  font-family: "Gill Sans", "Trebuchet MS", "Century Gothic", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-size: 0.7rem;
  color: var(--accent-3);
  margin-bottom: 10px;
}

h1 {
  font-size: clamp(1.6rem, 2.4vw, 2.4rem);
  color: #f2f3f5;
  margin-bottom: 8px;
}

.status-panel {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 12px 14px;
  width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 6px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.9rem;
}

.status-row .label {
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.status-row .value {
  color: #f2f3f5;
}

.app-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
  justify-items: center;
}

.board-wrap {
  background: var(--container-dark);
  padding: 26px;
  border-radius: 24px;
  box-shadow: 0 30px 60px rgba(10, 8, 12, 0.45);
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 14px;
  justify-items: center;
  width: min(92vw, 860px);
}

.board-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: none;
  pointer-events: none;
}

.board-wrap::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: 3px;
  width: min(82vw, 720px);
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  box-shadow: 0 0 0 8px #3d4045;
  overflow: hidden;
  position: relative;
  animation: board-reveal 0.7s ease-out;
  background: #3d4045;
}

@keyframes board-reveal {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.player-box {
  width: min(82vw, 720px);
  background: rgba(18, 22, 28, 0.95);
  border-radius: 14px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  color: #dfe3ea;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6);
  position: relative;
}

.player-box.is-active {
  background: rgba(18, 22, 28, 0.95);
  box-shadow: 0 0 26px var(--glow), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  border-color: var(--accent-1);
}

.player-box::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 70%;
  border-radius: 999px;
  background: #f7f5f2;
  opacity: 0.9;
}

.player-box[data-player="p1"]::before {
  background: #111317;
}

.player-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.55);
  margin-left: 10px;
}

.player-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  grid-column: 2 / 3;
}

.player-name {
  font-size: 1rem;
  font-weight: 600;
  color: #f2f3f5;
  text-align: left;
}

.player-time {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f2f3f5;
  letter-spacing: 0.04em;
 }

.player-name.is-hidden {
  display: none;
}

.player-input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f2f3f5;
  font-size: 1rem;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 8px;
  grid-column: 2 / 3;
  width: 100%;
}

.player-input:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 2px var(--glow);
}
.player-score {
  min-width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: #f2f3f5;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.player-input.is-hidden {
  display: none;
}

.player-edit {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #f2f3f5;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
}

.win-message {
  font-size: 1.1rem;
  margin-bottom: 16px;
}
.player-edit:hover {
  background: rgba(255, 255, 255, 0.2);
}

.cell {
  border: none;
  background: var(--board-light);
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cell.dark {
  background: var(--board-light);
}

.cell:focus {
  outline: 2px solid var(--accent-1);
  outline-offset: -2px;
}

.cell.highlight {
  box-shadow: inset 0 0 0 3px rgba(209, 143, 63, 0.55);
}

.cell.blockable {
  box-shadow: inset 0 0 0 2px var(--accent-1);
}

.cell.selected {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.65);
}

.cell.center {
  box-shadow: none;
}

.cell.center::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(60, 64, 72, 0.9);
  box-shadow: 0 0 0 2px rgba(30, 33, 38, 0.6);
}

.cell.center.center-occupied::after {
  opacity: 0;
}

.cell.barrier {
  background: var(--barrier);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.2);
  cursor: not-allowed;
}

.cell:hover:not(.barrier):not(.selected) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.pawn {
  width: 100%;
  height: 100%;
  display: inline-block;
  background: linear-gradient(180deg, #3a3f45 0%, #2b2f34 15%, #1a1d22 50%, #0f1215 85%, #080a0c 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    inset 0 -8px 12px rgba(0, 0, 0, 0.5),
    inset 0 4px 6px rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 2px 8px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.pawn.p2 {
  background: linear-gradient(180deg, #fffaf0 0%, #f6e9c9 15%, #ede0c0 50%, #ddcaa4 85%, #d0bd96 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.7),
    inset 0 -8px 12px rgba(0, 0, 0, 0.3),
    inset 0 4px 6px rgba(255, 255, 255, 0.6),
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.4);
}

.bottom-btn {
  width: min(420px, 100%);
  border: none;
  background: linear-gradient(135deg, #e44741, #9f1d1a);
  color: #fef4f2;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bottom-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px var(--glow);
}

.help-button {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #f2f3f5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.help-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
}

.help-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.help-modal.is-open {
  display: flex;
}

.help-content {
  width: min(92vw, 480px);
  background: #1a1f25;
  color: #e2e6eb;
  border-radius: 16px;
  padding: 18px 20px;
  border: 1px solid #2b3139;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.help-close {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #f2f3f5;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

.help-list {
  display: grid;
  gap: 8px;
  padding-left: 18px;
  margin-bottom: 12px;
}

.help-subtitle {
  font-size: 0.95rem;
  margin: 12px 0 6px;
  color: #f3f4f6;
}

.settings-options {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.settings-option {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f2f3f5;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.settings-option:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-1);
}

.settings-option.active {
  background: var(--accent-1);
  border-color: var(--accent-1);
  color: #f2f3f5;
}

.settings-audio {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.settings-audio-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
}

.settings-slider {
  width: 100%;
  accent-color: var(--accent-1);
}

.settings-audio-button {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #f2f3f5;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.settings-audio-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-1);
}

.mute-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2em;
  height: 1.2em;
  position: relative;
  font-size: 1.1rem;
}

.settings-audio-button.is-muted .mute-icon::after {
  content: "";
  position: absolute;
  width: 1.6em;
  height: 2px;
  background: var(--accent-1);
  transform: rotate(-35deg);
  border-radius: 2px;
}

.dark-mode-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2em;
  height: 1.2em;
  position: relative;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.settings-audio-button.is-dark .dark-mode-icon {
  filter: brightness(1.2);
}

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

.color-option {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.color-option:hover {
  transform: scale(1.1);
}

.color-option.active {
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
}

body:not(.dark-mode) .color-option.active {
  border-color: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.legend-row:last-child {
  margin-bottom: 0;
}

.legend-row .pawn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  transform: translateY(0);
}

.help-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.8rem;
  opacity: 0.6;
}

.barrier-swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ff5b56, #b51b1b);
  position: relative;
  overflow: hidden;
}

.barrier-swatch::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), transparent 60%);
}

@media (max-width: 900px) {
  .board {
    width: 100%;
  }
}

@media (min-width: 1000px) {
  .page {
    max-width: 1600px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    margin-bottom: 0;
  }

  .top-bar {
    width: min(86vw, 980px);
  }

  .board {
    width: min(62vmin, 820px);
  }

  .player-box {
    width: min(62vmin, 820px);
  }

  .board-wrap {
    padding: 36px;
    width: min(86vw, 980px);
  }
}

@media (max-width: 700px) {
  body {
    background: #0f1115;
    color: #f3f4f6;
  }

  .page {
    max-width: none;
    min-height: 100svh;
    padding: 10px 10px 12px;
    gap: 12px;
  }

  .top-bar {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .eyebrow {
    display: none;
  }

  .brand {
    text-align: center;
  }

  .top-actions {
    justify-content: center;
  }

  h1 {
    font-size: 1.4rem;
    color: #f3f4f6;
  }

  .status-panel {
    width: 100%;
  }

  .status-row .value {
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .app-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
  }

  .board-wrap {
    padding: 10px;
    border-radius: 18px;
    width: 100%;
  }

  .board {
    width: 100%;
    margin: 0 auto;
  }

  .player-box {
    width: 100%;
  }

  .bottom-btn {
    padding: 16px 18px;
    font-size: 1rem;
  }
}
