:root {
  --bg: #1e1e1e;
  --bg-2: #252526;
  --panel: #2d2d30;
  --panel-2: #1f1f23;
  --panel-3: #17181b;
  --border: #3c3c3c;
  --border-soft: #2b2b2d;
  --text: #d4d4d4;
  --muted: #9b9b9b;
  --accent: #007acc;
  --accent-soft: rgba(0, 122, 204, 0.18);
  --danger: #f14c4c;
  --success: #89d185;
  --warning: #d7ba7d;
  --board-light: #eeeed2;
  --board-dark: #769656;
  --board-frame: #101113;
  --app-backdrop-image: none;
  --app-backdrop-opacity: 0;
  --app-backdrop-tint: rgba(0, 0, 0, 0);
  --board-backdrop-image: none;
  --board-backdrop-opacity: 0;
  --board-backdrop-glow: rgba(0, 0, 0, 0);
  --board-backdrop-tint: rgba(0, 0, 0, 0);
  --shadow: none;
  --chrome-height: 30px;
  --status-height: 22px;
  --worker-log-height: 30px;
  --workspace-padding: 8px;
  --dock-height: clamp(118px, 17vh, 190px);
  --dock-resizer-height: 9px;
  --dock-gap: 8px;
  --board-size: clamp(
    330px,
    min(
      calc((100vw - (var(--workspace-padding) * 2) - 176px) * 0.705),
      calc((100vh - var(--chrome-height) - var(--status-height) - var(--worker-log-height) - var(--dock-height) - var(--dock-resizer-height) - (var(--workspace-padding) * 2) - var(--dock-gap) - 8px) * 0.877551)
    ),
    520px
  );
  --strip-height: clamp(32px, calc(var(--board-size) * 0.073), 48px);
  --clock-width: clamp(78px, calc(var(--board-size) * 0.19), 110px);
  --eval-width: clamp(28px, calc(var(--board-size) * 0.071), 46px);
  --moves-width: clamp(230px, calc(var(--board-size) * 0.4725), 335px);
  --drawio-gap: clamp(10px, calc(var(--board-size) * 0.046512), 30px);
  --clock-gap: clamp(6px, calc(var(--board-size) * 0.02), 10px);
  --score-width: clamp(78px, calc(var(--board-size) * 0.18), 116px);
  --cpu-width: clamp(58px, calc(var(--board-size) * 0.12), 82px);
  --left-rail-width: calc(var(--clock-width) + var(--clock-gap) + var(--eval-width));
  --stage-width: calc(var(--left-rail-width) + var(--drawio-gap) + var(--board-size) + var(--drawio-gap) + var(--moves-width));
  --stage-height: calc(var(--strip-height) + var(--board-size) + var(--strip-height));
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #5d7b98 #23252b;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: linear-gradient(180deg, #23252b 0%, #1c1d22 100%);
  border-left: 1px solid rgba(255, 255, 255, 0.04);
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #5d7b98 0%, #466076 100%);
  border: 2px solid #23252b;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #7195b8 0%, #55748f 100%);
}

*::-webkit-scrollbar-corner {
  background: #1c1d22;
}

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  -webkit-app-region: no-drag;
}

.app-shell {
  position: fixed;
  inset: 0;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: var(--chrome-height) minmax(0, 1fr) auto var(--status-height);
  user-select: none;
  overflow: hidden;
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.app-shell::before {
  z-index: 0;
  background-image: var(--app-backdrop-image);
  background-size: cover;
  background-position: center;
  opacity: var(--app-backdrop-opacity);
  transform: scale(1.06);
  filter: saturate(1.06) blur(2px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.app-shell::after {
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), var(--app-backdrop-tint)),
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(8, 10, 14, 0.12), rgba(8, 10, 14, 0.34));
  opacity: var(--app-backdrop-opacity);
  transition: opacity 180ms ease;
}

.app-shell > * {
  min-width: 0;
  position: relative;
  z-index: 1;
}

.app-shell--board-backdrop-active .titlebar,
.app-shell--board-backdrop-active .player-zone,
.app-shell--board-backdrop-active .clock-panel,
.app-shell--board-backdrop-active .clock-column__meta,
.app-shell--board-backdrop-active .eval-meter,
.app-shell--board-backdrop-active .moves-panel,
.app-shell--board-backdrop-active .analysis-dock,
.app-shell--board-backdrop-active .dock-pane,
.app-shell--board-backdrop-active .dock-resize-handle,
.app-shell--board-backdrop-active .worker-log,
.app-shell--board-backdrop-active .statusbar {
  backdrop-filter: blur(14px) saturate(1.08);
}

.app-shell--board-backdrop-active .titlebar {
  background: rgba(22, 24, 29, 0.74);
}

.app-shell--board-backdrop-active .workspace {
  background: linear-gradient(180deg, rgba(6, 8, 12, 0.08), rgba(6, 8, 12, 0.18));
}

.app-shell--board-backdrop-active .player-zone,
.app-shell--board-backdrop-active .clock-panel,
.app-shell--board-backdrop-active .clock-column__meta,
.app-shell--board-backdrop-active .eval-meter,
.app-shell--board-backdrop-active .moves-panel,
.app-shell--board-backdrop-active .analysis-dock,
.app-shell--board-backdrop-active .dock-pane {
  background: rgba(23, 26, 31, 0.74);
}

.app-shell--board-backdrop-active .moves-panel__header,
.app-shell--board-backdrop-active .moves-table-head,
.app-shell--board-backdrop-active .moves-toolbar,
.app-shell--board-backdrop-active .moves-actions .btn,
.app-shell--board-backdrop-active .dock-resize-handle {
  background: rgba(27, 30, 35, 0.78);
}

.app-shell--board-backdrop-active .icon-btn,
.app-shell--board-backdrop-active .seat-toggle,
.app-shell--board-backdrop-active .btn {
  background: rgba(34, 37, 43, 0.72);
  backdrop-filter: blur(12px) saturate(1.08);
}

.app-shell--board-backdrop-active .worker-log {
  background: rgba(15, 17, 21, 0.82);
}

.app-shell--board-backdrop-active .statusbar {
  background: rgba(0, 122, 204, 0.76);
}

.app-shell > .titlebar {
  grid-row: 1;
}

.app-shell > .workspace {
  grid-row: 2;
}

.dock-textarea {
  user-select: text;
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--chrome-height);
  padding: 0 8px;
  background: #252526;
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
}

.titlebar__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.brand__icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: #040806;
  box-shadow: 0 0 0 1px rgba(57, 214, 126, 0.32);
  object-fit: contain;
}

.menu-bar {
  display: flex;
  align-items: center;
  gap: 0;
  -webkit-app-region: no-drag;
}

.menu-trigger {
  border: 0;
  background: transparent;
  color: var(--text);
  height: 22px;
  padding: 0 8px;
  border-radius: 2px;
  font-size: 12px;
  cursor: pointer;
}

.menu-trigger:hover,
.menu-trigger.active {
  background: rgba(255, 255, 255, 0.08);
}

.window-controls {
  display: flex;
  align-items: stretch;
  -webkit-app-region: no-drag;
}

.window-btn {
  width: 42px;
  height: var(--chrome-height);
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
}

.window-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.window-btn.close:hover {
  background: var(--danger);
  color: #fff;
}

.menu-popover {
  position: fixed;
  z-index: 160;
  min-width: 220px;
  max-height: min(420px, calc(100vh - 48px));
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  border-radius: 2px;
  padding: 4px;
  overflow: auto;
  -webkit-app-region: no-drag;
}

.menu-popover--history {
  overflow: visible;
}

.menu-popover--with-submenus {
  overflow: visible;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  padding: 2px 8px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
  cursor: pointer;
}

.menu-item:hover,
.menu-item.is-checked {
  background: var(--accent-soft);
}

.menu-item--disabled,
.menu-item--disabled:hover {
  background: transparent;
  color: var(--muted);
  cursor: default;
}

.menu-item__check {
  width: 14px;
  flex: 0 0 14px;
  color: var(--accent);
  text-align: center;
}

.menu-item__label {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item__meta {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.menu-group {
  position: relative;
  display: grid;
  gap: 2px;
}

.menu-item--submenu-toggle {
  justify-content: flex-start;
}

.menu-item__submenu-icon {
  color: var(--muted);
  transition: transform 140ms ease;
}

.menu-group.is-open .menu-item__submenu-icon,
.menu-item--submenu-toggle.is-open .menu-item__submenu-icon {
  transform: rotate(90deg);
}

.menu-submenu {
  display: none;
  position: absolute;
  top: -4px;
  left: calc(100% - 6px);
  z-index: 170;
  min-width: 210px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
}

.menu-group.is-open > .menu-submenu {
  display: grid;
  gap: 2px;
}

.menu-history-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: stretch;
  gap: 4px;
}

.menu-history-entry--submenu .menu-item {
  min-height: 21px;
}

.menu-item--history {
  min-width: 0;
}

.menu-item__trash {
  width: 24px;
  min-width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.menu-item__trash:hover {
  background: rgba(241, 76, 76, 0.18);
  color: #ffffff;
}

.menu-item__shortcut {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.menu-heading {
  padding: 8px 8px 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-separator {
  height: 1px;
  background: var(--border-soft);
  margin: 6px 4px;
}

.workspace {
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--workspace-padding);
  overflow: hidden;
}

.app-shell--log-hidden .workspace {
  padding-bottom: 0;
}

.main-stage {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  flex: 1 1 auto;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--dock-resizer-height) var(--dock-height);
  row-gap: 0;
  align-content: stretch;
  justify-items: center;
  overflow: hidden;
}

.main-stage.dock-hidden {
  grid-template-rows: minmax(0, 1fr);
}

.main-stage.dock-hidden .stage-grid {
  margin-bottom: 0;
}

.stage-grid {
  max-width: 100%;
  min-width: 0;
  width: var(--stage-width);
  height: var(--stage-height);
  min-height: var(--stage-height);
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-columns: var(--left-rail-width) var(--board-size) var(--moves-width);
  column-gap: var(--drawio-gap);
  row-gap: 0;
  margin: 0 0 var(--dock-gap);
  transition: width 160ms ease, height 160ms ease;
}

.left-rail {
  width: var(--left-rail-width);
  height: var(--stage-height);
  min-height: var(--stage-height);
  display: grid;
  grid-template-columns: var(--clock-width) var(--eval-width);
  column-gap: var(--clock-gap);
}

.main-stage.is-clock-hidden .stage-grid {
  width: calc(var(--eval-width) + var(--drawio-gap) + var(--board-size) + var(--drawio-gap) + var(--moves-width));
  grid-template-columns: var(--eval-width) var(--board-size) var(--moves-width);
}

.main-stage.is-clock-hidden .left-rail {
  width: var(--eval-width);
  grid-template-columns: var(--eval-width);
}

.main-stage.is-clock-hidden .clock-column {
  display: none;
}

.clock-column {
  width: var(--clock-width);
  height: var(--stage-height);
  min-height: var(--stage-height);
  display: grid;
  grid-template-rows: var(--strip-height) minmax(0, 1fr) var(--strip-height);
  gap: 0;
}

.clock-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #26272c 0%, #1c1d22 100%);
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: center;
}

.clock-panel--active {
  border-color: #4fc1ff;
  background: linear-gradient(180deg, #243948 0%, #1b2833 100%);
  box-shadow: inset 0 0 0 1px rgba(79, 193, 255, 0.22);
}

.clock-panel--disabled {
  border-color: rgba(92, 92, 96, 0.55);
  background: linear-gradient(180deg, #232429 0%, #1a1b20 100%);
}

.clock-panel--disabled .clock-panel__time,
.clock-panel--disabled .clock-panel__label {
  color: #8b8d94;
}

.clock-panel--expired {
  border-color: rgba(241, 76, 76, 0.72);
  background: linear-gradient(180deg, #3b2427 0%, #2a181a 100%);
}

.clock-panel--low:not(.clock-panel--expired) .clock-panel__time {
  color: #ffd0d0;
}

.clock-panel__label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}

.clock-panel__time {
  color: #ffffff;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: clamp(15px, calc(var(--board-size) * 0.041), 22px);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.clock-column__meta {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 6px;
  border-left: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #1b1c20 0%, #17181b 100%);
}

.clock-column__preset,
.clock-column__state {
  text-align: center;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.clock-column__preset {
  color: #9cdcfe;
}

.clock-column__state {
  color: #dcdcaa;
}

.eval-column {
  width: var(--eval-width);
  height: var(--stage-height);
  min-height: var(--stage-height);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.eval-meter {
  --eval-top: #15171a;
  --eval-bottom: #ece9db;
  width: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--panel-3);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.eval-meter__segment {
  min-height: 8%;
  transition: flex-basis 0.2s ease, background-color 0.2s ease;
}

.eval-meter__segment--top {
  background: var(--eval-top);
}

.eval-meter__segment--bottom {
  background: var(--eval-bottom);
}

.eval-meter__labels {
  position: absolute;
  inset: 4px 2px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  pointer-events: none;
  display: none;
}

.eval-meter__value {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  transform: translate(-50%, -50%) rotate(-90deg);
  min-width: 70px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 2px 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.42);
  color: #ffffff;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.eval-meter__value-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  border-radius: 999px;
  font-size: 9px;
  line-height: 1;
}

.eval-meter__value-badge--white {
  background: rgba(137, 209, 133, 0.18);
  color: #c8f5c5;
  border: 1px solid rgba(137, 209, 133, 0.38);
}

.eval-meter__value-badge--black {
  background: rgba(241, 76, 76, 0.18);
  color: #ffb8b8;
  border: 1px solid rgba(241, 76, 76, 0.42);
}

.board-arena {
  width: var(--board-size);
  height: var(--stage-height);
  min-height: var(--stage-height);
  display: grid;
  grid-template-rows: var(--strip-height) var(--board-size) var(--strip-height);
  gap: 0;
}

.player-zone {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--score-width) var(--cpu-width);
  align-items: center;
  gap: 0;
  height: var(--strip-height);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 0;
  box-shadow: var(--shadow);
}

.player-zone__captured {
  min-width: 0;
  min-height: 100%;
  display: flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
  white-space: nowrap;
  padding: 0 6px;
  border-right: 1px solid var(--border-soft);
}

.player-zone__captured img,
.captured-piece {
  width: clamp(16px, calc(var(--strip-height) * 0.62), 24px);
  height: clamp(16px, calc(var(--strip-height) * 0.62), 24px);
  flex: 0 0 auto;
  position: relative;
  margin-right: 1px;
}

.captured-piece--stacked {
  margin-left: clamp(-15px, calc(var(--strip-height) * -0.42), -10px);
}

.player-zone__identity {
  display: none;
}

.player-zone__name {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-zone__meta {
  color: var(--muted);
  font-size: 10px;
}

.player-zone__score {
  min-width: var(--score-width);
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  padding: 0 5px;
}

.player-zone__score-value {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-weight: 700;
  text-align: right;
  color: var(--warning);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.player-zone__score-value--positive {
  color: var(--success);
}

.player-zone__score-value--negative {
  color: #ff8f8f;
}

.player-zone__score-value--neutral {
  color: var(--warning);
}

.player-zone__mate-skull {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 4px;
  border-radius: 999px;
  line-height: 1;
  cursor: help;
}

.player-zone__mate-skull svg {
  width: 12px;
  height: 12px;
  display: block;
}

.player-zone__mate-skull-count {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.player-zone__mate-skull--warning {
  color: #f2d59a;
  background: rgba(215, 186, 125, 0.16);
  border: 1px solid rgba(215, 186, 125, 0.38);
}

.player-zone__mate-skull--danger {
  color: #ffb8b8;
  background: rgba(241, 76, 76, 0.16);
  border: 1px solid rgba(241, 76, 76, 0.38);
}

.player-zone__mate-skull--critical {
  color: #fff2f2;
  background: rgba(241, 76, 76, 0.22);
  border: 1px solid rgba(241, 76, 76, 0.54);
  box-shadow: 0 0 16px rgba(241, 76, 76, 0.22);
  animation: mate-skull-pulse 1.1s ease-in-out infinite;
}

@keyframes mate-skull-pulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}

.player-zone__review {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  color: #f2cf62;
  font-size: 9px;
  line-height: 1;
  cursor: help;
}

.player-zone__review.is-pending {
  color: #7e8088;
}

.player-zone__review-score {
  min-width: 1.6em;
  margin-right: 2px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.player-zone__review i {
  width: 8px;
  text-align: center;
}

.player-zone__result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  font-size: 13px;
  line-height: 1;
}

.player-zone__result--winner {
  color: #ffd24d;
  text-shadow: 0 0 6px rgba(255, 210, 77, 0.35);
}

.player-zone__result--loser {
  color: #ff8f8f;
}

.seat-toggle {
  justify-self: center;
  align-self: center;
  min-width: 0;
  width: calc(var(--cpu-width) - 10px);
  height: calc(var(--strip-height) - 9px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #3f3f46;
  border-radius: 3px;
  background: linear-gradient(180deg, #2b2b30 0%, #222329 100%);
  color: var(--text);
  font-size: clamp(11px, calc(var(--strip-height) * 0.32), 13px);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.seat-toggle.active {
  border-color: #2696d8;
  background: linear-gradient(180deg, #1686d9 0%, #0e639c 100%);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.board-shell {
  position: relative;
  isolation: isolate;
  width: var(--board-size);
  height: var(--board-size);
  min-width: var(--board-size);
  min-height: var(--board-size);
  display: grid;
  place-items: center;
  background: var(--board-frame);
  border: 1px solid #000;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  overflow: hidden;
}

.board-shell::before,
.board-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}

.board-shell::before {
  z-index: 0;
  background-image: var(--board-backdrop-image);
  background-size: cover;
  background-position: center;
  opacity: var(--board-backdrop-opacity);
  transform: scale(1.04);
  filter: saturate(1.08) contrast(1.05);
  transition: opacity 180ms ease, transform 180ms ease;
}

.board-shell::after {
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), var(--board-backdrop-tint)),
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.08), transparent 28%);
  opacity: var(--board-backdrop-opacity);
  transition: opacity 180ms ease;
}

.app-shell--board-backdrop-active .board-shell {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 0 28px var(--board-backdrop-glow);
}

.board-stack {
  position: relative;
  z-index: 1;
  width: var(--board-size);
  height: var(--board-size);
  display: grid;
  place-items: center;
  transition: width 160ms ease, height 160ms ease;
}

#board {
  position: relative;
  z-index: 1;
  width: var(--board-size);
  height: var(--board-size);
  display: grid;
  place-items: center;
  transition: width 160ms ease, height 160ms ease;
}

#board .chessboard-63f37 {
  margin: auto;
}

.board-arrows {
  position: absolute;
  inset: 0;
  z-index: 8;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  opacity: 0;
  transform: translateY(3px) scale(0.985);
  transform-origin: 50% 50%;
  transition: opacity 180ms ease, transform 180ms ease;
  will-change: opacity, transform;
}

.board-badges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 12;
}

.board-king-badge {
  position: absolute;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.board-king-badge svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28));
}

.board-arrows.is-visible {
  opacity: 1;
  transform: none;
}

#board .board-b72b1 {
  border: 0 !important;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03);
}

#board .white-1e1d7 {
  background: var(--board-light);
}

#board .black-3c85d {
  background: var(--board-dark);
}

#board .square-55d63 {
  position: relative;
  overflow: visible;
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

#board [class*="piece-"] {
  position: relative;
  z-index: 2;
}

#board .king-result-square--winner {
  box-shadow: inset 0 0 0 3px rgba(255, 215, 106, 0.34), 0 0 12px rgba(255, 218, 110, 0.18);
}

#board .king-result-square--loser {
  box-shadow: inset 0 0 0 3px rgba(255, 102, 125, 0.3);
}

.board-king-badge--winner {
  transform: translateY(-8%);
}

.board-king-badge--loser {
  transform: translate(10%, -10%);
}

#board .square-target::before {
  border-color: rgba(121, 246, 153, 0.82);
}

#board .square-attack::before {
  border-color: rgba(255, 96, 96, 0.82);
}

#board .square-will-check::before {
  border-color: rgba(118, 169, 255, 0.82);
}

#board .square-is-promo::before {
  border-color: rgba(0, 200, 0, 0.92);
}

#board .square-highlight {
  box-shadow: inset 0 0 0 4px rgba(255, 255, 0, 0.25);
}

#board .square-highlight-move-border {
  box-shadow: inset 0 0 0 4px rgba(0, 122, 204, 0.55);
}

.moves-pane {
  width: var(--moves-width);
  height: var(--stage-height);
  min-height: var(--stage-height);
  display: grid;
  grid-template-rows: var(--strip-height) var(--board-size) var(--strip-height);
  gap: 0;
}

.moves-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  height: var(--strip-height);
  border: 1px solid var(--border);
  border-bottom: 0;
  background: var(--border-soft);
  overflow: hidden;
}

.icon-btn {
  position: relative;
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, #2b2b30 0%, #232328 100%);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 11px;
  line-height: 1;
}

.icon-btn i {
  font-size: 13px;
}

.icon-btn:hover,
.icon-btn.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, #34343a 0%, #2c2c32 100%);
  color: #ffffff;
}

.icon-btn.active::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--accent);
}

.icon-btn--primary {
  background: transparent;
  border-color: var(--border-soft);
  color: #fff;
}

.icon-btn__text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icon-btn__badge {
  position: absolute;
  right: 2px;
  bottom: 2px;
  min-width: 14px;
  padding: 0 2px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.2;
}

.moves-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.moves-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--strip-height);
  padding: 0 7px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #2b2b30 0%, #242428 100%);
  color: #c6c6c6;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.moves-table-head {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr);
  gap: 3px;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border-bottom: 1px solid var(--border-soft);
  background: #222226;
  color: #85858b;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.moves-table-head span:first-child {
  text-align: right;
  padding-right: 2px;
}

.move-list {
  list-style: none;
  margin: 0;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #5d7b98 #23252b;
}

.move-list::-webkit-scrollbar {
  width: 10px;
}

.move-list::-webkit-scrollbar-track {
  background: linear-gradient(180deg, #23252b 0%, #1c1d22 100%);
  border-left: 1px solid rgba(255, 255, 255, 0.04);
}

.move-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #5d7b98 0%, #466076 100%);
  border: 2px solid #23252b;
  border-radius: 999px;
}

.move-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #7195b8 0%, #55748f 100%);
}

.move-list::-webkit-scrollbar-corner {
  background: #1c1d22;
}

.move-list__item {
  margin: 0;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 3px;
  border-radius: 2px;
}

.move-list__item:hover {
  background: rgba(86, 156, 214, 0.08);
}

.move-list__item:hover .move-row__number {
  color: var(--accent);
}

.move-list__variation-card {
  position: relative;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 5px;
  margin: 5px 0 5px 8px;
  padding: 5px 5px 5px 0;
  border: 1px solid rgba(197, 134, 192, 0.22);
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(197, 134, 192, 0.08), rgba(32, 28, 36, 0.64));
}

.move-list__variation-card--detached {
  border-color: rgba(220, 220, 170, 0.28);
  background: linear-gradient(90deg, rgba(220, 220, 170, 0.08), rgba(32, 30, 24, 0.62));
}

.move-variation__rail {
  grid-row: 1 / span 3;
  position: relative;
  min-height: 100%;
}

.move-variation__rail::before {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 6px;
  left: 6px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(197, 134, 192, 0.86), rgba(197, 134, 192, 0.18));
}

.move-variation__rail::after {
  content: "";
  position: absolute;
  top: 11px;
  left: 6px;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: rgba(197, 134, 192, 0.82);
}

.move-variation__rail span {
  position: absolute;
  top: 6px;
  left: 2px;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(244, 198, 243, 0.92);
  border-radius: 50%;
  background: #25212a;
  box-shadow: 0 0 0 2px rgba(197, 134, 192, 0.12);
}

.move-list__item--variation {
  grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr);
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
  background: rgba(197, 134, 192, 0.045);
}

.move-list__variation-header {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  margin: 0 0 2px;
  padding: 2px 6px;
  border: 1px solid rgba(197, 134, 192, 0.28);
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(197, 134, 192, 0.16), rgba(37, 37, 43, 0.9));
  color: #d7b7d8;
  font-size: 10px;
}

.move-list__variation-header--detached {
  border-color: rgba(220, 220, 170, 0.3);
  color: #dcdcaa;
}

.move-variation__graph-icon {
  width: 28px;
  height: 14px;
  position: relative;
  display: inline-block;
  opacity: 0.9;
}

.move-variation__graph-icon::before {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  top: 7px;
  height: 1px;
  background: rgba(197, 134, 192, 0.75);
}

.move-variation__graph-icon i {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c586c0;
  box-shadow: 0 0 0 1px rgba(244, 198, 243, 0.28);
}

.move-variation__graph-icon i:nth-child(1) {
  left: 1px;
  top: 4px;
}

.move-variation__graph-icon i:nth-child(2) {
  left: 11px;
  top: 1px;
}

.move-variation__graph-icon i:nth-child(3) {
  right: 1px;
  top: 7px;
}

.move-variation__table-head {
  grid-column: 2;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr);
  gap: 3px;
  align-items: center;
  min-height: 17px;
  padding: 0 2px;
  color: #b78abb;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.move-variation__table-head span:first-child {
  text-align: right;
  padding-right: 2px;
}

.move-variation__rows {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.move-variation__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 14px;
  border-radius: 999px;
  background: rgba(197, 134, 192, 0.22);
  color: #f4c6f3;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.move-variation__meta {
  margin-left: auto;
  color: #85858b;
  font-family: "Cascadia Mono", Consolas, monospace;
}

.move-list__empty {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #3b3b40;
  border-radius: 2px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.move-row__number {
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  text-align: right;
  padding-right: 2px;
}

.move-row__number--variation {
  color: #c586c0;
}

.move-cell {
  min-width: 0;
  min-height: 23px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  padding: 2px 6px;
  border: 1px solid #34343a;
  border-radius: 2px;
  background: linear-gradient(180deg, #202126 0%, #1a1b20 100%);
  color: #d7d7d7;
  cursor: pointer;
  text-align: left;
}

.move-cell:hover {
  background: linear-gradient(180deg, #26384a 0%, #223143 100%);
  border-color: var(--accent);
}

.move-cell--current {
  border-color: #8ab7e0;
  background: linear-gradient(180deg, #29445a 0%, #23384a 100%);
  box-shadow: inset 0 0 0 1px rgba(138, 183, 224, 0.24);
}

.move-cell--future {
  opacity: 0.5;
}

.move-cell--future:hover {
  opacity: 0.9;
}

.move-cell--dual-line {
  min-height: 29px;
  padding-top: 3px;
  padding-bottom: 3px;
}

.move-cell--custom,
.move-cell--uci-only {
  justify-content: center;
}

.move-cell--variation {
  border-color: rgba(197, 134, 192, 0.36);
  background: linear-gradient(180deg, #2b2230 0%, #211c26 100%);
}

.move-cell--variation:hover {
  border-color: #c586c0;
  background: linear-gradient(180deg, #3b2a43 0%, #2b2333 100%);
}

.move-cell:disabled,
.move-cell--empty {
  cursor: default;
}

.move-cell--empty {
  display: flex;
  justify-content: center;
  color: #5d5d63;
  background: #1b1c20;
  border-color: #2c2c31;
}

.move-cell__san,
.move-cell__uci {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.move-cell__san {
  min-width: 0;
  overflow: hidden;
  color: #f0f0f0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.move-cell__uci {
  color: #85858b;
  font-size: 8px;
  line-height: 1;
  text-transform: uppercase;
}

.move-cell__uci--solo {
  color: #dcdcaa;
  font-size: 10px;
  font-weight: 700;
}

.move-cell__custom {
  max-width: 100%;
  overflow: hidden;
  color: #9cdcfe;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moves-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  height: var(--strip-height);
  background: var(--border-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.btn:hover,
.btn.active {
  border-color: var(--accent);
  background: #313135;
}

.moves-actions .btn {
  border: 0;
  background: linear-gradient(180deg, #2b2b30 0%, #232328 100%);
  font-size: 11px;
  font-weight: 600;
}

.moves-actions .btn:hover {
  background: linear-gradient(180deg, #34343a 0%, #2c2c32 100%);
}

.dock-resize-handle {
  width: calc(100vw - (var(--workspace-padding) * 2));
  height: var(--dock-resizer-height);
  min-height: var(--dock-resizer-height);
  align-self: end;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-bottom: 0;
  background: linear-gradient(180deg, #202126 0%, #191a1e 100%);
  cursor: ns-resize;
}

.dock-resize-handle::before {
  content: "";
  width: 72px;
  height: 3px;
  border-radius: 999px;
  background: #5f636d;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.dock-resize-handle:hover::before,
body.is-resizing-dock .dock-resize-handle::before {
  background: #8ab7e0;
}

body.is-resizing-dock {
  cursor: ns-resize;
  user-select: none;
}

.analysis-dock {
  width: calc(100vw - (var(--workspace-padding) * 2));
  height: var(--dock-height);
  min-height: var(--dock-height);
  max-height: var(--dock-height);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 10px minmax(280px, 1.5fr) 10px minmax(240px, 1.4fr);
  align-self: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.dock-pane {
  min-width: 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--panel);
}

.dock-pane__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  min-height: 16px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dock-pane__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.dock-pane__actions .btn {
  flex: 1 1 108px;
  min-height: 21px;
  padding: 2px 5px;
  font-size: 11px;
}

.dock-pane--engine,
.dock-pane--prediction {
  min-height: 0;
}

.dock-divider {
  position: relative;
  background: var(--panel-3);
  border-left: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
  cursor: col-resize;
}

.dock-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 28px;
  transform: translate(-50%, -50%);
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.18) 2px,
    transparent 2px,
    transparent 5px
  );
}

.dock-textarea,
.engine-log,
.worker-log__output {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0;
  background: #17181b;
  color: #bfdcff;
  padding: 4px 6px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
}

.dock-textarea {
  min-height: 48px;
  flex: 1;
  resize: none;
  color: var(--text);
  overflow: auto;
}

.engine-log {
  flex: 1;
  min-height: 0;
  max-height: none;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overscroll-behavior: contain;
}

.engine-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.metric {
  background: #1f1f23;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 3px 4px;
}

.metric span {
  display: block;
  font-size: 9px;
  color: var(--muted);
}

.metric strong {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  font-size: 12px;
  min-height: 16px;
}

.metric__value-text {
  min-width: 0;
}

.metric__mate-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.metric__mate-badge--white {
  background: rgba(137, 209, 133, 0.18);
  color: #bff0bc;
  border: 1px solid rgba(137, 209, 133, 0.4);
}

.metric__mate-badge--black {
  background: rgba(241, 76, 76, 0.18);
  color: #ffb0b0;
  border: 1px solid rgba(241, 76, 76, 0.42);
}

.engine-bestline {
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  align-items: start;
  flex: 0 0 auto;
}

.dock-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.engine-bestline__value {
  min-width: 0;
  color: var(--text);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prediction-card {
  display: grid;
  gap: 5px;
  min-height: 0;
}

.prediction-meter {
  position: relative;
  height: 14px;
  border-radius: 0;
  overflow: hidden;
  background: linear-gradient(90deg, #f0ede0 0%, #f0ede0 50%, #15171a 50%, #15171a 100%);
  border: 1px solid var(--border);
}

.prediction-meter__white {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
  background: linear-gradient(90deg, #e6e2d3 0%, #ffffff 100%);
}

.prediction-meter__legend {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

.prediction-copy__winner {
  font-size: 14px;
  font-weight: 700;
}

.prediction-copy__summary {
  color: var(--muted);
  line-height: 1.25;
  font-size: 11px;
}

.worker-log {
  grid-row: 3;
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: var(--worker-log-height);
  height: var(--worker-log-height);
  border-top: 1px solid var(--border);
  background: #181818;
  color: var(--text);
  overflow: hidden;
}

.worker-log[hidden] {
  display: none;
}

.worker-log__label {
  min-width: 0;
  height: 100%;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.worker-log__output {
  min-width: 0;
  height: 100%;
  min-height: 0;
  max-height: none;
  margin: 0;
  border: 0;
  background: transparent;
  color: #b8d7ff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.statusbar {
  grid-row: 4;
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  display: flex;
  align-items: center;
  align-self: stretch;
  justify-self: stretch;
  height: var(--status-height);
  min-height: var(--status-height);
  gap: 8px;
  padding: 0 8px;
  background: #007acc;
  color: #fff;
  font-size: 11px;
}

.statusbar__spacer {
  flex: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(2px);
}

#textModal {
  z-index: 110;
}

.modal-card {
  width: min(760px, calc(100vw - 48px));
  max-height: min(82vh, 720px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #47474d;
  background: #252526;
  color: var(--text);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.48);
}

.modal-card--history {
  width: min(560px, calc(100vw - 48px));
}

.modal-card--about {
  position: relative;
  width: min(420px, calc(100vw - 48px));
  overflow: hidden;
  border: 1px solid rgba(143, 191, 255, 0.28);
  background: #111317;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55);
}

.modal-card--about::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 24% 16%, rgba(137, 209, 133, 0.22), transparent 28%),
    radial-gradient(circle at 80% 18%, rgba(79, 193, 255, 0.18), transparent 26%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 34%);
}

.modal-card--promotion {
  width: min(420px, calc(100vw - 48px));
}

.modal-card--transparency {
  width: min(460px, calc(100vw - 48px));
}

.transparency-control {
  display: grid;
  gap: 14px;
  padding: 4px 16px 10px;
}

.transparency-control__readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(137, 209, 133, 0.24);
  background: linear-gradient(135deg, rgba(137, 209, 133, 0.12), rgba(79, 193, 255, 0.08));
}

.transparency-control__readout span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.transparency-control__readout strong {
  color: #ffffff;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 24px;
}

.transparency-slider {
  width: 100%;
  accent-color: var(--accent-2);
}

.transparency-control__scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.transparency-control__hint {
  margin: 0;
  color: #c7d5e5;
  font-size: 12px;
  line-height: 1.4;
}

.modal-close--cover {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  color: #dfefff;
}

.about-cover {
  position: relative;
  min-height: 500px;
  display: grid;
  align-content: end;
  gap: 12px;
  padding: 104px 34px 30px 54px;
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.36) 0 28px, transparent 28px),
    linear-gradient(160deg, #234158 0%, #151b22 46%, #111317 100%);
}

.about-cover::before {
  content: "";
  position: absolute;
  inset: 18px 18px 18px 40px;
  z-index: -1;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.01));
}

.about-cover__spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #0b1116 0%, #17232c 100%);
  color: rgba(223, 239, 255, 0.72);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.about-cover__mark {
  position: absolute;
  top: 38px;
  right: 34px;
  color: rgba(255, 255, 255, 0.08);
  font-size: 124px;
  line-height: 1;
}

.about-cover__icon {
  width: 86px;
  height: 86px;
  border-radius: 23px;
  background: #040806;
  box-shadow: 0 0 0 1px rgba(57, 214, 126, 0.38), 0 18px 42px rgba(0, 0, 0, 0.38);
  object-fit: contain;
}

.about-cover__eyebrow {
  margin: 16px 0 0;
  color: #9cdcfe;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.about-cover h2 {
  margin: 0;
  color: #ffffff;
  font-size: 42px;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.about-cover__subtitle {
  max-width: 280px;
  margin: 0;
  color: #c7d5e5;
  font-size: 13px;
  line-height: 1.45;
}

.about-cover__rule {
  width: 94px;
  height: 3px;
  margin: 4px 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #89d185, #4fc1ff);
}

.about-cover__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 12px;
}

.about-cover__meta span {
  display: grid;
  gap: 3px;
}

.about-cover__meta small {
  color: rgba(212, 212, 212, 0.66);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.about-cover__meta strong {
  color: #ffffff;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.modal-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 0;
}

.modal-card__header h2 {
  margin: 0;
  color: #ffffff;
  font-size: 17px;
  font-weight: 600;
}

.modal-card__header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.modal-textarea {
  min-height: 190px;
  margin: 0 16px;
  padding: 10px 12px;
  border: 1px solid #3f3f46;
  background: #1e1e1e;
  color: #d7e8ff;
  resize: vertical;
  user-select: text;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  outline: none;
}

.modal-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 122, 204, 0.35);
}

.modal-error {
  min-height: 18px;
  padding: 0 16px;
  color: #ff8f8f;
  font-size: 12px;
}

.modal-actions,
.history-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 16px 16px;
}

.promotion-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px;
}

.promotion-choice {
  min-height: 74px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #3f3f46;
  border-radius: 4px;
  background: linear-gradient(180deg, #202126 0%, #1a1b20 100%);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.promotion-choice:hover,
.promotion-choice:focus-visible {
  border-color: var(--accent);
  background: linear-gradient(180deg, #26384a 0%, #223143 100%);
  outline: none;
}

.promotion-choice__image {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.promotion-choice__label {
  min-width: 0;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
}

.btn--primary {
  border-color: #0e639c;
  background: #0e639c;
  color: #fff;
}

.btn--primary:hover {
  border-color: #1177bb;
  background: #1177bb;
}

.btn--ghost {
  background: transparent;
}

.history-list {
  min-height: 180px;
  max-height: min(52vh, 430px);
  margin: 0 16px 16px;
  padding: 4px;
  border: 1px solid #3f3f46;
  background: #1b1b1f;
  overflow: auto;
}

.history-empty {
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.history-group + .history-group {
  margin-top: 4px;
}

.history-row {
  width: 100%;
  min-height: 32px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.history-row:hover {
  background: rgba(0, 122, 204, 0.18);
}

.history-row--child {
  margin-left: 24px;
  width: calc(100% - 24px);
  grid-template-columns: 24px minmax(0, 1fr) auto auto auto;
  color: #c5d5e8;
}

.history-children {
  border-left: 1px solid #3f3f46;
  margin-left: 12px;
}

.history-row__delete {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  color: #ff8f8f;
  font-size: 16px;
  line-height: 1;
}

.history-row__delete:hover {
  background: rgba(241, 76, 76, 0.2);
  color: #fff;
}

.history-row__name {
  min-width: 0;
  overflow: hidden;
  color: #f0f0f0;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row__date,
.history-row__count,
.history-row__arrow {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.teacher-toast {
  position: fixed;
  top: calc(var(--chrome-height) + 12px);
  right: 16px;
  z-index: 120;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid #40688a;
  border-left: 3px solid #4fc1ff;
  background: rgba(37, 37, 38, 0.96);
  color: var(--text);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.teacher-toast--info {
  border-color: #40688a;
  border-left-color: #4fc1ff;
}

.teacher-toast--success {
  border-color: #476b47;
  border-left-color: #89d185;
}

.teacher-toast--danger {
  border-color: #7b4747;
  border-left-color: #f14c4c;
}

.teacher-toast--warning {
  border-color: #7b6840;
  border-left-color: #d7ba7d;
}

.teacher-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.teacher-toast__icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(79, 193, 255, 0.13);
  color: #8fd7ff;
  font-size: 15px;
}

.teacher-toast--success .teacher-toast__icon {
  background: rgba(137, 209, 133, 0.15);
  color: #b7efb3;
}

.teacher-toast--danger .teacher-toast__icon {
  background: rgba(241, 76, 76, 0.14);
  color: #ffb0b0;
}

.teacher-toast--warning .teacher-toast__icon {
  background: rgba(215, 186, 125, 0.16);
  color: #f2d59a;
}

.teacher-toast__copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.teacher-toast__copy strong {
  color: #ffffff;
  font-size: 13px;
}

.teacher-toast__copy span {
  color: #c7d5e5;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 760px), (max-height: 610px) {
  body {
    overflow: auto;
  }

  .app-shell {
    position: static;
    min-height: 100%;
    height: auto;
    grid-template-rows: var(--chrome-height) minmax(0, 1fr) auto var(--status-height);
  }

  .workspace {
    overflow: visible;
  }

  .main-stage {
    grid-template-rows: auto auto;
    align-content: start;
  }

  .stage-grid {
    grid-template-columns: 1fr;
    width: min(100%, var(--board-size));
    height: auto;
    min-height: 0;
    row-gap: 6px;
  }

  .left-rail {
    order: 2;
    width: min(100%, var(--board-size));
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    row-gap: 6px;
  }

  .main-stage.is-clock-hidden .stage-grid {
    width: min(100%, var(--board-size));
    grid-template-columns: 1fr;
  }

  .main-stage.is-clock-hidden .left-rail {
    width: min(100%, var(--board-size));
    grid-template-columns: 1fr;
  }

  .clock-column {
    width: min(100%, var(--board-size));
    height: auto;
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto;
    gap: 4px;
  }

  .clock-panel {
    min-height: 42px;
  }

  .clock-panel--north {
    grid-column: 1;
    grid-row: 1;
  }

  .clock-panel--south {
    grid-column: 2;
    grid-row: 1;
  }

  .main-stage.is-clock-hidden .clock-column {
    display: none;
  }

  .clock-column__meta {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 26px;
    padding: 6px 8px;
    border: 1px solid var(--border-soft);
    flex-direction: row;
    gap: 10px;
  }

  .eval-column {
    width: min(100%, var(--board-size));
    height: 22px;
    min-height: 22px;
  }

  .eval-meter {
    min-height: 22px;
    flex-direction: row;
  }

  .eval-meter__labels {
    inset: 2px 6px;
    flex-direction: row;
    writing-mode: horizontal-tb;
    transform: none;
  }

  .board-arena {
    grid-template-rows: auto auto auto;
    width: var(--board-size);
    height: auto;
    min-height: 0;
  }

  .player-zone {
    grid-template-columns: minmax(0, 1fr) var(--score-width) var(--cpu-width);
    grid-template-areas:
      "captured score toggle";
    min-height: auto;
    padding: 0;
  }

  .player-zone__captured {
    grid-area: captured;
  }

  .player-zone__identity {
    display: none;
  }

  .player-zone__score {
    grid-area: score;
  }

  .seat-toggle {
    grid-area: toggle;
  }

  .moves-pane {
    width: min(100%, var(--board-size));
    height: 260px;
    min-height: 260px;
  }

  .analysis-dock {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .dock-divider {
    display: none;
  }
}