:root {
  --bg-deep: #15251f;
  --bg-mid: #244236;
  --panel: rgba(245, 232, 210, 0.9);
  --panel-strong: rgba(252, 245, 232, 0.96);
  --text: #1f231f;
  --muted: #5b635f;
  --board: #d1b27a;
  --board-line: #5f4820;
  --accent: #d16b37;
  --accent-soft: rgba(209, 107, 55, 0.24);
  --white-piece: #f7f1df;
  --white-rim: #d5b77d;
  --black-piece: #1f2528;
  --black-rim: #8d7455;
  --shadow: 0 18px 50px rgba(7, 12, 10, 0.26);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 196, 120, 0.18), transparent 30%),
    radial-gradient(circle at right 20%, rgba(123, 193, 162, 0.18), transparent 28%),
    linear-gradient(145deg, var(--bg-deep), var(--bg-mid));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 72px),
    linear-gradient(rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 72px);
  pointer-events: none;
  opacity: 0.25;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.site-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 24px;
  border-radius: 24px;
  background: rgba(12, 24, 20, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.site-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #f7f1df;
}

.site-brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #d1b27a, #d16b37);
  color: #1f231f;
  font-weight: 900;
}

.site-brand-copy {
  display: grid;
  gap: 2px;
}

.site-brand-copy span {
  color: rgba(247, 241, 223, 0.74);
  font-size: 0.92rem;
}

.site-return,
.site-support {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  text-decoration: none;
  color: #1f231f;
  background: linear-gradient(135deg, #f4e4bf, #d1b27a);
  font-weight: 800;
}

.site-support {
  background: linear-gradient(135deg, #ffdc42, #f0b90a);
}

.hero {
  color: #f7f1df;
  max-width: 760px;
  margin-bottom: 28px;
  animation: rise-in 520ms ease-out both;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  margin: 0 0 10px;
  color: rgba(247, 241, 223, 0.8);
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2rem, 3.5vw, 3.6rem);
  line-height: 1.04;
}

.hero-copy {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.6;
  color: rgba(247, 241, 223, 0.85);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr);
  gap: 24px;
  align-items: start;
}

.board-panel,
.player-card,
.rules-card {
  background: var(--panel);
  border: 1px solid rgba(95, 72, 32, 0.12);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.board-panel {
  padding: 22px;
  border-radius: 30px;
  animation: rise-in 620ms ease-out both;
}

.setup-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, 0.6fr);
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.setup-group {
  display: grid;
  gap: 10px;
}

.setup-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-pill {
  position: relative;
  cursor: pointer;
}

.choice-pill input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.choice-pill span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(95, 72, 32, 0.12);
  color: var(--text);
  font-weight: 700;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.choice-pill:hover span,
.choice-pill input:focus-visible + span {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(31, 35, 31, 0.1);
}

.choice-pill input:checked + span {
  background: linear-gradient(135deg, rgba(30, 58, 50, 0.96), rgba(49, 89, 76, 0.9));
  border-color: rgba(30, 58, 50, 0.6);
  color: #f7f1df;
  box-shadow: 0 12px 24px rgba(20, 36, 30, 0.22);
}

.difficulty-field {
  display: grid;
  gap: 10px;
}

.difficulty-select {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(95, 72, 32, 0.18);
  border-radius: 16px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.difficulty-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mode-hint {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.status-bar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 18px;
}

.status-copy h2 {
  margin: 6px 0 8px;
  font-size: clamp(1.32rem, 2.2vw, 2rem);
}

.phase-label {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

.notice-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.reset-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #1e3a32, #31594c);
  color: #f7f1df;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 10px 24px rgba(20, 36, 30, 0.28);
}

.reset-button:hover,
.reset-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(20, 36, 30, 0.34);
}

.board-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 24px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(255, 246, 224, 0.55), rgba(199, 159, 96, 0.1)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent);
  overflow: hidden;
}

.board-shell::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 30%),
    linear-gradient(145deg, rgba(108, 79, 31, 0.22), rgba(255, 255, 255, 0.08));
  pointer-events: none;
}

.board-svg,
.board-positions,
.board-overlay {
  position: absolute;
  inset: 16px;
}

.board-svg {
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  filter: drop-shadow(0 10px 14px rgba(58, 39, 10, 0.15));
}

.board-svg rect,
.board-svg line {
  fill: none;
  stroke: var(--board-line);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.board-positions {
  z-index: 2;
}

.board-overlay {
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}

.mill-line {
  fill: none;
  stroke: rgba(209, 107, 55, 0.92);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  filter: drop-shadow(0 0 12px rgba(209, 107, 55, 0.5));
  animation:
    mill-draw 360ms ease forwards,
    mill-breathe 840ms ease-in-out infinite alternate;
}

.position {
  position: absolute;
  width: clamp(34px, 5.2vw, 46px);
  height: clamp(34px, 5.2vw, 46px);
  border-radius: 50%;
  border: 0;
  transform: translate(-50%, -50%);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.position:hover,
.position:focus-visible {
  transform: translate(-50%, -50%) scale(1.08);
}

.position:focus-visible {
  outline: 3px solid rgba(209, 107, 55, 0.45);
  outline-offset: 4px;
}

.position.empty {
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.15) 40%, transparent 42%),
    radial-gradient(circle, rgba(95, 72, 32, 0.28), rgba(95, 72, 32, 0.12));
  box-shadow: 0 0 0 1px rgba(95, 72, 32, 0.22), inset 0 0 0 10px rgba(255, 248, 228, 0.08);
}

.position.occupied-white {
  background: radial-gradient(circle at 30% 30%, #ffffff, var(--white-piece) 58%, #d6c29c);
  box-shadow:
    inset -6px -8px 12px rgba(0, 0, 0, 0.12),
    inset 4px 4px 8px rgba(255, 255, 255, 0.7),
    0 8px 18px rgba(74, 58, 27, 0.22);
}

.position.occupied-black {
  background: radial-gradient(circle at 30% 28%, #495257, var(--black-piece) 55%, #0d1113);
  box-shadow:
    inset -6px -8px 12px rgba(0, 0, 0, 0.45),
    inset 4px 4px 8px rgba(255, 255, 255, 0.08),
    0 8px 18px rgba(0, 0, 0, 0.26);
}

.position.selected {
  box-shadow:
    0 0 0 5px rgba(209, 107, 55, 0.22),
    0 14px 24px rgba(95, 72, 32, 0.24);
}

.position.target {
  box-shadow:
    0 0 0 6px rgba(43, 102, 88, 0.24),
    0 0 0 12px rgba(43, 102, 88, 0.08);
}

.position.in-mill {
  box-shadow:
    0 0 0 4px rgba(95, 72, 32, 0.15),
    0 0 0 8px rgba(209, 107, 55, 0.14);
}

.position.removable {
  animation: removable-pulse 900ms ease-in-out infinite alternate;
}

.position.computer-focus {
  box-shadow:
    0 0 0 6px rgba(67, 135, 126, 0.28),
    0 0 0 14px rgba(67, 135, 126, 0.12),
    0 16px 26px rgba(23, 53, 45, 0.22);
}

.position.capture-preview {
  box-shadow:
    0 0 0 6px rgba(198, 58, 36, 0.34),
    0 0 0 14px rgba(198, 58, 36, 0.16),
    0 16px 28px rgba(105, 32, 18, 0.28);
  animation: capture-warning 680ms ease-in-out infinite alternate;
}

.position.capture-trace {
  background:
    radial-gradient(circle, rgba(198, 58, 36, 0.26), rgba(198, 58, 36, 0.06) 52%, transparent 56%),
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.15) 40%, transparent 42%),
    radial-gradient(circle, rgba(95, 72, 32, 0.28), rgba(95, 72, 32, 0.12));
  box-shadow:
    0 0 0 5px rgba(198, 58, 36, 0.18),
    0 0 0 12px rgba(198, 58, 36, 0.08);
  animation: capture-trace-fade 500ms ease-out both;
}

.sidebar {
  display: grid;
  gap: 18px;
  animation: rise-in 720ms ease-out both;
}

.player-card,
.rules-card {
  border-radius: 24px;
  padding: 18px 20px;
}

.player-card {
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.player-card.active {
  background: var(--panel-strong);
  border-color: rgba(209, 107, 55, 0.22);
  transform: translateY(-2px);
}

.player-card.winner {
  background:
    linear-gradient(135deg, rgba(209, 107, 55, 0.18), rgba(255, 255, 255, 0.72)),
    var(--panel-strong);
}

.player-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.player-piece {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-block;
}

.piece-white {
  background: radial-gradient(circle at 30% 30%, #ffffff, var(--white-piece) 58%, #d6c29c);
  box-shadow: inset -4px -6px 10px rgba(0, 0, 0, 0.12), inset 4px 4px 8px rgba(255, 255, 255, 0.7);
}

.piece-black {
  background: radial-gradient(circle at 30% 28%, #495257, var(--black-piece) 55%, #0d1113);
  box-shadow: inset -5px -7px 10px rgba(0, 0, 0, 0.46), inset 4px 4px 8px rgba(255, 255, 255, 0.08);
}

.player-name {
  margin: 0 0 2px;
  font-size: 1.1rem;
  font-weight: 800;
}

.player-role {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.player-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.player-stats div {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.46);
}

.player-stats dt {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.player-stats dd {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
}

.rules-card h3 {
  margin: 0 0 14px;
  font-size: 1.12rem;
}

.rules-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.content-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.content-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 20px 22px;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 38%),
    var(--panel-strong);
  border: 1px solid rgba(95, 72, 32, 0.16);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.44);
  backdrop-filter: blur(10px);
}

.content-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, rgba(209, 107, 55, 0.92), rgba(95, 72, 32, 0.78));
}

.content-card-wide {
  grid-column: 1 / -1;
}

.content-card h2 {
  margin: 0;
  font-size: 1.26rem;
  line-height: 1.2;
}

.content-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.content-list,
.link-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.faq-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.faq-list div {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(95, 72, 32, 0.1);
}

.faq-list dt {
  margin: 0 0 6px;
  font-weight: 800;
}

.faq-list dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.link-list a {
  color: #244236;
  font-weight: 800;
  text-decoration-thickness: 2px;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes removable-pulse {
  from {
    box-shadow:
      0 0 0 4px rgba(209, 107, 55, 0.18),
      0 0 0 10px rgba(209, 107, 55, 0.08);
  }

  to {
    box-shadow:
      0 0 0 6px rgba(209, 107, 55, 0.28),
      0 0 0 14px rgba(209, 107, 55, 0.12);
  }
}

@keyframes mill-draw {
  from {
    stroke-dashoffset: 120;
    opacity: 0;
  }

  to {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

@keyframes mill-breathe {
  from {
    opacity: 0.72;
  }

  to {
    opacity: 1;
  }
}

@keyframes capture-warning {
  from {
    transform: translate(-50%, -50%) scale(1);
  }

  to {
    transform: translate(-50%, -50%) scale(1.1);
  }
}

@keyframes capture-trace-fade {
  from {
    opacity: 1;
  }

  to {
    opacity: 0.2;
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .content-sections {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rules-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app {
    width: min(100% - 20px, 760px);
    padding: 20px 0 32px;
  }

  .site-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .site-topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .board-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .status-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .setup-panel {
    grid-template-columns: 1fr;
  }

  .site-return,
  .site-support,
  .reset-button {
    width: 100%;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .player-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .position {
    width: clamp(36px, 10vw, 48px);
    height: clamp(36px, 10vw, 48px);
  }

  .choice-pill {
    width: 100%;
  }

  .choice-pill span {
    width: 100%;
  }
}
