/* The inline SVG icon sprite (no style attribute: the website's CSP forbids them). */
.icon-sprite {
  position: absolute;
}
/* WoodWhiz Smart Chess — every UI colour comes from these tokens. */
:root {
  --page: #f6f1e7;
  --surface: #fbf8f2;
  --card: #ffffff;
  --card-alt: #f4eee3;
  --input: #ffffff;
  --text: #2b2118;
  --muted: #74675a;
  --border: #e5dccd;
  --border-strong: #d5c7b1;
  --accent: #b7832f;
  --accent-strong: #946620;
  --accent-text: #ffffff;
  --accent-soft: #f5e9d2;
  --success: #2f8f5b;
  --success-soft: #e3f3ea;
  --warning: #b9781a;
  --warning-soft: #fbf0dc;
  --danger: #c2412d;
  --danger-soft: #fbe7e3;
  --info: #2f6fb0;
  --info-soft: #e5eef8;
  --viewer: #efe6d6;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 8px 24px rgb(60 40 20 / 8%);
  --shadow-strong: 0 18px 50px rgb(40 25 10 / 22%);
  --overlay: rgb(30 22 14 / 45%);
  --piece-light: #faf6ee;
  --piece-light-text: #3a2c1e;
  --piece-dark: #2c2620;
  --piece-dark-text: #f4ebdd;
  --on-danger: #ffffff;
  --logo-badge: #fbf6ee;
  --sim-square-dark: #3a3530;
  --sim-square-light: #4a443d;
  --sim-inset: rgb(0 0 0 / 30%);
  /* 3D scene backdrops (independent of the UI theme). */
  --scene-studio: radial-gradient(ellipse at 50% 42%, #a9acb0 0%, #93969a 52%, #74777b 100%);
  --scene-light: radial-gradient(ellipse at 50% 42%, #f6efe3 0%, #e8dfcf 60%, #d9cfbd 100%);
  --scene-dark: radial-gradient(ellipse at 50% 42%, #272a30 0%, #17191d 60%, #0d0e11 100%);
  --radius: 14px;
  --sidebar-width: 224px;
  color-scheme: light;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  background: var(--page);
  color: var(--text);
}
:root[data-theme="dark"] {
  --page: #121418;
  --surface: #181b20;
  --card: #1f2329;
  --card-alt: #272c33;
  --input: #15181c;
  --text: #ece7df;
  --muted: #a29b91;
  --border: #30353d;
  --border-strong: #3d434c;
  --accent: #d9a650;
  --accent-strong: #ebbd6f;
  --accent-text: #1b1406;
  --accent-soft: #3a3120;
  --success: #4cc38a;
  --success-soft: #19352a;
  --warning: #e6a23c;
  --warning-soft: #3a2d16;
  --danger: #f0705a;
  --danger-soft: #3d1f1a;
  --info: #6ca8e8;
  --info-soft: #1b2b3d;
  --viewer: #0e1013;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 28px rgb(0 0 0 / 28%);
  --shadow-strong: 0 18px 50px rgb(0 0 0 / 55%);
  --overlay: rgb(0 0 0 / 55%);
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--page);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
}
h1,
h2,
h3 {
  line-height: 1.2;
}
button,
select {
  font: inherit;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
button:hover,
select:hover {
  border-color: var(--accent);
}
.primary,
.preview-state-buttons button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input {
  font: inherit;
  color: var(--text);
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-strong);
}

/* App shell: left sidebar on desktop, bottom tab bar on phones. */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 5;
}
/* WoodWhiz Toys logo: the supplied artwork, never stretched. It has black
   outlines and no dark-background variant, so on the dark theme it sits on a
   light badge. */
.brand {
  display: grid;
  justify-items: start;
  gap: 4px;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  text-align: left;
}
.brand:hover {
  background: transparent;
}
.brand-badge {
  display: block;
  border-radius: 12px;
  line-height: 0;
}
:root[data-theme="dark"] .brand-badge {
  padding: 6px 8px;
  background: var(--logo-badge);
}
.brand-wordmark {
  display: block;
  width: 168px;
  height: auto;
  image-rendering: auto;
}
.brand-icon {
  display: none;
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.brand-text {
  padding-left: 2px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-items {
  display: grid;
  gap: 3px;
}
.nav-item,
.nav-sub button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 600;
}
.nav-item {
  padding: 10px 12px;
}
.nav-item svg {
  width: 22px;
  height: 22px;
  flex: none;
  color: var(--muted);
}
.nav-item:hover,
.nav-sub button:hover {
  background: var(--card-alt);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.nav-item.active svg {
  color: var(--accent-strong);
}
.nav-sub {
  display: grid;
  gap: 1px;
  margin: -1px 0 4px 44px;
}
.nav-sub button {
  padding: 6px 10px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--muted);
}
.nav-sub button.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
}
.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}
.board-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--card-alt);
  border-color: var(--border);
  color: var(--muted);
}
.board-chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.board-chip.connected {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}
.board-chip.connected .board-chip-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}
.board-chip.paused {
  background: var(--warning-soft);
  border-color: var(--warning);
  color: var(--warning);
}
.board-chip.paused .board-chip-dot {
  background: var(--warning);
}
.board-chip.web {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.board-chip.web .board-chip-dot {
  background: var(--accent);
}
.board-chip.searching .board-chip-dot {
  background: var(--accent);
  animation: board-chip-pulse 1.2s ease-in-out infinite;
}
@keyframes board-chip-pulse {
  50% {
    opacity: 0.3;
  }
}
.sidebar-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.icon-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  font-size: 0.82rem;
  color: var(--muted);
}
.icon-toggle svg {
  width: 18px;
  height: 18px;
}
.icon-toggle[aria-pressed="true"] {
  color: var(--accent-strong);
  border-color: var(--accent);
}
#sound-toggle[aria-pressed="false"] svg {
  opacity: 0.45;
}
:root[data-theme="dark"] .when-light,
:root:not([data-theme="dark"]) .when-dark {
  display: none;
}
.content {
  min-width: 0;
}
.view {
  padding: 22px 28px;
}
.page-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 28px 28px 48px;
}
.page-shell > h1 {
  margin: 0 0 18px;
  font-size: 1.8rem;
}
.setting-note,
.device,
.background-image-setting small {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

/* Home */
.hero {
  margin: 8px 0 26px;
  padding: 34px 32px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 85% 20%, var(--accent-soft), transparent 55%),
    linear-gradient(135deg, var(--card), var(--card-alt));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
}
.hero-text {
  max-width: 560px;
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
}
.hero-button {
  padding: 13px 38px;
  font-size: 1.1rem;
  border-radius: 12px;
}
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.mode-card {
  position: relative;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  justify-content: flex-end;
  text-align: left;
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.mode-card:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.mode-card strong {
  font-size: 1.12rem;
  color: var(--text);
}
.mode-card span {
  color: var(--muted);
}
.mode-card .mode-icon {
  font-size: 1.9rem;
  color: var(--accent-strong);
  margin-bottom: auto;
}
.badge {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong) !important;
  font-size: 0.72rem;
  font-weight: 700;
}

/* Play screen: board first, players above and below, panel on the right. */
.play-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
  height: 100vh;
  padding: 8px 14px;
}
.board-column {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.board-column.flipped {
  flex-direction: column-reverse;
}
.viewer-wrap {
  position: relative;
  flex: 1;
  align-self: stretch;
  min-height: 320px;
}
/* The scene is transparent; the viewer panel carries the backdrop, so there is
   no visible box edge. */
#viewer {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--scene-studio);
}
body[data-backdrop="light"] #viewer,
body[data-backdrop="light"] .preview-board {
  background: var(--scene-light);
}
body[data-backdrop="dark"] #viewer,
body[data-backdrop="dark"] .preview-board {
  background: var(--scene-dark);
}
/* Image backdrop: the picture is blurred and dimmed behind the transparent scene. */
body[data-backdrop="image"] #viewer,
body[data-backdrop="image"] .preview-board {
  background: var(--scene-dark);
  isolation: isolate;
}
body[data-backdrop="image"] #viewer::before,
body[data-backdrop="image"] .preview-board::before {
  content: "";
  position: absolute;
  inset: calc(-2 * var(--backdrop-blur, 6px));
  z-index: -1;
  background: var(--backdrop-image) center / cover no-repeat;
  filter: blur(var(--backdrop-blur, 6px)) brightness(var(--backdrop-dim, 0.65));
}
.preview-board {
  position: relative;
}
#viewer canvas,
.preview-board canvas {
  display: block;
  width: 100%;
  height: 100%;
}
/* Slim strips as wide as the board on screen (set from the 3D view), centred. */
.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  width: min(var(--board-width, 100%), 720px, 100%);
  height: 44px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
}
.player-card.to-move {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}
.avatar {
  width: 30px;
  height: 30px;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
  flex: none;
  border: 2px solid var(--border-strong);
}
.player-card[data-color="w"] .avatar {
  background: var(--piece-light);
  color: var(--piece-light-text);
}
.player-card[data-color="b"] .avatar {
  background: var(--piece-dark);
  color: var(--piece-dark-text);
}
.player-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.player-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-captured {
  white-space: nowrap;
  font-size: 0.98rem;
  letter-spacing: -0.06em;
  color: var(--muted);
}
.player-advantage {
  margin-left: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted);
}
.player-tags {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
.tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.tag-turn {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.tag-check {
  background: var(--danger);
  color: var(--on-danger);
}
.game-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}
.status-card {
  padding: 16px 18px;
}
.status-card h1 {
  margin: 0;
  font-size: 1.35rem;
}
.status-card .device {
  margin: 8px 0 0;
  font-size: 0.8rem;
}
.guidance {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
  line-height: 1.4;
  font-weight: 600;
  border-left: 4px solid var(--info);
  background: var(--info-soft);
  color: var(--text);
}
.guidance.warning {
  border-color: var(--warning);
  background: var(--warning-soft);
}
.guidance.danger {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.guidance.success {
  border-color: var(--success);
  background: var(--success-soft);
}
.card-title {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.moves-card {
  flex: 1;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  padding: 14px 10px 10px 14px;
}
.move-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
}
.move-row {
  display: grid;
  grid-template-columns: 38px 1fr 1fr;
  gap: 4px;
  padding: 3px 4px;
  border-radius: 6px;
}
.move-row:nth-child(even) {
  background: var(--card-alt);
}
.move-number {
  color: var(--muted);
}
.move-san {
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 600;
}
.move-san.last {
  background: var(--accent);
  color: var(--accent-text);
}
.move-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 4px;
}
.game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.game-actions .primary {
  grid-column: 1/-1;
  padding: 11px;
  font-size: 1.02rem;
}
.game-over {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--overlay);
  z-index: 3;
}
.game-over-card {
  min-width: min(340px, 90%);
  padding: 24px 26px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-strong);
  text-align: center;
}
.game-over-card h2 {
  margin: 0 0 6px;
  font-size: 1.9rem;
}
.game-over-card p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
}
.game-over-card .settings-actions {
  justify-content: center;
}

/* Guidance cards (Move Lab, board setup). */
.physical-guidance {
  display: grid;
  gap: 7px;
  padding: 14px;
  border-left: 4px solid var(--danger);
}
.physical-guidance.info {
  border-left-color: var(--info);
}
.guidance-pill {
  width: max-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.physical-guidance.info .guidance-pill {
  background: var(--info-soft);
  color: var(--info);
}
.physical-guidance strong {
  font-size: 0.98rem;
}
.physical-guidance p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

/* Dialogs and toasts. */
.dialog {
  width: min(420px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-strong);
}
.dialog::backdrop {
  background: var(--overlay);
}
.dialog h2 {
  margin: 0 0 16px;
}
.field {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  font-weight: 600;
}
.field input,
.board-form input,
.board-form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--input);
}
.promotion {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  padding: 18px;
}
.promotion p {
  margin: 0 0 10px;
  font-weight: 700;
}
.promotion div {
  display: flex;
  gap: 8px;
}
#save-toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 11px 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-strong);
}
.about-card {
  padding: 6px 22px;
  line-height: 1.6;
}

/* Settings: one page, tabs, controls on the left, sticky live preview right. */
.settings-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100vh;
  padding: 16px 22px;
}
.settings-head {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
.settings-head h1 {
  margin: 0;
  font-size: 1.5rem;
}
.settings-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.settings-tab {
  position: relative;
  padding: 8px 16px;
  font-weight: 600;
}
.settings-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.unsaved-dot {
  display: none;
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}
.settings-tab.dirty .unsaved-dot {
  display: block;
}
.settings-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(320px, 1.05fr);
  gap: 18px;
}
.settings-controls {
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-color: var(--accent) var(--card-alt);
}
.settings-preview {
  align-self: start;
  position: sticky;
  top: 0;
  padding: 14px;
}
.settings-preview h2,
.settings-section h2 {
  margin: 0 0 9px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.settings-section {
  margin: 0 0 18px;
}
.settings-group {
  display: grid;
  gap: 8px;
}
.preview-board {
  width: 100%;
  aspect-ratio: 1.35/1;
  min-height: 260px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--scene-studio);
}
.led-preview-tools {
  margin-bottom: 10px;
}
.preview-state-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 8px;
}
.preview-state-buttons button {
  padding: 5px 8px;
  font-size: 0.74rem;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.setting {
  display: grid;
  gap: 6px;
  align-items: center;
  padding: 9px 11px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 11px;
  min-width: 0;
}
.setting-label {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.color-setting {
  grid-template-columns: minmax(0, 1fr) 34px 86px;
}
.range-setting {
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
}
.range-setting .setting-label {
  grid-column: 1/-1;
}
.select-setting,
.image-setting {
  grid-template-columns: 1fr;
}
.toggle-setting {
  grid-template-columns: minmax(0, 1fr) auto;
}
.setting-unit,
.setting-help {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}
.setting-help {
  grid-column: 1/-1;
  margin-top: -2px;
}
.setting-value {
  min-width: 56px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-strong);
}
.setting input[type="color"] {
  height: 30px;
  width: 34px;
  border: 0;
  background: none;
  padding: 0;
}
.setting input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.setting input[type="text"],
.setting input[type="number"],
.setting select {
  width: 100%;
  min-width: 0;
  background: var(--input);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 7px;
  padding: 6px;
}
.setting small {
  color: var(--muted);
}
/* On/off settings are switches, not checkboxes. */
.switch {
  appearance: none;
  position: relative;
  width: 42px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background 0.15s ease;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 1px 3px rgb(0 0 0 / 25%);
  transition: transform 0.15s ease;
}
.switch:checked {
  background: var(--accent);
}
.switch:checked::after {
  transform: translateX(18px);
}
.advanced {
  margin: 4px 0 18px;
  padding: 8px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
}
.advanced > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
}
.advanced[open] > summary {
  margin-bottom: 10px;
}
/* LED states and moments: always expanded cards. */
.state-card {
  margin: 0 0 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}
.state-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.state-header h3 {
  margin: 0;
  font-size: 0.95rem;
}
.state-card > .settings-group {
  padding: 10px;
}
.state-swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  flex: none;
}
.state-swatch::-webkit-color-swatch-wrapper {
  padding: 0;
}
.state-swatch::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}
.state-swatch::-moz-color-swatch {
  border: 0;
  border-radius: 50%;
}
.state-name {
  flex: 1;
}
.state-preview {
  padding: 4px 10px;
  font-size: 0.78rem;
}
.settings-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding: 12px 0;
  background: linear-gradient(to top, var(--page) 70%, transparent);
}
.settings-actions,
.preview-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
/* Laptop: the live preview may sit left of the controls (Settings › View). */
body[data-preview-side="left"] .settings-body {
  grid-template-columns: minmax(320px, 1.05fr) minmax(340px, 1fr);
}
body[data-preview-side="left"] .settings-preview {
  order: -1;
}
/* Tablet: a smaller live preview stays on top while the controls scroll. */
@media (max-width: 1000px) and (min-width: 701px) {
  .settings-page {
    height: auto;
  }
  .settings-body,
  body[data-preview-side="left"] .settings-body {
    grid-template-columns: 1fr;
  }
  .settings-preview {
    order: -1;
    position: sticky;
    top: 0;
    z-index: 3;
  }
  .settings-preview .preview-board {
    min-height: 0;
    height: 30vh;
    aspect-ratio: auto;
  }
  .sim-grid {
    width: min(100%, 220px);
  }
  .settings-controls {
    overflow: visible;
  }
}
/* Phone: everything stacked. */
@media (max-width: 700px) {
  .settings-page {
    height: auto;
  }
  .settings-body,
  body[data-preview-side="left"] .settings-body {
    grid-template-columns: 1fr;
  }
  .settings-preview {
    order: -1;
    position: static;
  }
  .settings-controls {
    overflow: visible;
  }
}

/* Debug strip (?debug=1), behaviour unchanged. */
/* The debug strip is fixed at the bottom: keep the page (and the bottom player
   card) clear of it. */
.ww-shadow-debug {
  padding-bottom: 126px;
}
.ww-shadow-debug .play-view {
  height: calc(100vh - 126px);
}
#shadow-reconciler-debug {
  position: fixed;
  z-index: 30;
  right: 12px;
  bottom: 10px;
  left: 12px;
  max-height: 112px;
  overflow: auto;
  padding: 7px 10px;
  border: 1px solid var(--info);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font:
    12px/1.35 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  box-shadow: var(--shadow-strong);
}
#shadow-reconciler-debug strong {
  margin-right: 10px;
  color: var(--info);
  letter-spacing: 0.08em;
}
#shadow-reconciler-debug button {
  float: right;
  padding: 3px 7px;
  font: inherit;
}
#shadow-reconciler-debug div {
  display: flex;
  gap: 5px 12px;
  flex-wrap: wrap;
  margin-top: 5px;
}
#shadow-reconciler-debug span {
  white-space: nowrap;
}
#shadow-reconciler-debug code {
  color: var(--accent-strong);
  font: inherit;
}

/* Tablets: narrower panel. */
@media (max-width: 1150px) {
  :root {
    --sidebar-width: 76px;
  }
  .brand-text,
  .nav-item span,
  .nav-sub,
  .toggle-label,
  #board-chip-label {
    display: none;
  }
  /* Narrow sidebar: the square logo instead of the wordmark. */
  .brand-wordmark {
    display: none;
  }
  .brand-icon {
    display: block;
  }
  .nav-item,
  .brand {
    justify-content: center;
  }
  .board-chip {
    justify-content: center;
  }
  .sidebar-toggles {
    grid-template-columns: 1fr;
  }
  .play-view {
    grid-template-columns: minmax(0, 1fr) 290px;
  }
}

/* Phones: bottom tab bar, stacked play screen. */
@media (max-width: 760px) {
  .app-shell {
    display: block;
    padding-bottom: 68px;
  }
  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    flex-direction: row;
    padding: 6px 8px;
    gap: 6px;
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  .brand,
  .nav-sub,
  .board-chip {
    display: none;
  }
  .nav-items {
    flex: 1;
    display: flex;
    justify-content: space-around;
  }
  .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 6px 4px;
    font-size: 0.68rem;
  }
  .nav-item span {
    display: block;
  }
  .sidebar-footer {
    margin: 0;
    display: flex;
    align-items: center;
  }
  .sidebar-toggles {
    display: flex;
    gap: 4px;
  }
  .icon-toggle {
    padding: 6px;
  }
  .view,
  .page-shell {
    padding: 14px;
  }
  .settings-tabs {
    padding: 14px 14px 0;
  }
  .play-view {
    display: block;
    height: auto;
  }
  .viewer-wrap {
    height: 92vw;
    max-height: 560px;
    min-height: 300px;
    flex: none;
  }
  .game-panel {
    margin-top: 12px;
    overflow: visible;
  }
  .moves-card {
    max-height: 260px;
  }
  .hero {
    padding: 24px 20px;
  }
  .mode-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .preview-board {
    min-height: 220px;
  }
  .settings-page {
    padding: 12px;
  }
}

/* Settings › Effects: the 8×8 LED simulator (exactly what the board receives). */
.effects-sim {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.sim-scenarios {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sim-scenarios button {
  padding: 5px 9px;
  font-size: 0.76rem;
}
.sim-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  width: min(100%, 340px);
  aspect-ratio: 1;
  padding: 8px;
  border-radius: 12px;
  background: var(--piece-dark);
}
.sim-cell {
  --led: #000000;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--sim-square-dark);
  box-shadow: inset 0 0 0 2px var(--sim-inset);
}
.sim-cell.light {
  background: var(--sim-square-light);
}
.sim-cell.lit {
  background: var(--led);
  box-shadow:
    inset 0 0 0 2px var(--sim-inset),
    0 0 10px var(--led);
}
.sim-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

/* About › ownership, Licences & credits. */
.about-card + .about-card {
  margin-top: 14px;
}
.about-card h2 {
  margin: 14px 0 8px;
  font-size: 1.1rem;
}
.credits-list {
  display: grid;
  gap: 10px;
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
}
.credits-list li {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card-alt);
}
.credits-list small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
.credits-upcoming {
  border-style: dashed;
}
