/* Intransitive: design tokens */

:root {
  --bg: #f4efe6;
  --bg-2: #ebe3d3;
  --surface: #fffdf9;
  --surface-2: #f6f1e7;
  --text: #1e1b16;
  --muted: #6b655b;
  --border: #e3dac9;
  --accent: #2f6ee8;
  --accent-ink: #ffffff;
  --blue: #3a7bff;
  --blue-deep: #1f4fc9;
  --blue-soft: rgba(58, 123, 255, 0.16);
  --red: #f0524f;
  --red-deep: #c42b2b;
  --red-soft: rgba(240, 82, 79, 0.16);
  --cell-a: #f0e4c9;
  --cell-b: #d8c39a;
  --frame: #5b3f27;
  --frame-2: #7a573a;
  --ring-wash: rgba(47, 110, 232, 0.16);
  --dot: rgba(30, 27, 22, 0.28);
  --ok: #2e8f5b;
  --warn: #b7791f;
  --gold: #e0a83a;
  --shadow: 0 1px 2px rgba(30, 24, 16, 0.06), 0 10px 30px rgba(30, 24, 16, 0.08);
  --shadow-lg: 0 20px 60px rgba(30, 24, 16, 0.22);
  --radius: 16px;
  --font-display: "Outfit", "Manrope", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1116;
  --bg-2: #161a22;
  --surface: #1a1f2a;
  --surface-2: #212735;
  --text: #eaedf3;
  --muted: #98a0b1;
  --border: #2b3242;
  --accent: #6b9cff;
  --accent-ink: #0d1322;
  --blue: #4a86ff;
  --blue-deep: #2a5be0;
  --blue-soft: rgba(74, 134, 255, 0.2);
  --red: #ff5f5c;
  --red-deep: #c93232;
  --red-soft: rgba(255, 95, 92, 0.2);
  --cell-a: #5a5361;
  --cell-b: #423c4a;
  --frame: #221e28;
  --frame-2: #332d3b;
  --ring-wash: rgba(107, 156, 255, 0.2);
  --dot: rgba(234, 237, 243, 0.32);
  --ok: #5fc48a;
  --warn: #e0a94a;
  --gold: #f0be55;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, var(--blue-soft), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, var(--red-soft), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}

a {
  color: var(--accent);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 0.5em;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 800;
}

h2 {
  font-size: 1.45rem;
  margin-top: 1.6em;
}

h3 {
  font-size: 1.1rem;
  margin-top: 1.2em;
}

p {
  margin: 0 0 1em;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

button, select, textarea, input {
  font: inherit;
  color: inherit;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.9rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(47, 110, 232, 0.12);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn:focus-visible, .cell:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 2px;
}

.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 90%, #fff), var(--accent));
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(47, 110, 232, 0.3);
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
  box-shadow: none;
}

.btn.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.88rem;
  border-radius: 10px;
}

.btn.icon {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border-radius: 12px;
}

.btn.icon svg, .btn svg {
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.btn[aria-pressed="true"] {
  background: var(--blue-soft);
  border-color: var(--accent);
  color: var(--text);
}

.btn.big {
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
  border-radius: 14px;
}

select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
}

textarea {
  width: 100%;
  min-height: 7rem;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px;
  padding: 0.7rem;
  resize: vertical;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}

.seg button {
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.seg button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Header */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.2rem;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.wordmark .logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.tabs {
  display: flex;
  gap: 0.1rem;
  margin-left: 0.4rem;
}

.tabs a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.tabs a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tabs a.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border), var(--shadow);
}

.top-right {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.4rem 1.2rem 5rem;
}

.view[hidden] {
  display: none;
}

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.card > h2, .card-title {
  font-family: var(--font-body);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 0.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-title .btn {
  text-transform: none;
  letter-spacing: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.row.between {
  justify-content: space-between;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

/* Home */

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2.5rem;
  align-items: center;
  padding: 2.5rem 0 2rem;
}

.hero h1 {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  margin-bottom: 0.4rem;
  line-height: 1.02;
}

.hero .lead {
  font-size: 1.2rem;
  color: var(--muted);
  max-width: 34rem;
}

.hero .cta {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-top: 1.4rem;
}

.hero-meta {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  margin-top: 1.6rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-meta strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.15rem;
  display: block;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.8rem;
}

.demo-wrap {
  position: relative;
  max-width: 460px;
  margin: 0 auto;
  width: 100%;
}

.demo-caption {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.6rem;
}

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0 2.5rem;
}

.feature {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.feature:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.feature .icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--accent);
}

.feature .icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.feature h3 {
  margin: 0.2rem 0 0;
}

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

.feature .go {
  margin-top: auto;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.92rem;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0 0.4rem;
}

.section-head h2 {
  margin: 0;
}

/* Play layout */

.play-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.matchup {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem 0.35rem 0.5rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.matchup .vs {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

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

.board-column {
  position: relative;
  max-width: 700px;
}

.board-frame {
  display: grid;
  grid-template-columns: 14px 1.3rem minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 1.3rem;
  gap: 0.35rem 0.4rem;
  user-select: none;
  -webkit-user-select: none;
}

.eval-bar {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.eval-bar .fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: linear-gradient(180deg, var(--blue), var(--blue-deep));
  transition: height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.eval-bar .mid {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: rgba(255, 255, 255, 0.55);
}

.eval-bar[hidden] {
  display: none !important;
}

.ranks, .files {
  display: grid;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ranks {
  grid-column: 2;
  grid-row: 1;
  grid-template-rows: repeat(9, 1fr);
}

.ranks span {
  display: grid;
  place-items: center;
}

.files {
  grid-column: 3;
  grid-row: 2;
  grid-template-columns: repeat(9, 1fr);
}

.files span {
  text-align: center;
}

.board-area {
  grid-column: 3;
  grid-row: 1;
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
}

.board {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 0 5px var(--frame), 0 0 0 6px var(--frame-2), 0 16px 40px rgba(0, 0, 0, 0.28);
  background: var(--cell-a);
}

.board.dragging {
  cursor: grabbing;
}

.cell {
  position: relative;
  border: 0;
  padding: 0;
  margin: 0;
  background: var(--cell-a);
  display: grid;
  place-items: center;
  font-family: inherit;
  cursor: default;
  min-width: 0;
  min-height: 0;
}

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

.cell.home-blue {
  background: color-mix(in srgb, var(--blue) 28%, var(--cell-a));
}

.cell.home-red {
  background: color-mix(in srgb, var(--red) 28%, var(--cell-a));
}

.cell.home-blue::before, .cell.home-red::before {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  border: 2px dashed currentColor;
  opacity: 0.4;
  pointer-events: none;
}

.cell.home-blue::before {
  color: var(--blue-deep);
}

.cell.home-red::before {
  color: var(--red-deep);
}

.cell.last {
  box-shadow: inset 0 0 0 100px rgba(255, 196, 0, 0.26);
}

.cell.ring-odd {
  box-shadow: inset 0 0 0 100px var(--ring-wash);
}

.cell.ring-odd.last {
  box-shadow: inset 0 0 0 100px rgba(255, 196, 0, 0.26), inset 0 0 0 100px var(--ring-wash);
}

.cell.selected {
  box-shadow: inset 0 0 0 4px var(--accent);
}

.cell.hint-from {
  box-shadow: inset 0 0 0 100px rgba(47, 110, 232, 0.28);
}

.cell.hint-to {
  box-shadow: inset 0 0 0 4px var(--accent), inset 0 0 0 100px rgba(47, 110, 232, 0.18);
}

.cell.target::after {
  content: "";
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--dot);
  pointer-events: none;
  transform: scale(0.6);
  animation: pop-in 0.16s ease forwards;
}

.cell.capture::after {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  border: 4px solid var(--dot);
  background: transparent;
  width: auto;
  height: auto;
  pointer-events: none;
  animation: pop-in 0.16s ease forwards;
}

.cell.drop-hover {
  box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--accent) 85%, #fff);
}

.cell.attacked::before {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 3px solid var(--red);
  opacity: 0.9;
  pointer-events: none;
  animation: pulse 1.4s ease-in-out infinite;
  z-index: 2;
}

.cell.threat::before {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 3px solid var(--ok);
  opacity: 0.9;
  pointer-events: none;
  z-index: 2;
}

.cell.mark-ok {
  box-shadow: inset 0 0 0 3px var(--ok);
}

.cell.mark-no {
  box-shadow: inset 0 0 0 3px var(--red);
}

.cell.mark-no::after {
  content: "";
  position: absolute;
  inset: 30%;
  background:
    linear-gradient(45deg, transparent 44%, var(--red) 44%, var(--red) 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--red) 44%, var(--red) 56%, transparent 56%);
  pointer-events: none;
}

.cell.mark-path {
  box-shadow: inset 0 0 0 100px rgba(46, 143, 91, 0.28);
}

.cell.mark-danger {
  box-shadow: inset 0 0 0 100px rgba(240, 82, 79, 0.3);
}

.cell.mark-goal {
  box-shadow: inset 0 0 0 3px var(--ok);
}

.cell.flash {
  animation: flash 0.4s ease;
}

.ringno {
  position: absolute;
  left: 5px;
  bottom: 3px;
  font-size: clamp(8px, 1.1vw, 11px);
  font-weight: 700;
  opacity: 0.6;
  pointer-events: none;
  line-height: 1;
}

.label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: clamp(11px, 2vw, 18px);
  opacity: 0.8;
  pointer-events: none;
}

/* Pieces */

.piece {
  --p-hi: #9ab9ff;
  --p-base: #3a7bff;
  --p-deep: #1f4fc9;
  position: relative;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 36% 30%, var(--p-hi) 0%, var(--p-base) 48%, var(--p-deep) 100%);
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.16), inset 0 2px 0 rgba(255, 255, 255, 0.28);
  z-index: 1;
  transition: transform 0.15s ease, opacity 0.15s ease;
  touch-action: none;
}

.piece.blue {
  --p-hi: #9ab9ff;
  --p-base: var(--blue);
  --p-deep: var(--blue-deep);
}

.piece.red {
  --p-hi: #ffb0ae;
  --p-base: var(--red);
  --p-deep: var(--red-deep);
}

.piece svg {
  width: 60%;
  height: 60%;
  fill: none;
  stroke: #fff;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.cell.draggable {
  cursor: grab;
}

.cell.draggable:hover .piece {
  transform: translateY(-2px) scale(1.05);
}

.piece.lifted {
  opacity: 0.3;
}

.piece.ghost {
  opacity: 0.4;
}

.piece.captured-anim {
  position: absolute;
  z-index: 0;
  animation: capture-out 0.42s ease forwards;
  pointer-events: none;
}

.drag-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  overflow: visible;
}

.drag-ghost {
  position: absolute;
  transform: translate(-50%, -50%) scale(1.15);
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

.arrows path {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 85%, #fff);
  stroke-width: 0.16;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.arrows path.head {
  fill: color-mix(in srgb, var(--accent) 85%, #fff);
  stroke: none;
}

.arrows .best path {
  stroke: var(--ok);
}

.arrows .best path.head {
  fill: var(--ok);
}

.board.diagram .cell {
  cursor: default;
}

.board-frame.compact {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.board-frame.compact .ranks, .board-frame.compact .files, .board-frame.compact .eval-bar {
  display: none;
}

.board-frame.compact .board-area {
  grid-column: 1;
  grid-row: 1;
}

.board-frame.compact .board {
  box-shadow: 0 0 0 3px var(--frame), 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* Result overlay */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 12, 16, 0.4);
  border-radius: 10px;
  z-index: 9;
  backdrop-filter: blur(2px);
  animation: fade-in 0.25s ease;
}

.overlay .card {
  text-align: center;
  padding: 1.4rem 1.6rem;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.overlay .card h3 {
  margin: 0 0 0.3rem;
  font-size: 1.5rem;
}

.overlay .card p {
  color: var(--muted);
  margin-bottom: 1rem;
}

.overlay .card .row {
  justify-content: center;
}

.board-dim {
  filter: saturate(0.6) brightness(0.92);
}

/* Panel */

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

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

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

.dot.none {
  background: var(--muted);
}

.dot.thinking {
  animation: pulse 1s ease-in-out infinite;
}

.players {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid transparent;
}

.player-row.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}

.player-row .name {
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.counts-inline {
  display: flex;
  gap: 0.45rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9rem;
}

.counts-inline span {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.counts-inline .mini {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.counts-inline .mini.blue {
  background: var(--blue);
}

.counts-inline .mini.red {
  background: var(--red);
}

.counts-inline .mini svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.counts-inline .zero {
  color: var(--red);
}

.counts-inline .low {
  color: var(--warn);
}

.notice {
  font-size: 0.88rem;
  color: var(--warn);
  margin-top: 0.4rem;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
}

.actions .btn {
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.55rem 0.3rem;
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: 12px;
}

.actions .btn svg {
  width: 1.3rem;
  height: 1.3rem;
}

.moves-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow: auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.93rem;
  display: grid;
  grid-template-columns: 2.2rem 1fr 1fr;
  align-content: start;
}

.moves-list .num {
  color: var(--muted);
  padding: 0.15rem 0.2rem;
}

.moves-list .mv {
  padding: 0.15rem 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
}

.moves-list .mv:hover {
  background: var(--surface-2);
}

.moves-list .mv.current {
  background: var(--blue-soft);
  font-weight: 700;
}

.moves-list .mv.cap {
  font-weight: 600;
}

.moves-list .empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.3rem 0.2rem;
}

.q {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  flex: none;
}

.q.best {
  background: var(--ok);
}

.q.good {
  background: #4b8ac9;
}

.q.inacc {
  background: var(--warn);
}

.q.mistake {
  background: #d97a2b;
}

.q.blunder {
  background: var(--red);
}

.review-bar {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  margin-top: 0.6rem;
}

.review-bar .btn {
  flex: 1;
  padding: 0.35rem;
}

.review-status {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.4rem;
  min-height: 1.2em;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  text-align: center;
}

.stat {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.6rem 0.3rem;
}

.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.1;
}

.stat span {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}

.badge.earned {
  background: color-mix(in srgb, var(--gold) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--gold) 60%, var(--border));
  color: var(--text);
}

.badge svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tip {
  font-size: 0.95rem;
  line-height: 1.5;
}

.tip strong {
  font-family: var(--font-display);
}

.banner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--blue-soft), transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  margin-bottom: 1rem;
}

.banner p {
  margin: 0;
  flex: 1;
}

/* Dialogs */

dialog {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  padding: 1.4rem;
  max-width: 460px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(10, 12, 16, 0.5);
  backdrop-filter: blur(3px);
}

dialog h2 {
  margin-top: 0;
  font-size: 1.4rem;
}

dialog.wide {
  max-width: 720px;
}

.error {
  color: var(--red);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.field > span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.choice {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.choice strong {
  font-family: var(--font-display);
}

.choice span {
  font-size: 0.78rem;
  color: var(--muted);
}

.choice.active {
  border-color: var(--accent);
  background: var(--blue-soft);
}

.choice .dot {
  width: 12px;
  height: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tutorial-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 1.2rem;
  align-items: start;
}

.tutorial-progress {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.tutorial-progress i {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
}

.tutorial-progress i.done {
  background: var(--accent);
}

.keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  align-items: center;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border);
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  pointer-events: none;
  max-width: calc(100% - 2rem);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.badge-toast {
  background: linear-gradient(90deg, var(--gold), #f6d27a);
  color: #2a1e05;
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

/* Learn pages */

.prose {
  max-width: 720px;
}

.prose p, .prose li {
  font-size: 1.02rem;
}

.lead {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 720px;
}

.figure-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
  margin: 1.2rem 0 1.8rem;
  max-width: 920px;
}

figure {
  margin: 0;
}

figure .board-frame {
  max-width: 320px;
}

figcaption {
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.6rem;
  max-width: 320px;
}

.callout {
  border-left: 4px solid var(--accent);
  background: var(--surface);
  padding: 0.8rem 1rem;
  border-radius: 0 12px 12px 0;
  margin: 1rem 0 1.4rem;
  max-width: 720px;
}

.video {
  position: relative;
  aspect-ratio: 16 / 9;
  max-width: 720px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #000;
  margin: 1rem 0 1.5rem;
}

.video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  max-width: 820px;
  margin: 1rem 0;
}

.links a.card {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.links a.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.links .card strong {
  display: block;
  margin-bottom: 0.2rem;
  font-family: var(--font-display);
}

/* Puzzles */

.puzzle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.4rem;
  align-items: start;
}

.puzzle-nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.puzzle-nav .btn {
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  position: relative;
}

.puzzle-nav .btn.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.puzzle-nav .btn.solved::after {
  content: "";
  position: absolute;
  right: -3px;
  top: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--surface);
}

.feedback {
  min-height: 3em;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 0.95rem;
}

.feedback.good {
  background: color-mix(in srgb, var(--ok) 16%, var(--surface-2));
}

.feedback.bad {
  background: color-mix(in srgb, var(--red) 14%, var(--surface-2));
}

.progress {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width 0.4s ease;
}

.daily {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
}

footer {
  border-top: 1px solid var(--border);
  padding: 1.4rem 1.2rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.bottom-nav {
  display: none;
}

/* Animations */

@keyframes pop-in {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@keyframes flash {
  0% { box-shadow: inset 0 0 0 100px rgba(240, 82, 79, 0.6); }
  100% { box-shadow: inset 0 0 0 100px rgba(240, 82, 79, 0); }
}

@keyframes capture-out {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(1.15); opacity: 0.9; }
  100% { transform: scale(0.2); opacity: 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise {
  from { transform: translateY(14px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.3s ease;
}

/* Responsive */

@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.6rem;
    padding-top: 1.4rem;
  }
  .features {
    grid-template-columns: 1fr;
  }
  .play-layout, .puzzle-layout, .tutorial-layout {
    grid-template-columns: 1fr;
  }
  .board-column {
    max-width: 100%;
  }
  .tabs {
    display: none;
  }
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    min-width: 3.6rem;
  }
  .bottom-nav a svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .bottom-nav a.active {
    color: var(--accent);
    background: var(--blue-soft);
  }
  main {
    padding: 1rem 0.9rem 6rem;
  }
}

@media (max-width: 560px) {
  .top {
    padding: 0.5rem 0.8rem;
  }
  h1 {
    font-size: 1.8rem;
  }
  .hero h1 {
    font-size: 2.4rem;
  }
  .actions {
    grid-template-columns: repeat(4, 1fr);
  }
  .board-frame {
    grid-template-columns: 10px 1rem minmax(0, 1fr);
    gap: 0.25rem 0.3rem;
  }
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .choice-grid {
    grid-template-columns: 1fr;
  }
  dialog {
    padding: 1.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}

/* Strategy guide */

.guide {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 2.2rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: 4.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem;
}

.toc a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border-left: 3px solid transparent;
}

.toc a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--blue-soft);
}

.toc .toc-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 0.2rem 0.6rem 0.5rem;
}

.chapter {
  scroll-margin-top: 4.6rem;
  padding-bottom: 1.6rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}

.chapter:last-child {
  border-bottom: 0;
}

.chapter h2 {
  margin-top: 0.4rem;
  font-size: 1.6rem;
}

.chapter .kicker {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.rule {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  background: linear-gradient(90deg, var(--blue-soft), transparent 70%);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 14px;
  padding: 0.8rem 1rem;
  margin: 1rem 0 1.2rem;
  max-width: 720px;
}

.rule .rule-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  flex: none;
  font-family: var(--font-display);
  font-weight: 800;
}

.rule p {
  margin: 0;
}

.rule strong {
  font-family: var(--font-display);
}

.cheat {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
  margin: 1rem 0 1.4rem;
}

.cheat .card {
  padding: 0.8rem 0.9rem;
}

.cheat .card strong {
  display: block;
  font-family: var(--font-display);
  margin-bottom: 0.2rem;
}

.cheat .card p {
  margin: 0;
  font-size: 0.93rem;
  color: var(--muted);
}

.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin: 1.2rem 0 1.6rem;
  max-width: 820px;
}

.widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.widget-head h3 {
  margin: 0;
  font-size: 1rem;
}

.widget-tag {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.widget-tag.lab {
  background: var(--ok);
}

.widget-tag.quiz {
  background: var(--warn);
}

.widget-body {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 1.2rem;
  align-items: start;
}

.widget-body.single {
  grid-template-columns: 1fr;
}

.widget-body .board-frame {
  max-width: 320px;
}

.line-caption {
  min-height: 4.2em;
  font-size: 0.98rem;
  line-height: 1.5;
}

.line-move {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.3rem;
  min-height: 1.3em;
}

.line-controls {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}

.line-controls .btn {
  padding: 0.4rem 0.6rem;
}

.line-steps {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.6rem;
}

.line-steps i {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
}

.line-steps i.done {
  background: var(--accent);
}

.lab-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.7rem;
}

.lab-palette .pal {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.lab-palette .pal.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.lab-palette .pal .piece {
  width: 28px;
  height: 28px;
  position: static;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.lab-palette .pal svg.erase {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.lab-verdict {
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  background: var(--surface-2);
  font-weight: 600;
  min-height: 3em;
  margin-top: 0.6rem;
}

.lab-verdict.blue {
  background: var(--blue-soft);
}

.lab-verdict.red {
  background: var(--red-soft);
}

.lab-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.6rem 0;
}

.quiz-options .btn {
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
  line-height: 1.35;
}

.quiz-options .btn.right {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 16%, var(--surface));
}

.quiz-options .btn.wrong {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 12%, var(--surface));
}

.quiz-explain {
  font-size: 0.95rem;
  color: var(--muted);
  min-height: 1.4em;
}

.ring-legend {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.6rem;
}

.matchup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  max-width: 720px;
  margin: 0.6rem 0 1.4rem;
}

.matchup-table th, .matchup-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.matchup-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 1.2rem;
  max-width: 720px;
  counter-reset: step;
}

.checklist li {
  position: relative;
  padding: 0.6rem 0.8rem 0.6rem 3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.45rem;
}

.checklist li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0.8rem;
  top: 0.6rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.checklist strong {
  font-family: var(--font-display);
}

.glossary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.6rem 1.2rem;
  max-width: 820px;
  margin: 0.6rem 0;
}

.glossary div {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.glossary dt {
  font-family: var(--font-display);
  font-weight: 700;
}

.glossary dd {
  margin: 0.15rem 0 0;
  font-size: 0.93rem;
  color: var(--muted);
}

.endgames {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.9rem;
  margin: 1rem 0 1.4rem;
  max-width: 920px;
}

.endgames .card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.endgames .board-frame {
  max-width: 100%;
}

.endgames h4 {
  margin: 0.2rem 0 0;
}

.endgames p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  flex: 1;
}

.next-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  font-weight: 700;
  text-decoration: none;
}

.opening-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
  max-width: 720px;
  margin: 0.6rem 0 1rem;
}

.opening-list .card {
  padding: 0.6rem 0.8rem;
}

.opening-list strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  display: block;
}

.opening-list span {
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 960px) {
  .guide {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .toc {
    position: sticky;
    top: 3.4rem;
    z-index: 10;
    flex-direction: row;
    overflow-x: auto;
    gap: 0.3rem;
    padding: 0.4rem 0.2rem;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 0;
    border: 0;
    box-shadow: none;
    scrollbar-width: none;
  }
  .toc .toc-title {
    display: none;
  }
  .toc a {
    white-space: nowrap;
    border-left: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
  }
  .toc a.active {
    border-color: var(--accent);
  }
  .widget-body {
    grid-template-columns: 1fr;
  }
  .widget-body .board-frame {
    max-width: 360px;
  }
}

/* Puzzle page additions */

.puzzle-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.chip-count {
  font-size: 0.72rem;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}

.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 0.3rem;
  max-height: 260px;
  overflow: auto;
  padding: 2px;
}

.pg {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  position: relative;
  color: var(--muted);
  padding: 0;
}

.pg:hover {
  border-color: var(--accent);
  color: var(--text);
}

.pg.solved {
  background: color-mix(in srgb, var(--ok) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--ok) 50%, var(--border));
  color: var(--text);
}

.pg.current {
  outline: 3px solid var(--accent);
  outline-offset: -1px;
  color: var(--text);
}

.pg.daily::after {
  content: "";
  position: absolute;
  right: -3px;
  top: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--surface);
}

.puzzle-theme {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.puzzle-diffdots {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--warn);
}

.rush-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}

.rush-label {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: var(--accent);
}

.rush-time {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
}

.rush-score strong {
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.rush-strikes {
  color: var(--red);
  font-weight: 800;
  letter-spacing: 0.2em;
  margin-left: auto;
}

/* Ratings */

.stat {
  position: relative;
}

.stat-sub {
  display: block;
  font-style: normal;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.1rem;
  min-height: 0.9em;
}

.spark {
  width: 100%;
  height: 44px;
  margin-top: 0.6rem;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spark circle {
  fill: var(--accent);
  stroke: none;
}

.rating-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}

/* Players and leaderboard */

.name-input {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 120px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
  background: var(--surface);
}

.name-input input {
  border: 0;
  background: transparent;
  width: 100%;
  min-width: 0;
  outline: none;
}

.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 1.4rem 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.92rem;
}

.leaderboard .lb-rank {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--muted);
}

.leaderboard .lb-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard .lb-rec {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.leaderboard strong {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
}

/* Clocks, online, coach, report, settings, themes */

.clock {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.15rem 0.5rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-left: 0.4rem;
}

.clock.running {
  border-color: var(--accent);
  background: var(--blue-soft);
}

.clock.low {
  color: var(--red);
}

.link-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.top-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.top-list span {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.2rem 0.5rem;
  font-weight: 700;
}

.top-list span.best {
  background: color-mix(in srgb, var(--ok) 18%, var(--surface-2));
}

.top-list em {
  font-style: normal;
  color: var(--muted);
  font-weight: 600;
}

.arrows .alt path {
  stroke: color-mix(in srgb, var(--accent) 60%, transparent);
}

.arrows .alt path.head {
  fill: color-mix(in srgb, var(--accent) 60%, transparent);
}

.coach-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.93rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.eval-graph {
  width: 100%;
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  display: block;
  cursor: pointer;
}

.eval-graph .eg-red {
  fill: color-mix(in srgb, var(--red) 55%, var(--surface));
}

.eval-graph .eg-blue {
  fill: color-mix(in srgb, var(--blue) 60%, var(--surface));
}

.eval-graph .eg-line {
  fill: none;
  stroke: #fff;
  stroke-width: 1.5;
}

.eval-graph .eg-mid {
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.eval-graph .eg-cursor {
  stroke: var(--gold);
  stroke-width: 2;
}

.eval-graph .eg-pt {
  fill: transparent;
}

.eval-graph .eg-pt:hover {
  fill: rgba(255, 255, 255, 0.5);
}

.report-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.92rem;
}

.rep-side {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.6rem;
  background: var(--surface-2);
  border-radius: 10px;
}

.rep-acc {
  font-family: var(--font-display);
  font-weight: 800;
}

.rep-turn {
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 16%, var(--surface-2));
}

.daily-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.daily-strip {
  display: inline-flex;
  gap: 3px;
}

.daily-strip i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--border);
}

.daily-strip i.done {
  background: var(--ok);
}

.theme-chip {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--border);
  padding: 0;
  cursor: pointer;
  background: linear-gradient(135deg, var(--ta) 50%, var(--tb) 50%);
  box-shadow: inset 0 0 0 3px var(--tf);
}

.theme-chip.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--tf), 0 0 0 3px var(--blue-soft);
}

/* Board themes */

:root[data-board="slate"] {
  --cell-a: #cfd6e0;
  --cell-b: #8d9bb0;
  --frame: #2c3442;
  --frame-2: #414c5e;
}

:root[data-board="forest"] {
  --cell-a: #e8e6d5;
  --cell-b: #7a9a6d;
  --frame: #2f4a2a;
  --frame-2: #476b40;
}

:root[data-board="sand"] {
  --cell-a: #f6ecd8;
  --cell-b: #e2c99a;
  --frame: #a3763c;
  --frame-2: #c5955a;
}

:root[data-board="ocean"] {
  --cell-a: #dbe9f2;
  --cell-b: #7fa8c9;
  --frame: #1f3a55;
  --frame-2: #2f5378;
}

:root[data-theme="dark"][data-board="slate"] {
  --cell-a: #5c6675;
  --cell-b: #3c4453;
  --frame: #1a1f28;
  --frame-2: #2a313c;
}

:root[data-theme="dark"][data-board="forest"] {
  --cell-a: #5b6b52;
  --cell-b: #3c4d36;
  --frame: #1e2b1b;
  --frame-2: #2d4028;
}

:root[data-theme="dark"][data-board="sand"] {
  --cell-a: #7a6a4e;
  --cell-b: #5b4d36;
  --frame: #3a2c17;
  --frame-2: #55411f;
}

:root[data-theme="dark"][data-board="ocean"] {
  --cell-a: #4f6b82;
  --cell-b: #34495e;
  --frame: #15222f;
  --frame-2: #223547;
}

:root[data-pieces="letters"] .piece svg {
  display: none;
}

:root[data-pieces="letters"] .piece::after {
  content: attr(data-letter);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(11px, 2.6vw, 22px);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

:root[data-motion="off"] .piece, :root[data-motion="off"] .cell, :root[data-motion="off"] .overlay {
  transition: none !important;
  animation: none !important;
}

/* Accessibility */

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 0.9rem;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0.6rem;
}

main:focus {
  outline: none;
}

.ringno {
  font-size: clamp(9px, 1.1vw, 12px);
}

.chip {
  min-height: 36px;
}

.q.good {
  background: #3a6fb0;
}

.q.inacc {
  background: #e0a83a;
  color: #2a1e05;
}

.q.mistake {
  background: #e08a3c;
  color: #2a1e05;
}

.q.blunder {
  background: #c42b2b;
}

.cell.threat::before {
  border-style: dashed;
}

:root[data-palette="friendly"] {
  --red: #f28c28;
  --red-deep: #b85f0a;
  --red-soft: rgba(242, 140, 40, 0.18);
}

:root[data-palette="friendly"] .piece.red {
  --p-hi: #ffc48a;
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.16), inset 0 0 0 3px rgba(255, 255, 255, 0.75);
}

:root[data-palette="friendly"] .piece.blue {
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.16), inset 0 2px 0 rgba(255, 255, 255, 0.28);
}

:root[data-palette="friendly"] .dot.red, :root[data-palette="friendly"] .counts-inline .mini.red {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75);
}

@media (max-width: 960px) {
  .btn.small, .review-bar .btn, .btn.ghost.small {
    min-height: 38px;
  }
  .moves-list .mv {
    min-height: 34px;
  }
  .tutorial-progress i {
    height: 8px;
  }
}

.image-preview {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: block;
  background: var(--surface-2);
}

/* Tooltips, tour, guide line, collapsible cards, grouped tools */

.tooltip {
  position: fixed;
  z-index: 200;
  max-width: 260px;
  background: var(--text);
  color: var(--bg);
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.4;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}

.tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.tooltip::after {
  content: "";
  position: absolute;
  left: var(--arrow-x, 50%);
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: var(--text);
  transform: translateX(-50%) rotate(45deg);
}

.tooltip.below::after {
  bottom: auto;
  top: -5px;
}

.board-hint {
  margin: 0.6rem 0 0;
  font-size: 0.92rem;
  color: var(--muted);
  min-height: 1.4em;
  text-align: center;
}

.board-hint strong {
  color: var(--text);
}

.cell.preview::after {
  content: "";
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: var(--dot);
  opacity: 0.45;
  pointer-events: none;
}

.action-group {
  margin-bottom: 0.6rem;
}

.action-group:last-child {
  margin-bottom: 0;
}

.group-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.collapsible > h2 {
  margin-bottom: 0;
}

.collapsible.open > h2 {
  margin-bottom: 0.7rem;
}

.collapse-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.chev {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin-left: 2px;
}

.collapsible.open .chev {
  transform: rotate(45deg);
}

.collapsible:not(.open) .collapse-body {
  display: none;
}

.tour {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(10, 12, 16, 0.55);
}

.tour[hidden] {
  display: none;
}

body.touring .tour-target {
  position: relative;
  z-index: 151;
  box-shadow: 0 0 0 4px var(--accent), 0 0 0 9999px rgba(10, 12, 16, 0.55);
  border-radius: 14px;
}

.tour-callout {
  position: fixed;
  z-index: 152;
  width: min(360px, calc(100vw - 20px));
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-lg);
  transition: top 0.25s ease, left 0.25s ease;
}

.tour-step {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.tour-callout h3 {
  margin: 0.2rem 0 0.3rem;
}

.tour-callout p {
  margin: 0 0 0.8rem;
  font-size: 0.95rem;
}

.tour-callout .row {
  justify-content: flex-end;
}

/* Daily teaser on the home page */

.daily-teaser {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1.4rem;
  align-items: center;
  margin: 0.6rem 0 2rem;
  max-width: 920px;
}

.daily-teaser-board .board-frame {
  max-width: 300px;
}

@media (max-width: 720px) {
  .daily-teaser {
    grid-template-columns: 1fr;
  }
  .daily-teaser-board .board-frame {
    max-width: 100%;
  }
}
