:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-strong: #eef3fa;
  --text: #202b3c;
  --muted: #6d7890;
  --border: #dce4ef;
  --primary: #3273dc;
  --primary-strong: #2359b8;
  --success: #22a06b;
  --danger: #d64550;
  --warning: #d98b18;
  --light-square: #eaf0d8;
  --dark-square: #82a36f;
  --button-bg: #ffffff;
  --hover-border: #b8c7db;
  --tag-info-bg: #e3efff;
  --tag-success-bg: #ddf7ec;
  --tag-success-text: #14724a;
  --tag-danger-bg: #ffe5e8;
  --tag-danger-text: #a52933;
  --soft-line: #eef2f7;
  --square-mark: rgba(217, 139, 24, 0.42);
  --square-target: rgba(32, 43, 60, 0.32);
  --fog-deep: rgba(72, 82, 85, 0.9);
  --fog-mid: rgba(137, 143, 137, 0.8);
  --fog-light: rgba(222, 218, 199, 0.68);
  --fog-dust: rgba(242, 231, 195, 0.34);
  --shadow: 0 18px 45px rgba(32, 43, 60, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--text);
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
  transition: 140ms ease;
}

button:hover {
  border-color: var(--hover-border);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.tabs,
.toolbar,
.segmented {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tabs {
  padding: 4px;
  border-radius: 8px;
  background: var(--panel-strong);
}

.tab {
  flex: 1;
  border-color: transparent;
  background: transparent;
}

.tab.is-active,
.segmented .is-selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.minigame-button {
  border-color: #e7852f;
  background: linear-gradient(135deg, #ff9f43, #f36f38);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 7px 18px rgba(226, 105, 43, 0.2);
}

.minigame-button:hover {
  border-color: #d65d2e;
  box-shadow: 0 9px 22px rgba(226, 105, 43, 0.3);
}

.trainer-button {
  border-color: #6e56cf;
  background: linear-gradient(135deg, #8067dc, #5846b8);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 7px 18px rgba(88, 70, 184, 0.22);
}

.trainer-button:hover {
  border-color: #4d3aa8;
  box-shadow: 0 9px 22px rgba(88, 70, 184, 0.32);
}

.trainer-hint-button {
  border-color: #19986b;
  background: linear-gradient(135deg, #25b982, #16835d);
  color: #fff;
  font-weight: 800;
}

.workspace {
  min-width: 0;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.segmented {
  padding: 4px;
  border-radius: 8px;
  background: var(--panel-strong);
}

.segmented button {
  border-color: transparent;
  background: transparent;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel.compact {
  padding: 14px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.compact .panel-title {
  padding: 0 0 12px;
  border-bottom: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.tag.is-info {
  background: var(--tag-info-bg);
  color: var(--primary-strong);
}

.tag.is-success {
  background: var(--tag-success-bg);
  color: var(--tag-success-text);
}

.tag.is-danger {
  background: var(--tag-danger-bg);
  color: var(--tag-danger-text);
}

.fen-box,
.engine-line {
  min-height: 42px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.field.check {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.field.check input {
  width: auto;
}

.field output {
  color: var(--text);
}

.clocks {
  display: grid;
  gap: 10px;
}

.clock {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--button-bg);
}

.clock.is-running {
  border-color: var(--primary);
  box-shadow: inset 4px 0 0 var(--primary);
}

.clock strong {
  font-variant-numeric: tabular-nums;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

#playView {
  grid-template-columns: minmax(330px, 760px) minmax(280px, 380px);
  gap: 18px;
  align-items: start;
}

#playView.is-active {
  display: grid;
}

.board-stage {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.minigame-hud {
  width: min(100%, 800px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(229, 124, 47, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(255, 243, 216, 0.96), rgba(255, 226, 204, 0.96));
  color: #58301f;
  box-shadow: 0 12px 28px rgba(168, 82, 29, 0.12);
}

.minigame-hud[hidden] {
  display: none;
}

.minigame-hud > div:first-child strong {
  display: block;
  margin-top: 2px;
}

.minigame-kicker {
  display: block;
  color: #c45625;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.minigame-stats {
  display: flex;
  gap: 8px;
}

.minigame-stats > span {
  min-width: 78px;
  border: 1px solid rgba(196, 86, 37, 0.2);
  border-radius: 8px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.minigame-stats small,
.minigame-stats strong {
  display: block;
}

.minigame-stats small {
  color: #9b6249;
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.minigame-stats strong {
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.board-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 0 minmax(300px, 76vmin);
  width: min(100%, 800px);
}

.board-wrap.show-eval {
  grid-template-columns: 18px minmax(300px, 76vmin);
}

.board-layer {
  position: relative;
  min-width: 300px;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--text);
  box-shadow: var(--shadow);
  user-select: none;
  touch-action: none;
}

.board.is-locked {
  cursor: not-allowed;
  filter: saturate(0.72);
}

.board.is-generating {
  filter: saturate(0.45) brightness(0.82);
}

.trainer-loader {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  border-radius: 8px;
  background: radial-gradient(circle, rgba(45, 32, 94, 0.64), rgba(19, 14, 42, 0.82));
  color: #fff;
  pointer-events: none;
  text-align: center;
  backdrop-filter: blur(2px);
}

.trainer-loader[hidden] {
  display: none;
}

.trainer-loader small {
  color: rgba(255, 255, 255, 0.76);
}

.trainer-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.24);
  border-top-color: #fff;
  border-radius: 50%;
  animation: trainer-spin 720ms linear infinite;
}

@keyframes trainer-spin {
  to { transform: rotate(360deg); }
}

.square {
  position: relative;
  overflow: hidden;
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  min-width: 0;
  min-height: 100%;
  font-size: clamp(1.8rem, 6.8vmin, 4.9rem);
  line-height: 1;
}

.square.light {
  background: var(--light-square);
}

.square.dark {
  background: var(--dark-square);
}

.square.is-fogged::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: -18%;
  border-radius: 28%;
  background:
    radial-gradient(circle at 16% 28%, var(--fog-light) 0 12%, transparent 34%),
    radial-gradient(circle at 78% 18%, var(--fog-dust) 0 7%, transparent 27%),
    radial-gradient(circle at 66% 76%, var(--fog-light) 0 10%, transparent 36%),
    radial-gradient(circle at 28% 82%, var(--fog-dust) 0 6%, transparent 24%),
    linear-gradient(138deg, var(--fog-deep), var(--fog-mid) 48%, var(--fog-deep));
  box-shadow:
    inset 0 0 18px rgba(35, 42, 43, 0.34),
    0 0 12px rgba(222, 218, 199, 0.18);
  filter: blur(1.6px) saturate(0.72);
  opacity: 0.97;
  pointer-events: none;
  transform: translate3d(-2%, 1%, 0) scale(1.05);
  animation: fog-drift 7.5s ease-in-out infinite alternate;
}

.square.is-fogged:nth-child(3n)::before {
  animation-delay: -2.4s;
  animation-duration: 9s;
}

.square.is-fogged:nth-child(4n)::before {
  animation-delay: -4.8s;
  animation-duration: 8.2s;
}

.square.is-fogged.is-fog-revealed::before {
  opacity: 0.38;
  filter: blur(0.8px) saturate(0.82);
  box-shadow:
    inset 0 0 12px rgba(35, 42, 43, 0.2),
    0 0 8px rgba(222, 218, 199, 0.12);
}

.is-postgame-fog .square.is-fog-revealed .piece {
  filter: drop-shadow(0 2px 2px rgba(255, 255, 255, 0.34));
}

@keyframes fog-drift {
  from { transform: translate3d(-3%, 2%, 0) scale(1.04) rotate(-0.5deg); }
  to { transform: translate3d(3%, -2%, 0) scale(1.12) rotate(0.7deg); }
}

.square.is-last::after,
.square.is-last-move-from::after,
.square.is-last-move-to::after,
.square.is-hint::after,
.square.is-target::after,
.square.is-check::after,
.square.is-marked::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 6px;
  pointer-events: none;
}

.square.is-last-move-from::after,
.square.is-last-move-to::after {
  inset: 0;
  border-radius: 0;
  background: rgba(34, 193, 220, 0.22);
}

.square.is-last::after {
  background: rgba(50, 115, 220, 0.24);
}

.square.is-hint::after {
  inset: 0;
  border: 0;
  border-radius: 0;
  background: rgba(34, 160, 107, 0.42);
  box-shadow: none;
}

.square.is-target::after {
  inset: 36%;
  border-radius: 50%;
  background: var(--square-target);
}

.square.is-check::after {
  background: rgba(214, 69, 80, 0.35);
}

.square.is-marked::after {
  inset: 0;
  border: 0;
  border-radius: 0;
  background: var(--square-mark);
}

.piece {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  cursor: grab;
  font-family: "Arial Unicode MS", "DejaVu Sans", "Noto Sans Symbols 2", "Apple Symbols", serif;
  font-size: 0.96em;
  font-weight: 400;
  font-variant-emoji: text;
  line-height: 1;
  text-align: center;
  transform: translateY(-0.09em);
  transition: transform 120ms ease, opacity 120ms ease;
}

.piece[hidden] {
  display: none;
}

.piece.is-white,
.drag-piece.is-white,
.transition-piece.is-white {
  color: #fff;
  text-shadow:
    -1.4px -1.4px 0 #050505,
    0 -1.6px 0 #050505,
    1.4px -1.4px 0 #050505,
    1.6px 0 0 #050505,
    1.4px 1.4px 0 #050505,
    0 1.6px 0 #050505,
    -1.4px 1.4px 0 #050505,
    -1.6px 0 0 #050505,
    0 2.5px 2px rgba(0, 0, 0, 0.2);
}

.piece.is-black,
.drag-piece.is-black,
.transition-piece.is-black {
  color: #050505;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.piece.is-checker,
.drag-piece.is-checker,
.transition-piece.is-checker {
  color: transparent;
  text-shadow: none;
}

.piece.is-checker.is-white,
.drag-piece.is-checker.is-white,
.transition-piece.is-checker.is-white {
  --checker-fill: #c63832;
  --checker-edge: #7f1e1b;
  --checker-ring: #e9665f;
}

.piece.is-checker.is-black,
.drag-piece.is-checker.is-black,
.transition-piece.is-checker.is-black {
  --checker-fill: #252b32;
  --checker-edge: #0b0e12;
  --checker-ring: #555e69;
}

.piece.is-checker::before,
.drag-piece.is-checker::before,
.transition-piece.is-checker::before {
  content: "";
  position: absolute;
  inset: 15%;
  border: max(2px, 0.045em) solid var(--checker-edge);
  border-radius: 50%;
  background: var(--checker-fill);
  box-shadow:
    inset 0 0 0 max(2px, 0.055em) var(--checker-ring),
    inset 0 max(2px, 0.045em) 0 rgba(255, 255, 255, 0.2),
    0 max(2px, 0.055em) max(2px, 0.07em) rgba(0, 0, 0, 0.3);
}

.piece.is-checker.is-king::after,
.drag-piece.is-checker.is-king::after,
.transition-piece.is-checker.is-king::after {
  content: "♛";
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: #ffd36a;
  font-size: 0.4em;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(56, 31, 0, 0.72);
}

.piece:active {
  cursor: grabbing;
}

.coord {
  position: absolute;
  z-index: 4;
  color: rgba(32, 43, 60, 0.62);
  font-size: clamp(0.62rem, 1.35vmin, 0.82rem);
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.square.dark .coord {
  color: rgba(255, 255, 255, 0.72);
}

.coord-rank {
  top: 5px;
  left: 5px;
}

.coord-file {
  right: 5px;
  bottom: 5px;
}

.square.is-drag-source .piece {
  opacity: 0.18;
  transform: translateY(-0.09em) scale(0.92);
}

.drag-piece {
  position: fixed;
  z-index: 50;
  width: var(--drag-size);
  height: var(--drag-size);
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: calc(var(--drag-size) * 0.78);
  line-height: 1;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, 0.28));
  transform: translate(-50%, -50%) scale(1.08);
  transition: transform 120ms ease;
}

.transition-piece {
  position: fixed;
  z-index: 45;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: var(--transition-size);
  line-height: 1;
  filter: drop-shadow(0 16px 16px rgba(0, 0, 0, 0.25));
}

.drag-piece,
.transition-piece {
  font-family: "Arial Unicode MS", "DejaVu Sans", "Noto Sans Symbols 2", "Apple Symbols", serif;
  font-weight: 400;
  font-variant-emoji: text;
}

.fruit {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: 0.58em;
  line-height: 1;
  filter: drop-shadow(0 5px 3px rgba(67, 36, 18, 0.28));
  animation: fruit-pop 280ms cubic-bezier(.2, 1.4, .4, 1) both;
  pointer-events: none;
}

@keyframes fruit-pop {
  from { opacity: 0; transform: scale(0.25) rotate(-12deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.harvest-points {
  position: fixed;
  z-index: 90;
  color: #fff;
  font-weight: 950;
  text-shadow: 0 2px 8px rgba(77, 27, 7, 0.75);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: harvest-float 720ms ease-out forwards;
}

@keyframes harvest-float {
  0% { opacity: 0; transform: translate(-50%, -25%) scale(0.65); }
  25% { opacity: 1; transform: translate(-50%, -75%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(0.92); }
}

.annotation-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.eval-ruler {
  position: relative;
  width: 10px;
  margin-right: 8px;
  border-radius: 99px;
  background: #202b3c;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.board-wrap.show-eval .eval-ruler {
  opacity: 1;
}

#evalFill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: #fff;
  transition: height 180ms ease;
}

.captured {
  display: flex;
  gap: 4px;
  min-height: 28px;
  color: var(--muted);
  font-size: 1.25rem;
}

.right-rail {
  display: grid;
  gap: 16px;
}

.moves-panel {
  max-height: 56vh;
  overflow: auto;
}

.game-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px 4px;
  border-top: 1px solid var(--soft-line);
}

.game-actions[hidden] {
  display: none;
}

.game-actions button {
  min-width: 0;
  padding-inline: 8px;
  font-size: 0.82rem;
  font-weight: 750;
}

.game-actions .offer-takeback {
  grid-column: 1 / -1;
}

.is-danger-action {
  border-color: color-mix(in srgb, var(--danger) 58%, var(--border));
  color: var(--danger);
}

.request-accept {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.move-list {
  display: grid;
  grid-template-columns: 42px 1fr 1fr;
  gap: 0;
  margin: 0;
  padding: 10px 16px 16px;
  list-style: none;
  font-size: 0.9rem;
}

.move-list span {
  min-height: 26px;
  padding: 4px 0;
  border-bottom: 1px solid var(--soft-line);
}

.preview-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  padding: 14px 16px 16px;
}

.top-lines {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
}

.coach-actions {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--soft-line);
}

.coach-actions[hidden] {
  display: none;
}

.preview-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--button-bg);
  cursor: pointer;
}

.preview-card strong {
  display: block;
}

.analysis-layout,
.tournament-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 18px;
}

#playView.is-analysis-mode {
  margin-bottom: 18px;
}

.wide {
  min-height: 360px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px;
}

.metric {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--button-bg);
}

.metric span {
  color: var(--muted);
  font-size: 0.8rem;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 1.35rem;
}

.timeline,
.pv-list,
.tournament-log {
  padding: 16px;
}

.timeline {
  display: flex;
  align-items: end;
  gap: 3px;
  min-height: 150px;
}

.bar {
  flex: 1;
  min-width: 4px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
}

.pv-list,
.tournament-log {
  display: grid;
  gap: 8px;
}

.line-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--button-bg);
}

.line-item[data-uci] {
  cursor: pointer;
}

.line-item[data-uci]:hover,
.line-item[data-uci]:focus-visible {
  border-color: var(--primary);
}

.line-item.is-waiting {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
}

.modal {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(18, 27, 40, 0.45);
}

.modal header,
.modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal footer {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.modal h2 {
  margin: 0;
  font-size: 1.05rem;
}

.options-body {
  min-height: 330px;
  padding: 0;
}

.options-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 12px 16px 0;
  border-bottom: 1px solid var(--border);
}

.options-tab {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.options-tab:hover {
  border-color: transparent;
  background: var(--panel-strong);
  transform: none;
}

.options-tab.is-active {
  border-bottom-color: var(--primary);
  color: var(--primary-strong);
}

.options-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.options-panel {
  padding: 18px 16px 20px;
}

.options-panel[hidden] {
  display: none;
}

.options-section-heading h3,
.options-section-heading p {
  margin: 0;
}

.options-section-heading h3 {
  font-size: 1rem;
}

.options-section-heading p,
.graphics-options small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.options-grid {
  padding: 14px 0 0;
}

.options-grid .field,
.graphics-options .field {
  margin-top: 0;
}

.graphics-options {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.7fr);
  gap: 20px;
  align-items: stretch;
  padding-top: 16px;
}

.theme-preview {
  position: relative;
  min-height: 142px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 9px;
  background-color: var(--light-square);
  background-image:
    linear-gradient(45deg, var(--dark-square) 25%, transparent 25%, transparent 75%, var(--dark-square) 75%),
    linear-gradient(45deg, var(--dark-square) 25%, transparent 25%, transparent 75%, var(--dark-square) 75%);
  background-position: 0 0, 32px 32px;
  background-size: 64px 64px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.theme-preview span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border-radius: 5px;
  padding: 5px 7px;
  background: rgba(20, 30, 43, 0.72);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 750;
}

.glyph-preview {
  display: grid;
  align-content: center;
  gap: 10px;
  min-height: 142px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px;
  background: linear-gradient(135deg, var(--light-square) 0 50%, var(--dark-square) 50%);
}

.glyph-preview-row {
  overflow: hidden;
  border-radius: 6px;
  padding: 6px 9px;
  font-family: "Arial Unicode MS", "DejaVu Sans", "Noto Sans Symbols 2", "Apple Symbols", serif;
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.glyph-preview-row.is-white {
  background: rgba(12, 20, 30, 0.36);
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.glyph-preview-row.is-black {
  background: rgba(255, 255, 255, 0.46);
  color: #050505;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}

body.glyph-outline .piece {
  font-size: 0.92em;
}

body.glyph-monogram .piece,
body.glyph-monogram .drag-piece,
body.glyph-monogram .transition-piece {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
}

body.glyph-monogram .piece {
  font-size: 0.72em;
  transform: translateY(-0.04em);
}

.engine-decision-modal {
  width: min(520px, calc(100vw - 32px));
}

.engine-decision-modal p {
  margin: 0;
}

.engine-decision-modal .engine-decision-copy {
  margin-top: 10px;
  color: var(--muted);
}

.new-game-modal {
  width: min(620px, calc(100vw - 32px));
}

.new-game-modal header > div h2 {
  margin-top: 3px;
}

.new-game-kicker {
  color: var(--primary-strong);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.new-game-copy {
  margin: 0 0 14px;
  color: var(--muted);
}

.new-game-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.new-game-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 13px;
  min-height: 104px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--button-bg);
  color: var(--text);
  text-align: left;
}

.new-game-card:hover,
.new-game-card:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(45, 96, 130, 0.13);
}

.new-game-card-icon {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 14px;
  background: var(--panel);
  color: var(--primary-strong);
  font-size: 2.2rem;
  font-weight: 900;
}

.chess960-card .new-game-card-icon {
  font-size: 1.05rem;
  letter-spacing: -0.04em;
}

.fog-card {
  grid-column: 1 / -1;
  border-color: rgba(100, 118, 123, 0.42);
  background: linear-gradient(135deg, rgba(241, 244, 241, 0.98), rgba(211, 220, 217, 0.9));
}

.fog-card .new-game-card-icon {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(183, 198, 197, 0.74));
  color: #536b70;
  font-size: 1.9rem;
  text-shadow: 0 4px 10px rgba(72, 82, 85, 0.18);
}

.checkers-card {
  grid-column: 1 / -1;
  border-color: rgba(170, 57, 48, 0.4);
  background: linear-gradient(135deg, rgba(255, 245, 239, 0.98), rgba(241, 215, 205, 0.9));
}

.checkers-card .new-game-card-icon {
  background: linear-gradient(145deg, #d84942, #8f2420);
  color: #fff3e5;
  text-shadow: 0 3px 6px rgba(49, 10, 8, 0.36);
}

.new-game-card strong,
.new-game-card small {
  display: block;
}

.new-game-card strong {
  font-size: 1rem;
}

.new-game-card small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

.multiplayer-modal-title {
  display: flex;
  align-items: center;
  gap: 9px;
}

.leaderboard-modal[open] {
  animation: leaderboard-pop 360ms cubic-bezier(.2, 1.25, .35, 1) both;
}

.minigame-picker-modal {
  width: min(680px, calc(100vw - 32px));
}

.minigame-picker-modal header > div h2 {
  margin-top: 3px;
}

.minigame-picker-copy {
  margin: 0 0 14px;
  color: var(--muted);
}

.minigame-library {
  display: grid;
  gap: 12px;
}

.minigame-card {
  display: grid;
  grid-template-columns: 76px 1fr 28px;
  align-items: center;
  gap: 14px;
  min-height: 124px;
  border: 1px solid rgba(229, 124, 47, 0.38);
  border-radius: 12px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(255, 247, 225, 0.96), rgba(255, 224, 200, 0.86));
  color: #58301f;
  text-align: left;
  box-shadow: 0 10px 24px rgba(168, 82, 29, 0.1);
}

.minigame-card:hover {
  border-color: #e67b39;
  box-shadow: 0 14px 30px rgba(168, 82, 29, 0.18);
}

.minigame-card-art {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 2.65rem;
  filter: drop-shadow(0 6px 5px rgba(88, 48, 31, 0.2));
}

.minigame-card-copy,
.minigame-card-copy strong,
.minigame-card-copy small,
.minigame-card-meta {
  display: block;
}

.minigame-card-copy strong {
  font-size: 1.08rem;
}

.minigame-card-copy small {
  margin-top: 4px;
  color: #80513c;
  line-height: 1.35;
}

.minigame-card-meta {
  margin-top: 9px;
  color: #c45625;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.minigame-card-arrow {
  color: #c45625;
  font-size: 1.5rem;
  font-weight: 900;
}

.trainer-card {
  border-color: rgba(110, 86, 207, 0.4);
  background: linear-gradient(135deg, rgba(246, 242, 255, 0.98), rgba(222, 212, 255, 0.9));
  color: #30245f;
}

.trainer-card .minigame-card-copy small {
  color: #62558c;
}

.trainer-card .minigame-card-meta,
.trainer-card .minigame-card-arrow {
  color: #6e56cf;
}

.leaderboard-modal::backdrop {
  background: rgba(38, 20, 12, 0.62);
  backdrop-filter: blur(4px);
}

@keyframes leaderboard-pop {
  from { opacity: 0; transform: translateY(22px) scale(0.93); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal .leaderboard-hero {
  border: 0;
  padding: 22px;
  background: linear-gradient(135deg, #fff1cf, #ffc99b);
  color: #572b19;
}

.leaderboard-hero h2 {
  margin-top: 4px;
  font-size: 1.55rem;
}

.final-score {
  min-width: 130px;
  border-radius: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.68);
  text-align: right;
}

.final-score small,
.final-score strong {
  display: block;
}

.final-score small {
  color: #9d5b3c;
  font-weight: 750;
}

.final-score strong {
  font-size: 1.7rem;
  font-variant-numeric: tabular-nums;
}

.leaderboard-rank {
  margin: 0 0 12px;
  color: var(--muted);
  text-align: center;
}

.leaderboard-signature {
  margin-bottom: 14px;
  border: 1px solid rgba(229, 124, 47, 0.36);
  border-radius: 10px;
  padding: 13px;
  background: rgba(255, 233, 207, 0.38);
}

.leaderboard-signature[hidden],
.leaderboard-locked[hidden] {
  display: none;
}

.leaderboard-signature > label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.leaderboard-signature-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.leaderboard-signature-row input {
  min-width: 0;
}

.leaderboard-signature > small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.leaderboard-locked {
  margin-bottom: 14px;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--tag-success-bg);
  color: var(--tag-success-text);
  font-weight: 800;
  text-align: center;
}

.leaderboard-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: leaders;
}

.leaderboard-list li {
  counter-increment: leaders;
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--button-bg);
}

.leaderboard-list li::before {
  content: counter(leaders);
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.leaderboard-list li.is-current {
  border-color: #f08a3e;
  background: rgba(255, 224, 193, 0.38);
}

.leaderboard-list li strong {
  font-variant-numeric: tabular-nums;
}

.modal-body {
  padding: 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.icon-button {
  display: grid;
  min-width: 36px;
  padding: 0;
  place-items: center;
}

.small button {
  min-height: 30px;
}

body.theme-mint {
  --light-square: #dff4e8;
  --dark-square: #5a9f84;
}

body.theme-graphite {
  --light-square: #d8dee8;
  --dark-square: #667085;
}

body.dark-mode {
  --bg: #111722;
  --panel: #182232;
  --panel-strong: #223047;
  --text: #edf3fb;
  --muted: #9fb0c8;
  --border: #2f415b;
  --primary: #66a6ff;
  --primary-strong: #b8d6ff;
  --success: #54d494;
  --danger: #ff6b78;
  --warning: #f0b45b;
  --light-square: #a8b887;
  --dark-square: #58724f;
  --button-bg: #1f2b3d;
  --hover-border: #5f789e;
  --tag-info-bg: #1e3a5f;
  --tag-success-bg: #1c4d3d;
  --tag-success-text: #a7f4ca;
  --tag-danger-bg: #5a2530;
  --tag-danger-text: #ffc4ca;
  --soft-line: #29394f;
  --square-mark: rgba(240, 180, 91, 0.46);
  --square-target: rgba(237, 243, 251, 0.32);
  --fog-deep: rgba(31, 39, 45, 0.94);
  --fog-mid: rgba(78, 91, 94, 0.84);
  --fog-light: rgba(171, 177, 166, 0.48);
  --fog-dust: rgba(209, 198, 164, 0.22);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

body.dark-mode.theme-mint {
  --light-square: #b7d8ca;
  --dark-square: #3f7f6d;
}

body.dark-mode.theme-graphite {
  --light-square: #aeb8c6;
  --dark-square: #4b5668;
}

body.dark-mode .minigame-hud,
body.dark-mode .modal .leaderboard-hero,
body.dark-mode .minigame-card {
  background: linear-gradient(135deg, #4e2d22, #6b3525);
  color: #fff1df;
}

body.dark-mode .minigame-kicker,
body.dark-mode .minigame-stats small,
body.dark-mode .final-score small {
  color: #ffb784;
}

body.dark-mode .minigame-stats > span,
body.dark-mode .final-score,
body.dark-mode .minigame-card-art {
  background: rgba(20, 12, 9, 0.28);
}

body.dark-mode .minigame-card-copy small {
  color: #e6bda7;
}

body.dark-mode .leaderboard-signature {
  background: rgba(107, 53, 37, 0.28);
}

body.dark-mode .fog-card {
  border-color: rgba(142, 162, 166, 0.36);
  background: linear-gradient(135deg, rgba(42, 53, 60, 0.98), rgba(55, 68, 72, 0.94));
}

body.dark-mode .fog-card .new-game-card-icon {
  background: linear-gradient(145deg, rgba(112, 130, 132, 0.46), rgba(28, 38, 44, 0.76));
  color: #d9e3df;
}

body.dark-mode .checkers-card {
  border-color: rgba(214, 95, 84, 0.42);
  background: linear-gradient(135deg, rgba(73, 38, 37, 0.98), rgba(91, 45, 40, 0.94));
}

body.dark-mode .checkers-card .new-game-card-icon {
  background: linear-gradient(145deg, #e25c54, #8c2723);
  color: #fff3e5;
}

@media (prefers-reduced-motion: reduce) {
  .square.is-fogged::before {
    animation: none;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  #playView.is-active,
  .analysis-layout,
  .tournament-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .graphics-options {
    grid-template-columns: 1fr;
  }

  .theme-preview {
    min-height: 110px;
  }

  .new-game-library {
    grid-template-columns: 1fr;
  }

  .fog-card {
    grid-column: auto;
  }

  .checkers-card {
    grid-column: auto;
  }

  .minigame-hud {
    align-items: stretch;
    flex-direction: column;
  }

  .minigame-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .minigame-stats > span {
    min-width: 0;
  }

  .minigame-card {
    grid-template-columns: 58px 1fr 20px;
    gap: 10px;
    padding: 11px;
  }

  .minigame-card-art {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    font-size: 2rem;
  }

  .leaderboard-signature-row {
    grid-template-columns: 1fr;
  }
}
