:root {
  color-scheme: light;
  --ink: #171815;
  --ink-soft: #4f514b;
  --paper: #ebe9e2;
  --panel: rgba(250, 249, 245, 0.94);
  --panel-solid: #faf9f5;
  --line: rgba(23, 24, 21, 0.18);
  --line-strong: rgba(23, 24, 21, 0.38);
  --light: #d8d0c0;
  --dark: #695b4d;
  --mark: #a7332b;
  --mark-soft: rgba(167, 51, 43, 0.2);
  --wood-deep: #3d2e24;
  --wood-mid: #75563d;
  --wood-light: #bd9b72;
  --stone: #8b8b84;
  --blue: #2f6fdd;
  --shadow-low: 0 1px 2px rgba(20, 17, 13, 0.14),
    0 8px 22px rgba(20, 17, 13, 0.08);
  --shadow-high: 0 2px 4px rgba(20, 17, 13, 0.18),
    0 28px 70px rgba(20, 17, 13, 0.24);
  --radius-small: 8px;
  --radius-medium: 14px;
  --radius-large: 22px;
  --font-interface: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: Iowan Old Style, Baskerville, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-family: var(--font-interface);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: #242523;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -12%, rgba(255, 255, 255, 0.14), transparent 42%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.025), transparent 38%),
    #292a28;
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

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

button,
select,
input[type="url"],
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  color: var(--ink);
  background: rgba(235, 233, 226, 0.76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

button {
  cursor: pointer;
}

button:hover:not(:disabled),
select:hover,
input:hover,
textarea:hover {
  border-color: var(--line-strong);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.control-menu-toggle:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(47, 111, 221, 0.3);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

main {
  width: min(1180px, calc(100% - 40px));
  min-width: 0;
  margin: 0 auto;
  padding: 48px 0 30px;
}

header {
  max-width: 760px;
  margin: 0 0 34px;
  color: #f5f2e9;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 10vw, 7.8rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.82;
}

h2 {
  margin-bottom: 16px;
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow,
footer {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lede {
  max-width: 620px;
  margin-bottom: 0;
  color: rgba(245, 242, 233, 0.68);
  font-size: 0.84rem;
  letter-spacing: 0.02em;
}

.control-bar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 760px);
  margin: 0 0 16px;
  padding: 10px 4px 14px;
  border: 0;
  background: transparent;
}

.control-menu {
  display: contents;
}

.control-menu[hidden],
.control-menu-body[hidden] {
  display: none;
}

.control-menu-toggle {
  position: relative;
  min-width: 0;
  min-height: 54px;
  padding: 10px 14px;
  border: 0;
  border-radius: 9px;
  background: rgba(250, 249, 245, 0.9);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: left;
  list-style: none;
}

.control-menu.is-open .control-menu-toggle,
.control-menu-toggle[aria-expanded="true"] {
  order: -1;
  grid-column: 1 / -1;
  background: #fff;
}

.control-menu-toggle::before {
  display: inline-block;
  margin-right: 8px;
  color: var(--mark);
  content: "◆";
  font-size: 0.54rem;
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.control-menu.is-open .control-menu-toggle::before,
.control-menu-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.control-menu-body {
  position: static;
  grid-column: 1 / -1;
  width: 100%;
  max-height: min(70vh, 680px);
  max-height: min(70dvh, 680px);
  margin-top: 2px;
  padding: 18px;
  overflow-y: auto;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-medium);
  background: var(--panel-solid);
  box-shadow: var(--shadow-high);
}

.control-menu.is-open .control-menu-body {
  order: -1;
}

.menu-context {
  margin-bottom: 4px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.player-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.team-designation {
  grid-column: 1 / -1;
  margin-top: 2px;
}

.team-designation .check {
  margin: 0 0 8px;
}

.team-random-actions {
  grid-template-columns: repeat(2, 1fr);
}

.match {
  display: grid;
  grid-template-columns: minmax(280px, 760px);
  gap: 24px;
  align-items: start;
}

.match.with-record {
  grid-template-columns: minmax(280px, 760px) minmax(170px, 230px);
}

.match-state {
  width: min(100%, 760px);
  margin: 0;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(245, 242, 233, 0.92);
  font-size: 0.9rem;
}

.clocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 0 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-small);
  background: rgba(16, 17, 15, 0.45);
  color: rgba(245, 242, 233, 0.68);
}

.clocks span {
  padding: 9px 11px;
}

.clocks span + span {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  text-align: right;
}

.clocks .active {
  color: #fff;
  background: var(--mark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.board-frame {
  position: relative;
  display: grid;
  grid-template-areas:
    "north"
    "board"
    "south";
  width: min(100%, 760px);
}

.board-frame .board {
  grid-area: board;
}

.board {
  --board-padding: clamp(10px, 1.1vw, 13px);
  --board-radius: 12px;
  --board-light: #d8d0c0;
  --board-light-line: rgba(104, 77, 51, 0.025);
  --board-dark: #695b4d;
  --rim-base: #292a28;
  --rim-line-a: rgba(235, 233, 226, 0.04);
  --rim-line-b: rgba(139, 139, 132, 0.035);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, minmax(0, 1fr));
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: var(--board-padding);
  overflow: hidden;
  border: 1px solid rgba(248, 250, 243, 0.19);
  border-radius: var(--board-radius);
  background:
    radial-gradient(ellipse at -6% -8%, rgba(255, 255, 255, 0.064), transparent 31%),
    radial-gradient(ellipse at 83% 88%, rgba(255, 255, 255, 0.019), transparent 24%),
    var(--rim-base);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.144),
    inset -1px -1px 0 rgba(0, 0, 0, 0.22),
    inset 0 0 0 2px rgba(255, 255, 255, 0.032),
    inset 0 0 14px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(7, 9, 8, 0.35),
    0 12px 26px rgba(7, 9, 8, 0.18);
  container-type: inline-size;
}

.board::before,
.board::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.board::before {
  inset: clamp(4px, 0.55vw, 6px);
  z-index: 2;
  border: 1px solid var(--rim-line-a);
  border-radius: calc(var(--board-radius) - 4px);
  box-shadow:
    inset 1px 1px 0 rgba(235, 233, 226, 0.018),
    inset -1px -1px 0 rgba(3, 5, 4, 0.18);
}

.board::after {
  inset: var(--board-padding);
  z-index: 2;
  border: 1px solid var(--rim-line-b);
  border-radius: 3px;
  box-shadow:
    -1px -1px 0 rgba(235, 233, 226, 0.016),
    1px 1px 0 rgba(0, 0, 0, 0.1),
    inset 1px 1px 0 rgba(235, 233, 226, 0.014),
    inset -1px -1px 0 rgba(0, 0, 0, 0.09);
}

.player-banner {
  display: flex;
  min-width: 0;
  padding: 14px 4px;
  flex-direction: column;
  gap: 2px;
  color: rgba(245, 242, 233, 0.96);
  font-size: 0.86rem;
  line-height: 1.2;
  text-align: center;
}

.player-banner strong,
.player-banner span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-banner strong {
  font-size: 1rem;
  font-weight: 720;
  letter-spacing: 0.015em;
}

.player-banner.active-player strong::before {
  margin-right: 7px;
  color: var(--mark);
  content: "◆";
  font-size: 0.58em;
  vertical-align: 0.16em;
}

.player-banner.turn-ping {
  animation: turn-ping 880ms ease-out 1;
}

@keyframes turn-ping {
  0%, 100% {
    color: rgba(245, 242, 233, 0.96);
    text-shadow: none;
  }
  24% {
    color: #fff;
    text-shadow: 0 0 18px rgba(167, 51, 43, 0.9);
  }
}

.player-banner span {
  color: rgba(245, 242, 233, 0.66);
  font-size: 0.72rem;
}

.player-north {
  grid-area: north;
}

.player-south {
  grid-area: south;
}

.board-frame.sideways,
.board-frame.sideways-black {
  grid-template-areas: "board";
}

.player-west,
.player-east {
  position: absolute;
  top: 50%;
  width: 56px;
  writing-mode: vertical-rl;
}

.player-west {
  left: -64px;
  transform: translateY(-50%) rotate(180deg);
}

.player-east {
  right: -64px;
  transform: translateY(-50%);
}

.square {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  font-family: "Arial Unicode MS", "Noto Sans Symbols 2", serif;
  font-size: clamp(1.8rem, 11cqi, 5.2rem);
  line-height: 1;
}

.square::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.018);
  content: "";
}

.square.light {
  background:
    repeating-linear-gradient(94deg, transparent 0 12px, var(--board-light-line) 12px 13px),
    var(--board-light);
}

.square.dark {
  background:
    repeating-linear-gradient(93deg, transparent 0 15px, rgba(255, 255, 255, 0.024) 15px 16px),
    var(--board-dark);
}

.piece {
  z-index: 1;
  pointer-events: none;
  filter:
    drop-shadow(0 1px 0 rgba(255, 255, 255, 0.22))
    drop-shadow(0 4px 3px rgba(0, 0, 0, 0.34));
  transform-origin: center;
}

.piece.white {
  color: #faf8ef;
  text-shadow:
    0 -1px 0 #fff,
    0 1px 0 #8c887f;
}

.piece.black {
  color: #332f2a;
  text-shadow:
    0 -1px 0 #6d665e,
    0 1px 0 #090908;
}

.board.white .piece.white,
.board.white .piece.black {
  transform: translateY(-8%) scale(0.86);
}

.board.black .piece.white {
  transform: translateY(-8%) scale(0.86);
}

.board.black .piece.black {
  transform: translateY(-8%) scale(0.86);
}

.board.sideways .piece.white {
  transform: translateX(8%) rotate(90deg) scale(0.86);
}

.board.sideways .piece.black {
  transform: translateX(-8%) rotate(-90deg) scale(0.86);
}

.board.sideways-black .piece.white {
  transform: translateX(-8%) rotate(-90deg) scale(0.86);
}

.board.sideways-black .piece.black {
  transform: translateX(8%) rotate(90deg) scale(0.86);
}

.square:hover,
.square:focus-visible {
  z-index: 2;
  outline: 2px solid rgba(255, 255, 255, 0.86);
  outline-offset: -3px;
}

.square.selected {
  box-shadow:
    inset 0 0 0 4px rgba(167, 51, 43, 0.96),
    inset 0 0 18px var(--mark-soft);
}

.square.target::after,
.square.capture::after {
  position: absolute;
  z-index: 2;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(167, 51, 43, 0.88);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.26);
  content: "";
}

.square.capture::after {
  width: 70%;
  border: 4px solid rgba(167, 51, 43, 0.9);
  background: transparent;
  box-shadow: none;
}

aside {
  display: grid;
  gap: 18px;
}

.record {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-medium);
  color: rgba(245, 242, 233, 0.88);
  background: rgba(16, 17, 15, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
}

.record h2 {
  margin-bottom: 12px;
}

.record ol {
  max-height: 300px;
  margin: 0;
  padding-left: 30px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.75;
}

.record li {
  padding: 1px 3px;
  border-radius: 4px;
}

.move-record {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 1px 3px;
  border: 0;
  text-align: left;
  color: inherit;
  background: transparent;
  box-shadow: none;
}

.record li.current {
  color: #fff;
  background: var(--mark);
}

.record li.current .move-record {
  font-weight: 700;
}

label {
  display: block;
  margin: 14px 0 6px;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 600;
}

select,
input[type="url"],
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 8px 10px;
}

.clock-settings {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 8px 10px;
  align-items: center;
}

.clock-settings label {
  margin: 0;
}

.budget-grid {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 8px 10px;
  align-items: center;
}

.budget-grid label {
  margin: 0;
}

.clock-settings input {
  width: 100%;
  padding: 8px;
}

.budget-grid input {
  width: 100%;
  padding: 8px;
}

textarea {
  resize: vertical;
}

.check {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 18px 0;
  color: var(--ink);
  font-weight: 400;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.actions button,
.primary-action {
  padding: 9px 12px;
  border-color: transparent;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}

.actions button:active,
.primary-action:active {
  transform: translateY(1px);
}

.primary-action {
  width: 100%;
  margin-top: 18px;
}

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

.match-actions .primary-action {
  margin-top: 0;
}

.actions .secondary {
  border-color: var(--line);
  color: var(--ink);
  background: rgba(235, 233, 226, 0.72);
}

.actions.compact {
  grid-template-columns: repeat(3, 1fr);
}

.actions.compact button {
  min-width: 0;
}

.relay-retry {
  width: 100%;
  padding: 9px 12px;
}

.relay-session-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.relay-session-actions button {
  grid-column: 1 / -1;
  margin-top: 0;
}

.relay-seat {
  margin-top: 16px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.relay-commerce-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.relay-commerce-row output {
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.relay-commerce-row button {
  min-height: 34px;
  padding: 6px 10px;
  white-space: nowrap;
}

.move-token-control {
  margin: 14px 0 18px;
}

.move-token-control label {
  margin-top: 0;
}

.move-token-control input[type="range"] {
  width: 100%;
  accent-color: var(--mark);
}

.move-token-control datalist {
  display: flex;
  justify-content: space-between;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.58rem;
}

.move-token-status {
  display: block;
  margin-top: 9px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.move-token-control .note {
  margin-bottom: 0;
}

.relay-advanced {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.relay-advanced summary {
  padding: 14px 0 0;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
}

.menu-library {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.menu-library h2 {
  margin-bottom: 2px;
}

.menu-library select {
  min-height: 118px;
}

.import-control {
  display: block;
  margin-top: 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.import-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.note {
  display: block;
  margin: 12px 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.55;
}

.replay-controls {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) auto minmax(100px, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: min(100%, 760px);
  margin: 0 0 14px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-small);
  color: rgba(245, 242, 233, 0.82);
  background: rgba(16, 17, 15, 0.35);
}

.replay-controls label {
  margin: 0;
  color: inherit;
}

.replay-controls input[type="range"] {
  width: 100%;
}

.replay-controls .actions {
  display: flex;
}

.replay-controls button {
  min-height: 34px;
  padding: 5px 8px;
}

dialog {
  width: 600px;
  max-width: calc(100vw - 28px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-large);
  color: var(--ink);
  background: var(--panel-solid);
  box-shadow: var(--shadow-high);
}

dialog::backdrop {
  background: rgba(30, 31, 29, 0.66);
  backdrop-filter: blur(6px) saturate(0.7);
}

.bridge-dialog {
  min-width: 0;
  padding: 28px;
}

.bridge-summary {
  max-width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--mark);
  border-radius: 3px var(--radius-small) var(--radius-small) 3px;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 10px 22px;
  width: min(100%, 760px);
  max-width: 100%;
  margin-top: 38px;
  padding: 14px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(245, 242, 233, 0.42);
  text-align: left;
}

footer a {
  color: inherit;
  text-underline-offset: 3px;
}

/* Living style guide */

.style-guide {
  background:
    radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.12), transparent 34rem),
    #292a28;
}

.style-guide main {
  width: min(1180px, calc(100% - 40px));
}

.sg-hero {
  display: grid;
  min-height: 72vh;
  padding: 7vh 0 8vh;
  align-content: space-between;
}

.sg-kicker {
  color: #c9766e;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sg-hero h1 {
  max-width: 930px;
  margin: 8vh 0 28px;
  color: #f5f2e9;
  font-size: clamp(5.2rem, 13vw, 10.8rem);
}

.sg-thesis {
  max-width: 650px;
  color: rgba(245, 242, 233, 0.66);
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  line-height: 1.28;
}

.sg-section {
  margin: 0 0 26px;
  padding: clamp(24px, 4vw, 48px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-large);
  color: var(--ink);
  background: var(--panel-solid);
  box-shadow: var(--shadow-low);
}

.sg-section-dark {
  color: #f5f2e9;
  background: rgba(16, 17, 15, 0.52);
  backdrop-filter: blur(16px);
}

.sg-section > header {
  display: grid;
  grid-template-columns: minmax(170px, 0.35fr) minmax(280px, 0.65fr);
  gap: 30px;
  max-width: none;
  margin: 0 0 38px;
  color: inherit;
}

.sg-section > header p {
  max-width: 670px;
  margin: 0;
  color: var(--ink-soft);
}

.sg-section-dark > header p {
  color: rgba(245, 242, 233, 0.58);
}

.sg-principles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--line);
}

.sg-principle {
  min-height: 250px;
  padding: 28px;
  background: var(--panel-solid);
}

.sg-number {
  display: block;
  margin-bottom: 56px;
  color: var(--mark);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.sg-principle h3 {
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
}

.sg-principle p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.sg-palette {
  display: grid;
  grid-template-columns: repeat(6, minmax(100px, 1fr));
  gap: 10px;
}

.sg-swatch {
  min-height: 150px;
  padding: 14px;
  border-radius: var(--radius-small);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.sg-swatch span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
}

.sg-swatch span + span {
  margin-top: 4px;
  opacity: 0.62;
}

.sg-type {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

.sg-type-card {
  min-height: 270px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--paper);
}

.sg-display-sample {
  margin: 28px 0 18px;
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 8vw, 6.8rem);
  letter-spacing: -0.055em;
  line-height: 0.84;
}

.sg-interface-sample {
  margin: 42px 0 20px;
  font-size: clamp(1.4rem, 3vw, 2.3rem);
  font-weight: 560;
  letter-spacing: -0.025em;
}

.sg-meta {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sg-board-stage {
  padding: clamp(8px, 2vw, 24px);
}

.sg-board-stage .board-frame {
  margin: 0 auto;
}

.sg-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.sg-control-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--paper);
}

.sg-control-card label:first-child {
  margin-top: 0;
}

.sg-dialog-demo {
  padding: clamp(22px, 7vw, 90px);
  border-radius: var(--radius-medium);
  background:
    linear-gradient(rgba(41, 42, 40, 0.66), rgba(41, 42, 40, 0.66)),
    repeating-conic-gradient(from 45deg, #d6cbb9 0 25%, #6e5c4b 0 50%) 50% / 120px 120px;
}

.sg-dialog-card {
  width: min(100%, 640px);
  margin: auto;
  padding: 30px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-large);
  background: var(--panel-solid);
  box-shadow: var(--shadow-high);
}

.sg-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.sg-dialog-actions button {
  min-width: 90px;
  padding: 8px 18px;
}

.sg-dialog-actions .confirm {
  border-color: transparent;
  color: #fff;
  background: var(--blue);
}

.sg-code {
  position: relative;
  max-height: 620px;
  margin: 0;
  padding: 24px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-medium);
  color: #e9e4d9;
  background: #151613;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
}

.sg-footer {
  max-width: 680px;
  margin: 80px 0 30px;
  color: rgba(245, 242, 233, 0.62);
}

.sg-footer strong {
  display: block;
  margin-bottom: 14px;
  color: #f5f2e9;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 5rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 800px) {
  main,
  .style-guide main {
    width: min(100% - 24px, 680px);
    padding-top: 28px;
  }

  .match,
  .match.with-record {
    grid-template-columns: 1fr;
  }

  .sg-hero {
    min-height: 62vh;
  }

  .sg-section > header,
  .sg-type {
    grid-template-columns: 1fr;
  }

  .sg-principles {
    grid-template-columns: 1fr;
  }

  .sg-principle {
    min-height: 0;
  }

  .sg-number {
    margin-bottom: 26px;
  }

  .sg-palette {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 4rem;
  }

  .lede {
    font-size: 0.76rem;
  }

  .control-bar,
  .sg-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .control-bar {
    width: 100%;
  }

  .control-menu {
    min-width: 0;
  }

  .player-grid,
  .match-actions {
    grid-template-columns: 1fr;
  }

  .player-banner {
    padding: 9px 3px;
    font-size: 0.76rem;
  }

  .player-banner strong {
    font-size: 0.86rem;
  }

  .player-banner span {
    font-size: 0.64rem;
  }

  .player-west {
    left: 2px;
  }

  .player-east {
    right: 2px;
  }

  .actions.compact {
    grid-template-columns: 1fr;
  }

  .relay-commerce-row {
    grid-template-columns: 1fr 1fr;
  }

  .relay-commerce-row output {
    grid-column: 1 / -1;
  }

  .replay-controls {
    grid-template-columns: auto 1fr;
  }

  .replay-controls .actions {
    grid-column: 1 / -1;
  }

  .bridge-dialog {
    padding: 20px;
  }

  .sg-hero h1 {
    margin-top: 12vh;
    font-size: 4.5rem;
  }

  .sg-section {
    padding: 22px;
  }

  .sg-palette {
    grid-template-columns: repeat(2, 1fr);
  }

  .sg-controls {
    grid-template-columns: 1fr;
  }

  .sg-dialog-demo {
    padding: 18px;
  }

  .sg-dialog-card {
    padding: 22px;
  }
}
