:root {
  --bg: #f4efe3;
  --ink: #11243b;
  --muted: #526170;
  --surface: rgba(255, 251, 244, 0.8);
  --surface-strong: #fffaf2;
  --line: rgba(17, 36, 59, 0.12);
  --gold: #f2a84b;
  --coral: #ee6c4d;
  --teal: #2a9d8f;
  --navy: #17324d;
  --light-square: #f8ead3;
  --dark-square: #be7d42;
  --board-border: rgba(23, 50, 77, 0.16);
  --selection: rgba(42, 157, 143, 0.8);
  --target: rgba(238, 108, 77, 0.82);
  --correct: #1f9d72;
  --wrong: #d44d3d;
  --shadow: 0 22px 60px rgba(20, 37, 61, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at top left, rgba(242, 168, 75, 0.25), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(42, 157, 143, 0.2), transparent 26%),
    linear-gradient(180deg, #f4efe3 0%, #efe3cb 100%);
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
}

button,
a {
  font: inherit;
}

.page-shell {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  padding: 32px 20px 48px;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.45;
  pointer-events: none;
}

.ambient-a {
  top: 40px;
  right: -40px;
  width: 240px;
  height: 240px;
  background: rgba(242, 168, 75, 0.35);
}

.ambient-b {
  left: -60px;
  bottom: 120px;
  width: 260px;
  height: 260px;
  background: rgba(42, 157, 143, 0.22);
}

.ambient-c {
  top: 48%;
  left: 48%;
  width: 180px;
  height: 180px;
  background: rgba(238, 108, 77, 0.14);
}

.hero,
.layout {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
}

.hero {
  margin-bottom: 28px;
}

.hero-bar {
  display: flex;
  gap: 18px;
  align-items: start;
  justify-content: space-between;
}

.eyebrow,
.label {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1,
.board-topline h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: 0.96;
}

.hero h1 {
  max-width: 10ch;
  font-size: clamp(3.3rem, 8vw, 6.6rem);
}

.hero-copy {
  max-width: 40rem;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.hero-actions,
.control-row,
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-actions {
  margin-top: 22px;
}

.settings-cog {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--navy);
  box-shadow: 0 12px 28px rgba(23, 50, 77, 0.14);
  font-size: 1.7rem;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background-color 180ms ease;
}

.settings-cog:hover {
  transform: translateY(-1px) rotate(8deg);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 20px;
  align-items: start;
}

.surface {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.board-panel,
.meta-card,
.move-card,
.note-card {
  padding: 22px;
}

.board-topline,
.card-heading {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.board-topline h2 {
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.spoiler-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.button:hover,
.pill-button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
  box-shadow: none;
}

.button-primary {
  background: var(--navy);
  color: #fffaf3;
  box-shadow: 0 10px 24px rgba(23, 50, 77, 0.25);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  border: 1px solid rgba(17, 36, 59, 0.08);
}

.button-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(17, 36, 59, 0.16);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(23, 50, 77, 0.08);
  color: var(--navy);
  font-size: 0.92rem;
  font-weight: 700;
}

.pill-button {
  border: 0;
  cursor: pointer;
}

.board-wrap {
  margin-top: 18px;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(100%, 760px);
  aspect-ratio: 1 / 1;
  border-radius: 26px;
  overflow: hidden;
  border: 10px solid var(--board-border);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 20px 45px rgba(23, 50, 77, 0.18);
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  user-select: none;
}

.square.light {
  background: var(--light-square);
}

.square.dark {
  background: var(--dark-square);
}

.board[data-piece-style="classic"] .piece-shell {
  width: min(72%, 56px);
  filter: none;
}

.board[data-piece-style="classic"] .piece-disc {
  display: none;
}

.board[data-piece-style="classic"] .piece-glyph {
  font-size: 42px;
}

.board[data-piece-style="glass"] .piece-shell.white .piece-disc {
  fill: rgba(255, 255, 255, 0.34);
}

.board[data-piece-style="glass"] .piece-shell.black .piece-disc {
  fill: rgba(9, 30, 49, 0.34);
}

.board[data-piece-style="glass"] .piece-glyph {
  font-size: 36px;
}

.square.selected::after,
.square.target::after,
.square.last-move::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 18px;
  pointer-events: none;
}

.square.selected::after {
  border: 4px solid var(--selection);
}

.square.target::after {
  background: radial-gradient(circle, var(--target) 0 22%, transparent 24%);
}

.square.last-move::before {
  background: rgba(255, 255, 255, 0.18);
}

.piece-shell {
  display: block;
  width: min(78%, 62px);
  aspect-ratio: 1 / 1;
  filter: drop-shadow(0 5px 10px rgba(17, 36, 59, 0.16));
}

.piece-art {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.piece-disc {
  opacity: 0.92;
}

.piece-shell.white .piece-disc {
  fill: rgba(23, 50, 77, 0.18);
}

.piece-shell.black .piece-disc {
  fill: rgba(255, 247, 231, 0.2);
}

.piece-glyph {
  font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", "Arial Unicode MS", serif;
  font-size: 38px;
  font-weight: 700;
  paint-order: stroke fill;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.piece-shell.white .piece-glyph {
  fill: #fffdf7;
  stroke: #17324d;
}

.piece-shell.black .piece-glyph {
  fill: #17324d;
  stroke: #fff1da;
}

.coord-file,
.coord-rank {
  position: absolute;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.7;
  pointer-events: none;
}

.coord-file {
  right: 8px;
  bottom: 6px;
}

.coord-rank {
  top: 6px;
  left: 8px;
}

.status-strip {
  margin-top: 18px;
}

.status-message,
.hint-message,
.note-card p,
.fine-print {
  margin: 0;
  line-height: 1.6;
}

.status-message {
  font-size: 1rem;
  font-weight: 700;
}

.status-message.is-success {
  color: var(--correct);
}

.status-message.is-error {
  color: var(--wrong);
}

.hint-message {
  min-height: 1.6em;
  margin-top: 6px;
  color: var(--muted);
}

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

.info-panel {
  display: grid;
  gap: 20px;
}

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

.meta-grid div {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
}

.meta-grid dt {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.meta-grid dd {
  margin: 0;
  font-weight: 700;
}

.progress-copy {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.spoiler-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.spoiler-controls .button {
  min-height: 40px;
  padding: 0 16px;
}

.move-list {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.move-list li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.48);
}

.move-number {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.move-text {
  font-weight: 700;
}

.move-list li.pending {
  opacity: 0.5;
}

.move-list li.current {
  outline: 2px solid rgba(42, 157, 143, 0.32);
}

.move-list li.done {
  background: rgba(42, 157, 143, 0.14);
}

.move-list li.spoiler {
  background: rgba(255, 255, 255, 0.34);
}

.move-text.is-hidden {
  color: var(--muted);
  letter-spacing: 0.02em;
}

.move-text.is-revealed {
  color: var(--ink);
}

.note-card {
  background:
    linear-gradient(145deg, rgba(255, 250, 242, 0.9), rgba(255, 243, 229, 0.84));
}

.fine-print {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.settings-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 4;
  width: min(92vw, 360px);
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.settings-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.settings-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.settings-title {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 1.8rem;
}

.settings-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.setting-row,
.setting-block {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
}

.setting-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.setting-row span,
.setting-block span {
  font-weight: 700;
}

.setting-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.setting-block select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(17, 36, 59, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.settings-note {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

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

  .hero h1 {
    max-width: 100%;
  }

  .hero-bar {
    flex-direction: column;
  }

  .settings-cog {
    align-self: flex-end;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 20px 14px 32px;
  }

  .board-panel,
  .meta-card,
  .move-card,
  .note-card {
    padding: 18px;
  }

  .board-topline,
  .card-heading {
    flex-direction: column;
  }

  .settings-panel {
    top: 14px;
    right: 14px;
    left: 14px;
    width: auto;
  }

  .progress-copy {
    text-align: left;
  }

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

  .move-list li {
    grid-template-columns: 52px 1fr;
  }

  .piece-shell {
    width: min(82%, 58px);
  }

  .piece-glyph {
    font-size: 34px;
  }
}
