/* Themes. Each sets colours, board and fonts; the piece set is chosen in app.js (THEMES). */
:root,
[data-theme="classic"] {
  --bg: #e8e0cb;            /* lime white */
  --panel: #eeefea;         /* chiffon */
  --panel-edge: #c7beb3;    /* elephant's breath */
  --text: #2a2622;
  --muted: #6f665c;
  --light: #f0d9b5;
  --dark: #b58863;
  --frame: #0c0c0c;
  --lens: #e8b23a;          /* lit key lens (amber) */
  --lens-face: #ffe08a;
  --lens-off: #4a4038;      /* dark key lens */
  --legend-off: #f4ead8;
  --cap: #fffdd0;           /* cream keycap */
  --select: rgba(232, 178, 58, 0.75);
  --last: rgba(232, 178, 58, 0.35);
  --font: "Nunito", ui-rounded, system-ui, sans-serif;
  --display: var(--font);
  --display-size: 1;
}

[data-theme="studio"] {
  --bg: #0e0f11;
  --panel: #1b1d21;
  --panel-edge: #0a0b0c;
  --text: #e9e7e2;
  --muted: #85837e;
  --light: #d6cfc2;
  --dark: #7c7468;
  --frame: #050506;
  --lens: #e0603a;
  --lens-face: #ffc27e;
  --lens-off: #2c2f35;
  --legend-off: #b4b2ad;
  --cap: #e9e7e2;
  --select: rgba(224, 96, 58, 0.7);
  --last: rgba(232, 178, 58, 0.4);
  --font: "Atkinson Hyperlegible", "Trebuchet MS", system-ui, sans-serif;
  --display: var(--font);
}

[data-theme="teletext"] {
  --bg: #050506;
  --panel: #0d0e12;
  --panel-edge: #000;
  --text: #f2efe6;
  --muted: #8e8b84;
  --light: #43dce4;
  --dark: #3d5bd8;
  --frame: #000;
  --lens: #f0dc4a;
  --lens-face: #fff8c0;
  --lens-off: #14151b;
  --legend-off: #43dce4;
  --cap: #f2efe6;
  --select: rgba(240, 220, 74, 0.85);
  --last: rgba(98, 216, 112, 0.55);
  --font: "Atkinson Hyperlegible", "Trebuchet MS", system-ui, sans-serif;
  --display: "VT323", "Courier New", monospace;
  --display-size: 1.35;
}

[data-theme="mint"] {
  --bg: #16201a;
  --panel: #24332a;
  --panel-edge: #121a15;
  --text: #e6f2e6;
  --muted: #9cb5a2;
  --light: #eeeed2;
  --dark: #769656;
  --frame: #0c0c0c;
  --lens: #6fdc84;
  --lens-face: #d8ffd8;
  --lens-off: #1f2b23;
  --legend-off: #9ee6a0;
  --cap: #e8f5e0;
  --select: rgba(186, 202, 68, 0.85);
  --last: rgba(246, 246, 105, 0.5);
  --font: "Fredoka", ui-rounded, system-ui, sans-serif;
  --display: var(--font);
}

[data-theme="navy"] {
  --bg: #262c55;
  --panel: #353d70;
  --panel-edge: #232958;
  --text: #eef1ff;
  --muted: #a9b4e0;
  --light: #dee3e6;
  --dark: #8ca2ad;
  --frame: #0c0c0c;
  --lens: #5aa8ff;
  --lens-face: #d6ecff;
  --lens-off: #30376a;
  --legend-off: #c4cdf2;
  --cap: #f4fdff;           /* cool white */
  --select: rgba(90, 168, 255, 0.6);
  --last: rgba(155, 199, 0, 0.4);
  --font: "Exo 2", system-ui, sans-serif;
  --display: var(--font);
}

[data-theme="sunshine"] {
  --bg: #fff3c4;
  --panel: #fffdf2;
  --panel-edge: #f0cf7a;
  --text: #3b2410;
  --muted: #8a6a45;
  --light: #ffe9a8;
  --dark: #f2a65a;
  --frame: #3b2410;
  --lens: #ff7a45;
  --lens-face: #ffd3a8;
  --lens-off: #6b4a2b;
  --legend-off: #ffe9c4;
  --cap: #fffdd0;
  --select: rgba(80, 200, 255, 0.6);
  --last: rgba(255, 122, 69, 0.35);
  --font: "Baloo 2", ui-rounded, system-ui, sans-serif;
  --display: var(--font);
}

/* GFX palette pack (colours from the GFX panel themes in gfx-lab-ui) */

[data-theme="robinson"] {          /* Ember: warm brown, burnt orange */
  --bg: #180f0b;
  --panel: #221812;
  --panel-edge: #120a07;
  --text: #f6e6d4;
  --muted: #c9a88c;
  --light: #e6b07a;
  --dark: #a8502a;
  --frame: #0c0806;
  --lens: #e8782e;
  --lens-face: #ffd0a0;
  --lens-off: #3d2b1e;
  --legend-off: #e0c6ae;
  --cap: #f8eadc;
  --select: rgba(232, 120, 46, 0.7);
  --last: rgba(245, 154, 82, 0.45);
  --font: "Rubik", system-ui, sans-serif;
  --display: var(--font);
}

[data-theme="bedford"] {          /* Studio (light): pale grey, green */
  --bg: #d6d8dc;
  --panel: #e4e5e8;
  --panel-edge: #b8bbc2;
  --text: #1e2025;
  --muted: #5a5f69;
  --light: #e6ecdc;
  --dark: #8daa7a;
  --frame: #24272d;
  --lens: #4e9a5a;
  --lens-face: #c8f0c8;
  --lens-off: #3a3e45;      /* dark well, light legend */
  --legend-off: #e4e5e8;
  --cap: #f4f5f7;
  --select: rgba(78, 154, 90, 0.6);
  --last: rgba(169, 185, 142, 0.6);
  --font: "Lexend", system-ui, sans-serif;
  --display: var(--font);
}

[data-theme="russell"] {          /* Mint: pastel green */
  --bg: #d0e8de;
  --panel: #e4f2ec;
  --panel-edge: #9cc4b6;
  --text: #1e3a30;
  --muted: #4c6e62;
  --light: #eef8f3;
  --dark: #6cc0a2;
  --frame: #1e3a30;
  --lens: #4faf8e;
  --lens-face: #c8f5e4;
  --lens-off: #2e5a4c;
  --legend-off: #e4f2ec;
  --cap: #f6fcf9;
  --select: rgba(62, 142, 114, 0.6);
  --last: rgba(127, 208, 178, 0.55);
  --font: "Quicksand", ui-rounded, system-ui, sans-serif;
  --display: var(--font);
}

[data-theme="edith"] {          /* Blossom: pastel lilac and pink */
  --bg: #e8d6e4;
  --panel: #f3e8f0;
  --panel-edge: #c4a8c2;
  --text: #3e2440;
  --muted: #705a72;
  --light: #fbeff7;
  --dark: #c98cc0;
  --frame: #3e2440;
  --lens: #c77db8;
  --lens-face: #f6d4ee;
  --lens-off: #5a3a5e;
  --legend-off: #f3e8f0;
  --cap: #fcf6fa;
  --select: rgba(142, 98, 168, 0.55);
  --last: rgba(168, 160, 216, 0.55);
  --font: "Andika", system-ui, sans-serif;
  --display: var(--font);
}

[data-theme="livingstone"] {          /* Olive: olive, moss, sage, amber */
  --bg: #0f120c;
  --panel: #161a12;
  --panel-edge: #0a0c08;
  --text: #e9eddc;
  --muted: #aeb89a;
  --light: #c8d0b4;
  --dark: #6e7a3a;
  --frame: #0a0c08;
  --lens: #e0a030;
  --lens-face: #ffe0a0;
  --lens-off: #2a3222;
  --legend-off: #cbd3ba;
  --cap: #f0f2e6;
  --select: rgba(224, 160, 48, 0.7);
  --last: rgba(242, 190, 90, 0.4);
  --font: "Bitter", Georgia, serif;
  --display: var(--font);
}

[data-theme="castle"] {          /* Velvet: aubergine, plum, lilac */
  --bg: #120c18;
  --panel: #1a1222;
  --panel-edge: #0b0710;
  --text: #eee4f6;
  --muted: #b7a6c6;
  --light: #d3c4e2;
  --dark: #7a4592;
  --frame: #08050b;
  --lens: #b58ad8;
  --lens-face: #eedcff;
  --lens-off: #31243f;
  --legend-off: #d3c4e2;
  --cap: #f2ecf8;
  --select: rgba(181, 138, 216, 0.7);
  --last: rgba(208, 174, 236, 0.4);
  --font: "Atkinson Hyperlegible", "Trebuchet MS", system-ui, sans-serif;
  --display: "Cinzel", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1, h2 { font-family: var(--display); }
h2 { font-size: calc(1.25rem * var(--display-size, 1)); }

.topbar {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-weight: 800;
  font-size: calc(1.3rem * var(--display-size, 1));
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}
.logo img { width: 36px; height: 36px; }
.home-btn { text-decoration: none; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

/* Panels: a narrow darker bottom/right edge for depth and a small rivet in each corner. */
.card {
  position: relative;
  border-radius: 8px;
  border-right: 3px solid var(--panel-edge);
  border-bottom: 3px solid var(--panel-edge);
  padding: 22px;
  margin-bottom: 16px;
  --rivet: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.55) 0 1px, rgba(0, 0, 0, 0.35) 2px 3px, transparent 3.5px);
  background-color: var(--panel);
  background-image: var(--rivet), var(--rivet), var(--rivet), var(--rivet);
  background-size: 10px 10px;
  background-position: 6px 6px, calc(100% - 6px) 6px, 6px calc(100% - 6px), calc(100% - 6px) calc(100% - 6px);
  background-repeat: no-repeat;
}
.card h2 { margin: 0 0 8px; }

.hint { color: var(--muted); font-size: 0.95rem; margin: 4px 0 12px; }
.error { color: #e0603a; font-weight: 700; }
.muted { color: var(--muted); }

.me-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.big-emoji { font-size: 3rem; line-height: 1; }

.picker { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.picker label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 4px; }

/* Display boxes: dark recessed box with light text. */
select, input {
  font: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 4px;
  border: 0;
  background: #2a2622;
  color: #f4ead8;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5), inset -1px -1px 0 rgba(255, 255, 255, 0.08);
}

/* ---------- GFX lamp keys ----------
   A coloured lens in a dark well. Off: dim tinted glass with a light legend.
   Lit: a warm glow, paler towards the centre, with a soft halo.
   Light from the top left, so keys throw a soft layered shadow down and to the right. */

.btn {
  --rim: var(--lens);
  --face: var(--lens-face);
  position: relative;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 6px;
  border: 4px solid var(--frame);
  cursor: pointer;
  color: var(--legend-off);
  background:
    radial-gradient(120% 140% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.28) 100%),
    var(--lens-off);
  box-shadow:
    2px 3px 2px rgba(0, 0, 0, 0.13),
    3px 4px 4px rgba(0, 0, 0, 0.13),
    4px 6px 6px rgba(0, 0, 0, 0.13),
    6px 8px 9px rgba(0, 0, 0, 0.13),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform 0.06s, filter 0.15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translate(1px, 2px); }
.btn:disabled { opacity: 0.4; cursor: default; filter: none; transform: none; }
.btn:focus-visible { outline: 3px solid var(--lens); outline-offset: 2px; }

/* Lit keys: the main action on each panel. */
.btn.primary {
  color: #1a0d07;
  background: radial-gradient(90% 120% at 50% 45%, color-mix(in srgb, var(--face) 55%, #fff6e0) 0%, var(--face) 45%, var(--rim) 100%);
  box-shadow:
    0 0 14px color-mix(in srgb, var(--rim) 55%, transparent),
    2px 3px 2px rgba(0, 0, 0, 0.13),
    3px 4px 4px rgba(0, 0, 0, 0.13),
    4px 6px 6px rgba(0, 0, 0, 0.13),
    6px 8px 9px rgba(0, 0, 0, 0.13);
}
/* Function colours, as on the panels: green = go, red-orange = stop (MUTE), amber = IN / SOLO. */
.btn.go { --rim: #3fb950; --face: #b8f5b0; }
.btn.stop { --rim: #d0461e; --face: #ffc27e; }
.btn.amber { --rim: #c88a16; --face: #ffe08a; }
.btn.go:not(.primary) { color: #9ee6a0; }
.btn.stop:not(.primary) { color: #ffb08a; }
.btn.amber:not(.primary) { color: #ffd66a; }

.btn.big { width: 100%; font-size: 1.2rem; min-height: 60px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.85rem; }

/* Cream selector keys with an amber LED (clock choice). */
.clock-choice { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.clock-choice label {
  flex: 1;
  min-width: 96px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  color: #2a2622;
  background: linear-gradient(#fffef0, var(--cap));
  border: 3px solid var(--frame);
  box-shadow: 2px 3px 2px rgba(0, 0, 0, 0.13), 4px 6px 6px rgba(0, 0, 0, 0.13), inset -2px -3px 0 rgba(0, 0, 0, 0.12);
}
.clock-choice label::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5a3a12;
  box-shadow: 0 0 0 2px #0c0c0c;
}
.clock-choice label:has(input:checked)::before {
  background: radial-gradient(circle at 35% 35%, #fff6c8, #ffb020 60%);
  box-shadow: 0 0 0 2px #0c0c0c, 0 0 10px 2px rgba(255, 176, 32, 0.8);
}
.clock-choice input { position: absolute; opacity: 0; pointer-events: none; }

.join { display: flex; gap: 10px; }
.join input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 0.15em; font-weight: 700; font-family: "VT323", ui-monospace, monospace; font-size: 1.6rem; color: #ffb020; }

/* ---------- Theme picker ---------- */

.themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.theme {
  font: inherit;
  text-align: left;
  border: 3px solid #0c0c0c;
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 2px 3px 2px rgba(0, 0, 0, 0.13), 4px 6px 6px rgba(0, 0, 0, 0.13);
}
.theme[aria-pressed="true"] { outline: 4px solid var(--lens); outline-offset: 2px; }
.theme .mini { display: grid; grid-template-columns: repeat(4, 1fr); }
.theme .mini span { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; }
.theme .mini img { width: 88%; }
.theme .label { display: block; padding: 8px 10px; font-weight: 800; }
.theme .label small { display: block; font-weight: 400; opacity: 0.75; font-size: 0.8rem; }

.style-head { margin: 18px 0 8px; font-family: var(--display); }
.piecesets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
}
.pieceset {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 3px solid var(--frame);
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  box-shadow: 2px 3px 2px rgba(0, 0, 0, 0.13), 4px 6px 6px rgba(0, 0, 0, 0.13);
}
.pieceset[aria-pressed="true"] { outline: 4px solid var(--lens); outline-offset: 2px; }
.pieceset .mini { display: grid; grid-template-columns: repeat(4, 1fr); }
.pieceset .mini span { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; background: var(--light); }
.pieceset .mini span:nth-child(even) { background: var(--dark); }
.pieceset .mini img { width: 92%; }
.pieceset .label { display: block; padding: 6px 8px; font-weight: 800; font-size: 0.9rem; }
.more-sets { margin-top: 14px; }
.more-sets summary { cursor: pointer; font-weight: 800; margin-bottom: 10px; }

dialog.style-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(560px, calc(100vw - 32px));
  width: 100%;
}
dialog.style-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog.style-dialog .card { margin: 0; color: var(--text); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; }

/* ---------- Game ---------- */

/* Keep the board, reactions and buttons on screen on short laptop/Chromebook displays. */
#game { max-width: max(320px, min(560px, calc(100vh - 380px))); }

/* Taken pieces: loose beside the board on wider screens (top player's captures level with the
   top of the board, yours at the bottom); in a row above / below the board on phones. No box:
   a soft halo in the theme's text colour keeps dark pieces visible on dark pages and light ones on light. */
.board-row {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "top" "board" "bottom";
  gap: 4px;
}
.board-row .board-wrap { grid-area: board; }
.taken.top { grid-area: top; }
.taken.bottom { grid-area: bottom; }
.taken {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 2px;
  min-height: 26px;
  color: var(--text);
  font-weight: 800;
  font-size: 0.95rem;
}
.taken img {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 0 1px color-mix(in srgb, var(--text) 75%, transparent)) drop-shadow(0 0 0.5px var(--text));
}
.taken img + img.same { margin-left: -12px; }
.taken .lead { margin-left: 6px; }
@media (min-width: 640px) {
  #game { max-width: calc(max(320px, min(560px, calc(100vh - 380px))) + 92px); }
  .board-row {
    grid-template-columns: 1fr 80px;
    grid-template-rows: 1fr 1fr;
    grid-template-areas: "board top" "board bottom";
    gap: 0 10px;
  }
  .taken { align-content: flex-start; gap: 0; }
  .taken.top { align-self: start; }
  .taken.bottom { align-self: end; align-content: flex-end; }
  .taken img { width: 34px; height: 34px; }
  .taken img + img.same { margin-left: -14px; }
  .taken .lead { width: 100%; margin: 2px 0 0 4px; }
}

/* Dragging a piece: the one under the finger / pointer floats; the square it left shows a ghost. */
.drag-piece {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.15);
  filter: drop-shadow(4px 6px 6px rgba(0, 0, 0, 0.35));
}
.sq.dragging img { opacity: 0.3; }
.sq.mine { touch-action: none; cursor: grab; }
.sq.hover-target { box-shadow: inset 0 0 0 4px var(--lens); }

.player-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  min-height: 52px;
}
.who { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.who .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { font-size: 1.8rem; line-height: 1; }
.side { width: 22px; height: 22px; }

/* Status LED: round, in a black ring, with a highlight and halo when lit. */
.dot { width: 10px; height: 10px; border-radius: 50%; background: #3a3a3a; box-shadow: 0 0 0 2px #0c0c0c; flex: none; }
.dot.on {
  background: radial-gradient(circle at 35% 35%, #eaffea, #3fdc5a 60%);
  box-shadow: 0 0 0 2px #0c0c0c, 0 0 8px 1px rgba(63, 220, 90, 0.7);
}

/* Clock: a dark recessed display, lit amber while running. */
.clock {
  font-family: "VT323", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.9rem;
  line-height: 1;
  padding: 4px 12px;
  border-radius: 4px;
  background: #2a2622;
  color: #8a7a5a;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5);
  border: 3px solid var(--frame);
}
.clock.running { color: #ffb020; text-shadow: 0 0 6px rgba(255, 176, 32, 0.6); }
.clock.low.running { color: #ff5a3e; text-shadow: 0 0 6px rgba(255, 90, 62, 0.7); }

.bubble {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: var(--cap);
  color: #2a2622;
  border: 3px solid var(--frame);
  border-radius: 14px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 1.1rem;
  animation: pop 0.2s ease-out;
  box-shadow: 4px 6px 10px rgba(0, 0, 0, 0.25);
}
.player-bar:has(.clock) .bubble { right: 120px; }
@keyframes pop { from { transform: translateY(-50%) scale(0.6); opacity: 0; } }

.board-wrap { position: relative; }
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  width: 100%;
  border: 6px solid var(--frame);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 2px 3px 2px rgba(0, 0, 0, 0.13), 3px 4px 4px rgba(0, 0, 0, 0.13), 4px 6px 6px rgba(0, 0, 0, 0.13), 6px 8px 9px rgba(0, 0, 0, 0.13);
  user-select: none;
}

.sq {
  position: relative;
  border: 0;
  padding: 0;
  margin: 0;
  aspect-ratio: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }
.sq img { width: 92%; height: 92%; pointer-events: none; position: relative; z-index: 1; }
.sq.last::before, .sq.selected::before, .sq.check::before {
  content: "";
  position: absolute;
  inset: 0;
}
.sq.last::before { background: var(--last); }
.sq.selected::before { background: var(--select); }
.sq.check::before { background: radial-gradient(circle, rgba(239, 68, 68, 0.8) 30%, transparent 75%); }
.sq.target::after {
  content: "";
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  z-index: 2;
}
.sq.capture::after {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  border: 5px solid rgba(0, 0, 0, 0.25);
  z-index: 2;
}
.coord {
  position: absolute;
  font-size: 0.65rem;
  font-weight: 800;
  opacity: 0.8;
  z-index: 0;
}
.sq.light .coord { color: var(--dark); }
.sq.dark .coord { color: var(--light); }
.coord.rank { top: 2px; left: 3px; }
.coord.file { bottom: 1px; right: 3px; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.5);
  padding: 16px;
}
.overlay-card {
  background: var(--panel);
  color: var(--text);
  border: 4px solid var(--frame);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.overlay-card h2 { margin: 8px 0; }
.overlay-card a { color: var(--muted); }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0 6px; }

.share-code {
  font-family: "VT323", ui-monospace, monospace;
  font-size: 3rem;
  line-height: 1;
  letter-spacing: 0.12em;
  padding: 10px 8px 6px;
  border-radius: 4px;
  background: #2a2622;
  color: #ffb020;
  text-shadow: 0 0 8px rgba(255, 176, 32, 0.5);
  border: 3px solid var(--frame);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.promo-choices { display: flex; gap: 8px; justify-content: center; }
.promo { width: 64px; height: 64px; border-radius: 6px; border: 3px solid var(--frame); background: var(--light); cursor: pointer; padding: 4px; }
.promo img { width: 100%; height: 100%; }

.status {
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: calc(1.1rem * var(--display-size, 1));
  min-height: 1.6em;
  margin: 8px 0;
}
.status.flash { color: #e0603a; }

.draw-offer {
  background: var(--panel);
  border: 3px solid var(--frame);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  text-align: center;
  font-weight: 600;
}
.draw-offer .row { margin: 8px 0 0; }

/* Reactions: raised cream keycaps; the pressed one flashes mint. */
.reactions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.react {
  font: inherit;
  font-weight: 800;
  min-width: 40px;
  min-height: 40px;
  border-radius: 8px;
  border: 2px solid var(--frame);
  padding: 6px 12px;
  background: linear-gradient(#fffef4, var(--cap));
  color: #2a2622;
  cursor: pointer;
  box-shadow: inset -2px -3px 0 rgba(0, 0, 0, 0.14), 2px 3px 2px rgba(0, 0, 0, 0.13), 4px 6px 6px rgba(0, 0, 0, 0.13);
}
.react:active { background: #b8f5c8; transform: translate(1px, 2px); }

.controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.moves { margin-top: 12px; color: var(--muted); }
.moves summary { cursor: pointer; font-weight: 700; }
.moves ol { columns: 3; font-variant-numeric: tabular-nums; font-size: 0.9rem; }

/* Opening name: a dark recessed display box. */
.opening {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 4px;
  background: #2a2622;
  color: #f4ead8;
  border: 3px solid var(--frame);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5);
  font-size: 0.95rem;
}
.opening-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opening .eco { font-family: "VT323", ui-monospace, monospace; font-size: 1.2rem; color: #ffb020; }
.opening-tip { color: #c9bfae; font-size: 0.85rem; }
.opening-tip:empty { display: none; }

/* Tactic call-outs float over the bottom of the board for a few seconds. */
.insight {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 8;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--cap);
  color: #2a2622;
  border: 4px solid var(--frame);
  box-shadow: 0 0 18px color-mix(in srgb, var(--lens) 60%, transparent), 4px 6px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  animation: rise 0.25s ease-out;
}
.insight-emoji { font-size: 2rem; line-height: 1; }
.insight-title { font-family: var(--display); font-size: calc(1.15rem * var(--display-size, 1)); }
.insight-text { margin: 2px 0 0; font-size: 0.95rem; line-height: 1.3; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

/* Computer levels: three big lit keys. */
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 10px; }
.btn.blue { --rim: #3b82f6; --face: #cfe4ff; }
.btn.red { --rim: #b0201a; --face: #ff9a8a; }
.btn.level { flex-direction: column; gap: 2px; min-height: 96px; padding: 10px 6px; font-size: 1rem; }
.btn.level small { font-size: 0.7rem; letter-spacing: 0.02em; text-transform: none; font-weight: 700; opacity: 0.8; }
.level-emoji { font-size: 1.9rem; line-height: 1.1; }
