:root {
  --bg-deep: #0c241c;
  --bg-mid: #174634;
  --panel: rgba(242, 247, 241, 0.96);
  --panel-soft: rgba(248, 251, 247, 0.92);
  --ink: #17261e;
  --muted: #596a61;
  --line: rgba(23, 38, 30, 0.12);
  --board: #2c8c62;
  --board-deep: #1d6245;
  --glow: #d7f2cb;
  --shadow: 0 22px 48px rgba(3, 11, 24, 0.28);
  --cell-size: clamp(38px, 7vw, 70px);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(215, 242, 203, 0.18), transparent 22%),
    radial-gradient(circle at 86% 10%, rgba(66, 130, 102, 0.22), transparent 22%),
    linear-gradient(155deg, var(--bg-deep), var(--bg-mid));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.035), transparent 28%),
    linear-gradient(rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 80px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 80px);
  pointer-events: none;
  opacity: 0.34;
}

.reversi-app {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.reversi-topbar,
.reversi-controls-panel,
.board-panel,
.player-card,
.rules-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.reversi-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 24px;
}

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

.reversi-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--ink);
}

.reversi-brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f0f4ef, #2c8c62);
  color: #16221b;
  font-weight: 900;
}

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

.reversi-brand-copy strong {
  font-size: 1.04rem;
}

.reversi-brand-copy span {
  color: var(--muted);
  font-size: 0.92rem;
}

.reversi-return,
.reversi-support,
.action-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
  border: 1px solid rgba(21, 34, 55, 0.12);
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.reversi-return,
.reversi-support,
.action-button {
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(145deg, #f8fbff, #dfe9fb);
  color: var(--ink);
}

.reversi-support {
  background: linear-gradient(145deg, #ffdc42, #f0b90a);
  color: #24150f;
}

.action-button.primary {
  background: linear-gradient(145deg, #d8f0c6, #5cb07d);
  color: #122117;
}

.reversi-return:hover,
.reversi-return:focus-visible,
.action-button:hover,
.action-button:focus-visible {
  transform: translateY(-1px);
}

.action-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.reversi-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(360px, 1.08fr);
  gap: 20px;
  align-items: start;
  padding: 28px 0 18px;
}

.eyebrow {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.reversi-copy h1,
.status-copy h2,
.rules-card h3,
.result-overlay h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

.reversi-copy h1 {
  margin: 0 0 14px;
  max-width: 12ch;
  color: #fff8ec;
  font-size: clamp(2.4rem, 5vw, 4.7rem);
  line-height: 0.95;
}

.reversi-copy p:last-child {
  margin: 0;
  max-width: 60ch;
  color: rgba(239, 245, 255, 0.86);
  line-height: 1.65;
}

.reversi-controls-panel {
  border-radius: 30px;
  padding: 22px;
}

.status-copy h2 {
  margin: 0;
  font-size: clamp(1.28rem, 2.4vw, 1.82rem);
  line-height: 1.12;
}

.notice-text,
.mode-hint {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.setup-panel {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

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

.setup-label {
  margin: 0;
  color: #425069;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.choice-pill {
  position: relative;
  display: inline-flex;
  min-height: 48px;
  align-items: center;
}

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

.choice-pill span {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(21, 34, 55, 0.12);
  border-radius: 999px;
  background: #f6f9ff;
  color: #374862;
  font-weight: 800;
  cursor: pointer;
}

.choice-pill input:checked + span {
  background: linear-gradient(145deg, rgba(44, 140, 98, 0.16), rgba(215, 242, 203, 0.24));
  border-color: rgba(44, 140, 98, 0.28);
  color: #18513b;
}

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

.difficulty-select {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(21, 34, 55, 0.12);
  border-radius: 16px;
  background: #f6f9ff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.metric-card {
  padding: 14px;
  border: 1px solid rgba(21, 34, 55, 0.1);
  border-radius: 20px;
  background: var(--panel-soft);
}

.metric-card span {
  display: block;
  margin-bottom: 6px;
  color: #5f6b82;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: 1.45rem;
}

.action-row {
  margin-top: 18px;
}

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

.board-panel,
.player-card,
.rules-card {
  border-radius: 30px;
}

.board-panel {
  padding: 22px;
}

.board-shell {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 12px;
  border-radius: 30px;
  background:
    radial-gradient(circle at 22% 16%, rgba(255, 255, 255, 0.14), transparent 20%),
    linear-gradient(145deg, var(--board), var(--board-deep));
  overflow: hidden;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  gap: 8px;
}

.reversi-cell {
  position: relative;
  width: var(--cell-size);
  height: var(--cell-size);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), transparent 34%),
    linear-gradient(145deg, #2f9a6d, #206949);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.reversi-cell:hover:not(:disabled),
.reversi-cell:focus-visible:not(:disabled) {
  transform: translateY(-1px);
}

.reversi-cell:disabled {
  cursor: default;
}

.reversi-cell.valid-move {
  box-shadow: inset 0 0 0 2px rgba(215, 242, 203, 0.34);
}

.reversi-cell.last-move {
  box-shadow:
    inset 0 0 0 2px rgba(215, 242, 203, 0.28),
    0 0 0 2px rgba(255, 255, 255, 0.14);
}

.move-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(215, 242, 203, 0.82);
}

.reversi-disc {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  box-shadow: 0 10px 22px rgba(7, 14, 12, 0.2);
}

.reversi-disc.black {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 24%),
    radial-gradient(circle at 34% 28%, #4c544f 0, #1e2320 48%, #070809 100%);
}

.reversi-disc.white {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.76) 24%, rgba(255, 255, 255, 0) 26%),
    radial-gradient(circle at 34% 28%, #ffffff 0, #f3f2ec 54%, #d4d5cf 100%);
}

.reversi-sidebar {
  display: grid;
  gap: 16px;
}

.player-card,
.rules-card {
  padding: 18px;
}

.player-card.active {
  transform: translateY(-2px);
  box-shadow: 0 26px 52px rgba(3, 11, 24, 0.3);
}

.player-card.black {
  background:
    linear-gradient(145deg, rgba(31, 35, 32, 0.12), rgba(255, 255, 255, 0.86)),
    var(--panel);
}

.player-card.white {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(223, 234, 226, 0.9)),
    var(--panel);
}

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

.player-token {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 10px 22px rgba(7, 14, 12, 0.18);
}

.token-black {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 24%),
    radial-gradient(circle at 34% 28%, #4c544f 0, #1e2320 48%, #070809 100%);
}

.token-white {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.74) 24%, rgba(255, 255, 255, 0) 26%),
    radial-gradient(circle at 34% 28%, #ffffff 0, #f3f2ec 54%, #d4d5cf 100%);
}

.player-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 900;
}

.player-role {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

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

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

.player-stats dt {
  margin: 0 0 6px;
  color: #69777a;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.player-stats dd {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 900;
}

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

.rules-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.72;
}

.result-overlay {
  position: absolute;
  inset: 18px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  border-radius: 28px;
  background: rgba(247, 251, 246, 0.94);
  border: 1px solid rgba(23, 38, 30, 0.08);
  text-align: center;
}

.result-overlay[hidden] {
  display: none;
}

.overlay-kicker {
  margin: 0;
  color: #5c6a66;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.result-overlay h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
}

.overlay-message {
  margin: 0;
  max-width: 38ch;
  color: #5c6a66;
  line-height: 1.7;
}

.overlay-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.overlay-stats span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(23, 38, 30, 0.08);
  color: #314340;
  font-weight: 800;
}

@media (max-width: 1060px) {
  .reversi-hero,
  .reversi-layout {
    grid-template-columns: 1fr;
  }

  .reversi-copy h1 {
    max-width: 14ch;
  }
}

@media (max-width: 760px) {
  .reversi-app {
    width: min(100%, calc(100% - 20px));
    padding: 18px 0 34px;
  }

  .reversi-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .reversi-topbar-actions {
    width: 100%;
  }

  .metric-grid,
  .player-stats {
    grid-template-columns: 1fr;
  }

  .reversi-return,
  .reversi-support,
  .action-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .reversi-app {
    width: calc(100% - 16px);
  }

  .board-panel,
  .reversi-controls-panel,
  .player-card,
  .rules-card {
    padding-left: 14px;
    padding-right: 14px;
  }

  .board-shell {
    padding: 8px;
  }
}
