/* Zechmate
   Layout: the demo board on the classroom wall. The board fills the screen's height on the left;
   everything a teacher touches sits in one panel, within arm's reach, to its right. */

@font-face { font-family: "Archivo"; src: url(../fonts/archivo-wdth.woff2) format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url(../fonts/atkinson-next.woff2) format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url(../fonts/atkinson-next-italic.woff2) format("woff2"); font-weight: 200 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Mono"; src: url(../fonts/atkinson-mono.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  /* Color: tournament-vinyl green on a faintly green paper, with a clock-flag red for alerts */
  --paper: #f2f5f1;
  --surface: #ffffff;
  --raised: #e8ede8;
  --ink: #16201a;
  --muted: #56645b;
  --line: #d2dad3;
  --felt: #1f5a3f;
  --felt-ink: #ffffff;
  --felt-soft: #dbeae0;
  --flag: #b8352a;
  --flag-ink: #ffffff;
  --scrim: rgba(242, 245, 241, 0.6);
  --backdrop: rgba(10, 18, 13, 0.45);
  --shadow: 0 1px 2px rgba(22, 32, 26, 0.08), 0 8px 24px rgba(22, 32, 26, 0.10);

  /* Fixed chess colors (the same in both themes) */
  --side-white: #f7f7f2;
  --side-black: #2b2f2c;
  --sq-light: #ebecd0;
  --sq-dark: #779556;
  --brush-green: #15781B;
  --brush-red: #882020;
  --brush-blue: #003088;
  --brush-yellow: #e68f00;
  /* A little extra color for the fun parts (wheel slices, the pairing reveal, confetti). Soft, the same in both themes. */
  --wheel-0: #9cc28a;  /* sage */
  --wheel-1: #f4eed8;  /* cream */
  --wheel-2: #f2cb68;  /* soft gold */
  --wheel-3: #9cc4e4;  /* sky */
  --wheel-4: #ef9d8d;  /* coral, for confetti and accents */
  --wheel-ink: #1e2620;

  /* Type: Archivo for the wordmark and headings, Atkinson Hyperlegible for reading across a room */
  --font-display: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 10px;
  --gutter: max(16px, 1.25rem);
  --panel-w: clamp(330px, 31vw, 620px);
  --tap: 3rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1512; --surface: #161e1a; --raised: #1e2924; --ink: #e3ebe5; --muted: #98a69d; --line: #2b3832;
    --felt: #7ccb9d; --felt-ink: #08130d; --felt-soft: #1d3628; --flag: #ff8073; --flag-ink: #1a0806;
    --scrim: rgba(15, 21, 18, 0.6); --backdrop: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1512; --surface: #161e1a; --raised: #1e2924; --ink: #e3ebe5; --muted: #98a69d; --line: #2b3832;
  --felt: #7ccb9d; --felt-ink: #08130d; --felt-soft: #1d3628; --flag: #ff8073; --flag-ink: #1a0806;
  --scrim: rgba(15, 21, 18, 0.6); --backdrop: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
:root[data-board="brown"] { --sq-light: #f0d9b5; --sq-dark: #b58863; }
:root[data-board="blue"] { --sq-light: #dee3e6; --sq-dark: #8ca2ad; }

/* ---------- base ---------- */
html { font-size: clamp(15px, 0.5vw + 9px, 24px); height: 100%; -webkit-text-size-adjust: 100%; }
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; height: 100%;
  background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 1rem; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--felt); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2 { text-wrap: balance; }

.app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding-block: 0.45rem; padding-inline: var(--gutter);
  background: var(--surface); border-bottom: 1px solid var(--line);
  min-width: 0;
}
.wordmark {
  font-family: var(--font-display); font-weight: 800; font-stretch: 116%;
  font-size: 1.6rem; line-height: 1; letter-spacing: -0.015em;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.wordmark span + span { color: var(--felt); }
.tabs { display: flex; gap: 0.15rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tab-soon {
  position: relative; display: inline-flex; align-items: center;
  min-height: var(--tap); padding-inline: 0.95rem; border-radius: 8px;
  font-family: var(--font-display); font-weight: 650; font-size: 1.08rem; font-stretch: 100%;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.tabs a:hover { background: var(--raised); color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0.95rem; right: 0.95rem; bottom: 0.25rem;
  height: 3px; border-radius: 2px; background: var(--felt);
}
.tab-soon { opacity: 0.5; cursor: default; }
.tab-soon small {
  font-family: var(--font-body); font-weight: 700; font-size: 0.6rem;
  text-transform: uppercase; letter-spacing: 0.09em; margin-left: 0.4rem;
  padding: 0.1rem 0.35rem; border-radius: 4px; background: var(--raised);
}
.top-actions { display: flex; gap: 0.45rem; margin-left: auto; }
.icon-btn {
  width: var(--tap); height: var(--tap); display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.icon-btn:hover { border-color: var(--muted); }
.ic { width: 1.35em; height: 1.35em; flex: none; }

/* ---------- views ---------- */
.views { min-height: 0; min-width: 0; }
.view {
  height: 100%; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); gap: 1.25rem;
  padding-block: 1rem; padding-inline: var(--gutter);
}
.stage { min-width: 0; min-height: 0; display: flex; align-items: flex-start; justify-content: center; gap: 10px; }
.panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 0.75rem; overflow-y: auto; padding-bottom: 0.25rem; }
.panel-head { display: grid; gap: 0.2rem; }
.panel-title {
  margin: 0; font-family: var(--font-display); font-weight: 750; font-stretch: 108%;
  font-size: 1.65rem; line-height: 1.1; letter-spacing: -0.01em;
}
.panel-sub { margin: 0; color: var(--muted); font-size: 0.95rem; }
.status { display: flex; align-items: center; gap: 0.55rem; margin: 0.35rem 0 0; font-weight: 700; font-size: 1.1rem; }
.status.alert { color: var(--flag); }
.turn-dot {
  display: inline-block; flex: none; width: 1.05rem; height: 1.05rem; border-radius: 50%;
  border: 2px solid var(--ink); background: var(--side-white);
}
.turn-dot.b { background: var(--side-black); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 2.75rem; padding: 0.4rem 0.85rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 650; font-size: 0.95rem; line-height: 1.15; text-align: left;
}
.btn:hover { border-color: var(--muted); }
.btn .ic { width: 1.2em; height: 1.2em; }
.btn.small { min-height: 2.4rem; font-size: 0.88rem; padding: 0.3rem 0.7rem; }
.btn.primary { background: var(--felt); border-color: var(--felt); color: var(--felt-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { min-height: 3.4rem; font-size: 1.1rem; width: 100%; }
.btn[aria-pressed="true"] { background: var(--felt-soft); border-color: var(--felt); box-shadow: inset 0 0 0 1px var(--felt); }
.btn[data-armed] { background: var(--flag); border-color: var(--flag); color: var(--flag-ink); }
.btn.danger { color: var(--flag); }
.btn.danger[data-armed] { color: var(--flag-ink); }
.toolrow { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ---------- board ---------- */
.zb {
  position: relative; flex: none; width: 480px; height: 480px;
  user-select: none; -webkit-user-select: none; touch-action: none;
  border-radius: 3px; box-shadow: var(--shadow);
  --sq: 60px;
}
.zb-squares {
  position: absolute; inset: 0; border-radius: inherit;
  background: conic-gradient(var(--sq-dark) 0 90deg, var(--sq-light) 90deg 180deg, var(--sq-dark) 180deg 270deg, var(--sq-light) 270deg 360deg);
  background-size: 25% 25%;
}
.zb-hl, .zb-coords, .zb-pieces { position: absolute; inset: 0; pointer-events: none; }
.zb-hl > div { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; }
.zb-hl .last { background: rgba(155, 199, 0, 0.41); }
.zb-hl .sel { background: rgba(20, 85, 30, 0.5); }
.zb-hl .dest { background: radial-gradient(rgba(20, 85, 30, 0.5) 19%, rgba(0, 0, 0, 0) 20%); }
.zb-hl .dest.occ { background: radial-gradient(transparent 0%, transparent 79%, rgba(20, 85, 30, 0.35) 80%); }
.zb-hl .over { background: rgba(20, 85, 30, 0.35); box-shadow: inset 0 0 0 calc(var(--sq) * 0.04) rgba(20, 85, 30, 0.55); }
.zb-hl .check { background: radial-gradient(ellipse at center, rgba(255, 0, 0, 1) 0%, rgba(231, 0, 0, 1) 25%, rgba(169, 0, 0, 0) 89%, rgba(158, 0, 0, 0) 100%); }
.zb-coords { z-index: 3; }
.zb-coords span {
  position: absolute; font-family: var(--font-body); font-weight: 700;
  font-size: calc(var(--sq) * 0.2); line-height: 1;
}
.zb-coords .rank { left: calc(var(--sq) * 0.06); margin-top: calc(var(--sq) * 0.06); }
.zb-coords .file { bottom: calc(var(--sq) * 0.05); margin-left: calc(var(--sq) * 0.84); }
.zb-coords .on-light { color: var(--sq-dark); }
.zb-coords .on-dark { color: var(--sq-light); }
.zb-piece {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%;
  background-size: cover; background-repeat: no-repeat;
  transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1);
  will-change: transform;
}
.zb-piece.dragging { transition: none !important; z-index: 10; scale: 1.12; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.3)); cursor: grabbing; }
.zb-piece.dragging.removing { opacity: 0.4; }
.zb-piece.zb-origin { opacity: 0.3; transition: none; }
.zb-ghost { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; scale: 1.12; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.3)); }
.zb-shapes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; overflow: visible; }
.zb-promo { position: absolute; inset: 0; z-index: 20; background: var(--scrim); border-radius: inherit; }
.zb-promo-opt {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; padding: 0; border: 0;
  background: radial-gradient(circle, var(--surface) 0 62%, transparent 64%);
}
.zb-promo-opt:hover { background: radial-gradient(circle, var(--felt-soft) 0 62%, transparent 64%); }
.zb-promo-opt span { display: block; width: 100%; height: 100%; scale: 0.82; }
.zb.is-drawing, .zb.is-placing { cursor: crosshair; }
.zb.is-drawing::after {
  content: "Drawing"; position: absolute; right: 8px; top: 8px; z-index: 6; pointer-events: none;
  padding: 0.2rem 0.55rem; border-radius: 99px;
  background: var(--felt); color: var(--felt-ink); font-size: 0.8rem; font-weight: 700;
}
.zb-piece-img { background-size: cover; background-repeat: no-repeat; }
.wK { background-image: url(../pieces/wK.svg); }
.wQ { background-image: url(../pieces/wQ.svg); }
.wR { background-image: url(../pieces/wR.svg); }
.wB { background-image: url(../pieces/wB.svg); }
.wN { background-image: url(../pieces/wN.svg); }
.wP { background-image: url(../pieces/wP.svg); }
.bK { background-image: url(../pieces/bK.svg); }
.bQ { background-image: url(../pieces/bQ.svg); }
.bR { background-image: url(../pieces/bR.svg); }
.bB { background-image: url(../pieces/bB.svg); }
.bN { background-image: url(../pieces/bN.svg); }
.bP { background-image: url(../pieces/bP.svg); }
@media (prefers-reduced-motion: reduce) { .zb-piece { transition: none; } }

/* ---------- eval bar ---------- */
.evalbar {
  position: relative; flex: none; width: 1.5rem; border-radius: 3px; overflow: hidden;
  background: var(--side-black); box-shadow: var(--shadow);
}
.evalbar-white { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: var(--side-white); transition: height 0.4s ease; }
.evalbar.flipped .evalbar-white { bottom: auto; top: 0; }
.evalbar::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: var(--brush-yellow); opacity: 0.7; }
.evalbar-label {
  position: absolute; left: 0; right: 0; bottom: 4px; z-index: 1;
  font-family: var(--font-mono); font-size: 0.62rem; font-weight: 700; text-align: center;
  color: #ffffff; mix-blend-mode: difference;
}
.evalbar.flipped .evalbar-label { bottom: auto; top: 4px; }

/* ---------- engine ---------- */
.engine { padding: 0.55rem 0.8rem; }
.engine-head { display: flex; align-items: center; gap: 0.75rem; min-height: 2.6rem; }
.switch { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; font-weight: 700; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 3.1rem; height: 1.75rem; border-radius: 1rem;
  background: var(--raised); border: 1px solid var(--line); transition: background 0.15s;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: calc(1.75rem - 6px); height: calc(1.75rem - 6px);
  border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--felt); border-color: var(--felt); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(1.35rem); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--felt); outline-offset: 2px; }
.engine-meta { color: var(--muted); font-size: 0.85rem; }
.engine-eval { margin-left: auto; font-family: var(--font-mono); font-weight: 800; font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.engine-lines { list-style: none; margin: 0.5rem 0 0.1rem; padding: 0; display: grid; gap: 0.3rem; }
.engine-lines li { display: flex; align-items: baseline; gap: 0.5rem; min-width: 0; }
.line-eval {
  flex: none; min-width: 3.7em; padding: 0.1rem 0.35rem; border-radius: 5px; text-align: center;
  background: var(--raised); font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.line-moves { display: flex; flex-wrap: nowrap; gap: 0.1rem; overflow: hidden; min-width: 0; white-space: nowrap; mask-image: linear-gradient(to right, #000 85%, transparent); }
.pv-move { border: 0; background: none; padding: 0.1rem 0.2rem; border-radius: 4px; font-size: 0.92rem; white-space: nowrap; }
.pv-move:hover { background: var(--felt-soft); }

/* ---------- move list ---------- */
.moves-card { flex: 1 1 auto; min-height: 9rem; display: flex; flex-direction: column; overflow: hidden; }
.movelist {
  position: relative; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  display: grid; grid-template-columns: 2.7em 1fr 1fr; align-content: start;
  font-variant-numeric: tabular-nums;
}
.movelist .idx {
  display: flex; align-items: center; justify-content: center;
  background: var(--raised); color: var(--muted); font-size: 0.9rem;
  border-right: 1px solid var(--line);
}
.movelist .mv {
  border: 0; background: none; text-align: left; border-radius: 0;
  padding: 0.42rem 0.75rem; font-weight: 700; font-size: 1.08rem; min-height: 2.6rem;
}
.movelist button.mv:not(.active):hover { background: var(--felt-soft); }
.movelist .mv.active, .vm.active { background: var(--felt); color: var(--felt-ink); }
.movelist .mv.empty { color: var(--muted); font-weight: 400; display: flex; align-items: center; }
.movelist .nag { color: var(--felt); margin-left: 0.1em; }
.movelist .mv.active .nag { color: inherit; }
.interrupt {
  grid-column: 1 / -1; padding: 0.45rem 0.75rem;
  background: var(--paper); border-block: 1px solid var(--line); font-size: 0.95rem;
}
.variation {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.05rem 0.1rem;
  padding: 0.1rem 0 0.1rem 0.55rem; margin-block: 0.2rem; border-left: 2px solid var(--line);
}
.vm { border: 0; background: none; padding: 0.15rem 0.3rem; border-radius: 5px; font-size: 0.98rem; color: var(--ink); }
.vm:not(.active):hover { background: var(--felt-soft); }
.vnum { color: var(--muted); margin-right: 0.15em; font-weight: 400; }
.vm.active .vnum { color: inherit; }
.paren { color: var(--muted); }
.comment { margin: 0.15rem 0; color: var(--muted); font-style: italic; }
.variation .comment { margin: 0 0.25rem; }
.moves-empty { grid-column: 1 / -1; margin: 0; padding: 1rem; color: var(--muted); }
.result { grid-column: 1 / -1; margin: 0; padding: 0.6rem 0.75rem; font-weight: 800; text-align: center; border-top: 1px solid var(--line); }
.node-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem; border-top: 1px solid var(--line); background: var(--surface); }

/* ---------- navigation ---------- */
.navbar { display: grid; grid-template-columns: 1fr 1.2fr 1.6fr 1.6fr 1.2fr; gap: 0.4rem; }
.nav-btn {
  height: 3.5rem; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.nav-btn .ic { width: 1.75em; height: 1.75em; }
.nav-btn:hover:not(:disabled) { border-color: var(--muted); }
.nav-btn:active:not(:disabled) { background: var(--felt-soft); }
.nav-btn:disabled { opacity: 0.38; }

/* ---------- drawing tools ---------- */
.draw-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.55rem; }
.swatches { display: flex; gap: 0.3rem; }
.swatch {
  width: 2.6rem; height: 2.6rem; padding: 4px; border-radius: 50%;
  border: 2px solid transparent; background: none;
}
.swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; }
.swatch[aria-checked="true"] { border-color: var(--ink); }

/* ---------- editor ---------- */
.tray { padding: 0.6rem; display: grid; gap: 0.4rem; }
.tray-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.tray-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.35rem; }
.tray-piece {
  aspect-ratio: 1; max-width: 100%; padding: 8%;
  border-radius: 9px; border: 1px solid var(--line); background: var(--raised);
  cursor: grab; touch-action: none;
}
.tray-piece span { display: block; width: 100%; height: 100%; pointer-events: none; }
.tray-piece:hover { border-color: var(--muted); }
.tray-piece[aria-pressed="true"] { background: var(--felt-soft); border-color: var(--felt); box-shadow: inset 0 0 0 2px var(--felt); }
.field { display: grid; gap: 0.35rem; }
.field-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.8rem; padding: 0.4rem 0.6rem; border: 0; background: none; font-weight: 650;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--felt); color: var(--felt-ink); }
.seg button[aria-pressed="true"] .turn-dot { border-color: var(--felt-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  min-height: 2.5rem; padding: 0.3rem 0.75rem; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 650; font-size: 0.92rem;
}
.chip[aria-pressed="true"] { background: var(--felt-soft); border-color: var(--felt); }
.chip:disabled { opacity: 0.4; text-decoration: line-through; }
.fen-row { display: flex; gap: 0.4rem; }
.fen-row input {
  flex: 1; min-width: 0; min-height: 2.75rem; padding: 0.4rem 0.6rem;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  font-family: var(--font-mono); font-size: 0.85rem;
}
.error { margin: 0; color: var(--flag); font-weight: 650; font-size: 0.95rem; }
.primary-action { display: grid; gap: 0.5rem; margin-top: auto; }

/* ---------- dialogs ---------- */
dialog {
  width: min(42rem, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  padding: 1.25rem; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: var(--backdrop); }
dialog h2 { margin: 0 0 0.35rem; font-family: var(--font-display); font-weight: 750; font-stretch: 105%; font-size: 1.4rem; }
.dlg-note { margin: 0 0 0.75rem; color: var(--muted); }
dialog textarea {
  width: 100%; padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: 9px;
  background: var(--paper); font-family: var(--font-mono); font-size: 0.9rem; resize: vertical;
}
.dlg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.9rem; }
.spacer { flex: 1; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.setting { display: grid; gap: 0.4rem; margin-block: 0.9rem; }
.mini-board {
  display: inline-block; width: 1.3rem; height: 1.3rem; border-radius: 3px; flex: none;
  background: conic-gradient(var(--d) 0 90deg, var(--l) 90deg 180deg, var(--d) 180deg 270deg, var(--l) 270deg); background-size: 50% 50%;
}
.mini-board.green { --l: #ebecd0; --d: #779556; }
.mini-board.brown { --l: #f0d9b5; --d: #b58863; }
.mini-board.blue { --l: #dee3e6; --d: #8ca2ad; }
.credits { margin-top: 1rem; color: var(--muted); font-size: 0.9rem; }
.credits summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.credits a { color: var(--felt); }

.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); z-index: 2000;
  transform: translate(-50%, 1rem); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 0.65rem 1rem; border-radius: 10px;
  background: var(--ink); color: var(--paper); font-weight: 650; box-shadow: var(--shadow);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- narrow screens and portrait: board on top, panel below ---------- */
@media (max-width: 900px), (orientation: portrait) and (max-width: 1200px) {
  html, body { height: auto; }
  .app { height: auto; min-height: 100%; }
  .topbar { gap: 0.9rem; }
  .wordmark { font-size: 1.3rem; }
  .view { display: flex; flex-direction: column; height: auto; }
  .stage { flex: none; }
  .panel { overflow: visible; }
  .moves-card { flex: none; height: auto; max-height: 55vh; }
}

/* ---------- forms shared by roster and dialogs ---------- */
.text-input {
  width: 100%; min-height: 2.9rem; padding: 0.45rem 0.7rem;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink);
  font-size: 1.05rem;
}
.text-input:focus { border-color: var(--felt); outline: none; box-shadow: 0 0 0 3px var(--felt-soft); }
.add-row { display: flex; gap: 0.4rem; }
.add-row .text-input { flex: 1; min-width: 0; }
.check, .radio { display: flex; align-items: flex-start; gap: 0.55rem; font-weight: 650; cursor: pointer; }
.check input, .radio input { width: 1.25rem; height: 1.25rem; margin: 0.1rem 0 0; flex: none; accent-color: var(--felt); }
.radio span { font-weight: 400; }
.link-btn { border: 0; background: none; padding: 0.3rem 0; color: var(--felt); font-weight: 650; text-decoration: underline; text-align: left; }
.chip.static { cursor: default; min-height: 0; padding: 0.25rem 0.65rem; }
.name-fields { display: grid; grid-template-columns: minmax(0, 1fr) 7rem; gap: 0.6rem; }
.text-input.initial { text-transform: uppercase; text-align: center; }
.paste-modes { border: 0; padding: 0; margin: 0.9rem 0 0; display: grid; gap: 0.5rem; }
.paste-modes legend { margin-bottom: 0.4rem; }
.paste-preview { margin-top: 0.9rem; max-height: 30vh; overflow-y: auto; }
#paste-text { margin-bottom: 0.6rem; }
.archived-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.archived-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 9px; }
.account-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.sync-status { margin: 0; margin-top: auto; color: var(--muted); font-size: 0.88rem; }
.sync-status.warn { color: var(--flag); font-weight: 650; }

/* ---------- sign-in card ---------- */
.gate { display: grid; place-items: center; min-height: 0; padding-block: 2rem; }
.gate-card, .empty-card { width: min(34rem, 100%); padding: 1.5rem; display: grid; gap: 0.7rem; }
.gate-card h2, .empty-card h2 { margin: 0; font-family: var(--font-display); font-weight: 750; font-stretch: 105%; font-size: 1.5rem; }
.gate-note { margin: 0; color: var(--muted); }
.gate-google { width: 100%; gap: 0.7rem; background: var(--surface); border-color: var(--line); font-size: 1.05rem; }
.gate-google:hover { border-color: var(--felt); }
.gate-google .g-logo { width: 1.35rem; height: 1.35rem; flex: none; }
.gate-more summary { cursor: pointer; color: var(--muted); font-weight: 650; font-size: 0.92rem; padding: 0.25rem 0; }
.gate-more-body { display: grid; gap: 0.5rem; padding-top: 0.5rem; }
/* The sign-in card inside its window: the window is already the frame. */
#dlg-signin { width: min(34rem, calc(100vw - 2rem)); }
#dlg-signin .gate-card { width: auto; padding: 0; border: 0; background: none; box-shadow: none; }
.top-signin { white-space: nowrap; }
/* Phones: the tabs need the room. The home screen's demo note has its own Sign in. */
@media (max-width: 560px) { .top-signin { display: none; } }
.home-demo { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; padding: 0.8rem 1rem; margin-bottom: 1rem;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.home-demo[hidden] { display: none; }
.home-demo .demo-note { flex: 1 1 20rem; margin: 0; text-align: left; }
.pass-row { display: flex; gap: 0.5rem; }
.pass-row .text-input { flex: 1; min-width: 0; }
.gate-hint { margin: -0.3rem 0 0; color: var(--muted); font-size: 0.88rem; }
.empty-card { margin: 2rem auto; }

/* ---------- roster ---------- */
.view.view-wide { display: flex; flex-direction: column; gap: 0.9rem; }
.roster { display: flex; flex-direction: column; gap: 0.9rem; min-height: 0; flex: 1; }
/* Club tabs wrap onto more rows when they don't fit, so every club stays visible and one tap away
   (a sideways-scrolling row hid clubs: Mac browsers hide the scrollbar, and a mouse can't scroll sideways).
   Phones swipe sideways instead, so a long club list doesn't push the page down. */
.group-tabs { display: flex; flex-wrap: wrap; gap: 0.45rem; flex: none; }
@media (max-width: 560px) {
  .group-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.15rem; scrollbar-width: thin; }
}
.group-tab {
  flex: none; display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: var(--tap); padding: 0.4rem 1.15rem; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-family: var(--font-display); font-weight: 650; font-size: 1.12rem; white-space: nowrap;
}
.group-tab:hover { border-color: var(--muted); }
.group-tab .gt-coach { display: block; font-family: var(--font-body); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.75; margin-top: 0.1rem; }
.group-tab[aria-selected="true"] { background: var(--felt); border-color: var(--felt); color: var(--felt-ink); }
.group-tab.add { border-style: dashed; color: var(--muted); font-family: var(--font-body); font-size: 0.98rem; }
.roster-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); gap: 1.25rem; }
.roster-grid { min-height: 0; overflow-y: auto; padding: 2px; }
.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 0.6rem; }
.student {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.2rem;
  min-height: 5.2rem; padding: 0.7rem 1rem; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
  box-shadow: 0 1px 2px rgba(22, 32, 26, 0.06);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.student:hover { border-color: var(--muted); }
.sname {
  font-family: var(--font-display); font-weight: 700; font-stretch: 100%;
  font-size: clamp(1.25rem, 1.15vw + 0.6rem, 2rem); line-height: 1.1; overflow-wrap: anywhere;
}
.student.absent { background: var(--paper); color: var(--muted); border-style: dashed; box-shadow: none; }
.student.absent .sname { text-decoration: line-through; text-decoration-thickness: 2px; }
.stag { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--flag); }
.roster-grid.editing .student { border-style: dashed; border-color: var(--felt); }
.roster-grid.editing .student::after {
  content: "Edit"; position: absolute; top: 0.45rem; right: 0.6rem;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--felt);
}
.roster-panel { gap: 0.9rem; }
.ro-count { margin-top: 0.2rem; }

@media (max-width: 900px), (orientation: portrait) and (max-width: 1200px) {
  .roster-body { display: flex; flex-direction: column; }
  .roster-grid { overflow: visible; }
  .student-grid { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); }
}

/* ---------- wheel ---------- */
.wheel-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); gap: 1.25rem; }
.wheel-stage { position: relative; align-items: center; overflow: hidden; }
.wheel { display: block; max-width: 100%; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.wheel .slice { stroke: var(--side-black); stroke-width: 2; transition: opacity 0.35s; }
.wheel .slice.cream { fill: var(--wheel-1); }
.wheel .slice.green { fill: var(--wheel-0); }
.wheel .slice.blue { fill: var(--wheel-3); }
.wheel .slice.gold { fill: var(--wheel-2); }
.wheel .slice.win { fill: var(--felt); }
.wheel .slice-text { font-family: var(--font-display); font-weight: 750; pointer-events: none; fill: var(--wheel-ink); transition: opacity 0.35s; }
.wheel .slice-text.win { fill: var(--felt-ink); }
.wheel .slice-text.solo { font-size: 90px; }
/* After landing, the other names fade back so the pick stands out. */
.wheel .wheel-spin.landed .slice:not(.win), .wheel .wheel-spin.landed .slice-text:not(.win) { opacity: 0.4; }
.wheel .wheel-rim { fill: none; stroke: var(--side-black); stroke-width: 14; }
.wheel .wheel-hub { fill: var(--side-black); stroke: var(--side-white); stroke-width: 6; }
.wheel .wheel-hub-text { fill: var(--side-white); font-family: var(--font-display); font-weight: 800; font-size: 34px; letter-spacing: 2px; pointer-events: none; }
.wheel .wheel-pointer { fill: var(--flag); stroke: var(--side-black); stroke-width: 6; stroke-linejoin: round; }
.wheel .wheel-empty { fill: var(--raised); }
.wheel .wheel-empty-text { fill: var(--muted); font-family: var(--font-body); font-size: 44px; }
.wheel-result { min-height: 7.5rem; display: grid; place-items: center; padding: 1rem; text-align: center; overflow: hidden; }
.result-placeholder { color: var(--muted); font-size: 1.1rem; }
.result-name { font-family: var(--font-display); font-weight: 800; font-stretch: 108%; font-size: clamp(2.2rem, 2.6vw + 1rem, 4.2rem); line-height: 1; color: var(--felt); }
.pop { animation: zm-pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes zm-pop { 0% { transform: scale(0.55); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.fx-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 30; }
.fx-confetti span { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; animation: zm-confetti 2s cubic-bezier(0.2, 0.6, 0.4, 1) forwards; }
@keyframes zm-confetti { to { transform: translate(var(--dx), var(--fy)) rotate(var(--rot)); opacity: 0.9; } }
@media (prefers-reduced-motion: reduce) { .pop { animation: none; } }
@media (max-width: 900px), (orientation: portrait) and (max-width: 1200px) {
  .wheel-body { display: flex; flex-direction: column; }
}

/* ---------- matchups ---------- */
.mu-stage { position: relative; min-height: 0; overflow-y: auto; border-radius: var(--radius); }
.mu-boards { position: relative; min-height: 100%; padding: 2px; }
.mgrid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.7rem; align-content: start; }
.mboard { display: grid; gap: 0.35rem; padding: 0.75rem 1rem 0.9rem; }
.mnum { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.mrow { display: flex; align-items: center; gap: 0.65rem; min-height: 2.6rem; }
.mrow .dot { flex: none; width: 1.15rem; height: 1.15rem; border-radius: 50%; border: 2px solid var(--ink); }
.mrow .dot.w { background: var(--side-white); }
.mrow .dot.b { background: var(--side-black); }
.mrow .dot.t { background: linear-gradient(90deg, var(--side-white) 50%, var(--side-black) 50%); }
.mslot {
  display: inline-block; font-family: var(--font-display); font-weight: 750; font-stretch: 100%;
  font-size: clamp(1.3rem, 1.1vw + 0.7rem, 2rem); line-height: 1.1; color: var(--ink);
}
.mboard.bye { background: var(--paper); border-style: dashed; }
.mboard.trio .mnum { color: var(--felt); }
.mboard { position: relative; }
/* Before its reveal a board is a faint outline; its names are laid out but hidden so nothing shifts. */
.mboard.pending { background: transparent; border-style: dashed; }
.mboard.pending .mrow { visibility: hidden; }
.mboard.pending .mnum { opacity: 0.55; }
.mboard.poof-in { animation: zm-poof-in 0.42s cubic-bezier(0.2, 1.3, 0.4, 1); }
@keyframes zm-poof-in { from { opacity: 0; transform: scale(0.82); filter: blur(6px); } 60% { opacity: 1; filter: blur(0); } to { transform: scale(1); } }
.poof { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.poof span {
  position: absolute; left: 50%; top: 50%; width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  border-radius: 50%; opacity: 0; animation: zm-puff 0.7s ease-out forwards;
}
@keyframes zm-puff {
  0% { opacity: 0.9; transform: translate(0, 0) scale(0.3); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.5); }
}
@media (prefers-reduced-motion: reduce) { .mboard.poof-in { animation: none; } .poof { display: none; } }

/* ---------- pairings: events, round robin, ladder ---------- */
.event-bar { display: flex; flex-wrap: wrap; gap: 0.4rem; flex: none; }
.event-chip {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.6rem; padding: 0.3rem 0.85rem;
  border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-weight: 650;
}
.event-chip .ev-type { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.event-chip[aria-pressed="true"] { border-color: var(--felt); background: var(--felt-soft); box-shadow: inset 0 0 0 1px var(--felt); }
.event-chip.add { border-style: dashed; color: var(--muted); }
.pr-area { min-width: 0; min-height: 0; overflow: auto; padding: 2px; }
/* The side panel scrolls as a whole; its parts keep their full height instead of being squeezed. */
#pr-panel > * { flex-shrink: 0; }
.grid-note { margin: 0 0 0.6rem; color: var(--muted); }
.xt-wrap { overflow-x: auto; }
.xt2 { border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-variant-numeric: tabular-nums; }
.xt2 th, .xt2 td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.xt2 tr > :last-child { border-right: 0; }
.xt2 tbody tr:last-child > * { border-bottom: 0; }
.xt2 thead th { height: 2.6rem; font-size: 0.9rem; color: var(--muted); background: var(--raised); }
.xt2 th.row { text-align: left; padding: 0 0.8rem; white-space: nowrap; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; background: var(--surface); }
.xt2 .rnum { display: inline-block; min-width: 1.6em; color: var(--muted); font-family: var(--font-body); font-size: 0.85rem; font-weight: 700; }
.xt2 td { position: relative; width: 3.6rem; height: 3.4rem; min-width: 3.2rem; }
.xt2 td.self { background: var(--raised); }
.xt2 td.cell { cursor: pointer; font-weight: 800; font-size: 1.25rem; }
.xt2 td.cell:hover { background: var(--felt-soft); }
.xt2 td.cell.played { background: var(--paper); }
/* "Pick a game": the darting green light, the square it locks onto, and the two players' names. */
.xt2 td.cell.cursor { background: var(--felt); box-shadow: inset 0 0 0 3px var(--felt-ink), 0 0 22px 4px var(--felt); z-index: 1; }
.xt2 td.cell.locked { background: var(--felt); color: var(--felt-ink); box-shadow: inset 0 0 0 3px var(--felt-ink), 0 0 26px 6px var(--felt); z-index: 1; animation: pick-lock 0.55s ease-out 2; }
.xt2 td.cell.picked { background: var(--felt-soft); box-shadow: inset 0 0 0 3px var(--felt); }
.xt2 th.hl { background: var(--felt-soft); }
.xt2 th.col.hl .cname, .xt2 th.row.hl { color: var(--felt); }
@keyframes pick-lock { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .xt2 td.cell.locked { animation: none; } }
.pick-box { display: flex; gap: 0.5rem; align-items: stretch; }
.pick-box .btn { flex: 1; }
.pick-box .pick-sound { height: auto; min-height: var(--tap); width: 3.4rem; flex: none; color: var(--muted); }
.pick-box .pick-sound[aria-pressed="true"] { color: var(--ink); }
.pick-card { padding: 0.8rem 1rem; display: grid; gap: 0.5rem; border-color: var(--felt); }
.pick-match { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-family: var(--font-display); font-weight: 750; font-size: 1.3rem; }
.pick-match .cdot { position: static; display: inline-block; margin-right: 0.35rem; vertical-align: middle; }
.pick-match .vs { color: var(--muted); font-size: 1rem; font-weight: 600; }
.pick-res { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.xt2 td.away span, .xt2 td.away { color: var(--muted); }
.xt2 td.tot, .xt2 th.tot { font-weight: 800; padding: 0 0.7rem; background: var(--raised); }
.xt2 .cdot { position: absolute; top: 5px; left: 5px; }
.cdot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; border: 1.5px solid var(--ink); flex: none; }
.cdot.w { background: var(--side-white); }
.cdot.b { background: var(--side-black); }
.standings-wrap { overflow-x: auto; }
.standings { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-variant-numeric: tabular-nums; }
.standings th, .standings td { padding: 0.5rem 0.55rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.standings th { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.standings .name { text-align: left; width: 100%; font-weight: 700; }
.standings .pts { font-weight: 800; }
.standings .rank { color: var(--muted); }
.standings tr:last-child td { border-bottom: 0; }
.standings tr.away td { color: var(--muted); }
.round-filters { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-bottom: 0.5rem; }
.round { margin-top: 0.9rem; }
.round h3 { margin: 0 0 0.4rem; font-size: 1rem; display: flex; gap: 0.8rem; align-items: baseline; }
.bye-note { color: var(--muted); font-weight: 400; font-size: 0.9rem; }
.half-note { margin: 1.4rem 0 0; padding-top: 0.8rem; border-top: 1px solid var(--line); color: var(--muted); }
.round-games { display: grid; }
.rgame { display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: 0.4rem 0.8rem; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line); }
.rgame:last-child { border-bottom: 0; }
.rgame .p { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.1rem; min-width: 0; }
.rgame .p .away { color: var(--muted); }
.rgame.played .p { color: var(--muted); }
.rgame .res { display: flex; gap: 0.3rem; }
.rgame .res button { min-width: 3.3rem; min-height: 2.6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 700; font-variant-numeric: tabular-nums; }
.rgame .res button[aria-pressed="true"] { background: var(--felt); color: var(--felt-ink); border-color: var(--felt); }
.rgame.boarded { grid-template-columns: auto 1fr 1fr auto; }
.bnum { display: grid; place-items: center; min-width: 2.1rem; height: 2.1rem; border-radius: 7px; background: var(--raised); font-weight: 800; font-variant-numeric: tabular-nums; }
.spts { color: var(--muted); font-weight: 650; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.round-extra { margin: 0.45rem 0 0; color: var(--muted); }
.round-extra b { color: var(--ink); }
details.round.past { border-top: 1px solid var(--line); padding-top: 0.6rem; }
details.round.past summary { cursor: pointer; font-weight: 700; display: flex; gap: 0.8rem; align-items: baseline; min-height: 2.4rem; align-items: center; }
details.round.past[open] summary { margin-bottom: 0.4rem; }
.swiss-table td.sw { width: auto; min-width: 4.4rem; padding: 0 0.5rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.swiss-table td.sw .cdot { position: static; vertical-align: -0.05rem; margin-right: 0.3rem; }
.swiss-table td.sw .opp { color: var(--muted); font-size: 0.9rem; margin-right: 0.35rem; }
.swiss-table td.sw b { font-size: 1.15rem; }
.swiss-table td.sw.bye { font-weight: 800; color: var(--felt); }
.swiss-table td.sw.out { color: var(--muted); }
@media (max-width: 900px), (orientation: portrait) and (max-width: 1200px) {
  .rgame.boarded { grid-template-columns: auto 1fr 1fr; }
  .rgame.boarded .res { grid-column: 1 / -1; justify-content: flex-end; }
}
/* Small × to delete a tab (events, lesson slides). Shows on hover; on touch screens, on the selected tab. */
.chip-wrap { position: relative; display: inline-flex; }
.chip-x {
  position: absolute; top: -0.55rem; right: -0.55rem; z-index: 2; min-width: 1.6rem; height: 1.6rem; padding: 0 0.4rem;
  display: grid; place-items: center; border-radius: 99px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-weight: 800; font-size: 0.95rem; line-height: 1; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.chip-wrap:hover .chip-x, .chip-x:focus-visible, .chip-x[data-armed] { opacity: 1; pointer-events: auto; }
@media (hover: none) { .chip-wrap.active .chip-x { opacity: 1; pointer-events: auto; } }
.chip-x:hover { color: var(--flag); border-color: var(--flag); }
.chip-x[data-armed] { background: var(--flag); border-color: var(--flag); color: var(--flag-ink); font-size: 0.8rem; }

/* Round robin grid: column names (stood on end when there are many players) */
.xt2 th.col { padding: 0.35rem 0.3rem; vertical-align: bottom; }
.xt2 th.col .cnum { display: block; font-size: 0.75rem; }
.xt2 th.col .cname { display: block; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 0.98rem; white-space: nowrap; }
.xt2.many th.col .cname { writing-mode: vertical-rl; transform: rotate(180deg); margin: 0.2rem auto 0; max-height: 9rem; overflow: hidden; text-overflow: ellipsis; }
.xt2:not(.many) td { min-width: 5.2rem; }

/* Number stepper (Swiss rounds) */
.stepper { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.stepper .btn { min-width: 2.6rem; font-size: 1.2rem; }
.step-val { min-width: 2ch; text-align: center; font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stepper-row { gap: 0.75rem; }
.good-status { color: var(--felt); }

/* Ladder: drag handle and remove × */
.rung .grip { display: flex; flex-direction: column; gap: 4px; padding: 0.9rem 0.95rem 0.9rem 0.5rem; margin-left: -0.5rem; cursor: grab; touch-action: none; border-radius: 6px; }
.rung .grip i { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); box-shadow: 7px 0 0 var(--muted); }
.rung .grip:hover { background: var(--raised); }
.rung.lifting { position: relative; z-index: 5; box-shadow: var(--shadow); border-color: var(--felt); cursor: grabbing; transition: none; }
.ladder.sorting .rung:not(.lifting) { transition: transform 0.18s ease; }
.rung .rx { border: 1px solid transparent; background: none; color: var(--muted); border-radius: 99px; min-width: 2.2rem; height: 2.2rem; padding: 0 0.5rem; font-weight: 800; }
.rung .rx:hover { color: var(--flag); border-color: var(--flag); }
.rung .rx[data-armed] { background: var(--flag); color: var(--flag-ink); font-size: 0.8rem; }
@media (hover: hover) { .rung .rx { opacity: 0; } .rung:hover .rx, .rung .rx:focus-visible, .rung .rx[data-armed] { opacity: 1; } }

.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; max-width: 44rem; }
.rung {
  display: flex; align-items: center; gap: 0.9rem; min-height: 3.8rem; padding: 0.4rem 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.rung .rank { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; min-width: 2.2ch; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rung .rname { flex: 1; font-family: var(--font-display); font-weight: 750; font-size: clamp(1.25rem, 1vw + 0.7rem, 1.8rem); min-width: 0; }
.rung .rname small { font-family: var(--font-body); font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.rung .rrec { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 650; }
.rung.challenger { border-color: var(--felt); background: var(--felt-soft); box-shadow: inset 0 0 0 2px var(--felt); }
.rung.target { border-color: var(--flag); box-shadow: inset 0 0 0 2px var(--flag); }
.rung .rtag { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; color: var(--flag); }
.rung.dim { opacity: 0.45; }
.ladder-top { display: flex; align-items: flex-start; gap: 1rem; max-width: 44rem; }
.ladder-top .grid-note { flex: 1; }
.ladder.no-ranks .rung { padding-left: 1rem; }
.rung.busy { opacity: 0.5; background: var(--paper); border-style: dashed; cursor: default; }
.rung .rplaying { font-size: 0.85rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.pending-games { display: grid; gap: 0.5rem; }
.pgame { display: grid; gap: 0.45rem; padding: 0.6rem 0.75rem; border-color: var(--felt); }
.pgame-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 1.05rem; }
.pgame-head small { color: var(--muted); font-weight: 650; }
.pgame .rx { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 99px; min-width: 2.2rem; height: 2.2rem; padding: 0 0.5rem; font-weight: 800; }
.pgame .rx:hover { color: var(--flag); border-color: var(--flag); }
.pgame .rx[data-armed] { background: var(--flag); color: var(--flag-ink); font-size: 0.8rem; }
.pgame-res { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.35rem; }
.pgame-res .btn { justify-content: center; text-align: center; }
.rung.away .rname { color: var(--muted); }
.rung.left { border-style: dashed; }
.rung:first-child .rank { color: var(--felt); }
.ladder-log { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.3rem; }
.result-options { display: grid; gap: 0.5rem; margin-top: 0.6rem; }
.player-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.35rem 1rem; max-height: 40vh; overflow-y: auto; padding: 0.4rem 0; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.muted { color: var(--muted); }

/* ---------- editor: "save to lesson" banner ---------- */
.return-banner { display: grid; gap: 0.6rem; padding: 0.85rem 1rem; border-color: var(--felt); box-shadow: inset 0 0 0 1px var(--felt); }
.return-banner p { margin: 0; }

/* ---------- lessons ---------- */
.ls-library, .ls-lesson { display: flex; flex-direction: column; gap: 0.9rem; flex: 1; min-height: 0; }
.ls-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.7rem; align-content: start; overflow-y: auto; padding: 2px; }
.lesson-grid .empty-card { grid-column: 1 / -1; }
.lesson-card { display: grid; gap: 0.3rem; padding: 1rem 1.1rem; text-align: left; color: var(--ink); }
.lesson-card:hover { border-color: var(--felt); }
.lc-title { font-family: var(--font-display); font-weight: 750; font-stretch: 105%; font-size: 1.3rem; line-height: 1.15; }
.lc-meta { color: var(--ink); font-size: 0.95rem; }
.lc-date { color: var(--muted); font-size: 0.85rem; }

.ls-bar { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.ls-head .spacer { flex: 1; }
.ls-head { flex-wrap: wrap; justify-content: flex-start; }
.lc-private { color: var(--flag); font-weight: 700; }
.ls-readonly { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0.8rem; border-color: var(--felt); background: var(--felt-soft); }
.ls-readonly p { margin: 0; }
/* Someone else's lesson: hide everything that would change it. */
.ls-lesson.readonly #ls-add-slide, .ls-lesson.readonly #ls-delete, .ls-lesson.readonly .chip-x,
.ls-lesson.readonly #ls-keep-arrows, .ls-lesson.readonly [data-edit], .ls-lesson.readonly #ls-mode [data-mode="write"],
.ls-lesson.readonly #ls-ink-tools, .ls-lesson.readonly #ls-empty-add { display: none !important; }
.ls-lesson.readonly .ls-title { border-color: transparent; background: transparent; }
.ls-title { flex: 0 1 17rem; min-width: 9rem; font-family: var(--font-display); font-weight: 750; font-size: 1.15rem; }
.slide-chips { flex: 1; min-width: 0; display: flex; gap: 0.55rem; overflow-x: auto; padding: 0.7rem 0.7rem 2px 2px; margin-top: -0.7rem; scrollbar-width: thin; }
.slide-chip {
  flex: none; display: inline-flex; align-items: center; gap: 0.4rem; min-height: 2.75rem; max-width: 15rem;
  padding: 0.3rem 0.75rem 0.3rem 0.35rem; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.slide-chip:hover { border-color: var(--muted); }
.slide-chip[aria-pressed="true"] { background: var(--felt); border-color: var(--felt); color: var(--felt-ink); }
.sc-num { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 6px; background: var(--raised); font-weight: 750; }
.slide-chip[aria-pressed="true"] .sc-num { background: rgb(255 255 255 / 0.18); }
.sc-kind { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.slide-chips .chip-wrap { flex: none; }
.slide-chips.sorting .chip-wrap:not(.dragging) { transition: transform 0.16s ease; }
.slide-chips .chip-wrap.dragging { position: relative; z-index: 3; }
.slide-chips .chip-wrap.dragging .slide-chip { box-shadow: var(--shadow); cursor: grabbing; }
.slide-chips .chip-wrap.dragging .chip-x { opacity: 0; }
.sc-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Three columns: a narrow tool strip, the board (sized by script to fill the height), and the notes. */
.ls-body { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: auto auto minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 1rem; }
.ls-tools { display: flex; flex-direction: column; gap: 0.45rem; width: 5.2rem; min-height: 0; overflow-y: auto; }
.ls-tools .btn, .draw-tools.vertical .btn {
  flex-direction: column; gap: 0.2rem; width: 100%; padding: 0.45rem 0.2rem; min-height: 3.6rem;
  font-size: 0.74rem; text-align: center; line-height: 1.1;
}
.ls-tools .btn .ic { width: 1.5em; height: 1.5em; }
.draw-tools.vertical { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0.45rem; }
.draw-tools.vertical .swatches { flex-direction: column; align-items: center; gap: 0.15rem; }
.ls-stage { align-items: flex-start; }
.ls-side { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.ls-controls { flex: none; display: grid; gap: 0.55rem; padding: 0.8rem 0.9rem; max-height: 46%; overflow-y: auto; }
.ls-controls:empty { display: none; }
.ls-controls .panel-sub { line-height: 1.45; }
.slide-title { font-weight: 650; }
.slide-actions { padding-top: 0.15rem; border-top: 1px solid var(--line); margin-top: 0.1rem; padding-top: 0.55rem; }
.puzzle-status { margin: 0; }
.puzzle-status.good { color: var(--felt); }
.navbar.compact { grid-template-columns: repeat(4, 1fr); }
.mini-moves { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.1rem; max-height: 7.5rem; overflow-y: auto; margin-top: 0.3rem; }

.notes { flex: 1; min-height: 14rem; display: flex; flex-direction: column; overflow: hidden; }
.notes-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); }
.seg.small button { min-height: 2.4rem; padding: 0.3rem 0.9rem; }
.ink-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-left: auto; }
.ink-tools .swatch { width: 2.3rem; height: 2.3rem; }
/* Typed text scales with the pane's width, like the handwriting does, so a word underlined on the laptop
   is still underlined on the smart board. Below about 520px wide it stops shrinking (readability wins). */
.notes-area { position: relative; flex: 1; min-height: 0; container-type: inline-size; }
.notes-area textarea {
  position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border: 0; background: transparent;
  padding: 0.9rem 1.1rem; color: var(--ink); font: inherit; font-size: clamp(1.15rem, 0.7vw + 0.8rem, 1.75rem); line-height: 1.45;
  padding: max(0.65rem, 2cqw) max(0.75rem, 2.4cqw); font-size: max(1rem, 3.1cqw);
}
.notes-area textarea:focus { outline: none; }
.notes-area canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.notes-area canvas.writing { pointer-events: auto; touch-action: none; cursor: crosshair; }

.add-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.add-tiles.single { grid-template-columns: minmax(0, 1fr); }
.add-tile { flex-direction: column; justify-content: flex-start; text-align: center; gap: 0.35rem; padding: 0.9rem 0.6rem; min-height: 8.5rem; }
.add-tile .ic { width: 1.9rem; height: 1.9rem; color: var(--felt); }
.add-tile small { color: var(--muted); font-weight: 400; font-size: 0.8rem; line-height: 1.3; }
.add-tile:disabled { opacity: 0.55; }
.add-tile:not(:disabled):hover { border-color: var(--felt); }
.add-tiles.single .add-tile { min-height: 0; flex-direction: row; justify-content: flex-start; text-align: left; flex-wrap: wrap; }
.add-game-list { display: grid; gap: 0.4rem; }
.add-game-list .btn { justify-content: flex-start; }
@media (max-width: 560px) { .add-tiles { grid-template-columns: 1fr; } .add-tile { min-height: 0; flex-direction: row; text-align: left; flex-wrap: wrap; } }
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.btn.eye[aria-pressed="false"] { color: var(--muted); }
/* Whiteboard slide: no board, the page takes the whole width */
.ls-body.whiteboard { display: flex; flex-direction: column; }
.ls-body.whiteboard .ls-tools, .ls-body.whiteboard .ls-stage { display: none; }
.ls-body.whiteboard .ls-side { flex: 1; }
.ls-body.whiteboard .ls-controls { max-height: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; }
.ls-body.whiteboard .ls-controls .slide-title { flex: 0 1 22rem; }
.ls-body.whiteboard .ls-controls .slide-actions { border: 0; margin: 0 0 0 auto; padding: 0; }
.notes-area canvas.erasing { cursor: cell; }
.ls-body.whiteboard .notes-area textarea { font-size: max(1rem, 1.9cqw); padding: max(0.65rem, 1.2cqw) max(0.75rem, 1.5cqw); }

@media (max-width: 900px), (orientation: portrait) and (max-width: 1200px) {
  .ls-bar { flex-wrap: wrap; }
  .ls-title { flex: 1 1 12rem; }
  .slide-chips { order: 5; flex-basis: 100%; }
  .ls-body { display: flex; flex-direction: column; }
  .ls-tools { flex-direction: row; flex-wrap: wrap; width: auto; overflow: visible; }
  .ls-tools .btn, .draw-tools.vertical .btn { width: auto; min-height: 2.75rem; flex-direction: row; font-size: 0.88rem; padding: 0.35rem 0.7rem; }
  .draw-tools.vertical { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .draw-tools.vertical .swatches { flex-direction: row; }
  .ls-stage { width: 100%; }
  .ls-controls { max-height: none; }
  .notes { min-height: 22rem; }
}

/* ---------- home ---------- */
.home { width: min(76rem, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 1.25rem; padding-bottom: 1rem; }
.home-head { display: grid; gap: 0.2rem; }
.home-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; }
.home-tile {
  display: grid; align-content: start; justify-items: start; gap: 0.4rem; text-align: left; color: var(--ink);
  padding: 1.15rem 1.2rem 1.25rem; min-height: 11.5rem; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.home-tile:not(.locked):hover { border-color: var(--felt); box-shadow: var(--shadow); transform: translateY(-2px); }
.home-tile:not(.locked):active { transform: translateY(0); }
.ht-badge { display: grid; place-items: center; width: 3.1rem; height: 3.1rem; border-radius: 12px; color: var(--wheel-ink); margin-bottom: 0.35rem; }
.ht-badge .ic { width: 1.6rem; height: 1.6rem; }
.ht-badge.tone-0 { background: var(--wheel-0); }
.ht-badge.tone-1 { background: var(--wheel-1); box-shadow: inset 0 0 0 1px var(--line); }
.ht-badge.tone-2 { background: var(--wheel-2); }
.ht-badge.tone-3 { background: var(--wheel-3); }
.ht-badge.tone-4 { background: var(--wheel-4); }
.ht-title { font-family: var(--font-display); font-weight: 750; font-stretch: 105%; font-size: 1.45rem; line-height: 1.1; }
.ht-text { color: var(--muted); font-size: 0.95rem; line-height: 1.35; }
.ht-extra { margin-top: auto; padding-top: 0.35rem; font-size: 0.85rem; font-weight: 700; color: var(--felt); }
.home-tile.locked { opacity: 0.5; filter: grayscale(0.6); cursor: default; }
.home-tile.locked .ht-extra { color: var(--muted); }
.home-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem 1rem; padding-top: 0.5rem; }
.home-signin { flex-basis: 100%; display: grid; justify-items: center; }
.demo-note { margin: 0; max-width: 40rem; text-align: center; color: var(--muted); }
.demo-note.left { text-align: left; padding: 0.6rem 0.75rem; border-radius: 9px; background: var(--felt-soft); color: var(--ink); font-size: 0.92rem; }
.badge { display: inline-block; padding: 0.05rem 0.45rem; border-radius: 99px; background: var(--felt-soft); color: var(--felt); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: 0.1em; }
.gate-card.compact { padding: 1rem 1.1rem; gap: 0.55rem; width: min(26rem, 100%); }
@media (max-width: 1100px) { .home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px), (orientation: portrait) and (max-width: 1200px) {
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .home-tile { min-height: 0; padding: 0.9rem; }
  .ht-badge { width: 2.6rem; height: 2.6rem; }
  .ht-title { font-size: 1.2rem; }
  .ht-text { font-size: 0.85rem; }
}

/* ---------- admin ---------- */
.admin { width: min(64rem, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; padding-bottom: 1rem; }
.admin-card { padding: 1rem 1.1rem; display: grid; gap: 0.75rem; }
.admin-h { margin: 0; font-family: var(--font-display); font-weight: 750; font-size: 1.25rem; }
.admin-list { display: grid; }
.admin-row { display: grid; grid-template-columns: minmax(8rem, 1.2fr) minmax(8rem, 1.4fr) minmax(8rem, 1.2fr) auto; align-items: center; gap: 0.4rem 0.9rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.admin-row:last-child { border-bottom: 0; }
#admin-clubs .admin-row { grid-template-columns: minmax(9rem, 14rem) 1fr; align-items: start; }
.admin-club { display: grid; gap: 0.1rem; padding-top: 0.45rem; }
/* One tick per coach, as big touch targets that wrap onto more lines when there are many coaches. */
.access-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.access-chip { display: inline-flex; align-items: center; gap: 0.5rem; min-height: var(--tap); padding: 0.3rem 0.85rem 0.3rem 0.6rem;
  border: 1px solid var(--line); border-radius: 99px; background: var(--surface); cursor: pointer; user-select: none; font-weight: 650; }
.access-chip:hover { border-color: var(--muted); }
.access-chip:has(input:checked) { background: var(--felt-soft); border-color: var(--felt); }
.access-chip input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--felt); }
.access-chip input:disabled { opacity: 0.5; }
.admin-name { font-weight: 750; }
.admin-email, .admin-meta { color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.admin-add { display: grid; grid-template-columns: 1.3fr 1fr auto; gap: 0.5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 900px), (orientation: portrait) and (max-width: 1200px) {
  .admin-row, #admin-clubs .admin-row, .admin-add { grid-template-columns: 1fr; }
}
