:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-strong: #faedea;
  --ink: #1d2220;
  --muted: #65716e;
  --line: #cfd8d2;
  --control-border: #9aa69f;
  --accent: #d64a38;
  --accent-strong: #a83328;
  --accent-soft: rgba(214, 74, 56, 0.12);
  --control-hover: #fff0ed;
  --settings-active-bg: #fff0ed;
  --warning: #b84c3d;
  --tile: #d64a38;
  --tile-edge: #a83328;
  --tile-preview: #ea7a6a;
  --tile-preview-edge: #c84535;
  --available: #d64a38;
  --available-soft: rgba(214, 74, 56, 0.12);
  --available-fill: rgba(254, 238, 235, 0.58);
  --available-stroke: rgba(214, 74, 56, 0.68);
  --track-black: #151719;
  --track-white: #fbfaf0;
  --white-outline: #31383a;
  --winning-path-core: var(--accent);
  --winning-path-core-light: var(--tile-preview);
  --player-white-bg: #ffffff;
  --player-white-fg: #000000;
  --player-white-border: rgba(18, 22, 21, 0.28);
  --player-white-shadow: none;
  --player-black-bg: #000000;
  --player-black-fg: #ffffff;
  --player-black-border: rgba(255, 255, 255, 0.35);
  --player-black-shadow: none;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button {
  font: inherit;
}

.app {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  font-weight: 780;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 0.9rem;
  font-weight: 760;
  letter-spacing: 0;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header[hidden] {
  display: none;
}

.tool-button,
.icon-button,
.orientation-button,
.theme-option {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

.tool-button {
  min-height: 36px;
  padding: 0 12px;
  font-weight: 720;
}

.icon-button {
  width: 36px;
  height: 36px;
  font-size: 1.25rem;
  font-weight: 780;
  line-height: 1;
}

.control-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-button svg,
.help-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-button:hover,
.icon-button:hover,
.orientation-button:hover,
.theme-option:hover {
  border-color: var(--accent);
  background: var(--control-hover);
  color: var(--ink);
}

.tool-button:active,
.icon-button:active,
.orientation-button:active,
.theme-option:active {
  transform: translateY(1px);
}

.tool-button:disabled,
.tool-button:disabled:hover,
.icon-button:disabled,
.icon-button:disabled:hover,
.orientation-button:disabled,
.orientation-button:disabled:hover {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface) 72%, var(--line));
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.tutorial-next-button:disabled,
.tutorial-next-button:disabled:hover {
  border-style: dashed;
  box-shadow: none;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 0;
  overflow: hidden;
}

.layout.side-panel-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.board-section {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.board-viewport {
  flex: 1;
  min-height: 420px;
  position: relative;
  overflow: hidden;
  background: #eef1eb;
  outline: none;
  cursor: grab;
}

.board-viewport:focus-visible {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent);
}

.board-viewport.dragging {
  cursor: grabbing;
}

.turn-subtitle-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding: 0 14px;
  pointer-events: none;
}

.turn-subtitle {
  min-width: min(360px, 100%);
  padding: 14px 28px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(20, 24, 22, 0.24);
  font-size: 1.15rem;
  font-weight: 820;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.42);
  white-space: nowrap;
}

.turn-subtitle.white-turn {
  border-color: var(--player-white-border);
  background: var(--player-white-bg);
  color: var(--player-white-fg);
  text-shadow: var(--player-white-shadow);
}

.turn-subtitle.black-turn {
  border-color: var(--player-black-border);
  background: var(--player-black-bg);
  color: var(--player-black-fg);
  text-shadow: var(--player-black-shadow);
}

.board-svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  user-select: none;
  touch-action: none;
}

.board-grid-line {
  stroke: rgba(67, 59, 49, 0.2);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.board-grid-label {
  fill: #89938f;
  stroke: rgba(238, 241, 235, 0.92);
  stroke-width: 5;
  paint-order: stroke;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.candidate-cell {
  fill: var(--available-fill);
  stroke: var(--available-stroke);
  stroke-width: 2;
  stroke-dasharray: 7 7;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}

.candidate-cell:hover {
  fill: var(--available-soft);
}

.candidate-cell.covered,
.candidate-cell.covered:hover {
  fill: transparent;
  stroke: transparent;
}

.selected-cell {
  fill: none;
  stroke: var(--available);
  stroke-width: 5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.ghost-tile {
  opacity: 0.58;
  pointer-events: none;
}

.forced-preview-tile {
  opacity: 0.28;
  pointer-events: none;
}

.touch-play-target {
  cursor: pointer;
}

.touch-play-cell {
  fill: var(--tile);
  stroke: var(--tile-edge);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.touch-play-cell-highlight {
  fill: none;
  stroke: rgba(255,255,255,0.3);
  stroke-width: 2;
  pointer-events: none;
}

.touch-play-cell-edge {
  fill: none;
  stroke: var(--tile-edge);
  stroke-width: 3;
  pointer-events: none;
}

.touch-play-icon-edge,
.touch-play-icon {
  pointer-events: none;
  stroke-linejoin: round;
}

.touch-play-icon-edge {
  fill: #000;
  stroke: #000;
  stroke-width: 10;
}

.touch-play-target.player-white .touch-play-icon-edge {
  fill: var(--white-outline);
  stroke: var(--white-outline);
}

.touch-play-icon {
  fill: var(--track-black);
  stroke: var(--track-black);
  stroke-width: 4;
}

.touch-play-target.player-white .touch-play-icon {
  fill: var(--track-white);
  stroke: var(--track-white);
}

.tile-shadow {
  fill: rgba(0, 0, 0, 0.16);
  pointer-events: none;
}

.tile-group {
  pointer-events: none;
}

.tile-edge-overlay {
  pointer-events: none;
}

.winning-path-spark {
  fill: var(--winning-path-core);
  animation: winning-dot-marquee 0.85s steps(1, end) infinite;
  pointer-events: none;
  stroke: none;
}

.winning-path-spark.alternate {
  animation-name: winning-dot-marquee-alternate;
  fill: var(--winning-path-core-light);
}

@keyframes winning-dot-marquee {
  0%,
  49.99% {
    fill: var(--winning-path-core);
  }

  50%,
  100% {
    fill: var(--winning-path-core-light);
  }
}

@keyframes winning-dot-marquee-alternate {
  0%,
  49.99% {
    fill: var(--winning-path-core-light);
  }

  50%,
  100% {
    fill: var(--winning-path-core);
  }
}

@media (prefers-reduced-motion: reduce) {
  .winning-path-spark {
    animation: none;
  }
}

.side-panel {
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.side-panel[hidden] {
  display: none;
}

.board-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: start;
  pointer-events: none;
}

.board-toolbar button {
  pointer-events: auto;
}

.board-left-control-bar,
.view-control-bar,
.board-control-bar,
.board-right-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.board-left-control-bar {
  grid-column: 1;
}

.view-control-bar {
  grid-column: 1;
  grid-row: 2;
  align-items: flex-start;
  flex-direction: column;
  margin-top: 16px;
}

.board-right-control-group {
  grid-column: 3;
  grid-row: 1;
}

.puzzle-star {
  width: 24px;
  height: 24px;
  fill: transparent;
  stroke: var(--accent);
  stroke-linejoin: round;
  stroke-width: 2.6;
}

.puzzle-star.filled {
  fill: var(--accent);
}

.settings-button,
.help-button {
  display: grid;
  place-items: center;
  border-color: var(--control-border);
}

.board-control-bar .undo-button[hidden],
.board-control-bar .puzzle-restart-button[hidden],
.board-control-bar .next-puzzle-button[hidden] {
  display: none;
}

.view-control-bar .icon-button,
.board-control-bar .icon-button {
  display: grid;
  place-items: center;
}

.view-control-bar .icon-button,
.board-control-bar .icon-button,
.board-control-bar .tool-button {
  border-color: var(--control-border);
}

.new-game-button {
  justify-self: stretch;
}

.settings-curtain,
.help-curtain,
.new-game-curtain,
.first-run-curtain,
.confirmation-curtain {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(18, 22, 21, 0.46);
}

.settings-curtain,
.help-curtain,
.new-game-curtain,
.first-run-curtain,
.confirmation-curtain {
  position: fixed;
}

.settings-curtain[hidden],
.settings-dialog[hidden],
.help-curtain[hidden],
.help-dialog[hidden],
.new-game-curtain[hidden],
.new-game-dialog[hidden],
.first-run-curtain[hidden],
.first-run-dialog[hidden],
.confirmation-curtain[hidden],
.confirmation-dialog[hidden] {
  display: none;
}

.settings-dialog,
.help-dialog,
.new-game-dialog,
.first-run-dialog,
.confirmation-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  width: min(380px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(20, 24, 22, 0.34);
  transform: translate(-50%, -50%);
}

.settings-dialog,
.help-dialog,
.new-game-dialog {
  position: fixed;
}

.confirmation-dialog {
  position: fixed;
  width: min(360px, calc(100% - 32px));
}

.first-run-dialog {
  position: fixed;
  width: min(380px, calc(100% - 32px));
}

.help-dialog {
  width: min(760px, calc(100% - 32px));
  height: min(720px, calc(100% - 32px));
}

.new-game-dialog {
  width: min(380px, calc(100% - 32px));
}

.settings-body,
.new-game-body {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.settings-toggle {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.settings-toggle[hidden] {
  display: none;
}

@media (pointer: coarse), (max-width: 860px) {
  .desktop-play-control-setting {
    display: none;
  }
}

.game-mode-selector {
  width: 100%;
  min-height: 108px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: minmax(48px, auto);
  padding: 5px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: #ffffff;
}

.game-mode-option {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 780;
}

.game-mode-option:nth-child(-n + 3) {
  grid-column: span 2;
}

.game-mode-option:nth-child(n + 4) {
  grid-column: span 3;
}

.game-mode-option:hover {
  background: var(--control-hover);
}

.game-mode-option[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--settings-active-bg);
}

.game-mode-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.settings-toggle[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--settings-active-bg);
}

.toggle-track {
  width: 54px;
  height: 30px;
  padding: 3px;
  border: 1px solid var(--control-border);
  border-radius: 999px;
  background: #d9e0dc;
  transition:
    background 140ms ease,
    border-color 140ms ease;
}

.toggle-thumb {
  width: 22px;
  height: 22px;
  display: block;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 2px 5px rgba(20, 24, 22, 0.24);
  transition: transform 140ms ease;
}

.settings-toggle[aria-checked="true"] .toggle-track {
  border-color: var(--accent);
  background: var(--accent);
}

.settings-toggle[aria-checked="true"] .toggle-thumb {
  transform: translateX(24px);
}

.toggle-label {
  min-width: 0;
  overflow: hidden;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-settings {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.theme-option {
  min-width: 0;
  min-height: 78px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 8px;
  cursor: pointer;
  font: inherit;
}

.theme-option[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--settings-active-bg);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.theme-option svg {
  width: min(54px, 100%);
  aspect-ratio: 1;
}

.player-name-settings {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.player-name-field {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 780;
}

.player-name-field input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.player-name-field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.settings-actions,
.new-game-actions,
.confirmation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 16px 16px;
}

.confirmation-body {
  padding: 10px 18px 18px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 640;
  line-height: 1.4;
}

.first-run-dialog:focus {
  outline: none;
}

.first-run-dialog .confirmation-body {
  padding-bottom: 24px;
}

.first-run-dialog .confirmation-actions {
  padding-top: 8px;
  padding-bottom: 24px;
}

.first-run-preview {
  display: flex;
  justify-content: center;
  margin: 24px 0 10px;
}

.first-run-preview-svg {
  display: block;
  width: min(100%, 276px);
  height: auto;
}

.confirmation-confirm-button {
  border-color: var(--accent);
  background: var(--settings-active-bg);
}

.dialog-header,
.help-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 16px 8px 18px;
}

.dialog-header h1,
.help-header h1 {
  color: #000;
  font-size: 1.15rem;
  font-weight: 840;
  line-height: 1.1;
}

.help-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 36px 20px 18px;
  scrollbar-width: none;
}

.help-body::-webkit-scrollbar {
  display: none;
}

.help-section {
  color: #000;
}

.help-section + .help-section {
  margin-top: 26px;
}

.help-section-title {
  margin: 0 0 10px;
  color: #000;
  font-size: 0.98rem;
  font-weight: 840;
  line-height: 1.2;
}

.help-instructions {
  color: #000;
  font-size: 0.88rem;
  font-weight: 620;
  line-height: 1.4;
}

.help-instructions + .help-instructions {
  margin-top: 6px;
}

.help-tutorial-button {
  flex: 0 0 auto;
  min-width: 106px;
  margin-top: 10px;
  border-color: var(--accent);
  background: var(--settings-active-bg);
}

.custom-scrollbar {
  position: absolute;
  width: 16px;
  border: 2px solid var(--control-border);
  border-radius: 8px;
  background: #e0e4df;
  cursor: pointer;
  touch-action: none;
}

.custom-scrollbar:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.custom-scrollbar-thumb {
  position: absolute;
  top: 0;
  left: 2px;
  right: 2px;
  min-height: 44px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--accent);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.38);
  cursor: grab;
}

.custom-scrollbar-thumb:active {
  cursor: grabbing;
}

.custom-scrollbar.is-disabled .custom-scrollbar-thumb {
  opacity: 0.48;
  cursor: default;
}

.help-scrollbar {
  top: 60px;
  right: 9px;
  bottom: 10px;
}

.help-rules {
  margin: 0;
  padding-left: 24px;
  color: #000;
  font-size: 0.88rem;
  font-weight: 620;
  line-height: 1.42;
}

.help-rules > li {
  padding-left: 2px;
}

.help-rules > li + li {
  margin-top: 14px;
}

.help-rules strong {
  color: #000;
  font-weight: 840;
}

.help-theme-word {
  color: var(--accent);
  font-weight: 860;
}

.help-rules em {
  color: #000;
}

.help-rule-continuation,
.help-example-heading {
  display: block;
}

.help-rule-indent {
  padding-left: 20px;
}

.help-example-heading {
  margin-top: 8px;
  color: #000;
  font-weight: 640;
}

.help-example-heading + .help-example-canvas {
  margin-top: 6px;
}

.help-example-sequence {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.help-example-sequence-forced {
  align-items: flex-start;
  gap: 12px;
}

.help-example-step {
  display: grid;
  gap: 4px;
}

.help-example-label,
.help-example-link {
  color: #000;
  font-weight: 640;
}

.help-example-canvas,
.help-example-svg {
  display: block;
}

.help-legal-list {
  margin: 0;
  padding-left: 22px;
  color: #000;
  font-size: 0.86rem;
  font-weight: 620;
  line-height: 1.42;
}

.help-legal-list > li + li {
  margin-top: 10px;
}

.help-legal-list strong {
  color: #000;
  font-weight: 840;
}

.help-legal-list em {
  color: #000;
}

.new-game-detail {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.35;
}

.save-settings-button {
  min-width: 142px;
  border-color: var(--accent);
  background: var(--settings-active-bg);
  color: var(--ink);
}

.play-trax-button {
  border-color: var(--accent);
  background: var(--settings-active-bg);
}

.panel-section {
  flex: 1;
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.section-header {
  justify-content: space-between;
}

.side-status-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #fbfcf8;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.side-status-bar[hidden] {
  display: none;
}

.side-status-bar .tile-count,
.selected-readout {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-readout {
  justify-self: start;
}

.tile-count {
  justify-self: end;
  text-align: right;
}

.orientation-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.orientation-button {
  min-width: 0;
  aspect-ratio: 1;
  padding: 7px;
  display: grid;
  place-items: center;
  position: relative;
}

.orientation-button svg {
  width: 100%;
  height: 100%;
}

.orientation-button.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.orientation-button.not-local {
  opacity: 0.48;
}

.orientation-button .notation {
  position: absolute;
  right: 6px;
  bottom: 4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.move-log-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  margin: 0;
}

.move-log {
  height: 100%;
  overflow: auto;
  margin: 0;
  padding: 0;
  color: var(--ink);
  font-size: 0.86rem;
  scrollbar-width: none;
}

.move-log::-webkit-scrollbar {
  display: none;
}

.move-log-wrap.has-scrollbar .move-log {
  padding-right: 24px;
}

.game-info-scrollbar {
  top: 0;
  right: 0;
  bottom: 0;
}

.game-info-scrollbar[hidden] {
  display: none;
}

.plays-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.plays-table th,
.plays-table td {
  padding: 7px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  text-align: left;
  vertical-align: top;
}

.plays-table .play-number-header,
.plays-table .play-number-cell {
  width: 2.4rem;
  padding-right: 6px;
  color: var(--muted);
  text-align: right;
}

.plays-table .play-notation-header,
.plays-table .play-notation-cell {
  width: calc(50% - 2.4rem);
  min-width: 0;
}

.plays-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.plays-table tbody tr {
  background: var(--surface);
}

.plays-table tbody tr:nth-child(even) {
  background: var(--surface);
}

.plays-table tbody tr:nth-child(odd) {
  background: var(--control-hover);
}

.plays-table td {
  min-height: 34px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.plays-table .play-notation-cell:not(:empty) {
  color: var(--ink);
  font-weight: 720;
}

.puzzle-info {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
}

.tutorial-info {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
}

.tutorial-info[hidden] {
  display: none;
}

.tutorial-progress-label {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 780;
}

.tutorial-progress-track {
  flex: 0 0 auto;
  height: 18px;
  overflow: hidden;
  border: 2px solid var(--control-border);
  border-radius: 8px;
  background: #e0e4df;
}

.tutorial-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 5px;
  background: var(--accent);
  transition: width 180ms ease;
}

.tutorial-copy {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 620;
  line-height: 1.46;
}

.tutorial-copy h2 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 1.04rem;
}

.tutorial-copy p + p {
  margin-top: 12px;
}

.tutorial-objective {
  color: var(--ink);
  font-weight: 780;
}

.tutorial-objective[hidden] {
  display: none;
}

.tutorial-theme-word {
  color: var(--accent);
  font-weight: 860;
}

.tutorial-tile-examples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 8px;
}

.tutorial-tile-example-svg {
  display: block;
  width: 58px;
  height: 58px;
}

.tutorial-required-tile {
  float: right;
  display: block;
  width: 46px;
  margin: 1px 0 6px 10px;
}

.tutorial-required-tile-svg {
  display: block;
  width: 46px;
  height: 46px;
}

.tutorial-success {
  padding: 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--settings-active-bg);
  color: var(--ink);
  font-weight: 740;
}

.tutorial-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto auto;
  justify-content: space-between;
  gap: 8px;
}

.tutorial-actions[hidden] {
  display: none;
}

.tutorial-actions .tool-button {
  min-width: 0;
  padding: 0 9px;
  font-size: 0.78rem;
}

.tutorial-next-button {
  border-color: var(--accent);
  background: var(--settings-active-bg);
}

.puzzle-info[hidden] {
  display: none;
}

.puzzle-progress-label {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 780;
}

.puzzle-progress-track {
  height: 18px;
  overflow: hidden;
  border: 2px solid var(--control-border);
  border-radius: 8px;
  background: #e0e4df;
}

.puzzle-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 5px;
  background: var(--accent);
  transition: width 180ms ease;
}

.puzzle-list-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
}

.puzzle-list {
  height: 100%;
  display: grid;
  align-content: start;
  gap: 0;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: none;
}

.puzzle-list::-webkit-scrollbar {
  display: none;
}

.puzzle-list-wrap.has-scrollbar .puzzle-list {
  padding-right: 24px;
}

.puzzle-list-scrollbar {
  top: 0;
  right: 0;
  bottom: 0;
}

.puzzle-list-scrollbar[hidden] {
  display: none;
}

.puzzle-list-button {
  display: grid;
  grid-template-columns: 2rem 75px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  min-height: 36px;
  padding: 7px 10px 7px 4px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.puzzle-list-button:nth-child(odd) {
  background: var(--control-hover);
}

.puzzle-list-button:hover {
  background: var(--control-hover);
}

.puzzle-list-button.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.puzzle-list-stars {
  display: flex;
  align-items: center;
}

.puzzle-list-number {
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  white-space: nowrap;
  text-align: right;
}

.puzzle-list-target {
  min-width: 0;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 720;
  overflow-wrap: anywhere;
}

.puzzle-list-stars {
  gap: 1px;
}

.puzzle-list-stars .puzzle-star {
  width: 18px;
  height: 18px;
}

.puzzle-reset-wrap {
  min-height: 52px;
  display: grid;
  place-items: center;
  padding: 8px 10px;
  background: var(--surface);
}

.puzzle-reset-button {
  color: var(--muted);
  font-size: 0.76rem;
}

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

  .side-panel {
    height: min(240px, 32vh);
    min-height: min(240px, 32vh);
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .layout.puzzle-mode .side-panel {
    height: min(360px, 42vh);
    min-height: min(360px, 42vh);
  }

  .layout.tutorial-mode .side-panel {
    height: min(380px, 48vh);
    min-height: min(380px, 48vh);
  }

  .layout.tutorial-mode .board-viewport {
    min-height: 52vh;
  }

  .board-viewport {
    min-height: 58vh;
  }

  .orientation-grid {
    grid-template-columns: repeat(6, minmax(48px, 1fr));
  }
}

@media (max-width: 540px) {
  .settings-dialog,
  .help-dialog,
  .new-game-dialog,
  .first-run-dialog,
  .confirmation-dialog {
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
  }

  .settings-body,
  .new-game-body,
  .help-body,
  .confirmation-body {
    overflow-x: hidden;
    overscroll-behavior-x: none;
  }

  .tool-button {
    min-height: 44px;
    padding: 0 14px;
    font-size: 0.92rem;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .control-button svg,
  .settings-button svg,
  .help-button svg {
    width: 22px;
    height: 22px;
  }

  .board-toolbar {
    top: 12px;
    left: 12px;
    right: 12px;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .board-left-control-bar,
  .view-control-bar,
  .board-control-bar,
  .board-right-control-group {
    gap: 10px;
  }

  .board-left-control-bar {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  .view-control-bar {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    margin-top: 18px;
  }

  .board-right-control-group {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    margin-top: 0;
    min-width: 0;
    max-width: calc(100vw - 136px);
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .board-control-bar {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .board-control-bar .tool-button {
    padding: 0 12px;
    font-size: 0.86rem;
  }

  .settings-toggle,
  .game-mode-option {
    min-height: 48px;
  }

  .theme-option {
    min-height: 52px;
  }

  .orientation-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dialog-header,
  .help-header {
    padding-left: 14px;
  }

  .help-body {
    padding: 14px 34px 14px 14px;
    overflow-y: auto;
  }

  .help-section,
  .help-rules,
  .help-legal-list,
  .help-example-step {
    min-width: 0;
    max-width: 100%;
  }

  .help-example-sequence {
    max-width: 100%;
    overflow-x: hidden;
  }

  .help-example-canvas,
  .help-example-svg {
    max-width: 100%;
  }

  .help-example-svg {
    height: auto;
  }

  .help-tutorial-button {
    width: auto;
  }

  .help-example-sequence-forced {
    gap: 10px;
  }

  .turn-subtitle {
    width: 100%;
    min-width: 0;
    padding: 13px 18px;
    font-size: 1rem;
  }
}
