:root {
  --ink: #f4f8fb;
  --muted: #8fa9bb;
  --deep: #06111f;
  --navy: #091a2c;
  --panel: rgba(13, 35, 53, 0.86);
  --panel-solid: #0e263a;
  --line: rgba(163, 205, 227, 0.14);
  --cyan: #40e3d1;
  --cyan-bright: #7cf7e6;
  --cyan-dark: #0b807e;
  --coral: #ff7a68;
  --coral-bright: #ffab87;
  --coral-dark: #a73f4b;
  --gold: #ffc857;
  --blue: #3498ff;
  --cell: clamp(45px, 6.8vh, 66px);
  --radius: 22px;
  --shadow: 0 30px 70px rgba(0, 0, 0, 0.36);
  font-family: Inter, Avenir Next, Avenir, Montserrat, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: var(--deep); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--deep);
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(124, 247, 230, 0.7);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.13;
  pointer-events: none;
}
.ambient-one { background: var(--cyan); right: -160px; top: 12%; }
.ambient-two { background: #8c55c9; left: -220px; bottom: -150px; }

.app-shell { position: relative; z-index: 1; min-height: 100vh; }

.site-footer {
  width: min(100% - 40px, 1324px);
  margin: 0 auto;
  padding: 28px 4px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid rgba(23, 20, 63, .12);
}

.site-footer img {
  display: block;
  width: 108px;
  height: auto;
}

.site-footer p {
  margin: 0;
  color: #777386;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}

body.is-playing .site-footer { display: none; }

.site-header {
  height: 86px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  grid-template-columns: repeat(3, 8px);
  align-items: end;
  justify-content: center;
  gap: 3px;
  padding-bottom: 8px;
  border-radius: 13px;
  background: linear-gradient(145deg, #173b4b, #0b2334);
  border: 1px solid rgba(124, 247, 230, 0.24);
  box-shadow: inset 0 1px rgba(255,255,255,0.08), 0 8px 20px rgba(0,0,0,0.26);
}
.brand-mark i { display: block; border-radius: 3px 3px 1px 1px; background: var(--cyan); box-shadow: 0 0 12px rgba(64,227,209,.35); }
.brand-mark i:nth-child(1) { height: 12px; }
.brand-mark i:nth-child(2) { height: 23px; }
.brand-mark i:nth-child(3) { height: 17px; }
.brand-copy { display: flex; flex-direction: column; }
.brand-copy strong { font-size: 20px; letter-spacing: .03em; }
.brand-copy strong span { color: var(--cyan); letter-spacing: -.1em; margin: 0 .13em 0 .04em; }
.brand-copy small { margin-top: 1px; color: var(--muted); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }

.header-actions { display: flex; gap: 7px; }
.icon-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  padding: 5px 10px;
  border-radius: 12px;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover { color: var(--ink); border-color: var(--line); background: rgba(255,255,255,.03); }
.icon-button span { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; font-weight: 800; }
.icon-button em { font-size: 12px; font-style: normal; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }

.screen { display: none; }
.screen.is-active { display: block; animation: screen-in .45s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(9px); } }

.home-screen {
  max-width: 1360px;
  margin: 0 auto;
  padding: clamp(45px, 7vh, 85px) 36px 70px;
  display: none;
  grid-template-columns: minmax(400px, .9fr) minmax(490px, 1.1fr);
  gap: 70px;
  align-items: center;
}
.home-screen.is-active { display: grid; }

.eyebrow {
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--cyan-bright);
}
.eyebrow span { width: 18px; height: 2px; background: currentColor; box-shadow: 0 0 10px currentColor; }

.hero-copy h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 42px);
  line-height: .93;
  letter-spacing: -.065em;
  font-weight: 850;
}
.hero-copy h1 em { color: var(--cyan); font-style: normal; text-shadow: 0 0 32px rgba(64,227,209,.18); }
.hero-lead {
  max-width: 550px;
  color: #a9bdca;
  font-size: 17px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hero-lead span {
  font-size: 14px;
  opacity: 0.5;
}

.hero-actions { display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap; }
.primary-button {
  min-width: 260px;
  min-height: 70px;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  text-align: left;
  gap: 2px 22px;
  align-items: center;
  padding: 14px 18px 14px 23px;
  border: 0;
  border-radius: 16px;
  color: #062522;
  background: linear-gradient(140deg, var(--cyan-bright), #35ceb8);
  box-shadow: 0 10px 0 #117c73, 0 20px 38px rgba(24,190,174,.19), inset 0 1px rgba(255,255,255,.7);
  cursor: pointer;
  transform: translateY(-4px);
  transition: transform .18s, box-shadow .18s, filter .18s;
}
.primary-button:hover:not(.is-locked) { transform: translateY(-6px); filter: brightness(1.06); box-shadow: 0 12px 0 #117c73, 0 25px 46px rgba(24,190,174,.23), inset 0 1px rgba(255,255,255,.7); }
.primary-button:active:not(.is-locked) { transform: translateY(3px); box-shadow: 0 3px 0 #117c73, 0 10px 22px rgba(24,190,174,.15); }
.primary-button .button-kicker { grid-column: 1; color: #13736a; font-size: 9px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.primary-button strong { grid-column: 1; font-size: 16px; }
.primary-button b { grid-column: 2; grid-row: 1 / span 2; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #eafffb; background: rgba(3,78,71,.23); font-size: 19px; }

.secondary-button {
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid rgba(124,247,230,.2);
  border-radius: 16px;
  padding: 0 20px;
  background: rgba(19,48,64,.7);
  color: var(--ink);
  cursor: pointer;
}
.secondary-button:hover:not(.is-locked) { border-color: var(--cyan); background: rgba(37,85,95,.72); }
.secondary-button span { color: var(--cyan); }
.secondary-button.is-locked { cursor: not-allowed; color: #6f8390; border-color: var(--line); }
.secondary-button.is-locked span { color: #60737f; }
.lock-note { margin: 14px 0 0; color: #617987; font-size: 11px; }

.hero-meta { display: flex; gap: 24px; margin-top: 35px; }
.hero-meta div { display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 8px; padding-right: 24px; border-right: 1px solid var(--line); }
.hero-meta div:last-child { border: 0; }
.hero-meta strong { grid-row: 1 / 3; font-size: 23px; color: #dffbf7; }
.hero-meta span { max-width: 62px; color: #708896; font-size: 9px; line-height: 1.25; letter-spacing: .09em; text-transform: uppercase; }

.hero-stage {
  min-height: 600px;
  position: relative;
  display: grid;
  place-items: center;
  perspective: 1000px;
}
.stage-glow { position: absolute; width: 74%; height: 62%; border-radius: 50%; background: rgba(50,195,182,.15); filter: blur(45px); transform: translateY(40px); }
.preview-board-wrap { position: relative; transform: rotateX(54deg) rotateZ(-7deg); transform-style: preserve-3d; }
.preview-board {
  display: grid;
  grid-template-columns: repeat(5, 58px);
  grid-template-rows: repeat(var(--preview-rows, 5), 58px);
  gap: 4px;
  padding: 20px;
  border: 9px solid #14374b;
  border-radius: 26px;
  background: #0b2435;
  box-shadow: 0 28px 0 #061725, 0 46px 85px rgba(0,0,0,.55), inset 0 0 0 2px rgba(124,247,230,.08);
  transform-style: preserve-3d;
}
.preview-cell { position: relative; border-radius: 9px; background: linear-gradient(145deg, #183e51, #102f42); box-shadow: inset 0 1px rgba(255,255,255,.045), 0 3px 0 #081d2b; }
.preview-cell:nth-child(odd) { background: linear-gradient(145deg, #1a4355, #123245); }
.preview-piece {
  position: absolute;
  inset: 7px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
  font-size: 18px;
  transform: translateZ(24px);
  box-shadow: 0 8px 0 var(--piece-edge), 0 13px 18px rgba(0,0,0,.3), inset 0 2px rgba(255,255,255,.42);
  background: linear-gradient(145deg, var(--piece-hi), var(--piece));
  color: var(--piece-ink);
}
.preview-piece.you { --piece-hi: var(--cyan-bright); --piece: var(--cyan); --piece-edge: #168b84; --piece-ink: #073f3b; }
.preview-piece.ai { --piece-hi: var(--coral-bright); --piece: var(--coral); --piece-edge: #a53c4a; --piece-ink: #551e27; }
.preview-score { position: absolute; z-index: 3; width: 88px; height: 88px; display: grid; place-items: center; align-content: center; border-radius: 20px; background: rgba(13,35,53,.9); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.preview-score span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.preview-score strong { margin-top: 3px; font-size: 30px; }
.preview-score-ai { top: 12%; right: 4%; transform: rotate(4deg); }
.preview-score-ai strong { color: var(--coral); }
.preview-score-you { bottom: 13%; left: 1%; transform: rotate(-5deg); }
.preview-score-you strong { color: var(--cyan); }
.target-orbit { position: absolute; right: 4%; bottom: 15%; width: 106px; height: 106px; display: grid; place-items: center; align-content: center; border-radius: 50%; border: 1px dashed rgba(255,200,87,.35); color: var(--gold); animation: drift 4s ease-in-out infinite; }
.target-orbit::before { content: ''; position: absolute; inset: 8px; border: 1px solid rgba(255,200,87,.18); border-radius: 50%; }
.target-orbit span { font-size: 9px; letter-spacing: .17em; }
.target-orbit strong { font-size: 36px; }
@keyframes drift { 50% { transform: translateY(-7px) rotate(2deg); } }

.journey-strip { grid-column: 1 / -1; margin-top: 55px; padding-top: 42px; border-top: 1px solid var(--line); }
.journey-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 24px; }
.journey-heading .eyebrow { margin-bottom: 7px; }
.journey-heading h2 { margin: 0; font-size: 30px; letter-spacing: -.035em; }
.journey-heading > p { max-width: 440px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.chapter-list { display: grid; grid-template-columns: repeat(6, 1fr); gap: 11px; }
.chapter-card {
  position: relative;
  min-height: 126px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(20,50,70,.76), rgba(9,28,43,.76));
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  transition: transform .2s, border-color .2s, background .2s;
}
.chapter-card:hover:not(:disabled) { transform: translateY(-4px); border-color: rgba(64,227,209,.36); background: linear-gradient(145deg, rgba(25,66,80,.86), rgba(10,33,48,.82)); }
.chapter-card:disabled { cursor: not-allowed; opacity: .43; }
.chapter-card .chapter-number { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: rgba(255,255,255,.055); color: var(--muted); font-size: 10px; font-weight: 900; }
.chapter-card strong { display: block; margin: 14px 0 4px; font-size: 14px; }
.chapter-card small { color: var(--muted); font-size: 10px; }
.chapter-card .chapter-state { position: absolute; right: 14px; top: 14px; color: #607986; font-size: 13px; }
.chapter-card.is-complete { border-color: rgba(64,227,209,.25); }
.chapter-card.is-complete .chapter-number { color: #073f3b; background: var(--cyan); }
.chapter-card.is-complete .chapter-state { color: var(--cyan); }
.chapter-card.is-current::after { content: ''; position: absolute; left: 0; bottom: 0; width: 58%; height: 3px; background: var(--cyan); box-shadow: 0 0 14px var(--cyan); }

/* Game table */
.game-screen { max-width: 1480px; margin: 0 auto; padding: 16px 30px 34px; }
.game-toolbar { min-height: 65px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 15px; }
.back-button { justify-self: start; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.back-button:hover { color: var(--ink); }
.back-button span { margin-right: 7px; color: var(--cyan); font-size: 17px; }
.mode-heading { text-align: center; }
.mode-heading span { display: block; color: var(--cyan); font-size: 9px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.mode-heading h1 { margin: 3px 0 0; font-size: 23px; letter-spacing: -.025em; }
.turn-pill { justify-self: end; display: flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid rgba(64,227,209,.25); border-radius: 999px; background: rgba(11,42,54,.8); color: var(--cyan-bright); font-size: 10px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.turn-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.turn-pill.is-ai { border-color: rgba(255,122,104,.25); color: var(--coral-bright); }
.turn-pill.is-thinking i { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

.game-layout { display: grid; grid-template-columns: minmax(205px, 250px) auto minmax(205px, 250px); justify-content: center; align-items: center; gap: clamp(18px, 3vw, 48px); margin-top: 10px; }
.game-panel { align-self: center; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(150deg, rgba(18,48,66,.81), rgba(8,26,41,.82)); box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.panel-label { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: #6f8998; font-size: 9px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.panel-label span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: #063a36; background: var(--cyan); font-size: 9px; }
.objective-panel h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.objective-panel > p { min-height: 54px; margin: 9px 0 17px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.objective-progress { display: flex; align-items: center; gap: 9px; padding: 10px; border-radius: 11px; background: rgba(0,0,0,.18); color: #a7bdc9; font-size: 10px; font-weight: 700; }
.objective-progress i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px rgba(255,200,87,.38); }
.objective-progress.is-complete i { background: var(--cyan); }
.rule-card { display: flex; gap: 11px; align-items: center; margin-top: 16px; padding: 13px; border: 1px solid rgba(64,227,209,.11); border-radius: 13px; background: rgba(40,105,106,.1); }
.rule-icon { flex: 0 0 auto; width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; background: rgba(64,227,209,.12); color: var(--cyan); font-size: 19px; }
.rule-card strong, .rule-card small { display: block; }
.rule-card strong { font-size: 11px; }
.rule-card small { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.move-readout { min-height: 70px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.readout-empty { color: #607986; font-size: 10px; line-height: 1.5; }
.readout-piece { display: grid; grid-template-columns: auto 1fr; gap: 4px 9px; align-items: center; }
.readout-piece b { grid-row: 1 / 3; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: #073f3b; background: var(--cyan); box-shadow: 0 5px 0 #168b84; font-size: 16px; }
.readout-piece strong { font-size: 11px; }
.readout-piece small { color: var(--muted); font-size: 9px; }
.readout-capture { color: var(--gold); font-size: 11px; line-height: 1.5; }
.readout-capture strong { display: block; color: var(--ink); font-size: 16px; }

.board-column { width: calc(var(--cell) * 5 + 48px); display: flex; flex-direction: column; align-items: stretch; }
.player-bar { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 8px 13px; }
.opponent-bar { margin-bottom: 4px; }
.you-bar { margin-top: 17px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; font-weight: 900; box-shadow: inset 0 1px rgba(255,255,255,.25), 0 5px 10px rgba(0,0,0,.2); }
.avatar-ai { color: #571e27; background: linear-gradient(145deg, var(--coral-bright), var(--coral)); }
.avatar-you { color: #073f3b; background: linear-gradient(145deg, var(--cyan-bright), var(--cyan)); }
.player-name span, .player-name small { display: block; }
.player-name span { font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.player-name small { margin-top: 2px; color: #68818f; font-size: 9px; }
.score-block { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 5px; text-align: right; }
.score-block > span { grid-column: 1 / -1; color: #607987; font-size: 8px; letter-spacing: .12em; text-transform: uppercase; }
.score-block strong { font-size: 23px; line-height: 1; }
.opponent-bar .score-block strong { color: var(--coral); }
.you-bar .score-block strong { color: var(--cyan); }
.score-block small { color: #5e7480; font-size: 9px; }

.board-perspective { perspective: 1000px; padding: 4px 0 14px; }
.board-frame {
  position: relative;
  width: calc(var(--cell) * 5 + 48px);
  height: calc(var(--cell) * 8 + 48px);
  padding: 24px;
  border-radius: 23px;
  background: linear-gradient(145deg, #17394d, #092337);
  transform: rotateX(8deg);
  transform-origin: center bottom;
  transform-style: preserve-3d;
  box-shadow: 0 15px 0 #061522, 0 23px 0 #030b12, 0 35px 65px rgba(0,0,0,.46), inset 0 1px rgba(255,255,255,.08), inset 0 0 0 2px rgba(124,247,230,.06);
  transition: transform .35s, height .35s;
}
.board-rim { position: absolute; inset: 10px; border: 1px solid rgba(124,247,230,.1); border-radius: 17px; pointer-events: none; }
.board-grid { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(5, var(--cell)); grid-template-rows: repeat(8, var(--cell)); gap: 0; border: 1px solid rgba(159,208,224,.13); border-radius: 8px; overflow: visible; background: #102d3e; box-shadow: inset 0 0 24px rgba(0,0,0,.3); }
.cell {
  position: relative;
  border: 0;
  border-right: 1px solid rgba(151,201,218,.085);
  border-bottom: 1px solid rgba(151,201,218,.085);
  background: linear-gradient(145deg, rgba(30,71,89,.67), rgba(15,48,65,.72));
  padding: 0;
  cursor: default;
  color: inherit;
}
.cell:nth-child(10n+6), .cell:nth-child(10n+8), .cell:nth-child(10n+10), .cell:nth-child(10n+1), .cell:nth-child(10n+3), .cell:nth-child(10n+5) { background: linear-gradient(145deg, rgba(34,77,94,.72), rgba(18,53,70,.76)); }
.cell:enabled { cursor: pointer; }
.cell .coord { position: absolute; left: 4px; bottom: 2px; color: rgba(154,198,214,.25); font-size: 7px; font-weight: 800; pointer-events: none; }
.cell.is-selected::before { content: ''; position: absolute; inset: 3px; z-index: 0; border: 2px solid var(--cyan-bright); border-radius: 10px; box-shadow: inset 0 0 14px rgba(64,227,209,.25), 0 0 13px rgba(64,227,209,.3); }
.cell.is-legal::after { content: ''; position: absolute; z-index: 5; left: 50%; top: 50%; width: 13px; height: 13px; transform: translate(-50%,-50%); border-radius: 50%; background: rgba(64,227,209,.34); border: 2px solid var(--cyan-bright); box-shadow: 0 0 0 5px rgba(64,227,209,.08), 0 0 13px rgba(64,227,209,.45); pointer-events: none; }
.cell.is-capture::after { width: 72%; height: 72%; background: rgba(255,122,104,.08); border: 2px dashed var(--coral-bright); box-shadow: 0 0 16px rgba(255,122,104,.35); animation: capture-ring 1.4s ease-in-out infinite; }
.cell.is-return::after { border-color: var(--gold); background: rgba(255,200,87,.25); box-shadow: 0 0 15px rgba(255,200,87,.38); }
@keyframes capture-ring { 50% { width: 79%; height: 79%; opacity: .62; } }
.cell.has-capture:not(.is-selected) .piece { box-shadow: 0 7px 0 var(--piece-edge), 0 11px 15px rgba(0,0,0,.29), 0 0 0 3px rgba(255,200,87,.5), 0 0 15px rgba(255,200,87,.35), inset 0 2px rgba(255,255,255,.45); }

.piece {
  --piece: #aaa;
  --piece-hi: #ddd;
  --piece-edge: #555;
  --piece-ink: #111;
  position: absolute;
  z-index: 4;
  left: 16%;
  top: 13%;
  width: 68%;
  height: 68%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--piece-hi), var(--piece) 70%);
  box-shadow: 0 7px 0 var(--piece-edge), 0 11px 15px rgba(0,0,0,.29), inset 0 2px rgba(255,255,255,.45);
  color: var(--piece-ink);
  font-weight: 950;
  font-size: clamp(15px, 2.4vh, 22px);
  text-shadow: 0 1px rgba(255,255,255,.25);
  transform: translateZ(14px);
  transition: transform .17s, filter .17s;
  pointer-events: none;
}
.cell:hover .piece[data-owner="human"] { transform: translateY(-3px) translateZ(14px); filter: brightness(1.05); }
.piece[data-owner="human"] { --piece: var(--cyan); --piece-hi: var(--cyan-bright); --piece-edge: #147c77; --piece-ink: #06423d; }
.piece[data-owner="ai"] { --piece: var(--coral); --piece-hi: var(--coral-bright); --piece-edge: #9e3d48; --piece-ink: #5b2029; }
.piece::before { content: ''; position: absolute; inset: 8%; border: 1px solid rgba(255,255,255,.27); border-radius: 50%; }
.piece::after { content: attr(data-owner-label); position: absolute; bottom: -5px; padding: 1px 4px; border-radius: 4px; background: var(--piece-edge); color: rgba(255,255,255,.82); font-size: 5px; letter-spacing: .08em; }
.piece-one { border-radius: 14px; transform: rotate(45deg) scale(.82) translateZ(14px); }
.piece-one .piece-value { transform: rotate(-45deg) scale(1.2); }
.cell:hover .piece-one[data-owner="human"] { transform: rotate(45deg) scale(.82) translate(0,-3px) translateZ(14px); }
.capture-flash { position: absolute; z-index: 10; left: 50%; top: 50%; width: 10px; height: 10px; border-radius: 50%; background: white; box-shadow: 0 0 0 9px var(--gold), 0 0 0 18px rgba(255,200,87,.2); animation: flash-out .6s ease-out both; pointer-events: none; }
@keyframes flash-out { from { transform: translate(-50%,-50%) scale(.2); opacity: 1; } to { transform: translate(-50%,-50%) scale(2.5); opacity: 0; } }
.board-shine { position: absolute; z-index: 8; inset: 24px; background: linear-gradient(125deg, rgba(255,255,255,.025), transparent 35%, transparent); pointer-events: none; }

.capture-code { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(151,201,218,.08); }
.capture-code b { flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.05); color: var(--gold); font-size: 13px; }
.capture-code strong, .capture-code small { display: block; }
.capture-code strong { font-size: 10px; }
.capture-code small { margin-top: 2px; color: #6b8492; font-size: 8px; }
.turn-log-wrap { margin-top: 17px; }
.turn-log-wrap .panel-label { margin-bottom: 4px; }
.turn-log { height: 69px; margin: 0; padding: 0; list-style: none; overflow: hidden; }
.turn-log li { padding: 4px 0; color: #708896; font-size: 8.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-log li:first-child { color: #bfd0d8; }
.table-actions { display: grid; gap: 7px; margin-top: 12px; }
.table-actions button { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: rgba(255,255,255,.025); color: #829ba8; font-size: 9px; font-weight: 700; text-align: left; cursor: pointer; }
.table-actions button:hover { color: var(--ink); border-color: rgba(64,227,209,.25); }
.table-actions button span { margin-right: 6px; color: var(--cyan); }
.observer-tools { margin-top: 17px; padding-top: 15px; border-top: 1px solid var(--line); }
.observer-tools .panel-label { margin-bottom: 8px; }
.telemetry-status { display: flex; align-items: center; gap: 7px; min-width: 0; color: #78909c; font-size: 8px; font-weight: 800; letter-spacing: .04em; }
.telemetry-status i { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.telemetry-status[data-status="connected"] { color: var(--cyan); }
.telemetry-status[data-status="checking"], .telemetry-status[data-status="consent_required"] { color: var(--gold); }
.telemetry-status[data-status="offline"] { color: var(--coral); }
.observer-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 9px; }
.observer-actions button, .research-session-row button { border: 1px solid var(--line); border-radius: 9px; padding: 7px 8px; background: rgba(255,255,255,.025); color: #8ca4b1; font-size: 8px; font-weight: 800; cursor: pointer; }
.observer-actions button:last-child { grid-column: 1 / -1; }
.observer-actions button:hover, .research-session-row button:hover { color: var(--ink); border-color: rgba(64,227,209,.28); }
.observer-actions button:disabled { cursor: not-allowed; opacity: .38; }
.observer-tools > small { display: block; margin-top: 8px; color: #607986; font-size: 7.5px; line-height: 1.4; }

.board-legend { display: flex; align-items: center; justify-content: center; gap: 17px; margin-top: 21px; color: #627a88; font-size: 9px; }
.board-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); }
.capture-dot { background: var(--coral); }
.return-dot { background: var(--gold); }
.portal-dot { background: linear-gradient(135deg, #45d4d1 0 48%, #6f32f5 52% 100%); box-shadow: 0 0 0 2px rgba(111,50,245,.12); }
.keyboard-note { padding-left: 17px; border-left: 1px solid var(--line); }

/* Modals */
.modal-backdrop { position: fixed; z-index: 50; inset: 0; background: rgba(2,8,14,.76); backdrop-filter: blur(7px); animation: fade-in .2s both; }
@keyframes fade-in { from { opacity: 0; } }
.modal {
  position: fixed;
  z-index: 51;
  left: 50%;
  top: 50%;
  width: min(570px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  transform: translate(-50%,-50%);
  border: 1px solid rgba(155,208,224,.16);
  border-radius: 24px;
  background: linear-gradient(155deg, #14364b, #071b2c 76%);
  box-shadow: 0 35px 90px rgba(0,0,0,.65), inset 0 1px rgba(255,255,255,.07);
  animation: modal-in .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes modal-in { from { opacity: 0; transform: translate(-50%,calc(-50% + 15px)) scale(.98); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 21px 23px; border-bottom: 1px solid var(--line); }
.modal-header span { color: var(--cyan); font-size: 9px; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.modal-header h2 { margin: 3px 0 0; font-size: 24px; }
.modal-close { width: 37px; height: 37px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.03); color: #8ca2ae; font-size: 23px; cursor: pointer; }
.modal-close:hover { color: white; background: rgba(255,255,255,.07); }
.settings-body, .rules-body { padding: 23px; }
.settings-body fieldset { border: 0; padding: 0; margin: 0 0 21px; }
.settings-body legend { margin-bottom: 10px; color: #8ca4b1; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.difficulty-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.difficulty-picker label { cursor: pointer; }
.difficulty-picker input { position: absolute; opacity: 0; }
.difficulty-picker span { min-height: 82px; display: flex; flex-direction: column; justify-content: center; padding: 12px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.025); transition: border-color .18s, background .18s, box-shadow .18s, transform .18s; }
.difficulty-picker b, .difficulty-picker small { display: block; }
.difficulty-picker b { font-size: 11px; }
.difficulty-picker small { margin-top: 4px; color: #6e8795; font-size: 8px; line-height: 1.35; }
.difficulty-picker label:hover span { transform: translateY(-1px); }
.difficulty-picker input:checked + span { border-color: var(--cyan); background: rgba(64,227,209,.1); box-shadow: 0 0 0 2px rgba(64,227,209,.1); }
.difficulty-picker input:focus-visible + span { outline: 3px solid rgba(64,227,209,.28); outline-offset: 2px; }
.setting-row { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid rgba(151,201,218,.08); }
.setting-row strong, .setting-row small { display: block; }
.setting-row strong { font-size: 11px; }
.setting-row small { margin-top: 3px; color: #6e8795; font-size: 8px; }
.switch { position: relative; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 40px; height: 23px; display: block; border-radius: 999px; background: #183444; box-shadow: inset 0 2px 5px rgba(0,0,0,.25); cursor: pointer; transition: background .2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: #78909c; box-shadow: 0 2px 5px rgba(0,0,0,.35); transition: transform .2s, background .2s; }
.switch input:checked + span { background: rgba(64,227,209,.25); }
.switch input:checked + span::after { transform: translateX(17px); background: var(--cyan); }
.setting-row select { border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; background: #0d283b; color: #bdd0d8; font-size: 9px; }
.settings-body fieldset.research-settings { margin: 20px 0 0; padding-top: 20px; border-top: 1px solid rgba(151,201,218,.12); }
.research-settings > p { margin: -2px 0 12px; color: #718996; font-size: 8px; line-height: 1.5; }
.research-settings .setting-row { min-height: 64px; }
.research-code-row input { width: 142px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; background: #0d283b; color: #bdd0d8; font-size: 9px; text-transform: uppercase; }
.research-code-row input::placeholder { color: #4e6876; }
.research-session-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 13px; border-top: 1px solid rgba(151,201,218,.08); }
.research-session-row button { flex: 0 0 auto; color: var(--cyan); }
.text-danger { margin-top: 17px; padding: 0; border: 0; background: none; color: #a96870; font-size: 9px; text-decoration: underline; cursor: pointer; }
.text-danger:hover { color: var(--coral-bright); }

.rules-modal { width: min(720px, calc(100vw - 32px)); }
.rule-intro { display: flex; align-items: baseline; gap: 12px; padding: 17px; border-radius: 14px; background: linear-gradient(100deg, rgba(64,227,209,.12), rgba(64,227,209,.025)); }
.rule-intro strong { white-space: nowrap; color: var(--cyan-bright); }
.rule-intro p { margin: 0; color: #9db1bd; font-size: 11px; line-height: 1.5; }
.rules-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 15px; }
.rules-grid article { position: relative; min-height: 125px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02); }
.rules-grid article > span { position: absolute; right: 13px; top: 11px; color: rgba(124,247,230,.23); font-size: 20px; font-weight: 900; }
.rules-grid h3 { margin: 0 0 8px; font-size: 13px; }
.rules-grid p { margin: 0; color: #8198a5; font-size: 9.5px; line-height: 1.55; }
.capture-equations { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 15px; }
.capture-equations span { padding: 10px; border-radius: 11px; background: rgba(255,200,87,.07); text-align: center; }
.capture-equations b, .capture-equations small { display: block; }
.capture-equations b { color: var(--gold); font-size: 12px; }
.capture-equations small { margin-top: 3px; color: #748c99; font-size: 8px; }
.digital-ruling { margin: 15px 0 0; color: #617986; font-size: 8px; line-height: 1.5; }

.result-modal { width: min(430px, calc(100vw - 32px)); padding: 38px 34px 30px; text-align: center; overflow: hidden; }
.result-kicker { color: var(--cyan); font-size: 9px; font-weight: 900; letter-spacing: .17em; text-transform: uppercase; }
.result-medallion { position: relative; z-index: 2; width: 90px; height: 90px; display: grid; place-items: center; margin: 20px auto; border-radius: 50%; color: #063e39; background: linear-gradient(145deg, var(--cyan-bright), var(--cyan)); box-shadow: 0 9px 0 #147c77, 0 18px 35px rgba(64,227,209,.2), inset 0 2px rgba(255,255,255,.6); font-size: 38px; font-weight: 950; }
.result-modal h2 { position: relative; z-index: 2; margin: 25px 0 9px; font-size: 29px; letter-spacing: -.04em; }
.result-modal > p { position: relative; z-index: 2; max-width: 310px; margin: 0 auto 24px; color: #8ba2ae; font-size: 11px; line-height: 1.55; }
.result-scores { position: relative; z-index: 2; display: flex; justify-content: center; align-items: center; gap: 18px; margin: 0 auto 24px; }
.result-scores span { color: #829aa7; font-size: 9px; text-transform: uppercase; letter-spacing: .09em; }
.result-scores strong { display: block; margin-top: 2px; color: var(--ink); font-size: 24px; }
.result-scores i { width: 1px; height: 32px; background: var(--line); }
.primary-button.compact { position: relative; z-index: 2; min-width: 220px; min-height: 53px; display: inline-grid; grid-template-columns: 1fr auto; grid-template-rows: 1fr; text-align: center; }
.primary-button.compact strong { grid-column: 1; }
.primary-button.compact b { grid-column: 2; grid-row: 1; width: 29px; height: 29px; }
.result-primary-actions { position: relative; z-index: 2; display: grid; justify-items: center; gap: 10px; }
.result-daily-secondary {
  position: relative;
  z-index: 2;
  min-width: 220px;
  min-height: 53px;
  display: inline-grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 11px 11px 11px 20px;
  border: 0;
  border-radius: 16px;
  background: var(--theme-secondary-soft, #eee4ff);
  color: var(--theme-secondary, var(--brand-purple));
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}
.result-daily-secondary strong { grid-column: 1; text-align: center; }
.result-daily-secondary b {
  grid-column: 2;
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--theme-secondary, var(--brand-purple));
}
.result-daily-secondary .ui-icon { width: 16px; height: 16px; filter: brightness(0) invert(1); }
.result-daily-secondary:hover { color: white; background: var(--theme-secondary, var(--brand-purple)); }
.result-daily-secondary:hover b { background: rgba(255,255,255,.18); }
.result-secondary { position: relative; z-index: 2; display: block; margin: 14px auto 0; border: 0; background: none; color: #6f8794; font-size: 9px; text-decoration: underline; cursor: pointer; }
.resign-confirm-actions {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.resign-confirm-actions button {
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 16px;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: color .18s ease, background-color .18s ease, transform .18s ease;
}
.resign-confirm-no {
  color: var(--theme-ink, var(--ink));
  background: var(--theme-secondary-soft, #eee4ff);
}
.resign-confirm-yes {
  color: var(--theme-secondary-ink, #fff);
  background: var(--theme-secondary, var(--purple));
}
.resign-confirm-actions button:hover { transform: translateY(-2px); }
.resign-confirm-no:hover { background: color-mix(in srgb, var(--theme-secondary, var(--purple)) 18%, white); }
.resign-confirm-yes:hover { background: color-mix(in srgb, var(--theme-secondary, var(--purple)) 84%, black); }
.resign-confirm-actions button:disabled { opacity: .56; cursor: wait; transform: none; }
.resign-confirm-medallion {
  color: var(--theme-secondary-ink, #fff);
  background: var(--theme-secondary, var(--purple));
  box-shadow: none;
}
.result-burst i { position: absolute; left: 50%; top: 105px; width: 3px; height: 160px; background: linear-gradient(var(--cyan), transparent); transform-origin: bottom; opacity: .12; }
.result-burst i:nth-child(1) { transform: translate(-50%,-100%) rotate(0deg); }
.result-burst i:nth-child(2) { transform: translate(-50%,-100%) rotate(60deg); }
.result-burst i:nth-child(3) { transform: translate(-50%,-100%) rotate(120deg); }
.result-burst i:nth-child(4) { transform: translate(-50%,-100%) rotate(180deg); }
.result-burst i:nth-child(5) { transform: translate(-50%,-100%) rotate(240deg); }
.result-burst i:nth-child(6) { transform: translate(-50%,-100%) rotate(300deg); }

.toast { position: fixed; z-index: 70; left: 50%; bottom: 25px; max-width: calc(100vw - 30px); padding: 11px 15px; border: 1px solid var(--line); border-radius: 11px; background: rgba(12,33,48,.96); color: #d6e5eb; box-shadow: 0 12px 30px rgba(0,0,0,.35); font-size: 10px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.is-visible { transform: translate(-50%,0); opacity: 1; }
.confetti { position: fixed; z-index: 65; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px; background: var(--confetti); animation: confetti-fall var(--fall-time) linear both; }
@keyframes confetti-fall { to { transform: translate(var(--drift), 110vh) rotate(760deg); } }

[hidden] { display: none !important; }

body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }

@media (max-width: 1120px) {
  :root { --cell: clamp(43px, 6.4vh, 59px); }
  .home-screen { grid-template-columns: minmax(350px, .9fr) minmax(430px, 1.1fr); gap: 35px; }
  .game-layout { grid-template-columns: 200px auto 200px; gap: 15px; }
  .game-panel { padding: 15px; }
  .objective-panel h2 { font-size: 20px; }
}

@media (max-width: 900px) {
  .site-header { padding-inline: 20px; }
  .home-screen, .home-screen.is-active { grid-template-columns: 1fr; padding: 45px 24px 60px; }
  .hero-copy { text-align: center; }
  .hero-copy .eyebrow { justify-content: center; }
  .hero-actions, .hero-meta { justify-content: center; }
  .lock-note { text-align: center; }
  .hero-stage { min-height: 565px; }
  .journey-strip { margin-top: 10px; }
  .chapter-list { grid-template-columns: repeat(3, 1fr); }
  .game-layout { grid-template-columns: auto minmax(200px, 250px); }
  .objective-panel { grid-column: 2; grid-row: 1; }
  .board-column { grid-column: 1; grid-row: 1 / span 2; }
  .tactics-panel { grid-column: 2; grid-row: 2; }
}

@media (max-width: 680px) {
  :root { --cell: min(15.6vw, 57px); }
  .site-header { height: 72px; padding: 12px 14px; }
  .brand-copy small, .icon-button em { display: none; }
  .home-screen, .home-screen.is-active { padding: 37px 17px 50px; }
  .hero-copy h1 { font-size: clamp(24px, 3vw, 42px); }
  .hero-actions { display: grid; }
  .primary-button, .secondary-button { width: 100%; }
  .hero-meta { gap: 10px; }
  .hero-meta div { padding-right: 10px; }
  .hero-stage { min-height: 440px; transform: scale(.78); margin: -50px -60px; }
  .journey-heading { display: block; text-align: center; }
  .journey-heading .eyebrow { justify-content: center; }
  .journey-heading > p { margin: 12px auto 0; }
  .chapter-list { grid-template-columns: 1fr; }
  .chapter-card { min-height: 92px; }
  .chapter-card strong { margin-top: 8px; }
  .game-screen { padding: 9px 8px 25px; }
  .game-toolbar { grid-template-columns: auto 1fr auto; }
  .back-button { font-size: 0; }
  .back-button span { font-size: 19px; }
  .mode-heading h1 { font-size: 18px; }
  .turn-pill { padding: 8px 10px; }
  .turn-pill span { display: inline; }
  .game-layout { display: flex; flex-direction: column; gap: 17px; }
  .board-column { order: 1; }
  .objective-panel { order: 2; width: min(100%, 520px); }
  .tactics-panel { order: 3; width: min(100%, 520px); }
  .objective-panel > p { min-height: 0; }
  .board-legend { flex-wrap: wrap; gap: 10px 15px; }
  .keyboard-note { flex-basis: 100%; justify-content: center; padding: 8px 0 0; border: 0; border-top: 1px solid var(--line); }
  .rules-grid { grid-template-columns: 1fr; }
  .capture-equations { grid-template-columns: repeat(2, 1fr); }
  .rule-intro { display: block; }
  .rule-intro p { margin-top: 5px; }
}

@media (max-height: 780px) and (min-width: 901px) {
  :root { --cell: 53px; }
  .game-screen { padding-top: 4px; }
  .game-toolbar { min-height: 54px; }
  .board-legend { margin-top: 10px; }
  .site-header { height: 72px; padding-top: 10px; padding-bottom: 10px; }
}

/* --------------------------------------------------------------------------
   Sunlit playroom theme
   Inspired by the supplied brand reference: airy cards, violet blocks,
   aqua curves, yellow highlights, and tactile objects with real depth.
   -------------------------------------------------------------------------- */

:root {
  --ink: #171745;
  --muted: #686884;
  --deep: #f7f4ec;
  --navy: #171745;
  --panel: rgba(255, 255, 255, .92);
  --panel-solid: #ffffff;
  --line: rgba(37, 34, 91, .12);
  --purple: #6f32f5;
  --purple-deep: #3d1b85;
  --purple-soft: #e7ddff;
  --cyan: #45d4d1;
  --cyan-bright: #bff3f1;
  --cyan-dark: #138e91;
  --coral: #ff716a;
  --coral-bright: #ffb0a7;
  --coral-dark: #b73f48;
  --gold: #ffca28;
  --gold-deep: #d59300;
  --blue: #5b63ec;
  --cell: clamp(45px, 6.7vh, 64px);
  --radius: 28px;
  --shadow: 0 24px 64px rgba(43, 34, 91, .16);
  color-scheme: light;
  font-family: "Segoe UI", Avenir, Montserrat, sans-serif;
}

html {
  background: var(--deep);
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 94% 7%, rgba(255,255,255,.98) 0 18%, transparent 35%),
    linear-gradient(180deg, #faf8f2 0%, #f7f4ec 66%, #f1eee7 100%);
}

body::before,
body::after {
  content: '';
  position: fixed;
  z-index: 0;
  pointer-events: none;
}

body::before {
  width: 70vw;
  height: 270px;
  left: -13vw;
  top: 90px;
  border-radius: 45% 58% 42% 52%;
  background: rgba(186, 239, 239, .82);
  transform: rotate(-12deg);
}

body::after {
  width: 43vw;
  height: 120px;
  right: -8vw;
  bottom: 5vh;
  border-radius: 50%;
  border: 3px solid rgba(111, 50, 245, .12);
  transform: rotate(9deg);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(111, 50, 245, .38);
  outline-offset: 4px;
}

.ambient {
  z-index: 0;
  filter: none;
  opacity: 1;
}

.ambient-one {
  width: 300px;
  height: 300px;
  right: -110px;
  top: 18%;
  background: rgba(190, 241, 239, .64);
  border-radius: 37% 63% 51% 49%;
  transform: rotate(20deg);
}

.ambient-two {
  width: 420px;
  height: 160px;
  left: 12%;
  bottom: -90px;
  background: rgba(155, 130, 235, .22);
  border-radius: 50%;
  transform: rotate(8deg);
}

.app-shell { isolation: isolate; }

.site-header {
  height: 94px;
  max-width: 1460px;
  padding: 18px 42px;
  border: 0;
}

.brand { gap: 0; color: var(--ink); }

.brand-mark {
  width: 48px;
  height: 48px;
  grid-template-columns: repeat(3, 7px);
  gap: 4px;
  padding-bottom: 9px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(145deg, #7c3cff, #5d27e4);
  box-shadow: 0 8px 0 #3f1a9a, 0 15px 28px rgba(81, 38, 190, .2), inset 0 1px rgba(255,255,255,.35);
}

.brand-mark i {
  background: #ffcf35;
  box-shadow: none;
}

.brand-mark i:nth-child(1) { height: 14px; }
.brand-mark i:nth-child(2) { height: 26px; background: white; }
.brand-mark i:nth-child(3) { height: 20px; background: #aeeeed; }

.brand-copy strong {
  color: var(--ink);
  font-family: "Arial Narrow", "Bahnschrift Condensed", "Segoe UI", sans-serif;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: .08em;
}

.brand-copy strong span { margin: 0; color: var(--purple); letter-spacing: .08em; }
.brand-copy small { color: #77758b; font-size: 9px; letter-spacing: .2em; }
.brand-logo {
  display: block;
  width: 145px;
  height: auto;
}

.header-actions {
  gap: 10px;
  padding: 5px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 999px;
  background: rgba(255,255,255,.68);
  box-shadow: 0 10px 30px rgba(44,38,86,.08);
  backdrop-filter: blur(12px);
}

.icon-button {
  min-height: 43px;
  padding: 5px 13px 5px 6px;
  color: #5f5c77;
  border-radius: 999px;
}

.icon-button:hover {
  color: var(--purple-deep);
  border-color: transparent;
  background: var(--purple-soft);
}

.icon-button span {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: white;
  color: var(--purple);
  box-shadow: 0 3px 10px rgba(54,43,105,.1);
}

.icon-button em { color: inherit; font-size: 10px; letter-spacing: .11em; }

.screen.is-active { animation: sunny-screen-in .5s cubic-bezier(.2,.75,.2,1) both; }
@keyframes sunny-screen-in { from { opacity: 0; transform: translateY(14px) scale(.99); } }

/* Home invitation */
.home-screen {
  max-width: 1420px;
  padding: 34px 48px 80px;
  grid-template-columns: minmax(450px, .88fr) minmax(560px, 1.12fr);
  gap: 0;
  align-items: stretch;
}

.hero-copy {
  position: relative;
  z-index: 3;
  min-height: 620px;
  padding: 66px 64px 48px;
  border-radius: 58px 22px 22px 58px;
  background:
    radial-gradient(circle at 80% 17%, rgba(255,255,255,.17) 0 3%, transparent 3.3%),
    linear-gradient(150deg, #7c3cff 0%, #6729ed 58%, #5420ca 100%);
  color: white;
  box-shadow: 0 28px 70px rgba(74, 38, 168, .27), inset 0 1px rgba(255,255,255,.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero-copy::before {
  content: '';
  position: absolute;
  width: 330px;
  height: 330px;
  right: -125px;
  top: 88px;
  border-radius: 50%;
  background: rgba(42, 20, 95, .52);
}

.hero-copy::after {
  content: '1  +  9  =  10';
  position: absolute;
  right: -42px;
  bottom: 30px;
  padding: 14px 74px 14px 22px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  color: rgba(255,255,255,.32);
  font-family: "Arial Narrow", "Bahnschrift Condensed", sans-serif;
  font-size: 15px;
  letter-spacing: .15em;
  transform: rotate(-8deg);
}

.hero-copy > * { position: relative; z-index: 1; }

.eyebrow {
  margin-bottom: 23px;
  color: var(--purple);
  font-size: 10px;
  letter-spacing: .19em;
}

.eyebrow span { background: currentColor; box-shadow: none; }
.hero-copy .eyebrow { color: #ffdd63; }

.hero-copy h1 {
  max-width: 530px;
  color: white;
  font-family: "Arial Narrow", "Bahnschrift Condensed", "Segoe UI", sans-serif;
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 400;
  line-height: .95;
  letter-spacing: -.025em;
}

.hero-copy h1 em {
  color: #c7f3f1;
  font-style: normal;
  font-weight: 700;
  text-shadow: none;
}

.hero-lead {
  max-width: 500px;
  color: rgba(255,255,255,.81);
  font-size: 16px;
  line-height: 1.65;
}

.hero-actions { gap: 13px; }

.primary-button {
  min-width: 268px;
  min-height: 72px;
  padding: 14px 18px 14px 24px;
  border-radius: 20px;
  color: #24184b;
  background: linear-gradient(150deg, #ffe06b, #ffc927);
  box-shadow: 0 9px 0 #d49300, 0 19px 35px rgba(71,41,7,.18), inset 0 2px rgba(255,255,255,.62);
  transform: translateY(-3px);
}

.primary-button:hover:not(.is-locked) {
  transform: translateY(-6px) rotate(-.5deg);
  filter: none;
  box-shadow: 0 12px 0 #d49300, 0 25px 42px rgba(71,41,7,.2), inset 0 2px rgba(255,255,255,.62);
}

.primary-button:active:not(.is-locked) { transform: translateY(4px); box-shadow: 0 2px 0 #d49300, 0 9px 18px rgba(71,41,7,.14); }
.primary-button .button-kicker { color: #866100; }
.primary-button strong { font-size: 16px; }
.primary-button b { color: white; background: var(--purple); border-radius: 50%; }
.primary-button.is-locked {
  cursor: not-allowed;
  opacity: .62;
  filter: saturate(.42);
}

.secondary-button {
  min-height: 68px;
  padding-inline: 19px;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 20px;
  background: rgba(255,255,255,.11);
  color: white;
}

.secondary-button:hover:not(.is-locked) { border-color: white; background: rgba(255,255,255,.18); }
.secondary-button span { color: #ffdd63; }
.secondary-button.is-locked { color: rgba(255,255,255,.48); border-color: rgba(255,255,255,.18); }
.secondary-button.is-locked span { color: rgba(255,255,255,.4); }
.learn-button { min-width: 182px; justify-content: flex-start; }
.learn-button .learn-button-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.learn-button .learn-button-icon .ui-icon { width: 17px; height: 17px; filter: brightness(0) invert(1); }
.learn-button .learn-button-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; color: white; }
.learn-button-copy strong { font-size: 16px; line-height: 1; }
.learn-button-copy small { color: rgba(255,255,255,.61); font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.lock-note { color: rgba(255,255,255,.57); font-size: 10px; }

.hero-meta { gap: 20px; margin-top: 37px; }
.hero-meta div { border-color: rgba(255,255,255,.2); }
.hero-meta strong { color: white; font-family: "Arial Narrow", "Bahnschrift Condensed", sans-serif; font-size: 28px; font-weight: 500; }
.hero-meta span { color: rgba(255,255,255,.55); }

.hero-stage {
  position: relative;
  z-index: 2;
  min-height: 620px;
  margin-left: -20px;
  border-radius: 24px 58px 58px 24px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 28px 70px rgba(48,43,91,.15), inset 0 1px white;
  overflow: hidden;
}

.hero-stage::before {
  content: '';
  position: absolute;
  width: 370px;
  height: 170px;
  right: -80px;
  top: -70px;
  border: 3px solid rgba(74,204,201,.27);
  border-radius: 50%;
  transform: rotate(-13deg);
}

.hero-stage::after {
  content: '';
  position: absolute;
  width: 430px;
  height: 185px;
  left: 32%;
  bottom: -90px;
  border-radius: 48% 52% 0 0;
  background: rgba(178, 232, 231, .55);
  transform: rotate(-8deg);
}

.stage-glow {
  width: 68%;
  height: 58%;
  background: rgba(104, 52, 232, .14);
  filter: blur(38px);
}

.stage-note {
  position: absolute;
  z-index: 5;
  left: 50px;
  top: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #77738b;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .17em;
}

.stage-note i { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); }

.preview-board-wrap { z-index: 2; transform: rotateX(51deg) rotateZ(-7deg) translate(10px, 20px); }

.preview-board {
  grid-template-columns: repeat(5, 57px);
  grid-template-rows: repeat(var(--preview-rows, 5), 57px);
  gap: 5px;
  padding: 21px;
  border: 9px solid #8b50ff;
  border-radius: 30px;
  background: #5f29d5;
  box-shadow: 0 25px 0 #3e1b8d, 0 44px 66px rgba(52,30,107,.28), inset 0 0 0 2px rgba(255,255,255,.2);
}

.preview-cell,
.preview-cell:nth-child(odd) {
  border-radius: 11px;
  background: linear-gradient(145deg, #fffdf7, #e9e4f3);
  box-shadow: inset 0 1px white, 0 3px 0 #c8bfdd;
}

.preview-cell:nth-child(odd) { background: linear-gradient(145deg, #e4faf8, #c9eceb); }

.preview-piece { box-shadow: 0 7px 0 var(--piece-edge), 0 12px 17px rgba(49,33,91,.24), inset 0 2px rgba(255,255,255,.55); }
.preview-piece.you { --piece-hi: #ffe375; --piece: #ffc928; --piece-edge: #c98b00; --piece-ink: #302259; }
.preview-piece.ai { --piece-hi: #a87dff; --piece: #7136ee; --piece-edge: #431994; --piece-ink: white; }

.preview-score {
  z-index: 6;
  border: 0;
  border-radius: 26px;
  background: white;
  box-shadow: 0 18px 40px rgba(49,37,95,.14);
}

.preview-score span { color: #89859b; }
.preview-score-ai { top: 15%; right: 5%; transform: rotate(5deg); }
.preview-score-ai strong { color: var(--purple); }
.preview-score-you { bottom: 13%; left: 5%; transform: rotate(-6deg); background: var(--gold); box-shadow: 0 9px 0 var(--gold-deep), 0 20px 38px rgba(108,75,0,.18); }
.preview-score-you span { color: #775900; }
.preview-score-you strong { color: var(--ink); }

.target-orbit {
  z-index: 5;
  right: 5%;
  bottom: 9%;
  border-color: rgba(111,50,245,.28);
  color: var(--purple);
}

.target-orbit::before { border-color: rgba(111,50,245,.12); }

/* Learn-by-playing path */
.journey-strip {
  position: relative;
  margin-top: 64px;
  padding: 42px 42px 38px;
  border: 0;
  border-radius: 48px;
  background: linear-gradient(135deg, #cdf2f0, #bfe9e8);
  box-shadow: 0 18px 46px rgba(45,114,114,.1), inset 0 1px rgba(255,255,255,.8);
  overflow: hidden;
}

.journey-strip::after {
  content: '1  2  3  5  8';
  position: absolute;
  right: -35px;
  top: 23px;
  color: rgba(22,93,97,.08);
  font-family: "Arial Narrow", "Bahnschrift Condensed", sans-serif;
  font-size: 78px;
  letter-spacing: .08em;
  transform: rotate(-5deg);
  pointer-events: none;
}

.journey-heading { position: relative; z-index: 1; }
.journey-heading h2 { color: var(--ink); font-family: "Arial Narrow", "Bahnschrift Condensed", sans-serif; font-size: 43px; font-weight: 500; letter-spacing: -.01em; }
.journey-heading > p { color: #3e7074; font-size: 13px; }
.journey-heading .eyebrow { color: var(--purple); }

.chapter-list { position: relative; z-index: 1; gap: 13px; }

.chapter-card {
  min-height: 140px;
  padding: 18px;
  border: 0;
  border-radius: 25px;
  background: rgba(255,255,255,.86);
  color: var(--ink);
  box-shadow: 0 9px 24px rgba(48,94,99,.1), inset 0 1px white;
}

.chapter-card:hover:not(:disabled) {
  transform: translateY(-7px) rotate(-.5deg);
  border-color: transparent;
  background: white;
  box-shadow: 0 16px 32px rgba(48,94,99,.16);
}

.chapter-card:disabled { opacity: .52; }
.chapter-card .chapter-number { background: var(--purple-soft); color: var(--purple); border-radius: 50%; }
.chapter-card strong { margin-top: 17px; font-size: 15px; }
.chapter-card small { color: #77748b; }
.chapter-card .chapter-state { color: #9a94ac; }
.chapter-card.is-complete { background: #fff6cf; }
.chapter-card.is-complete .chapter-number { color: var(--ink); background: var(--gold); }
.chapter-card.is-complete .chapter-state { color: var(--gold-deep); }
.chapter-card.is-current { color: white; background: linear-gradient(145deg, #7c3cff, #6228df); box-shadow: 0 11px 0 #431a9a, 0 20px 36px rgba(66,31,151,.18); }
.chapter-card.is-current .chapter-number { color: var(--ink); background: var(--gold); }
.chapter-card.is-current small { color: rgba(255,255,255,.7); }
.chapter-card.is-current .chapter-state { color: #ffdf66; }
.chapter-card.is-current::after { width: 43%; height: 5px; left: 18px; bottom: 0; border-radius: 4px 4px 0 0; background: var(--gold); box-shadow: none; }

/* Game table */
.game-screen { max-width: 1540px; padding: 14px 30px 42px; }

.game-toolbar {
  min-height: 72px;
  margin-bottom: 8px;
  padding: 0 12px;
}

.back-button {
  padding: 10px 15px;
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  color: #65627a;
  box-shadow: 0 8px 22px rgba(42,34,84,.08);
}

.back-button:hover { color: var(--purple); background: white; }
.back-button span { color: var(--purple); }
.mode-heading span { color: var(--purple); }
.mode-heading h1 { color: var(--ink); font-family: "Segoe UI", Avenir, sans-serif; font-size: 29px; font-weight: 500; letter-spacing: .01em; }

.turn-pill {
  padding: 11px 16px;
  border: 0;
  background: white;
  color: #118e8d;
  box-shadow: 0 8px 24px rgba(44,37,86,.1);
}

.turn-pill i { box-shadow: 0 0 0 5px rgba(69,212,209,.17); }
.turn-pill.is-ai { color: var(--purple); background: #f0eaff; }

.game-layout {
  grid-template-columns: minmax(215px, 260px) auto minmax(220px, 270px);
  gap: clamp(18px, 2.5vw, 42px);
  align-items: center;
}

.game-panel {
  padding: 22px;
  border: 0;
  border-radius: 30px;
  background: rgba(255,255,255,.93);
  color: var(--ink);
  box-shadow: 0 20px 55px rgba(52,43,99,.12), inset 0 1px white;
}

.objective-panel {
  position: relative;
  color: white;
  background: linear-gradient(155deg, #7d3cff, #5b24d0);
  box-shadow: 0 12px 0 #3f198f, 0 27px 55px rgba(61,29,137,.22), inset 0 1px rgba(255,255,255,.3);
  overflow: hidden;
}

.objective-panel::after {
  content: '';
  position: absolute;
  width: 180px;
  height: 180px;
  right: -90px;
  top: 28px;
  border-radius: 50%;
  background: rgba(42,17,94,.3);
  pointer-events: none;
}

.objective-panel > * { position: relative; z-index: 1; }
.panel-label { color: #858197; }
.objective-panel .panel-label { color: rgba(255,255,255,.64); }
.panel-label span { color: var(--ink); background: var(--gold); border-radius: 50%; }
.objective-panel h2 { font-family: "Arial Narrow", "Bahnschrift Condensed", sans-serif; font-size: 31px; font-weight: 500; }
.objective-panel > p { color: rgba(255,255,255,.74); }
.objective-panel > p { font-size: 13px; line-height: 1.55; }

.objective-progress {
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.86);
}

.objective-progress i { background: var(--gold); box-shadow: 0 0 0 5px rgba(255,202,40,.15); }
.objective-progress.is-complete i { background: #bff3f1; }

.rule-card {
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.1);
}

.rule-icon { color: var(--ink); background: var(--gold); border-radius: 50%; }
.rule-card small { color: rgba(255,255,255,.63); }
.rule-card strong { font-size: 12px; }
.rule-card small { font-size: 10px; }
.move-readout { border-color: rgba(255,255,255,.16); }
.readout-empty { color: rgba(255,255,255,.58); }
.readout-piece b { color: var(--ink); background: var(--gold); box-shadow: 0 5px 0 var(--gold-deep); }
.readout-piece small { color: rgba(255,255,255,.62); }
.readout-capture { color: #ffe06a; }
.readout-capture strong { color: white; }

.board-column { width: calc(var(--cell) * 5 + 56px); }

.player-bar {
  padding: 9px 14px;
  border-radius: 20px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 10px 28px rgba(45,38,88,.1);
}

.opponent-bar { margin-bottom: 12px; }
.you-bar { margin-top: 25px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; }
.avatar-ai { color: white; background: linear-gradient(145deg, #9e70ff, #6c31ec); box-shadow: 0 5px 0 #431994, 0 10px 15px rgba(61,24,145,.16); }
.avatar-you { color: var(--ink); background: linear-gradient(145deg, #ffe475, #ffc928); box-shadow: 0 5px 0 #c98b00, 0 10px 15px rgba(109,76,0,.13); }
.player-name span { color: var(--ink); }
.player-name small { color: #89869a; }
.score-block > span,
.score-block small { color: #8a879b; }
.opponent-bar .score-block strong { color: var(--purple); }
.you-bar .score-block strong { color: #b77a00; }

.board-perspective { perspective: 1100px; padding: 7px 0 18px; }

.board-frame {
  width: calc(var(--cell) * 5 + 56px);
  height: calc(var(--cell) * 8 + 56px);
  padding: 28px;
  border-radius: 32px;
  background: linear-gradient(145deg, #8a50ff, #642cda);
  transform: rotateX(8deg);
  box-shadow: 0 17px 0 #441d92, 0 27px 0 #32136f, 0 43px 62px rgba(54,34,103,.3), inset 0 2px rgba(255,255,255,.33), inset 0 0 0 2px rgba(255,255,255,.12);
}

.board-rim { inset: 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 22px; }

.board-grid {
  border: 0;
  border-radius: 13px;
  background: #d2c8e9;
  box-shadow: inset 0 0 22px rgba(58,39,98,.18), 0 2px 0 rgba(255,255,255,.45);
  overflow: hidden;
}

.cell,
.cell:nth-child(10n+6),
.cell:nth-child(10n+8),
.cell:nth-child(10n+10),
.cell:nth-child(10n+1),
.cell:nth-child(10n+3),
.cell:nth-child(10n+5) {
  border-right: 1px solid rgba(71,54,112,.09);
  border-bottom: 1px solid rgba(71,54,112,.09);
  background: linear-gradient(145deg, #fffdf7, #eee9f5);
}

.cell:nth-child(10n+6),
.cell:nth-child(10n+8),
.cell:nth-child(10n+10),
.cell:nth-child(10n+1),
.cell:nth-child(10n+3),
.cell:nth-child(10n+5) { background: linear-gradient(145deg, #ddf7f5, #c7ecea); }

.cell .coord { color: rgba(50,43,85,.27); }
.cell.is-selected::before { border-color: var(--purple); box-shadow: inset 0 0 0 3px rgba(111,50,245,.1), 0 0 0 3px rgba(255,255,255,.75); }
.cell.is-legal::after { background: rgba(69,212,209,.42); border-color: #148f91; box-shadow: 0 0 0 5px rgba(69,212,209,.17); }
.cell.is-capture::after { background: rgba(255,113,106,.12); border-color: var(--coral); box-shadow: 0 0 0 5px rgba(255,113,106,.12); }
.cell.is-return::after { border-color: var(--gold-deep); background: rgba(255,202,40,.4); }

.piece {
  box-shadow: 0 7px 0 var(--piece-edge), 0 12px 15px rgba(50,36,89,.24), inset 0 2px rgba(255,255,255,.6);
  text-shadow: none;
}

.piece[data-owner="human"] { --piece: #ffc928; --piece-hi: #ffe578; --piece-edge: #c88a00; --piece-ink: #2d214f; }
.piece[data-owner="ai"] { --piece: #6f32ed; --piece-hi: #a67cff; --piece-edge: #42188f; --piece-ink: #ffffff; }
.piece::before { border-color: rgba(255,255,255,.45); }
.piece::after { bottom: -6px; background: var(--piece-edge); }
.cell.has-capture:not(.is-selected) .piece { box-shadow: 0 7px 0 var(--piece-edge), 0 11px 15px rgba(45,31,84,.22), 0 0 0 4px white, 0 0 0 7px var(--coral), inset 0 2px rgba(255,255,255,.5); }
.board-shine { inset: 28px; background: linear-gradient(125deg, rgba(255,255,255,.25), transparent 25%, transparent); }

.tactics-panel { padding: 20px; }
.capture-code { gap: 11px; padding: 8px 0; border-color: var(--line); }
.capture-code b { color: var(--purple); background: var(--purple-soft); border-radius: 50%; }
.capture-code strong { color: var(--ink); }
.capture-code strong { font-size: 11px; }
.capture-code small { color: #858196; font-size: 9px; }
.turn-log li { color: #8b8799; }
.turn-log li { font-size: 9.5px; }
.turn-log li:first-child { color: var(--ink); }
.table-actions button {
  border: 0;
  border-radius: 12px;
  background: #f2eefb;
  color: #625c79;
}
.table-actions button:hover { color: var(--purple); border-color: transparent; background: var(--purple-soft); }
.table-actions button span { color: var(--purple); }
.table-actions button { font-size: 10px; }

/* Facilitator controls stay available without looking like the game HUD. */
.observer-tools {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.observer-tools summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #77738b;
  cursor: pointer;
  list-style: none;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.observer-tools summary::-webkit-details-marker { display: none; }
.observer-tools summary::after { content: '+'; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #f0ebf8; color: var(--purple); font-size: 15px; }
.observer-tools[open] summary::after { content: '−'; }
.observer-tools summary small { margin-left: auto; color: #aaa6b4; font-size: 7px; letter-spacing: .05em; text-transform: none; }
.observer-tools-body { padding-top: 11px; }
.telemetry-status { color: #918da0; }
.telemetry-status[data-status="connected"] { color: #128d8d; }
.telemetry-status[data-status="checking"],
.telemetry-status[data-status="consent_required"] { color: #b47800; }
.telemetry-status[data-status="offline"] { color: var(--coral-dark); }
.observer-actions button,
.research-session-row button { border-color: var(--line); background: #f7f4fb; color: #716c81; }
.observer-actions button:hover,
.research-session-row button:hover { color: var(--purple); border-color: rgba(111,50,245,.25); }
.observer-tools-body > small { display: block; margin-top: 8px; color: #9691a2; font-size: 7.5px; line-height: 1.4; }

.board-legend { color: #777488; }
.legend-dot { background: var(--cyan); }
.capture-dot { background: var(--coral); }
.return-dot { background: var(--gold); }
.keyboard-note { border-color: var(--line); }

/* Friendly paper modals */
.modal-backdrop { background: rgba(39,25,77,.37); backdrop-filter: blur(10px); }

.modal {
  border: 0;
  border-radius: 34px;
  background: #fffdf9;
  color: var(--ink);
  box-shadow: 0 34px 90px rgba(49,34,91,.28), inset 0 1px white;
}

.modal-header {
  padding: 24px 26px;
  border-color: var(--line);
  background: linear-gradient(100deg, rgba(229,220,255,.7), rgba(255,255,255,0));
}

.modal-header span { color: var(--purple); }
.modal-header h2 { font-family: "Arial Narrow", "Bahnschrift Condensed", sans-serif; font-size: 31px; font-weight: 500; }
.modal-close { border: 0; border-radius: 50%; background: white; color: var(--purple); box-shadow: 0 5px 15px rgba(53,42,94,.12); }
.modal-close:hover { color: white; background: var(--purple); }
.settings-body legend { color: #706b80; }
.difficulty-picker span { border-color: var(--line); background: #f8f5fb; }
.difficulty-picker small { color: #8a8697; }
.difficulty-picker input:checked + span { border-color: var(--purple); background: var(--purple-soft); box-shadow: 0 0 0 2px rgba(111,50,245,.09), 0 8px 18px rgba(52,35,108,.07); }
.difficulty-picker input:checked + span b { color: var(--purple-deep); }
.difficulty-picker input:focus-visible + span { outline-color: rgba(111,50,245,.28); }

.setting-row { border-color: var(--line); }
.setting-row small { color: #8a8697; }
.setting-row select,
.research-code-row input {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}
.research-code-row input::placeholder { color: #aaa6b3; }
.switch span { background: #e5e0eb; box-shadow: inset 0 2px 5px rgba(47,37,77,.12); }
.switch span::after { background: white; box-shadow: 0 3px 7px rgba(49,38,86,.2); }
.switch input:checked + span { background: var(--purple); }
.switch input:checked + span::after { background: var(--gold); }
.settings-body fieldset.research-settings { border-color: var(--line); }
.research-settings > p { color: #8b8797; }
.research-session-row { border-color: var(--line); }
.research-session-row button { color: var(--purple); }
.text-danger { color: #ae6069; }

.rule-intro { background: linear-gradient(100deg, #d9f5f3, #f3fbfa); }
.rule-intro strong { color: #137f80; }
.rule-intro p { color: #5f7180; }
.rules-grid article { border-color: var(--line); background: #faf8fc; }
.rules-grid article > span { color: rgba(111,50,245,.2); }
.rules-grid p { color: #777386; }
.capture-equations span { background: #fff4c5; }
.capture-equations b { color: #9a6900; }
.capture-equations small { color: #8b816a; }
.digital-ruling { color: #908b99; }

.result-modal { background: #fffdf9; }
.result-kicker { color: var(--purple); }
.result-medallion { color: var(--ink); background: linear-gradient(145deg, #ffe676, #ffc928); box-shadow: 0 9px 0 #c98a00, 0 18px 35px rgba(111,76,0,.17), inset 0 2px rgba(255,255,255,.65); }
.result-modal > p { color: #777386; }
.result-scores span { color: #898598; }
.result-scores strong { color: var(--ink); }
.result-scores i { background: var(--line); }
.result-secondary { color: #777386; }
.result-burst i { background: linear-gradient(var(--purple), transparent); }

.toast { border: 0; border-radius: 999px; background: var(--ink); color: white; box-shadow: 0 15px 35px rgba(36,27,72,.26); }

@media (max-width: 1180px) {
  :root { --cell: clamp(42px, 6.2vh, 57px); }
  .home-screen { grid-template-columns: minmax(390px, .9fr) minmax(480px, 1.1fr); padding-inline: 28px; }
  .hero-copy { padding-inline: 45px; }
  .game-layout { grid-template-columns: 205px auto 215px; gap: 16px; }
  .game-panel { padding: 17px; }
}

@media (max-width: 940px) {
  .home-screen,
  .home-screen.is-active { grid-template-columns: 1fr; padding: 26px 24px 60px; }
  .hero-copy { min-height: auto; padding: 56px 55px 48px; border-radius: 48px 48px 22px 22px; text-align: left; }
  .hero-copy .eyebrow { justify-content: flex-start; }
  .hero-actions,
  .hero-meta { justify-content: flex-start; }
  .lock-note { text-align: left; }
  .hero-stage { min-height: 600px; margin: -17px 26px 0; border-radius: 22px 22px 48px 48px; }
  .journey-strip { margin-top: 45px; }
  .chapter-list { grid-template-columns: repeat(3, 1fr); }
  .game-layout { grid-template-columns: auto minmax(220px, 260px); }
  .objective-panel { grid-column: 2; grid-row: 1; }
  .board-column { grid-column: 1; grid-row: 1 / span 2; }
  .tactics-panel { grid-column: 2; grid-row: 2; }
}

@media (max-width: 700px) {
  :root { --cell: min(15.4vw, 56px); }
  body::before { width: 120vw; left: -38vw; top: 80px; }
  .site-header { height: 78px; padding: 12px 15px; }
  .brand-mark { width: 41px; height: 41px; box-shadow: 0 6px 0 #3f1a9a, 0 12px 22px rgba(81,38,190,.18); }
  .header-actions { background: transparent; border: 0; box-shadow: none; }
  .icon-button { padding: 4px; }
  .home-screen,
  .home-screen.is-active { padding: 18px 13px 48px; }
  .hero-copy { padding: 44px 26px 38px; border-radius: 37px 37px 18px 18px; }
  .hero-copy h1 { font-size: clamp(24px, 3vw, 42px); }
  .hero-copy::before { width: 240px; height: 240px; }
  .hero-actions { display: grid; }
  .hero-meta { gap: 8px; }
  .hero-meta div { padding-right: 9px; }
  .hero-stage { min-height: 470px; margin: -10px 9px 0; transform: none; border-radius: 18px 18px 36px 36px; }
  .stage-note { left: 26px; top: 31px; }
  .preview-board-wrap { transform: rotateX(52deg) rotateZ(-7deg) scale(.74) translate(15px, 25px); }
  .preview-score-ai { right: 3%; }
  .preview-score-you { left: 2%; bottom: 8%; }
  .target-orbit { right: 1%; bottom: 4%; transform: scale(.78); }
  .journey-strip { margin-top: 32px; padding: 34px 20px 24px; border-radius: 36px; }
  .journey-heading { text-align: left; }
  .journey-heading .eyebrow { justify-content: flex-start; }
  .journey-heading > p { margin-inline: 0; }
  .chapter-list { grid-template-columns: 1fr; }
  .chapter-card { min-height: 96px; }
  .difficulty-picker { grid-template-columns: 1fr; }
  .difficulty-picker span { min-height: 56px; }
  .game-screen { padding: 8px 8px 28px; }
  .game-layout { display: flex; flex-direction: column; gap: 20px; }
  .board-column { order: 1; }
  .objective-panel { order: 2; width: min(100%, 520px); }
  .tactics-panel { order: 3; width: min(100%, 520px); }
  .game-panel { border-radius: 25px; }
  .board-frame { padding: 28px; }
  .board-legend { padding-inline: 12px; }
}

@media (max-height: 780px) and (min-width: 941px) {
  :root { --cell: 47px; }
  .site-header { height: 72px; }
  .game-toolbar { min-height: 55px; }
}

/* Top-down board and readability pass */
:root { --cell: clamp(58px, 7.5vh, 72px); }

.board-column {
  width: calc(var(--cell) * 5);
}

.board-perspective {
  perspective: none;
  padding: 0;
}

.board-frame {
  width: calc(var(--cell) * 5);
  height: calc(var(--cell) * 8);
  padding: 0;
  border-radius: 14px;
  background: transparent;
  transform: none;
  transform-origin: center;
  box-shadow: none;
}

.board-grid {
  border-radius: 14px;
  box-shadow: 0 16px 34px rgba(54,34,103,.18);
}

.piece::after,
.cell .coord {
  display: none;
  content: none;
}

.game-screen.is-full-match .game-toolbar {
  min-height: 50px;
  grid-template-columns: 1fr 1fr;
}

.game-screen.is-full-match .mode-heading { display: none; }
.game-screen.is-full-match .turn-pill { grid-column: 2; }

.board-score-race {
  position: absolute;
  z-index: 9;
  inset: 0;
  pointer-events: none;
}

.board-score-race[hidden] { display: none; }

.board-progress {
  --progress: 0%;
  position: absolute;
  top: 9px;
  bottom: 9px;
  width: 8px;
}

.board-progress-ai { left: -7px; }
.board-progress-human { right: -7px; }

.board-progress-track {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 999px;
  background: transparent;
}

.board-progress-ai .board-progress-track {
  background: repeating-linear-gradient(to bottom, rgba(111,50,245,.22) 0 10px, transparent 10px 18px);
}

.board-progress-human .board-progress-track {
  background: repeating-linear-gradient(to top, rgba(255,185,21,.28) 0 10px, transparent 10px 18px);
}

.board-progress-track i {
  position: absolute;
  left: 0;
  width: 100%;
  min-height: 0;
  border-radius: inherit;
  transition: height .55s cubic-bezier(.2,.85,.2,1);
}

.board-progress-ai .board-progress-track i {
  top: 0;
  background: linear-gradient(180deg, #9a67ff, #6026df);
  box-shadow: 0 0 14px rgba(111,50,245,.65);
}

.board-progress-human .board-progress-track i {
  bottom: 0;
  background: linear-gradient(0deg, #ffb915, #ffe36e);
  box-shadow: 0 0 14px rgba(255,185,21,.72);
}

.board-progress-marker {
  position: absolute;
  left: 50%;
  z-index: 2;
  width: 30px;
  height: 27px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0;
  border: 2px solid rgba(255,255,255,.92);
  border-radius: 999px;
  transform: translateX(-50%);
  font-variant-numeric: tabular-nums;
  transition: top .55s cubic-bezier(.2,.85,.2,1), bottom .55s cubic-bezier(.2,.85,.2,1);
}

.board-progress-marker b { font-size: 11px; line-height: 1; }
.board-progress-marker small { display: none; }

.board-progress-ai .board-progress-marker {
  top: clamp(0px, calc(var(--progress) - 13.5px), calc(100% - 27px));
  color: white;
  background: linear-gradient(145deg, #9867ff, #6427e1);
  box-shadow: 0 3px 0 #42188f, 0 7px 15px rgba(66,24,143,.23);
}

.board-progress-human .board-progress-marker {
  bottom: clamp(0px, calc(var(--progress) - 13.5px), calc(100% - 27px));
  color: #2d214f;
  background: linear-gradient(145deg, #ffe679, #ffc928);
  box-shadow: 0 3px 0 #c88a00, 0 7px 15px rgba(137,91,0,.19);
}

.board-progress.is-scoring .board-progress-marker {
  animation: board-score-pop .62s cubic-bezier(.18,.85,.25,1.35);
}

@keyframes board-score-pop {
  0%, 100% { scale: 1; }
  42% { scale: 1.32; filter: brightness(1.12); }
}

/* Captions should be readable from across a physical table. */
.panel-label { font-size: 11px; }
.player-name span { font-size: 12px; }
.player-name small { font-size: 10.5px; }
.score-block > span { font-size: 9.5px; }
.score-block small { font-size: 10px; }
.objective-panel > p { font-size: 14px; }
.objective-progress { font-size: 11px; }
.rule-card strong { font-size: 13px; }
.rule-card small { font-size: 11px; }
.readout-empty { font-size: 11px; }
.readout-piece strong { font-size: 12px; }
.readout-piece small { font-size: 10px; }
.capture-code strong { font-size: 12px; }
.capture-code small { font-size: 10px; line-height: 1.35; }
.turn-log li { font-size: 10.5px; }
.table-actions button { font-size: 11px; }
.observer-tools summary { font-size: 10px; }
.observer-tools summary small { font-size: 9px; }
.observer-tools-body > small { font-size: 9px; }
.telemetry-status { font-size: 9px; }
.board-legend { font-size: 10.5px; }

@media (max-width: 700px) {
  .game-screen.is-full-match .game-toolbar { min-height: 46px; }
}

.rules-lab-note {
  margin-top: 16px;
  padding: 16px 17px;
  border: 1px solid rgba(112, 55, 255, .18);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(112, 55, 255, .09), rgba(255, 213, 38, .12));
}

.rules-lab-note strong {
  color: var(--purple-dark);
  font-size: 14px;
}

.rules-lab-note p {
  margin: 7px 0;
  line-height: 1.5;
}

.rules-lab-note small {
  color: #747082;
  line-height: 1.45;
}

.experimental-status {
  display: grid;
  gap: 3px;
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid rgba(255,255,255,.18);
  border-left: 4px solid #bff3f1;
  border-radius: 12px;
  background: rgba(255,255,255,.1);
}

.experimental-status strong {
  color: #c8f6f3;
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.experimental-status span {
  color: rgba(255,255,255,.78);
  font-size: 11px;
  line-height: 1.4;
}

.experimental-status.is-urgent {
  border-left-color: var(--gold);
  background: rgba(255,202,40,.14);
}

.experimental-status.is-urgent strong { color: #ffe67a; }

.challenge-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  margin-top: 10px;
  padding: 11px 12px;
  border-radius: 13px;
  background: linear-gradient(145deg, #ffe67a, #ffc928);
  color: var(--ink);
  box-shadow: 0 5px 0 #c98a00;
}

.challenge-card > span {
  grid-column: 1 / -1;
  color: #7c5c00;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.challenge-card strong { font-size: 14px; }
.challenge-card small { align-self: center; color: #6e5718; font-size: 10px; line-height: 1.35; }

@media (max-width: 700px) {
  :root { --cell: min(17.5vw, 68px); }
  .experimental-status span { font-size: 11px; }
}

@media (max-width: 1180px) and (min-width: 701px) {
  :root { --cell: clamp(54px, 7.5vh, 70px); }
}

@media (max-height: 780px) and (min-width: 941px) {
  :root { --cell: 60px; }
}

/* Spark momentum and pawn portals */
.portal-charge-ring {
  --portal-fill: 0%;
  --portal-active: #38dcd5;
  position: absolute;
  display: none;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 90%;
  height: 90%;
  translate: -50% -50%;
  border-radius: 50%;
  background: conic-gradient(from -90deg, var(--portal-active) 0 var(--portal-fill), transparent var(--portal-fill) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  filter: drop-shadow(0 0 5px rgba(56,220,213,.42));
  pointer-events: none;
}

.board-grid.portals-enabled .portal-charge-ring { display: block; }

.portal-charge-ring.portal-ready {
  animation: portal-ring-ready 1.05s ease-in-out infinite;
  filter: drop-shadow(0 0 7px rgba(56,220,213,.8));
}

.piece.just-moved { animation: pawn-land .58s cubic-bezier(.16,.82,.25,1.25); }

.piece.opening-deal {
  opacity: 0;
  animation: opening-pawn-deal .62s cubic-bezier(.18,.84,.24,1.22) both;
  animation-delay: calc(var(--deal-order, 0) * 42ms);
}

@keyframes opening-pawn-deal {
  0% { opacity: 0; translate: 0 -20px; scale: .52; filter: brightness(1.4) saturate(1.2); }
  62% { opacity: 1; translate: 0 3px; scale: 1.1; filter: brightness(1.1) saturate(1.08); }
  82% { opacity: 1; translate: 0 -1px; scale: .97; }
  100% { opacity: 1; translate: 0 0; scale: 1; filter: brightness(1) saturate(1); }
}

@keyframes pawn-land {
  0% { scale: .72; filter: brightness(1.35); }
  58% { scale: 1.15; }
  100% { scale: 1; filter: brightness(1); }
}

@keyframes portal-ring-ready {
  0%, 100% { scale: 1; opacity: .8; }
  50% { scale: 1.13; opacity: 1; }
}

.spark-reward {
  position: absolute;
  z-index: 14;
  left: 50%;
  top: 5%;
  padding: 4px 7px;
  border: 2px solid white;
  border-radius: 999px;
  color: #075b57;
  background: #bff8f3;
  box-shadow: 0 5px 12px rgba(21,130,122,.23);
  font-size: 8px;
  font-weight: 950;
  letter-spacing: .05em;
  white-space: nowrap;
  pointer-events: none;
  animation: spark-rise .86s cubic-bezier(.16,.8,.25,1) both;
}

.spark-reward.is-ready {
  color: white;
  background: linear-gradient(145deg, #9a67ff, #6427e1);
  box-shadow: 0 5px 13px rgba(92,37,205,.32);
}

@keyframes spark-rise {
  0% { opacity: 0; transform: translate(-50%, 13px) scale(.65); }
  24% { opacity: 1; transform: translate(-50%, -3px) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -25px) scale(.92); }
}

.cell.is-portal-choice {
  isolation: isolate;
  background: radial-gradient(circle at 50% 50%, rgba(93,241,231,.32), transparent 61%), linear-gradient(145deg, #e8fffc, #d8e7ff);
  box-shadow: inset 0 0 0 3px rgba(111,50,245,.18), inset 0 0 22px rgba(69,212,209,.38);
}

.cell.is-portal-stay {
  box-shadow: inset 0 0 0 3px rgba(111,50,245,.34), inset 0 0 25px rgba(69,212,209,.5);
}

.portal-stay-mark {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: 3px;
  translate: -50% 0;
  padding: 2px 5px;
  border-radius: 999px;
  color: white;
  background: #6427e1;
  box-shadow: 0 3px 8px rgba(70,31,148,.25);
  font-size: 6px;
  font-weight: 950;
  letter-spacing: .08em;
  pointer-events: none;
}

.portal-vortex {
  position: absolute;
  z-index: 8;
  inset: 18%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #45d4d1, #6f32f5, #bff8f3, #45d4d1);
  filter: drop-shadow(0 0 7px rgba(111,50,245,.45));
  animation: portal-vortex-spin 1.25s linear infinite;
  pointer-events: none;
}

.portal-vortex::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  background: rgba(235,253,252,.94);
  box-shadow: inset 0 0 9px rgba(69,212,209,.35);
}

@keyframes portal-vortex-spin { to { rotate: 1turn; } }

.portal-flash {
  position: absolute;
  z-index: 15;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, white 0 12%, #6ff3e8 13% 28%, rgba(111,50,245,.78) 31% 46%, transparent 68%);
  filter: drop-shadow(0 0 13px rgba(111,50,245,.62));
  pointer-events: none;
  animation: portal-arrival .7s ease-out both;
}

@keyframes portal-arrival {
  from { opacity: 1; scale: .25; rotate: 0turn; }
  to { opacity: 0; scale: 1.65; rotate: .45turn; }
}

.portal-readout {
  display: grid;
  gap: 5px;
  color: rgba(255,255,255,.72);
}

.portal-readout strong { color: #bff8f3; font-size: 13px; }
.portal-readout small { font-size: 10px; line-height: 1.4; }

.portal-readout button {
  justify-self: start;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 999px;
  color: white;
  background: rgba(255,255,255,.1);
  font: inherit;
  font-size: 9px;
  font-weight: 850;
  cursor: pointer;
}

.portal-readout button:hover { background: rgba(255,255,255,.2); }

/* Campaign-first board: the board teaches, side panels do not. */
.game-screen {
  max-width: 1120px;
  padding-bottom: 54px;
}

.game-toolbar {
  grid-template-columns: 1fr auto 1fr;
  max-width: 760px;
  margin-inline: auto;
}

.game-screen.is-full-match .game-toolbar {
  grid-template-columns: 1fr auto 1fr;
}

.game-screen.is-full-match .turn-pill { grid-column: 3; }

.campaign-progress {
  min-width: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.campaign-progress i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d8d1e7;
  box-shadow: inset 0 1px 2px rgba(43,31,79,.12);
}

.campaign-progress i.is-complete { background: var(--gold); }
.campaign-progress i.is-current { width: 24px; border-radius: 999px; background: var(--purple); box-shadow: 0 0 0 5px rgba(111,50,245,.1); }
.campaign-progress strong { color: var(--purple); font-size: 11px; letter-spacing: .13em; }
.campaign-progress span { color: #8a8598; font-size: 10px; }

.game-layout {
  display: block;
  margin-top: 2px;
}

.board-column {
  width: min(100%, 720px);
  margin-inline: auto;
  align-items: center;
}

.lesson-banner {
  width: min(100%, 690px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: 0 auto 15px;
  padding: 14px 17px;
  border: 1px solid rgba(111,50,245,.09);
  border-radius: 24px;
  background: rgba(255,255,255,.94);
  color: var(--ink);
  box-shadow: 0 14px 34px rgba(51,39,96,.1), inset 0 1px white;
}

.lesson-number {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.lesson-number span {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, #9767ff, #672be7);
  box-shadow: 0 5px 0 #431994;
  font-size: 13px;
  font-weight: 950;
}

.lesson-number small {
  max-width: 80px;
  color: #8c8799;
  font-size: 7px;
  font-weight: 850;
  letter-spacing: .07em;
  text-align: center;
  text-transform: uppercase;
}

.lesson-copy h1 {
  margin: 0 0 4px;
  color: var(--ink);
  font-family: "Arial Narrow", "Bahnschrift Condensed", sans-serif;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 550;
  letter-spacing: -.02em;
}

.lesson-copy p { margin: 0; line-height: 1.42; }
.lesson-copy p strong { display: block; color: var(--purple); font-size: 12px; }
.lesson-copy p span { display: block; margin-top: 2px; color: #716d80; font-size: 13px; }

.lesson-banner .objective-progress {
  max-width: 155px;
  padding: 9px 11px;
  border-radius: 999px;
  color: #625d73;
  background: #f2eef9;
  line-height: 1.25;
}

.lesson-banner.is-feedback {
  animation: lesson-answer .62s cubic-bezier(.2,.8,.2,1);
  border-color: rgba(69,212,209,.5);
  background: linear-gradient(115deg, #e8fbf9, #ffffff 72%);
}

@keyframes lesson-answer {
  0% { transform: translateY(7px) scale(.98); opacity: .62; }
  45% { transform: translateY(-3px) scale(1.015); }
  100% { transform: none; opacity: 1; }
}

.board-rule-strip {
  width: calc(var(--cell) * 5);
  display: grid;
  gap: 8px;
  margin: 0 auto 11px;
}

.board-rule-strip .rule-card {
  min-height: 51px;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 17px;
  color: var(--ink);
  background: linear-gradient(110deg, #fff5bd, #fffbed);
  box-shadow: 0 7px 18px rgba(90,69,20,.08);
}

.board-rule-strip .rule-card strong { color: var(--ink); }
.board-rule-strip .rule-card small { color: #756d5a; }
.board-rule-strip .experimental-status { margin: 0; border-color: rgba(111,50,245,.12); background: #f2ecff; }
.board-rule-strip .experimental-status strong { color: var(--purple); }
.board-rule-strip .experimental-status span { color: #716b82; }
.board-rule-strip .challenge-card { margin: 0; }

.opponent-bar,
.you-bar,
.board-perspective,
.move-readout,
.table-actions,
.game-details {
  width: calc(var(--cell) * 5);
}

.opponent-bar { margin-bottom: 10px; }
.you-bar { margin-top: 12px; }

.board-frame {
  width: calc(var(--cell) * 5);
  height: calc(var(--cell) * var(--board-rows, 8));
}

.board-grid {
  grid-template-rows: repeat(var(--board-rows, 8), var(--cell));
  transition: height .35s ease;
}

.move-readout {
  min-height: 54px;
  margin-top: 11px;
  padding: 11px 14px;
  border: 0;
  border-radius: 17px;
  color: var(--ink);
  background: rgba(255,255,255,.9);
  box-shadow: 0 8px 24px rgba(49,38,88,.08);
}

.move-readout .readout-empty,
.move-readout .readout-piece small { color: #858094; }
.move-readout .readout-piece strong { color: var(--ink); }
.move-readout .readout-capture { color: #7a7487; }
.move-readout .readout-capture strong { color: var(--purple); font-size: 14px; }
.move-readout .portal-readout { color: #7a7487; }
.move-readout .portal-readout strong { color: #138b8c; }
.move-readout .portal-readout button { border-color: rgba(111,50,245,.16); color: var(--purple); background: var(--purple-soft); }

.table-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.table-actions button {
  flex: 1;
  padding: 10px 14px;
  text-align: center;
}

.game-details {
  margin-top: 9px;
  padding: 0 14px;
  border-radius: 16px;
  color: #777285;
  background: rgba(255,255,255,.58);
}

.game-details > summary {
  padding: 11px 0;
  cursor: pointer;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}

.game-details .turn-log-wrap { padding: 4px 0 10px; }
.game-details .observer-tools { margin-top: 4px; padding-bottom: 13px; }

.chapter-list {
  grid-template-columns: repeat(5, 1fr);
  gap: 16px 12px;
}

.campaign-node {
  min-height: 126px;
  padding: 15px;
  border-radius: 28px;
}

.campaign-node em {
  display: block;
  margin-top: 10px;
  color: #9993a8;
  font-size: 7px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.campaign-node.is-current em,
.campaign-node.is-current small { color: rgba(255,255,255,.72); }
.campaign-node .chapter-state { max-width: 58px; font-size: 9px; letter-spacing: 1px; }

@media (max-width: 760px) {
  :root { --cell: min(17.7vw, 64px); }
  .game-toolbar { min-height: 60px; padding-inline: 2px; }
  .campaign-progress { min-width: 120px; gap: 4px; }
  .campaign-progress i { width: 6px; height: 6px; }
  .campaign-progress i.is-current { width: 17px; }
  .lesson-banner { grid-template-columns: auto 1fr; gap: 12px; padding: 12px; border-radius: 20px; }
  .lesson-banner .objective-progress { grid-column: 1 / -1; width: 100%; max-width: none; justify-content: center; }
  .lesson-copy p span { font-size: 12px; }
  .chapter-list { grid-template-columns: repeat(2, 1fr); }
  .campaign-node { min-height: 116px; }
  .board-legend { justify-content: center; flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .lesson-number small { display: none; }
  .lesson-copy h1 { font-size: 25px; }
  .lesson-copy p strong { font-size: 11px; }
  .lesson-copy p span { font-size: 11px; }
  .player-bar { padding-inline: 9px; }
  .avatar { width: 35px; height: 35px; }
}

/* Keep controls available while giving the board most of the playing viewport. */
body.is-playing .site-header {
  height: 62px;
  padding-top: 7px;
  padding-bottom: 7px;
}

body.is-playing .brand-logo { width: 126px; }

body.is-playing .brand-copy small,
body.is-playing .icon-button em {
  display: none;
}

/* Local IconSVG assets use ordinary background images so they also render when
   index.html is opened directly from disk. */
.ui-icon {
  --icon-file: none;
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  background-color: transparent;
  background-image: var(--icon-file);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.ui-icon[data-icon="help-circle"] { --icon-file: url("assets/icons/help-circle.svg"); }
.ui-icon[data-icon="settings"] { --icon-file: url("assets/icons/settings.svg"); }
.ui-icon[data-icon="arrow-right"] { --icon-file: url("assets/icons/arrow-right.svg"); }
.ui-icon[data-icon="chevron-right"] { --icon-file: url("assets/icons/chevron-right.svg"); }
.ui-icon[data-icon="arrow-left"] { --icon-file: url("assets/icons/arrow-left.svg"); }
.ui-icon[data-icon="lock"] { --icon-file: url("assets/icons/lock.svg"); }
.ui-icon[data-icon="unlock"] { --icon-file: url("assets/icons/unlock.svg"); }
.ui-icon[data-icon="arrow-up"] { --icon-file: url("assets/icons/arrow-up.svg"); }
.ui-icon[data-icon="move"] { --icon-file: url("assets/icons/move.svg"); }
.ui-icon[data-icon="minus"] { --icon-file: url("assets/icons/minus.svg"); }
.ui-icon[data-icon="x-circle"] { --icon-file: url("assets/icons/x-circle.svg"); }
.ui-icon[data-icon="maximize"] { --icon-file: url("assets/icons/maximize.svg"); }
.ui-icon[data-icon="home"] { --icon-file: url("assets/icons/home.svg"); }
.ui-icon[data-icon="corner-down-left"] { --icon-file: url("assets/icons/corner-down-left.svg"); }
.ui-icon[data-icon="power"] { --icon-file: url("assets/icons/power.svg"); }
.ui-icon[data-icon="trending-up"] { --icon-file: url("assets/icons/trending-up.svg"); }
.ui-icon[data-icon="cpu"] { --icon-file: url("assets/icons/cpu.svg"); }
.ui-icon[data-icon="refresh-cw"] { --icon-file: url("assets/icons/refresh-cw.svg"); }
.ui-icon[data-icon="x"] { --icon-file: url("assets/icons/x.svg"); }
.ui-icon[data-icon="check"] { --icon-file: url("assets/icons/check.svg"); }
.ui-icon[data-icon="star"] { --icon-file: url("assets/icons/star.svg"); }
.ui-icon[data-icon="play-circle"] { --icon-file: url("assets/icons/play-circle.svg"); }
.ui-icon[data-icon="play"] { --icon-file: url("assets/icons/play.svg"); }
.ui-icon[data-icon="copy"] { --icon-file: url("assets/icons/copy.svg"); }
.ui-icon[data-icon="download"] { --icon-file: url("assets/icons/download.svg"); }
.ui-icon[data-icon="grid-four"] { --icon-file: url("assets/icons/grid-four.svg"); }

.icon-slot .ui-icon { width: 16px; height: 16px; }
.back-button .ui-icon { width: 17px; height: 17px; }
.rule-icon .ui-icon { width: 19px; height: 19px; }
.avatar-ai .ui-icon { width: 22px; height: 22px; }
.table-actions .ui-icon { width: 14px; height: 14px; vertical-align: -2px; }
.modal-close .ui-icon { width: 18px; height: 18px; transition: filter .16s ease; }
.modal-close:hover .ui-icon { filter: brightness(0) invert(1); }
.chapter-number .ui-icon { width: 16px; height: 16px; }
.chapter-state { display: inline-flex; align-items: center; gap: 2px; }
.chapter-state .ui-icon { width: 11px; height: 11px; }
.coin-rating {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 18px;
}

.rating-coin {
  position: relative;
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(145deg, #e8e6ec, #c3bfca);
  box-shadow: 0 2px 0 #9f9aa8, inset 0 1px 0 rgba(255,255,255,.8);
}

.rating-coin:nth-child(2) {
  width: 16px;
  height: 16px;
}

.rating-coin::after {
  content: '';
  position: absolute;
  inset: 20%;
  border: 1px solid rgba(255,255,255,.48);
  border-radius: inherit;
}

.rating-coin.is-earned {
  background: linear-gradient(145deg, #ffe978, #ffc51f);
  box-shadow: 0 2px 0 #c98a00, inset 0 1px 0 rgba(255,255,255,.85);
}

.chapter-card .rating-coin {
  opacity: 0;
  animation: coin-slot-settle .42s cubic-bezier(.2,.82,.25,1.2) both;
}

.chapter-card .rating-coin:nth-child(1) { animation-delay: 40ms; }
.chapter-card .rating-coin:nth-child(2) { animation-delay: 95ms; }
.chapter-card .rating-coin:nth-child(3) { animation-delay: 150ms; }

@keyframes coin-slot-settle {
  0% { opacity: 0; translate: 0 -7px; scale: .45; }
  68% { opacity: 1; translate: 0 1px; scale: 1.14; }
  100% { opacity: 1; translate: 0 0; scale: 1; }
}

.result-medallion.is-coin-rating {
  width: min(230px, 72vw);
  height: 96px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.result-medallion-coins {
  width: 100%;
  gap: 15px;
}

.result-medallion-coins .rating-coin {
  width: 52px;
  height: 52px;
  box-shadow: 0 7px 0 #9f9aa8, 0 13px 24px rgba(48,37,86,.14), inset 0 2px 0 rgba(255,255,255,.82);
  opacity: 0;
  animation: result-coin-pop .56s cubic-bezier(.16,.86,.22,1.28) both;
}

.result-medallion-coins .rating-coin:nth-child(2) {
  width: 70px;
  height: 70px;
}

.result-medallion-coins .rating-coin.is-earned {
  box-shadow: 0 7px 0 #c98a00, 0 15px 28px rgba(111,76,0,.18), inset 0 2px 0 rgba(255,255,255,.88);
}

.result-medallion-coins .rating-coin:nth-child(1) { animation-delay: 80ms; }
.result-medallion-coins .rating-coin:nth-child(2) { animation-delay: 190ms; }
.result-medallion-coins .rating-coin:nth-child(3) { animation-delay: 300ms; }

@keyframes result-coin-pop {
  0% { opacity: 0; translate: 0 9px; scale: .2; }
  58% { opacity: 1; translate: 0 -2px; scale: 1.3; }
  78% { translate: 0 1px; scale: .9; }
  100% { opacity: 1; translate: 0 0; scale: 1; }
}
.result-medallion .ui-icon { width: 38px; height: 38px; }
.primary-button b .ui-icon { width: 19px; height: 19px; }

/* Compact lesson card and board-attached score race. */
.lesson-banner {
  width: calc(var(--cell) * 5);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 10px;
  padding: 11px 14px 12px;
  border-radius: 18px;
}

.lesson-number,
.lesson-copy h1,
.lesson-copy p strong {
  display: none;
}

.lesson-copy {
  order: 2;
  width: 100%;
  min-width: 0;
}

.lesson-copy p { width: 100%; }

.lesson-copy p span {
  margin: 0;
  overflow: hidden;
  color: #5f5a6f;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-banner .objective-progress {
  order: 1;
  width: auto;
  max-width: 100%;
  min-height: 30px;
  padding: 7px 11px;
  color: #4f4960;
  background: #f1edf8;
  font-size: 10.5px;
  line-height: 1;
}

.board-rule-strip { display: none; }

.board-perspective { padding: 0; }

.board-frame {
  height: auto;
  overflow: visible;
}

.opponent-bar,
.you-bar {
  position: relative;
  z-index: 10;
}

.opponent-bar {
  margin-bottom: 0;
  border-radius: 20px 20px 0 0;
}

.you-bar {
  margin-top: 0;
  border-radius: 0 0 20px 20px;
}

.board-grid { border-radius: 0; }

.board-progress {
  top: 0;
  bottom: 0;
  width: 12px;
}

.board-progress-ai { left: -22px; }
.board-progress-human { right: -22px; }

.board-progress-track {
  border: 2px solid rgba(255,255,255,.94);
  background: #e8e2f1;
  box-shadow: 0 4px 14px rgba(48,35,90,.14), inset 0 1px 3px rgba(62,44,107,.12);
}

.board-progress-ai .board-progress-track,
.board-progress-human .board-progress-track {
  background: #e8e2f1;
}

.board-progress-marker {
  width: 32px;
  height: 29px;
}

.board-progress-ai .board-progress-marker {
  top: clamp(0px, calc(var(--progress) - 14.5px), calc(100% - 29px));
}

.board-progress-human .board-progress-marker {
  bottom: clamp(0px, calc(var(--progress) - 14.5px), calc(100% - 29px));
}

/* IconSVG assets are black by default; invert them on dark purple surfaces. */
.avatar-ai .ui-icon,
.primary-button b .ui-icon,
.campaign-node.is-current .ui-icon {
  filter: brightness(0) invert(1);
}

@media (max-width: 760px) {
  .lesson-banner {
    width: calc(var(--cell) * 5);
    display: flex;
    gap: 6px;
    padding: 10px 12px 11px;
  }

  .lesson-banner .objective-progress {
    width: auto;
    max-width: 100%;
    justify-content: flex-start;
  }

  .board-progress-ai { left: -16px; }
  .board-progress-human { right: -16px; }
}

@media (max-width: 420px) {
  .lesson-copy p span { font-size: 10.5px; }
  .lesson-banner .objective-progress { font-size: 10px; }
}

/* Final board-stack cleanup. */
.lesson-banner {
  display: none;
  align-items: center;
  margin-bottom: 12px;
  text-align: center;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.lesson-banner.is-feedback {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.game-screen.is-full-match .lesson-banner {
  display: none;
}

.board-column {
  position: relative;
}

.lesson-banner .objective-progress {
  display: none;
}

.move-readout,
.you-bar .player-name small {
  display: none;
}

.lesson-copy p span {
  color: var(--purple);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.move-celebration {
  position: absolute;
  z-index: 40;
  top: 32%;
  left: 50%;
  width: min(calc(var(--cell) * 5), 92vw);
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 12px 16px;
  color: white;
  text-align: center;
  text-shadow: 0 3px 0 rgba(58,25,135,.45), 0 7px 18px rgba(52,26,110,.3);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.72);
  opacity: 0;
}

.move-celebration[hidden] { display: none; }

.move-celebration.is-visible {
  animation: move-celebration-pop 1.8s cubic-bezier(.16,.8,.22,1) both;
}

.move-celebration.is-prompt.is-visible {
  animation-duration: 1.8s;
}

.move-celebration.is-prompt span {
  display: none;
}

.move-celebration strong {
  color: #fff;
  font-size: clamp(24px, 6vw, 42px);
  font-weight: 950;
  letter-spacing: .04em;
  line-height: .98;
  text-transform: uppercase;
}

.move-celebration span {
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

@keyframes move-celebration-pop {
  0% { opacity: 0; transform: translate(-50%, -44%) scale(.68) rotate(-3deg); }
  14% { opacity: 1; transform: translate(-50%, -54%) scale(1.08) rotate(1deg); }
  32% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  72% { opacity: 1; transform: translate(-50%, -53%) scale(1.02); }
  100% { opacity: 0; transform: translate(-50%, -72%) scale(.92); }
}

.cell.is-lesson-target:not(.is-selected) .piece {
  animation: lesson-target-jiggle 1.25s ease-in-out infinite;
}

@keyframes lesson-target-jiggle {
  0%, 64%, 100% { translate: 0 0; }
  70% { translate: -2px -2px; }
  75% { translate: 2px 0; }
  80% { translate: -1px -1px; }
  85% { translate: 0 0; }
}

.reduce-motion .move-celebration.is-visible,
.reduce-motion .cell.is-lesson-target:not(.is-selected) .piece,
.reduce-motion .piece.opening-deal,
.reduce-motion .chapter-card .rating-coin,
.reduce-motion .result-medallion-coins .rating-coin {
  animation: none;
}

.reduce-motion .piece.opening-deal,
.reduce-motion .chapter-card .rating-coin,
.reduce-motion .result-medallion-coins .rating-coin {
  opacity: 1;
  translate: 0 0;
  scale: 1;
}

@media (prefers-reduced-motion: reduce) {
  .piece.opening-deal,
  .chapter-card .rating-coin,
  .result-medallion-coins .rating-coin {
    animation: none;
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
}

/* Flat, centered pawns and an outline that follows their logo-square shape. */
.piece {
  left: 16%;
  top: 16%;
  width: 68%;
  height: 68%;
  background: var(--piece);
  box-shadow: 0 5px 13px rgba(52,31,71,.16), inset 0 1px 0 rgba(255,255,255,.26);
}

.cell:hover .piece[data-owner="human"],
.cell:hover .piece-one[data-owner="human"] {
  transform: translateZ(14px);
  filter: brightness(1.035);
}

.cell.has-capture:not(.is-selected) .piece {
  box-shadow:
    0 5px 13px rgba(52,31,71,.16),
    0 0 0 3px rgba(255,255,255,.88),
    0 0 0 6px var(--strike-color);
}

.preview-piece {
  background: var(--piece);
  box-shadow: 0 6px 14px rgba(52,31,71,.17), inset 0 1px 0 rgba(255,255,255,.26);
}

.portal-charge-ring {
  --portal-active: var(--brand-green);
  z-index: 3;
  width: 80%;
  height: 80%;
  box-sizing: border-box;
  padding: 3px;
  border-radius: 26%;
  background: conic-gradient(from -90deg, var(--portal-active) 0 var(--portal-fill), transparent var(--portal-fill) 100%) border-box;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  filter: drop-shadow(0 0 4px rgba(7,226,116,.32));
}

.portal-charge-ring.portal-ready {
  background: linear-gradient(135deg, var(--brand-green) 0 48%, var(--brand-purple) 52% 100%) border-box;
  filter: drop-shadow(0 0 6px rgba(93,10,224,.32));
}

@keyframes portal-ring-ready {
  0%, 100% { opacity: .78; }
  50% { opacity: 1; }
}

/* Clear glass board: no dark-purple platform or colored extrusion underneath. */
.board-frame {
  border: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.board-rim {
  border-color: rgba(255,255,255,.68);
  box-shadow: none;
}

.board-grid {
  box-shadow: inset 0 0 20px rgba(93,10,224,.045), inset 0 1px 0 rgba(255,255,255,.72);
}

/* Homepage polish and a true top-down preview of the live game board. */
.hero-copy .eyebrow { gap: 0; }
.hero-copy .eyebrow > span { display: none; }

.hero-meta { align-items: stretch; }
.hero-meta div {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-meta strong {
  grid-row: auto;
  flex: 0 0 auto;
  line-height: 1;
}
.hero-meta span {
  min-height: 2.5em;
  display: flex;
  align-items: center;
}

.hero-stage { perspective: none; }
.preview-board-wrap {
  z-index: 2;
  transform: none;
  transform-style: flat;
}

.preview-board {
  --preview-cell: clamp(42px, 5.8vw, 54px);
  grid-template-columns: repeat(5, var(--preview-cell));
  grid-template-rows: repeat(var(--preview-rows, 5), var(--preview-cell));
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 18px;
  background: rgba(239,233,249,.5);
  -webkit-backdrop-filter: blur(14px) saturate(145%);
  backdrop-filter: blur(14px) saturate(145%);
  box-shadow: inset 0 0 20px rgba(93,10,224,.045), inset 0 1px 0 rgba(255,255,255,.72);
  transform-style: flat;
}

.preview-cell,
.preview-cell:nth-child(odd) {
  border-radius: 0;
  border-right: 1px solid rgba(52,31,71,.09);
  border-bottom: 1px solid rgba(52,31,71,.09);
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.84);
}

.preview-cell:nth-child(odd) { background: rgba(223,255,238,.64); }

.preview-piece {
  inset: 16%;
  border-radius: 24%;
  background: var(--piece);
  box-shadow: 0 5px 13px rgba(52,31,71,.16), inset 0 1px 0 rgba(255,255,255,.26);
  transform: none;
}

/* Keep a visible page-background gap below the glass footer. */
.app-shell { padding-bottom: 30px; }
body.is-playing .app-shell { padding-bottom: 0; }
.site-footer { margin-bottom: 0; }

@media (max-width: 700px) {
  .app-shell { padding-bottom: 24px; }
  .preview-score { scale: .86; }
}

.reduce-motion .move-celebration.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.lesson-copy,
.lesson-copy p,
.lesson-copy p span {
  text-align: center;
}

.lesson-banner .objective-progress {
  justify-content: center;
}

.opponent-bar {
  margin-bottom: 12px;
  border-radius: 20px;
}

.opponent-bar .player-name small { display: none; }

.board-grid {
  overflow: hidden;
  border-radius: 18px;
}

.you-bar {
  margin-top: 12px;
  border-radius: 20px;
}

.move-readout.is-empty,
#hintBtn,
.game-details {
  display: none;
}

.table-actions {
  justify-content: center;
  margin-top: 10px;
}

.table-actions button {
  flex: 0 0 auto;
  min-width: 132px;
}

.board-legend {
  width: calc(var(--cell) * 5);
  flex-direction: column;
  gap: 8px;
  margin: 16px auto 0;
}

.legend-markers {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 17px;
}

.legend-markers > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.board-legend .keyboard-note {
  width: 100%;
  box-sizing: border-box;
  justify-content: center;
  padding: 8px 0 0;
  border-top: 1px solid var(--line);
  border-left: 0;
  text-align: center;
}

/* Player statistics */
.settings-storage-note {
  margin: 16px 0 0;
  color: #9691a2;
  font-size: 8px;
  line-height: 1.45;
  text-align: center;
}

.result-replay {
  position: relative;
  z-index: 2;
  min-width: 220px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 13px auto 0;
  border: 1px solid rgba(111,50,245,.24);
  border-radius: 999px;
  background: #f0eaff;
  color: var(--purple-deep);
  box-shadow: 0 8px 20px rgba(68,39,145,.08);
  font-size: 10px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .18s, background .18s, box-shadow .18s;
}

.result-replay:hover {
  transform: translateY(-1px);
  background: #e9dfff;
  box-shadow: 0 11px 24px rgba(68,39,145,.12);
}

.result-replay .ui-icon { width: 15px; height: 15px; }

.statistics-modal {
  width: min(640px, calc(100vw - 32px));
  overflow: auto;
  background: #fffdf9;
}

.statistics-header {
  position: sticky;
  z-index: 4;
  top: 0;
  justify-content: center;
  text-align: center;
  background: linear-gradient(110deg, rgba(229,220,255,.82), rgba(255,247,198,.55), rgba(255,255,255,.88));
}

.statistics-header .modal-close {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
}

.statistics-body {
  padding: 18px 24px 26px;
  background: #f8f6fb;
}

.statistics-share-preview {
  display: block;
  width: min(100%, 540px, max(300px, calc(100vh - 310px)));
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: visible;
}

.statistics-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 19px;
}

.statistics-actions button {
  min-width: 145px;
  min-height: 49px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, background .18s;
}

.statistics-actions button:hover { transform: translateY(-2px); }
.statistics-actions .ui-icon { width: 16px; height: 16px; }

.statistics-download {
  border: 1px solid #f5b900;
  background: linear-gradient(180deg, #ffdf62, #ffcb27);
  color: var(--ink);
  box-shadow: 0 6px 0 #c98a00, 0 14px 24px rgba(142,95,0,.16);
}

.statistics-download:hover { box-shadow: 0 7px 0 #c98a00, 0 17px 28px rgba(142,95,0,.18); }

.statistics-copy {
  border: 1px solid #6930e5;
  background: linear-gradient(180deg, #824cff, #642de0);
  color: white;
  box-shadow: 0 6px 0 #4819aa, 0 14px 24px rgba(77,39,177,.17);
}

.statistics-copy:hover { box-shadow: 0 7px 0 #4819aa, 0 17px 28px rgba(77,39,177,.2); }
.statistics-copy .ui-icon { filter: invert(1); }

.statistics-reset {
  border: 1px solid rgba(111,50,245,.32);
  background: rgba(255,255,255,.78);
  color: var(--purple-deep);
  box-shadow: 0 9px 22px rgba(53,39,100,.08);
}

.statistics-reset:hover { background: white; }

.statistics-actions button:disabled,
.statistics-actions button:disabled:hover {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.statistics-note {
  display: block;
  margin-top: 17px;
  color: #888395;
  font-size: 8px;
  line-height: 1.45;
  text-align: center;
}

@media (max-width: 540px) {
  .statistics-body { padding: 10px 12px 20px; }
  .statistics-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .statistics-actions button { min-width: 0; }
  .statistics-reset { grid-column: 1 / -1; justify-self: center; width: min(180px, 100%); }
}

@media (max-width: 430px) {
  .site-header .brand-copy { display: flex; }
  .site-header .brand-copy small { display: none; }
  .site-header .brand-logo { width: 112px; }
  .statistics-header { justify-content: flex-start; text-align: left; }
  .statistics-header .modal-close { right: 18px; }
}

@media (max-width: 600px) {
  .site-footer {
    padding-block: 24px 28px;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    text-align: center;
  }

  .site-footer img { width: 96px; }
}

/* Site-wide readability floor for labels, captions, and supporting copy. */
:root {
  --type-micro: 12px;
  --type-small: 13px;
}

.site-footer p,
.icon-button em,
.eyebrow,
.primary-button .button-kicker,
.learn-button-copy small,
.lock-note,
.hero-meta span,
.preview-score span,
.target-orbit span,
.stage-note,
.chapter-card .chapter-number,
.chapter-card small,
.mode-heading span,
.turn-pill,
.panel-label,
.objective-progress,
.player-name small,
.score-block > span,
.score-block small,
.board-progress-marker b,
.rule-card small,
.readout-empty,
.readout-piece small,
.capture-code small,
.turn-log li,
.board-legend,
.game-details > summary,
.telemetry-status,
.observer-tools summary,
.observer-tools summary small,
.observer-tools-body > small,
.observer-actions button,
.research-session-row button,
.modal-header span,
.settings-body legend,
.difficulty-picker small,
.setting-row small,
.setting-row select,
.research-settings > p,
.research-code-row input,
.text-danger,
.capture-equations small,
.digital-ruling,
.result-kicker,
.result-scores span,
.result-secondary,
.settings-storage-note,
.statistics-note,
.campaign-progress strong,
.campaign-progress span,
.lesson-number small,
.experimental-status strong,
.challenge-card > span,
.challenge-card small,
.portal-readout small,
.portal-readout button,
.campaign-node em,
.campaign-node .chapter-state {
  font-size: var(--type-micro);
}

.player-name span,
.capture-code strong,
.table-actions button,
.difficulty-picker b,
.setting-row strong,
.rule-intro p,
.rules-grid p,
.capture-equations b,
.result-modal > p,
.result-replay,
.statistics-actions button,
.toast,
.experimental-status span {
  font-size: var(--type-small);
}

.rules-grid h3 { font-size: 15px; }
.spark-reward { font-size: 11px; }
.portal-stay-mark { font-size: 10px; }

/* Anonymous live play */
.online-modal { width: min(560px, calc(100vw - 28px)); }
.online-modal-body { padding: 22px; }
.play-mode-modal { width: min(610px, calc(100vw - 28px)); }
.play-mode-choice {
  width: 100%; min-height: 82px; display: grid; grid-template-columns: 42px 1fr 25px;
  align-items: center; gap: 13px; margin: 0 0 11px; padding: 14px 16px;
  border: 1px solid rgba(113,50,245,.14); border-radius: 18px; background: rgba(255,255,255,.82);
  color: var(--ink); text-align: left; cursor: pointer; box-shadow: 0 7px 18px rgba(53,42,94,.06);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.play-mode-choice:hover { transform: translateY(-2px); border-color: rgba(113,50,245,.42); box-shadow: 0 12px 25px rgba(53,42,94,.12); }
.play-mode-choice:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.play-mode-choice > .ui-icon { width: 30px; height: 30px; filter: var(--icon-purple-filter); }
.play-mode-choice > b .ui-icon { width: 18px; height: 18px; }
.play-mode-choice span, .play-mode-choice strong, .play-mode-choice small { display: block; }
.play-mode-choice strong { font-size: 15px; }
.play-mode-choice small { margin-top: 4px; color: #777386; line-height: 1.4; }
.architect-choice { border-color: rgba(243,190,39,.42); background: rgba(255,250,225,.85); }
.online-availability { margin: 15px 3px 0; color: #777386; font-size: 10px; text-align: center; }
.online-availability.is-offline { color: #b44e54; }

.player-name-form p { margin: 0 0 18px; color: #716d80; line-height: 1.55; }
.player-name-form label { display: block; margin-bottom: 7px; color: #4d4760; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.player-name-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.player-name-form input, .invite-link-row input {
  width: 100%; height: 48px; padding: 0 14px; border: 1px solid rgba(113,50,245,.2);
  border-radius: 12px; background: white; color: var(--ink); font: inherit; outline: none;
}
.player-name-form input:focus, .invite-link-row input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(113,50,245,.1); }
.player-name-input-row button {
  min-width: 130px; height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 0 14px; border: 1px solid rgba(113,50,245,.24); border-radius: 12px;
  background: #f0eaff; color: var(--purple-deep); font-weight: 850; cursor: pointer;
}
.player-name-input-row button:hover { background: #e8dcff; }
.player-name-input-row button:disabled { opacity: .55; cursor: wait; }
.player-name-input-row button .ui-icon { width: 15px; height: 15px; }
.player-name-form > small { min-height: 22px; display: block; padding-top: 6px; color: #b44e54; }
.player-name-form > .name-generator-status { min-height: 0; color: #777386; }
.player-name-form .primary-button { width: 100%; }

.waiting-body { text-align: center; }
.waiting-body > p { margin: 12px auto 18px; max-width: 390px; color: #716d80; line-height: 1.55; }
.waiting-body > small { display: block; margin-top: 14px; color: #8b8797; }
.waiting-spinner { height: 30px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.waiting-spinner i { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); animation: live-wait 1s infinite ease-in-out; }
.waiting-spinner i:nth-child(2) { animation-delay: .14s; }
.waiting-spinner i:nth-child(3) { animation-delay: .28s; }
@keyframes live-wait { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-7px); opacity: 1; } }
.invite-link-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; text-align: left; }
.invite-link-row button { border: 0; border-radius: 12px; padding: 0 15px; background: var(--purple); color: white; font-weight: 800; cursor: pointer; }
.invite-link-row button .ui-icon { width: 16px; height: 16px; margin-right: 5px; filter: brightness(0) invert(1); vertical-align: -3px; }

.leaderboard-period-filter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 12px; padding: 5px; border-radius: 14px; background: rgba(113,50,245,.08); }
.leaderboard-period-filter button { min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: #716d80; font: inherit; font-size: 12px; font-weight: 850; cursor: pointer; }
.leaderboard-period-filter button:hover { color: var(--ink); background: rgba(255,255,255,.68); }
.leaderboard-period-filter button[aria-pressed="true"] { color: var(--theme-secondary-ink, #fff); background: var(--theme-secondary, var(--purple)); box-shadow: 0 5px 14px rgba(93,10,224,.18); }
.leaderboard-profile { margin-bottom: 14px; padding: 13px 15px; border-radius: 14px; background: #f0eaff; color: var(--ink); font-weight: 800; }
.leaderboard-table-wrap { max-height: min(55vh, 480px); overflow: auto; border: 1px solid rgba(113,50,245,.12); border-radius: 14px; background: white; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.leaderboard-table th { position: sticky; top: 0; z-index: 1; padding: 10px 12px; background: #f8f5ff; color: #716d80; font-size: 9px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
.leaderboard-table td { padding: 11px 12px; border-top: 1px solid rgba(113,50,245,.08); }
.leaderboard-table td:nth-child(1), .leaderboard-table td:nth-child(3) { font-weight: 900; }
.leaderboard-table tr.is-you { background: rgba(243,190,39,.14); }
.leaderboard-note { margin: 13px 2px 0; color: #8b8797; font-size: 9px; text-align: center; }
.game-screen.is-online-match .opponent-bar .player-name small { display: block; }

@media (max-width: 560px) {
  .play-mode-choice { min-height: 76px; grid-template-columns: 34px 1fr 20px; padding: 12px; }
  .invite-link-row { grid-template-columns: 1fr; }
  .invite-link-row button { min-height: 44px; }
  .leaderboard-table th, .leaderboard-table td { padding-inline: 8px; }
}

@media (max-width: 430px) {
  .player-name-input-row { grid-template-columns: 1fr; }
  .player-name-input-row button { width: 100%; }
}

/* --------------------------------------------------------------------------
   Classic default palette
   Green #07E274, purple #5D0AE0, and a soft off-white canvas.
   -------------------------------------------------------------------------- */

:root {
  --brand-green: #07e274;
  --brand-green-dark: #048c48;
  --brand-green-soft: color-mix(in srgb, #07e274 28%, #fff);
  --brand-purple: #5d0ae0;
  --brand-purple-dark: color-mix(in srgb, #5d0ae0 72%, #21172f);
  --brand-purple-soft: color-mix(in srgb, #5d0ae0 12%, #fff);
  --ink: #21172f;
  --muted: #655e70;
  --deep: #f7f8f4;
  --navy: #21172f;
  --panel: rgba(255,255,255,.95);
  --panel-solid: #fff;
  --line: rgba(52,31,71,.14);
  --purple: var(--brand-purple);
  --purple-deep: var(--brand-purple-dark);
  --purple-soft: var(--brand-purple-soft);
  --cyan: var(--brand-green);
  --cyan-bright: #6feeae;
  --cyan-dark: #048c48;
  --gold: var(--brand-green);
  --gold-deep: var(--brand-green-dark);
  --type-micro: 13px;
  --type-small: 14px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

html { background: var(--deep); }

body {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  background:
    radial-gradient(circle at 92% 4%, rgba(93,10,224,.075), transparent 27rem),
    radial-gradient(circle at 8% 72%, rgba(7,226,116,.09), transparent 31rem),
    linear-gradient(180deg, #fff 0%, #f7f8f4 72%, #f2f4ef 100%);
}

body::before {
  background: rgba(7,226,116,.12);
}

body::after {
  border-color: rgba(93,10,224,.11);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline-color: rgba(7,226,116,.75);
}

.ambient-one { background: rgba(7,226,116,.12); }
.ambient-two { background: rgba(93,10,224,.1); }

.site-header {
  width: min(100%, 1380px);
  height: 76px;
  padding: 12px 28px;
}

.brand,
.brand-copy {
  width: 44px;
  height: 44px;
}

.brand-logo,
body.is-playing .brand-logo,
.site-header .brand-logo {
  width: 44px !important;
  height: 44px !important;
  object-fit: contain;
}

.header-actions {
  gap: 5px;
  padding: 4px;
  border-color: rgba(52,31,71,.09);
  background: rgba(255,255,255,.88);
  box-shadow: 0 10px 28px rgba(45,27,62,.08);
}

.icon-button {
  min-height: 42px;
  padding: 5px 12px 5px 6px;
  color: #554d61;
}

.icon-button:hover {
  color: var(--brand-purple-dark);
  background: var(--brand-purple-soft);
}

.icon-button span { color: var(--brand-purple); }
.icon-button em { font-size: 12px; letter-spacing: .07em; }

.home-screen {
  max-width: 1360px;
  padding: 30px 32px 68px;
  grid-template-columns: minmax(420px, .9fr) minmax(520px, 1.1fr);
}

.hero-copy {
  min-height: 590px;
  padding: 58px 54px 46px;
  border-radius: 42px 18px 18px 42px;
  background:
    radial-gradient(circle at 80% 17%, rgba(255,255,255,.17) 0 3%, transparent 3.3%),
    linear-gradient(150deg, #6d18ec 0%, var(--brand-purple) 48%, var(--brand-purple-dark) 100%);
  box-shadow: 0 28px 68px rgba(53,0,128,.22), inset 0 1px rgba(255,255,255,.28);
}

.hero-copy::before { background: rgba(32,0,79,.36); }
.hero-copy .eyebrow { color: var(--brand-green); font-size: 13px; }

.hero-copy h1 {
  max-width: 560px;
  font-family: inherit;
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 720;
  line-height: 1;
  letter-spacing: -.045em;
}

.hero-copy h1 em { color: var(--brand-green); font-weight: 780; }

.hero-lead {
  max-width: 520px;
  color: rgba(255,255,255,.9);
  font-size: 17px;
  line-height: 1.65;
}

.primary-button {
  color: #13251b;
  background: linear-gradient(150deg, #35eb91, var(--brand-green));
  box-shadow: 0 7px 0 var(--brand-green-dark), 0 18px 34px rgba(0,143,73,.2), inset 0 2px rgba(255,255,255,.45);
}

.primary-button:hover:not(.is-locked) {
  box-shadow: 0 9px 0 var(--brand-green-dark), 0 23px 40px rgba(0,143,73,.24), inset 0 2px rgba(255,255,255,.48);
}

.primary-button:active:not(.is-locked) {
  box-shadow: 0 2px 0 var(--brand-green-dark), 0 8px 17px rgba(0,143,73,.17);
}

.primary-button .button-kicker { color: #075f36; }
.primary-button b { background: var(--brand-purple); }
.secondary-button span { color: var(--brand-green); }
.learn-button-copy small,
.lock-note,
.hero-meta span { color: rgba(255,255,255,.76); }
.lock-note { font-size: 13px; line-height: 1.5; }
.hero-meta span { font-size: 12px; }

.hero-stage {
  min-height: 590px;
  border-radius: 18px 42px 42px 18px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 28px 68px rgba(49,30,65,.13), inset 0 1px white;
}

.hero-stage::before { border-color: rgba(7,226,116,.28); }
.hero-stage::after { background: rgba(7,226,116,.13); }
.stage-glow { background: rgba(93,10,224,.13); }
.stage-note { color: #5f5769; font-size: 12px; }
.stage-note i { background: var(--brand-green); }

.preview-board {
  border-color: #7130eb;
  background: var(--brand-purple);
  box-shadow: 0 25px 0 var(--brand-purple-dark), 0 44px 66px rgba(53,0,128,.24), inset 0 0 0 2px rgba(255,255,255,.2);
}

.preview-cell:nth-child(odd) { background: linear-gradient(145deg, #f2fff8, #d8f8e8); }
.preview-piece.you,
.piece[data-owner="human"] {
  --piece-hi: #61f2a7;
  --piece: var(--brand-green);
  --piece-edge: var(--brand-green-dark);
  --piece-ink: #13251b;
}
.preview-piece.ai,
.piece[data-owner="ai"] {
  --piece-hi: #995dff;
  --piece: var(--brand-purple);
  --piece-edge: var(--brand-purple-dark);
  --piece-ink: #fff;
}

.preview-score-you {
  background: var(--brand-green);
  box-shadow: 0 8px 0 var(--brand-green-dark), 0 20px 38px rgba(0,143,73,.2);
}
.preview-score-you span { color: #075f36; }

.site-footer {
  width: min(100% - 56px, 1320px);
  padding: 21px 4px 26px;
  border-color: rgba(52,31,71,.12);
}

.site-footer img {
  width: 34px !important;
  height: 34px !important;
  object-fit: contain;
}

.site-footer p { color: #5f5769; font-size: 13px; }

.game-panel,
.player-bar {
  border: 1px solid rgba(52,31,71,.08);
  box-shadow: 0 18px 46px rgba(49,30,65,.1), inset 0 1px white;
}

.objective-panel {
  border: 0;
  background: linear-gradient(155deg, #6d18ec, var(--brand-purple-dark));
  box-shadow: 0 10px 0 #270060, 0 25px 50px rgba(53,0,128,.2), inset 0 1px rgba(255,255,255,.25);
}

.objective-progress i,
.rule-icon { background: var(--brand-green); }
.turn-pill { color: var(--cyan-dark); }
.turn-pill i { background: var(--brand-green); box-shadow: 0 0 0 5px rgba(7,226,116,.16); }
.turn-pill.is-ai { color: var(--brand-purple); background: var(--brand-purple-soft); }

.avatar-you {
  color: #13251b;
  background: linear-gradient(145deg, #61f2a7, var(--brand-green));
  box-shadow: 0 5px 0 var(--brand-green-dark), 0 10px 15px rgba(0,143,73,.14);
}

.avatar-ai {
  background: linear-gradient(145deg, #995dff, var(--brand-purple));
  box-shadow: 0 5px 0 var(--brand-purple-dark), 0 10px 15px rgba(53,0,128,.16);
}

.you-bar .score-block strong { color: var(--cyan-dark); }
.board-frame {
  background: linear-gradient(145deg, #7a31f4, var(--brand-purple));
  box-shadow: 0 17px 0 var(--brand-purple-dark), 0 27px 0 #25005c, 0 43px 62px rgba(53,0,128,.27), inset 0 2px rgba(255,255,255,.3);
}
.cell:nth-child(10n+6),
.cell:nth-child(10n+8),
.cell:nth-child(10n+10),
.cell:nth-child(10n+1),
.cell:nth-child(10n+3),
.cell:nth-child(10n+5) { background: linear-gradient(145deg, #effff6, #d5f8e6); }

.chapter-card.is-complete { background: var(--brand-green-soft); }
.chapter-card.is-complete .chapter-number { background: var(--brand-green); }
.chapter-card.is-current { background: linear-gradient(145deg, #741ff1, var(--brand-purple)); box-shadow: 0 10px 0 var(--brand-purple-dark), 0 20px 34px rgba(53,0,128,.16); }
.chapter-card.is-current::after { background: var(--brand-green); }

.modal {
  border-radius: 26px;
  box-shadow: 0 30px 80px rgba(49,30,65,.24), inset 0 1px white;
}
.modal-header {
  background: linear-gradient(105deg, rgba(93,10,224,.1), rgba(7,226,116,.07), rgba(255,255,255,0));
}
.modal-header h2 { font-family: inherit; font-size: 28px; font-weight: 750; line-height: 1.15; }
.modal-header span { color: var(--brand-purple); font-size: 13px; }
.online-modal-body,
.settings-body,
.rules-body { font-size: 15px; line-height: 1.6; }

.play-mode-choice {
  min-height: 86px;
  border-color: rgba(93,10,224,.15);
  background: #fff;
}
.play-mode-choice:hover { border-color: rgba(93,10,224,.42); box-shadow: 0 12px 25px rgba(53,0,128,.1); }
.play-mode-choice strong { font-size: 16px; }
.play-mode-choice small { color: #625b6c; font-size: 14px; }
.architect-choice { border-color: rgba(7,226,116,.38); background: var(--brand-green-soft); }

.player-name-form p,
.waiting-body > p { color: #5f5769; font-size: 15px; }
.player-name-form label { color: #4d4358; font-size: 13px; }
.player-name-form input,
.invite-link-row input { font-size: 16px; }
.player-name-input-row button { border-color: rgba(93,10,224,.22); background: var(--brand-purple-soft); color: var(--brand-purple-dark); }
.player-name-input-row button:hover { background: #e6d8ff; }
.player-name-form > .name-generator-status { color: #625b6c; }

.leaderboard-profile { background: var(--brand-purple-soft); }
.leaderboard-table { font-size: 13px; }
.leaderboard-table th { color: #5f5769; font-size: 12px; }
.leaderboard-table tr.is-you { background: var(--brand-green-soft); }
.leaderboard-note { color: #655e70; font-size: 13px; }

.statistics-download {
  border-color: var(--brand-green-dark);
  background: linear-gradient(180deg, #41ee96, var(--brand-green));
  color: #13251b;
  box-shadow: 0 6px 0 var(--brand-green-dark), 0 14px 24px rgba(0,143,73,.16);
}

.statistics-copy,
.invite-link-row button { background: var(--brand-purple); }

@media (max-width: 940px) {
  .home-screen,
  .home-screen.is-active { padding: 24px 22px 58px; }
  .hero-copy { min-height: auto; padding: 52px 46px 44px; border-radius: 34px 34px 16px 16px; }
  .hero-stage { min-height: 570px; margin: -14px 22px 0; border-radius: 16px 16px 34px 34px; }
}

@media (max-width: 700px) {
  .site-header { height: 68px; padding: 10px 14px; }
  .brand,
  .brand-copy,
  .brand-logo,
  body.is-playing .brand-logo,
  .site-header .brand-logo { width: 38px !important; height: 38px !important; }
  .header-actions { gap: 2px; }
  .icon-button { padding: 4px; }
  .icon-button span { width: 36px; height: 36px; }
  .home-screen,
  .home-screen.is-active { padding: 14px 11px 44px; }
  .hero-copy { padding: 40px 24px 34px; }
  .hero-copy h1 { font-size: clamp(24px, 3vw, 42px); }
  .hero-lead { font-size: 16px; }
  .hero-actions { display: grid; }
  .primary-button,
  .secondary-button { width: 100%; min-width: 0; }
  .hero-meta { gap: 12px; }
  .hero-meta div { padding-right: 12px; }
  .hero-stage { min-height: 455px; margin-inline: 7px; }
  .site-footer { width: calc(100% - 32px); }
  .site-footer img { width: 30px !important; height: 30px !important; }
}

/* Clean canvas: remove non-functional bubbles, spheres, glows, and backdrop noise. */
body {
  background: #f7f8f4;
}

body::before,
body::after,
.ambient,
.hero-copy::before,
.hero-copy::after,
.hero-stage::before,
.hero-stage::after,
.stage-glow,
.target-orbit::before,
.journey-strip::after,
.objective-panel::after {
  display: none !important;
  content: none !important;
}

.hero-copy {
  background: var(--brand-purple);
}

.hero-stage,
.modal-header {
  background: #fff;
}

/* CSS-only liquid glass. Strong enough to read as glass, quiet enough to keep
   the board and text in focus. */
:root {
  --glass-blur: 26px;
  --glass-surface: rgba(255,255,255,.72);
  --glass-surface-strong: rgba(255,255,255,.84);
  --glass-border: rgba(255,255,255,.82);
  --glass-shadow: 0 18px 48px rgba(41,24,55,.13), inset 0 1px 0 rgba(255,255,255,.9);
}

.header-actions,
.site-footer,
.modal {
  border: 1px solid var(--glass-border);
  background:
    linear-gradient(145deg, rgba(255,255,255,.88), rgba(249,246,255,.62));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(165%);
  backdrop-filter: blur(var(--glass-blur)) saturate(165%);
  box-shadow: var(--glass-shadow);
}

.header-actions {
  position: relative;
  overflow: hidden;
}

.header-actions::before {
  content: '';
  position: absolute;
  inset: 1px 16% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.95), transparent);
  pointer-events: none;
}

.icon-button,
.modal-close {
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  backdrop-filter: blur(12px) saturate(150%);
}

.icon-button span,
.modal-close {
  border: 1px solid rgba(255,255,255,.8);
  background: rgba(255,255,255,.58);
  box-shadow: 0 5px 16px rgba(41,24,55,.09), inset 0 1px 0 rgba(255,255,255,.92);
}

.site-footer {
  margin-bottom: 22px;
  padding: 16px 18px;
  border-radius: 22px;
}

.modal-backdrop {
  background: rgba(35,19,51,.24);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
  backdrop-filter: blur(18px) saturate(125%);
}

.modal {
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255,255,255,.88), rgba(248,245,255,.7));
}

.modal-header {
  border-bottom-color: rgba(72,45,94,.11);
  background: rgba(255,255,255,.32);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  backdrop-filter: blur(18px) saturate(145%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
}

.play-mode-choice,
.difficulty-picker span,
.setting-row select,
.research-code-row input,
.player-name-form input,
.invite-link-row input,
.leaderboard-table-wrap {
  background: rgba(255,255,255,.62);
  -webkit-backdrop-filter: blur(16px) saturate(145%);
  backdrop-filter: blur(16px) saturate(145%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.88), 0 8px 22px rgba(41,24,55,.06);
}

.architect-choice {
  background: rgba(228,255,241,.66);
}

.back-button,
.turn-pill,
.player-bar,
.game-panel,
.table-actions button,
.leaderboard-profile {
  border: 1px solid rgba(255,255,255,.78);
  background:
    linear-gradient(145deg, rgba(255,255,255,.8), rgba(248,246,252,.58));
  -webkit-backdrop-filter: blur(22px) saturate(155%);
  backdrop-filter: blur(22px) saturate(155%);
  box-shadow: 0 14px 38px rgba(41,24,55,.1), inset 0 1px 0 rgba(255,255,255,.9);
}

.objective-panel {
  border: 1px solid rgba(255,255,255,.28);
  background:
    linear-gradient(150deg, rgba(119,37,239,.86), rgba(53,0,128,.78));
  -webkit-backdrop-filter: blur(22px) saturate(165%);
  backdrop-filter: blur(22px) saturate(165%);
  box-shadow: 0 18px 46px rgba(53,0,128,.2), inset 0 1px 0 rgba(255,255,255,.34);
}

.board-frame {
  border: 1px solid rgba(255,255,255,.48);
  background:
    linear-gradient(145deg, rgba(135,63,246,.84), rgba(93,10,224,.7));
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  box-shadow:
    0 15px 0 rgba(53,0,128,.88),
    0 25px 0 rgba(37,0,92,.86),
    0 40px 60px rgba(53,0,128,.24),
    inset 0 2px 1px rgba(255,255,255,.48),
    inset 0 -14px 30px rgba(53,0,128,.18);
}

.board-rim {
  border-color: rgba(255,255,255,.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3);
}

.board-grid {
  border: 1px solid rgba(255,255,255,.62);
  background: rgba(239,233,249,.54);
  -webkit-backdrop-filter: blur(14px) saturate(145%);
  backdrop-filter: blur(14px) saturate(145%);
  box-shadow: inset 0 0 24px rgba(53,0,128,.13), 0 2px 0 rgba(255,255,255,.55);
}

.cell,
.cell:nth-child(10n+6),
.cell:nth-child(10n+8),
.cell:nth-child(10n+10),
.cell:nth-child(10n+1),
.cell:nth-child(10n+3),
.cell:nth-child(10n+5) {
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.84);
}

.cell:nth-child(10n+6),
.cell:nth-child(10n+8),
.cell:nth-child(10n+10),
.cell:nth-child(10n+1),
.cell:nth-child(10n+3),
.cell:nth-child(10n+5) {
  background: rgba(223,255,238,.64);
}

.board-shine {
  background: linear-gradient(125deg, rgba(255,255,255,.42), rgba(255,255,255,.08) 22%, transparent 42%);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .header-actions,
  .site-footer,
  .modal,
  .back-button,
  .turn-pill,
  .player-bar,
  .game-panel { background: rgba(255,255,255,.96); }
  .objective-panel { background: var(--brand-purple); }
  .board-frame { background: var(--brand-purple); }
}

/* Centered game controls and logo-shaped playing pieces. */
:root {
  --move-color: #07e274;
  --strike-color: #ff716a;
  --homecoming-color: #5d0ae0;
}

.back-button,
.turn-pill,
.table-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.back-button { gap: 7px; }
.back-button span,
.table-actions button span {
  display: inline-grid;
  place-items: center;
  margin: 0;
  line-height: 0;
}
.back-button .ui-icon,
.table-actions .ui-icon { display: block; vertical-align: 0; }
.table-actions { align-items: center; }
.table-actions button { gap: 7px; }

.piece,
.preview-piece {
  border-radius: 24%;
}

.piece::before {
  content: none;
  display: none;
}

.piece-one,
.cell:hover .piece-one[data-owner="human"] {
  border-radius: 24%;
  transform: translateZ(14px);
}

.cell:hover .piece-one[data-owner="human"] {
  transform: translateY(-3px) translateZ(14px);
}

.piece-one .piece-value { transform: none; }
.piece-value {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  line-height: 1;
  text-align: center;
}

/* The race thumbs use the exact same player colors as the pawns. */
.board-progress-track {
  border: 1px solid rgba(52,31,71,.14);
  background: rgba(255,255,255,.62);
}

.board-progress-ai .board-progress-track,
.board-progress-human .board-progress-track {
  background: rgba(255,255,255,.62);
}

.board-progress-ai .board-progress-track i {
  background: var(--brand-purple);
  box-shadow: 0 0 12px rgba(93,10,224,.3);
}

.board-progress-human .board-progress-track i {
  background: var(--brand-green);
  box-shadow: 0 0 12px rgba(7,226,116,.32);
}

.board-progress-marker {
  width: 30px;
  height: 30px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  line-height: 1;
}

.board-progress-marker b { line-height: 1; }
.board-progress-ai .board-progress-marker {
  top: clamp(0px, calc(var(--progress) - 15px), calc(100% - 30px));
  color: #fff;
  border-color: var(--brand-purple-dark);
  background: var(--brand-purple);
  box-shadow: 0 3px 0 var(--brand-purple-dark), 0 7px 15px rgba(53,0,128,.22);
}

.board-progress-human .board-progress-marker {
  bottom: clamp(0px, calc(var(--progress) - 15px), calc(100% - 30px));
  color: #13251b;
  border-color: var(--brand-green-dark);
  background: var(--brand-green);
  box-shadow: 0 3px 0 var(--brand-green-dark), 0 7px 15px rgba(0,143,73,.2);
}

/* Board hints and their legend now share one semantic palette. */
.move-dot { background: var(--move-color); }
.capture-dot { background: var(--strike-color); }
.return-dot { background: var(--homecoming-color); }
.portal-dot {
  background: linear-gradient(135deg, var(--move-color) 0 48%, var(--homecoming-color) 52% 100%);
  box-shadow: 0 0 0 2px rgba(93,10,224,.12);
}

.legend-dot { flex: 0 0 auto; }
.cell.is-legal::after {
  border-color: var(--move-color);
  background: rgba(7,226,116,.34);
  box-shadow: 0 0 0 5px rgba(7,226,116,.12), 0 0 13px rgba(7,226,116,.32);
}

.cell.is-capture::after {
  border-color: var(--strike-color);
  background: rgba(255,113,106,.12);
  box-shadow: 0 0 0 5px rgba(255,113,106,.12);
}

.cell.is-return::after {
  border-color: var(--homecoming-color);
  background: rgba(93,10,224,.2);
  box-shadow: 0 0 0 5px rgba(93,10,224,.1), 0 0 13px rgba(93,10,224,.25);
}

.cell.is-portal-choice {
  background: radial-gradient(circle at 50% 50%, rgba(7,226,116,.26), transparent 61%), linear-gradient(145deg, #effff7, #eee7ff);
  box-shadow: inset 0 0 0 3px rgba(93,10,224,.18), inset 0 0 22px rgba(7,226,116,.28);
}

.cell.is-portal-stay {
  box-shadow: inset 0 0 0 3px rgba(93,10,224,.34), inset 0 0 25px rgba(7,226,116,.36);
}

.portal-stay-mark { background: var(--homecoming-color); }
.portal-vortex {
  background: conic-gradient(from 0deg, var(--move-color), var(--homecoming-color), #b8ffd9, var(--move-color));
  filter: drop-shadow(0 0 7px rgba(93,10,224,.38));
}
.portal-vortex::after {
  box-shadow: inset 0 0 9px rgba(7,226,116,.3);
}
.portal-flash {
  background: radial-gradient(circle, white 0 12%, #61f2a7 13% 28%, rgba(93,10,224,.78) 31% 46%, transparent 68%);
  filter: drop-shadow(0 0 13px rgba(93,10,224,.52));
}

/* Solid page canvas: cards carry the color, never the page background. */
body {
  background: #f7f8f4;
  background-attachment: scroll;
}

@media (max-width: 700px) {
  body {
    background: #f7f8f4;
    background-attachment: scroll;
  }
}

/* Final gameplay surface lock: keep these after every theme and glass layer. */
.piece {
  left: 16%;
  top: 16%;
  width: 68%;
  height: 68%;
  background: var(--piece);
  box-shadow: 0 5px 13px rgba(52,31,71,.16), inset 0 1px 0 rgba(255,255,255,.26);
}

.piece-one,
.cell:hover .piece[data-owner="human"],
.cell:hover .piece-one[data-owner="human"] {
  transform: translateZ(14px);
}

.cell.has-capture:not(.is-selected) .piece {
  box-shadow:
    0 5px 13px rgba(52,31,71,.16),
    0 0 0 3px rgba(255,255,255,.88),
    0 0 0 6px var(--strike-color);
}

.preview-piece {
  background: var(--piece);
  box-shadow: 0 6px 14px rgba(52,31,71,.17), inset 0 1px 0 rgba(255,255,255,.26);
}

.portal-charge-ring {
  --portal-active: var(--brand-green);
  z-index: 3;
  width: 80%;
  height: 80%;
  box-sizing: border-box;
  padding: 3px;
  border-radius: 26%;
  background: conic-gradient(from -90deg, var(--portal-active) 0 var(--portal-fill), transparent var(--portal-fill) 100%) border-box;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  filter: drop-shadow(0 0 4px rgba(7,226,116,.32));
}

.portal-charge-ring.portal-ready {
  background: linear-gradient(135deg, var(--brand-green) 0 48%, var(--brand-purple) 52% 100%) border-box;
  filter: drop-shadow(0 0 6px rgba(93,10,224,.32));
}

.board-frame {
  border: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.board-rim { display: none; }

.board-grid {
  box-shadow: inset 0 0 20px rgba(93,10,224,.045), inset 0 1px 0 rgba(255,255,255,.72);
}

/* Player color themes. The selected id lives on body[data-theme]. */
.settings-modal { width: min(780px, calc(100vw - 32px)); }
.player-profile-settings { padding-bottom: 18px !important; border-bottom: 1px solid var(--theme-line, var(--line)) !important; }
.settings-player-name-form { display: grid; gap: 7px; }
.settings-player-name-form label { color: var(--theme-muted, var(--muted)); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.settings-player-name-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.settings-player-name-row input {
  width: 100%;
  height: 46px;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--theme-line, var(--line));
  border-radius: 13px;
  background: var(--theme-glass-strong, rgba(255,255,255,.82));
  color: var(--theme-ink, var(--ink));
  outline: none;
}
.settings-player-name-row input:focus { border-color: var(--theme-secondary, var(--brand-purple)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-secondary, var(--brand-purple)) 12%, transparent); }
.settings-player-name-row button {
  min-width: 112px;
  height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 13px;
  background: var(--theme-secondary, var(--brand-purple));
  color: var(--theme-secondary-ink, #fff);
  font-weight: 850;
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease;
}
.settings-player-name-row button:hover { transform: translateY(-1px); filter: brightness(1.06); }
.settings-player-name-row button:disabled { cursor: wait; opacity: .58; transform: none; }
.settings-player-name-form > small { min-height: 18px; color: var(--theme-muted, var(--muted)); font-size: 11px; line-height: 1.45; }
.settings-player-name-form > small.is-success { color: color-mix(in srgb, var(--theme-primary, var(--brand-green)) 68%, #07552f); }
.settings-player-name-form > small.is-error { color: var(--theme-strike, var(--strike-color)); }
.language-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding-bottom: 20px !important;
  border-bottom: 1px solid var(--theme-line, var(--line)) !important;
}
.language-settings label {
  color: var(--theme-muted, var(--muted));
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.language-settings select {
  width: 100%;
  min-height: 48px;
  padding: 0 42px 0 14px;
  border: 1px solid var(--theme-line, var(--line));
  border-radius: 13px;
  color: var(--theme-ink, var(--ink));
  background: var(--theme-surface-solid, #fff);
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
}
.language-settings select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--theme-primary, var(--brand-green)) 42%, transparent);
  outline-offset: 2px;
}
.language-settings .bt-language-dropdown { width: 100%; }
.language-settings .bt-language-dropdown-trigger {
  min-height: 48px;
  font-size: 14px;
}
.language-settings .bt-language-dropdown-menu {
  right: auto;
  left: 0;
  width: 100%;
}
.language-settings>small {
  color: var(--theme-muted, var(--muted));
  font-size: 11px;
  line-height: 1.45;
}
.theme-settings { padding-bottom: 20px !important; border-bottom: 1px solid var(--line) !important; }
.theme-help { margin: -3px 0 15px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.theme-picker { display: grid; gap: 8px; }
.theme-group {
  overflow: hidden;
  border: 1px solid var(--theme-line, var(--line));
  border-radius: 16px;
  background: var(--theme-glass-strong, rgba(255,255,255,.72));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.42);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.theme-group.is-open {
  border-color: color-mix(in srgb, var(--theme-secondary, var(--brand-purple)) 42%, var(--theme-line, var(--line)));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--theme-secondary, var(--brand-purple)) 8%, transparent), inset 0 1px 0 rgba(255,255,255,.48);
}
.theme-group-toggle {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 14px 11px 16px;
  border: 0;
  background: transparent;
  color: var(--theme-ink, var(--ink));
  text-align: left;
  cursor: pointer;
}
.theme-group-toggle:hover { background: color-mix(in srgb, var(--theme-secondary, var(--brand-purple)) 6%, transparent); }
.theme-group-toggle:focus-visible { outline-offset: -4px; }
.theme-group-heading { min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex: 1; }
.theme-group-heading strong { font-size: 13px; }
.theme-group-heading small { color: var(--theme-muted, var(--muted)); font-size: 11px; }
.theme-group-icon {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background: var(--theme-secondary-soft, var(--brand-purple-soft));
  color: var(--theme-secondary, var(--brand-purple));
  transition: transform .28s cubic-bezier(.2,.8,.2,1), background .2s ease, color .2s ease;
}
.theme-group-icon::before,
.theme-group-icon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
}
.theme-group-icon::after { transform: translate(-50%, -50%) rotate(90deg); }
.theme-group.is-open .theme-group-icon {
  transform: rotate(45deg);
  background: var(--theme-secondary, var(--brand-purple));
  color: var(--theme-secondary-ink, #fff);
}
.theme-group-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  transition: grid-template-rows .3s cubic-bezier(.2,.8,.2,1), opacity .2s ease, visibility 0s linear .3s;
}
.theme-group.is-open .theme-group-panel {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
  transition: grid-template-rows .3s cubic-bezier(.2,.8,.2,1), opacity .22s ease .05s, visibility 0s;
}
.theme-group-panel-inner { min-height: 0; overflow: hidden; }
.theme-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 2px 8px 10px; }
.theme-card { min-width: 0; cursor: pointer; }
.theme-card input { position: absolute; opacity: 0; pointer-events: none; }
.theme-card > span {
  min-height: 62px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 1px solid var(--theme-line, var(--line));
  border-radius: 15px;
  background: var(--theme-glass-strong, rgba(255,255,255,.72));
  color: var(--theme-ink, var(--ink));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.46);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.theme-card:hover > span { transform: translateY(-1px); }
.theme-card input:checked + span {
  border-color: var(--theme-secondary, var(--brand-purple));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-secondary, var(--brand-purple)) 18%, transparent), inset 0 1px 0 rgba(255,255,255,.55);
}
.theme-card input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--theme-primary, var(--brand-green)) 55%, transparent); outline-offset: 2px; }
.theme-swatch {
  width: 34px;
  height: 34px;
  display: block;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 11px;
  background: linear-gradient(135deg, var(--swatch-primary) 0 48%, var(--swatch-secondary) 52% 100%);
  box-shadow: 0 4px 10px rgba(35,21,48,.12);
}
.theme-swatch.is-four-color {
  background:
    linear-gradient(90deg, var(--swatch-top-left) 0 50%, var(--swatch-top-right) 50%) top / 100% 50% no-repeat,
    linear-gradient(90deg, var(--swatch-bottom-left) 0 50%, var(--swatch-bottom-right) 50%) bottom / 100% 50% no-repeat;
}
.theme-card-copy { min-width: 0; display: block; }
.theme-card-copy b,
.theme-card-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-card-copy b { font-size: 12px; line-height: 1.2; }
.theme-card-copy small { margin-top: 3px; color: var(--theme-muted, var(--muted)); font-size: 10px; line-height: 1.2; }

body[data-theme] {
  --theme-primary: #07e274;
  --theme-secondary: #5d0ae0;
  --theme-bg: #f7f8f4;
  --theme-ink: #21172f;
  --theme-muted: #655e70;
  --theme-surface-solid: #ffffff;
  --theme-glass: rgba(248,246,252,.62);
  --theme-glass-strong: rgba(255,255,255,.82);
  --theme-border: rgba(255,255,255,.8);
  --theme-line: rgba(52,31,71,.14);
  --theme-primary-ink: #13251b;
  --theme-secondary-ink: #ffffff;
  --theme-primary-icon-invert: 0;
  --theme-secondary-icon-invert: 1;
  --theme-strike: #ff716a;
  --theme-primary-dark: color-mix(in srgb, var(--theme-primary), #000 38%);
  --theme-primary-soft: color-mix(in srgb, var(--theme-primary), #fff 86%);
  --theme-secondary-dark: color-mix(in srgb, var(--theme-secondary), #000 42%);
  --theme-secondary-soft: color-mix(in srgb, var(--theme-secondary), #fff 88%);
  --theme-cell-a: color-mix(in srgb, var(--theme-secondary) 5%, var(--theme-surface-solid));
  --theme-cell-b: color-mix(in srgb, var(--theme-primary) 14%, var(--theme-surface-solid));
  --theme-board-bg: color-mix(in srgb, var(--theme-secondary) 8%, var(--theme-surface-solid));
  --brand-green: var(--theme-primary);
  --brand-green-dark: var(--theme-primary-dark);
  --brand-green-soft: var(--theme-primary-soft);
  --brand-purple: var(--theme-secondary);
  --brand-purple-dark: var(--theme-secondary-dark);
  --brand-purple-soft: var(--theme-secondary-soft);
  --purple: var(--theme-secondary);
  --purple-deep: var(--theme-secondary-dark);
  --purple-soft: var(--theme-secondary-soft);
  --cyan: var(--theme-primary);
  --cyan-bright: color-mix(in srgb, var(--theme-primary), #fff 42%);
  --cyan-dark: var(--theme-primary-dark);
  --gold: var(--theme-primary);
  --gold-deep: var(--theme-primary-dark);
  --ink: var(--theme-ink);
  --muted: var(--theme-muted);
  --deep: var(--theme-bg);
  --line: var(--theme-line);
  --move-color: var(--theme-primary);
  --strike-color: var(--theme-strike);
  --homecoming-color: var(--theme-secondary);
  color: var(--theme-ink);
  background: var(--theme-bg);
  background-attachment: scroll;
}

body[data-theme="battleten-classic"] { --theme-primary: #07e274; --theme-secondary: #5d0ae0; --theme-primary-ink: #13251b; }
body[data-theme="tenza-pop"] {
  --theme-primary: #ffe683;
  --theme-secondary: #ff3363;
  --theme-bg: #fff;
  --theme-ink: #222021;
  --theme-muted: rgba(34,32,33,.68);
  --theme-surface-solid: #fff;
  --theme-glass: rgba(255,255,255,.68);
  --theme-glass-strong: rgba(255,255,255,.9);
  --theme-border: rgba(34,32,33,.14);
  --theme-line: rgba(34,32,33,.16);
  --theme-primary-ink: #222021;
  --theme-secondary-ink: #222021;
  --theme-primary-icon-invert: 0;
  --theme-secondary-icon-invert: 0;
  --theme-strike: #ff3363;
  --theme-primary-dark: color-mix(in srgb, #ffe683 72%, #222021);
  --theme-secondary-dark: color-mix(in srgb, #ff3363 72%, #222021);
  --theme-cell-a: #fff;
  --theme-cell-b: color-mix(in srgb, #ffe683 34%, #fff);
  --theme-board-bg: color-mix(in srgb, #ff3363 5%, #fff);
}
body[data-theme="tenza-pop"] .hero-copy {
  color: #222021;
}
body[data-theme="tenza-pop"] .hero-copy .eyebrow {
  color: var(--theme-primary, #ffe683);
}
body[data-theme="tenza-pop"] .hero-copy :is(.hero-lead, .lock-note) {
  color: rgba(255,255,255,.82);
}
body[data-theme="tenza-pop"] .hero-copy :is(h1, h1 em) {
  color: #fff;
}
body[data-theme="tenza-pop"] .hero-play-friend {
  --mode-accent: #222021;
  --mode-ink: #fff;
  --mode-icon-invert: 1;
}
body[data-theme="ocean"] { --theme-primary: #00c2ff; --theme-secondary: #2747d9; --theme-bg: #f2fbff; --theme-ink: #12213b; --theme-muted: #53627a; }
body[data-theme="rose"] { --theme-primary: #ff4fa3; --theme-secondary: #7a1cac; --theme-bg: #fff6fa; --theme-ink: #32182b; --theme-muted: #735568; }
body[data-theme="forest"] { --theme-primary: #7bcf4c; --theme-secondary: #186b3a; --theme-bg: #f4faf1; --theme-ink: #172a1c; --theme-muted: #526658; }
body[data-theme="sunset"] { --theme-primary: #ff8a1f; --theme-secondary: #d63384; --theme-bg: #fff7f1; --theme-ink: #382019; --theme-muted: #765d54; }
body[data-theme="candy"] { --theme-primary: #28e0c0; --theme-secondary: #ff5d7d; --theme-bg: #fff7fb; --theme-ink: #2d1d2a; --theme-muted: #705b69; }
body[data-theme="royal"] { --theme-primary: #ffc928; --theme-secondary: #4f2bd6; --theme-bg: #faf8ff; --theme-ink: #251c3d; --theme-muted: #655d78; }
body[data-theme="sky"] { --theme-primary: #62d0ff; --theme-secondary: #123e9a; --theme-bg: #f3f9ff; --theme-ink: #14233b; --theme-muted: #56657a; }
body[data-theme="lavender"] { --theme-primary: #b277ff; --theme-secondary: #6a1fd2; --theme-bg: #fbf7ff; --theme-ink: #2b1d3c; --theme-muted: #6c5c7a; }
body[data-theme="citrus"] { --theme-primary: #f4d13d; --theme-secondary: #007f78; --theme-bg: #fbfbf1; --theme-ink: #202c26; --theme-muted: #5e6962; }

body[data-theme="midnight"],
body[data-theme="deep-sea"],
body[data-theme="ember"] {
  --theme-bg: #100d18;
  --theme-ink: #f7f4ff;
  --theme-muted: #aaa4b8;
  --theme-surface-solid: #1a1624;
  --theme-glass: rgba(22,18,31,.76);
  --theme-glass-strong: rgba(31,26,43,.88);
  --theme-border: rgba(255,255,255,.14);
  --theme-line: rgba(255,255,255,.14);
  --theme-cell-a: #211b2d;
  --theme-cell-b: #172b27;
  --theme-board-bg: #171320;
}
body[data-theme="midnight"] { --theme-primary: #36f59a; --theme-secondary: #8b5cff; --theme-bg: #100d18; }
body[data-theme="deep-sea"] { --theme-primary: #20d9d2; --theme-secondary: #4377ff; --theme-bg: #071b2c; --theme-surface-solid: #0d293a; --theme-glass: rgba(8,30,45,.78); --theme-glass-strong: rgba(14,40,57,.9); --theme-cell-a: #123244; --theme-cell-b: #103c3d; --theme-board-bg: #0c2838; }
body[data-theme="ember"] { --theme-primary: #ffb52e; --theme-secondary: #e4475d; --theme-bg: #1e1113; --theme-surface-solid: #2a191b; --theme-glass: rgba(37,20,23,.8); --theme-glass-strong: rgba(48,25,29,.9); --theme-cell-a: #342124; --theme-cell-b: #3b3020; --theme-board-bg: #29191c; }

body[data-theme="cv-blue-orange"] { --theme-primary: #0072b2; --theme-secondary: #e69f00; --theme-primary-ink: #fff; --theme-secondary-ink: #17120a; --theme-primary-icon-invert: 1; --theme-secondary-icon-invert: 0; --theme-strike: #cc79a7; --theme-bg: #f7fafc; --theme-ink: #101820; --theme-muted: #53616c; }
body[data-theme="cv-cyan-magenta"] { --theme-primary: #00a6d6; --theme-secondary: #cc79a7; --theme-secondary-ink: #21121c; --theme-secondary-icon-invert: 0; --theme-strike: #e69f00; --theme-bg: #f7fafc; --theme-ink: #131a20; --theme-muted: #56636d; }
body[data-theme="cv-high-contrast"] { --theme-primary: #ffd400; --theme-secondary: #0057b8; --theme-secondary-ink: #fff; --theme-strike: #d14900; --theme-bg: #fff; --theme-ink: #080808; --theme-muted: #454545; --theme-line: rgba(0,0,0,.34); --theme-border: rgba(0,0,0,.28); --theme-cell-a: #fff; --theme-cell-b: #e9f2ff; --theme-board-bg: #f4f4f4; }

body[data-theme] .header-actions,
body[data-theme] .site-footer,
body[data-theme] .modal,
body[data-theme] .back-button,
body[data-theme] .turn-pill,
body[data-theme] .player-bar,
body[data-theme] .game-panel,
body[data-theme] .table-actions button,
body[data-theme] .leaderboard-profile {
  border-color: var(--theme-border);
  background: linear-gradient(145deg, var(--theme-glass-strong), var(--theme-glass));
  color: var(--theme-ink);
}
body[data-theme] .hero-stage { background: var(--theme-glass-strong); }
body[data-theme] .hero-copy,
body[data-theme] .objective-panel { background: linear-gradient(150deg, color-mix(in srgb, var(--theme-secondary), #fff 10%), var(--theme-secondary) 50%, var(--theme-secondary-dark)); }
body[data-theme] .primary-button { color: var(--theme-primary-ink); background: linear-gradient(150deg, color-mix(in srgb, var(--theme-primary), #fff 24%), var(--theme-primary)); box-shadow: 0 7px 0 var(--theme-primary-dark), 0 18px 34px color-mix(in srgb, var(--theme-primary) 22%, transparent), inset 0 2px rgba(255,255,255,.4); }
body[data-theme] .primary-button b { background: var(--theme-secondary); }
body[data-theme] .icon-button { color: var(--theme-muted); }
body[data-theme] .icon-button:hover { color: var(--theme-secondary); background: var(--theme-secondary-soft); }
body[data-theme] .site-footer p,
body[data-theme] .stage-note,
body[data-theme] .theme-help,
body[data-theme] .settings-storage-note { color: var(--theme-muted); }
body[data-theme] .modal-header { border-color: var(--theme-line); background: linear-gradient(105deg, color-mix(in srgb, var(--theme-secondary) 13%, transparent), color-mix(in srgb, var(--theme-primary) 8%, transparent), transparent); }
body[data-theme] .modal-header span { color: var(--theme-secondary); }
body[data-theme] .play-mode-choice,
body[data-theme] .difficulty-picker span,
body[data-theme] .setting-row select,
body[data-theme] .player-name-form input,
body[data-theme] .settings-player-name-row input,
body[data-theme] .invite-link-row input,
body[data-theme] .leaderboard-table-wrap { border-color: var(--theme-line); background: var(--theme-glass-strong); color: var(--theme-ink); }
body[data-theme] .difficulty-picker input:checked + span,
body[data-theme] .switch input:checked + span { border-color: var(--theme-secondary); background: var(--theme-secondary-soft); }
body[data-theme] .switch input:checked + span::after { background: var(--theme-primary); }
body[data-theme] .preview-board,
body[data-theme] .board-grid { border-color: var(--theme-line); background: var(--theme-board-bg); }
body[data-theme] .cell,
body[data-theme] .cell:nth-child(10n+6),
body[data-theme] .cell:nth-child(10n+8),
body[data-theme] .cell:nth-child(10n+10),
body[data-theme] .cell:nth-child(10n+1),
body[data-theme] .cell:nth-child(10n+3),
body[data-theme] .cell:nth-child(10n+5),
body[data-theme] .preview-cell,
body[data-theme] .preview-cell:nth-child(odd) { border-color: var(--theme-line); background: var(--theme-cell-a); }
body[data-theme] .cell:nth-child(10n+6),
body[data-theme] .cell:nth-child(10n+8),
body[data-theme] .cell:nth-child(10n+10),
body[data-theme] .cell:nth-child(10n+1),
body[data-theme] .cell:nth-child(10n+3),
body[data-theme] .cell:nth-child(10n+5),
body[data-theme] .preview-cell:nth-child(odd) { background: var(--theme-cell-b); }
body[data-theme] .preview-piece.you,
body[data-theme] .piece[data-owner="human"] { --piece: var(--theme-primary); --piece-hi: color-mix(in srgb, var(--theme-primary), #fff 30%); --piece-edge: var(--theme-primary-dark); --piece-ink: var(--theme-primary-ink); }
body[data-theme] .preview-piece.ai,
body[data-theme] .piece[data-owner="ai"] { --piece: var(--theme-secondary); --piece-hi: color-mix(in srgb, var(--theme-secondary), #fff 28%); --piece-edge: var(--theme-secondary-dark); --piece-ink: var(--theme-secondary-ink); }
body[data-theme] .avatar-you,
body[data-theme] .preview-score-you,
body[data-theme] .board-progress-human .board-progress-marker { color: var(--theme-primary-ink); background: var(--theme-primary); border-color: var(--theme-primary-dark); }
body[data-theme] .avatar-ai,
body[data-theme] .board-progress-ai .board-progress-marker { color: var(--theme-secondary-ink); background: var(--theme-secondary); border-color: var(--theme-secondary-dark); }
body[data-theme] .board-progress-human .board-progress-track i { background: var(--theme-primary); }
body[data-theme] .board-progress-ai .board-progress-track i { background: var(--theme-secondary); }
body[data-theme] .cell.is-selected::before { border-color: var(--theme-secondary); }
body[data-theme] .cell.is-legal::after { border-color: var(--theme-primary); background: color-mix(in srgb, var(--theme-primary) 34%, transparent); }
body[data-theme] .cell.is-capture::after { border-color: var(--theme-strike); background: color-mix(in srgb, var(--theme-strike) 13%, transparent); }
body[data-theme] .cell.is-return::after { border-color: var(--theme-secondary); background: color-mix(in srgb, var(--theme-secondary) 20%, transparent); }
body[data-theme] .portal-charge-ring { --portal-active: var(--theme-primary); }
body[data-theme] .portal-charge-ring.portal-ready,
body[data-theme] .portal-dot { background: linear-gradient(135deg, var(--theme-primary) 0 48%, var(--theme-secondary) 52% 100%); }

body[data-theme-mode="dark"] .hero-stage,
body[data-theme-mode="dark"] .preview-score,
body[data-theme-mode="dark"] .modal-close,
body[data-theme-mode="dark"] .theme-card > span { color: var(--theme-ink); background: var(--theme-glass-strong); border-color: var(--theme-line); }
body[data-theme-mode="dark"] .icon-button .ui-icon,
body[data-theme-mode="dark"] .modal-close .ui-icon,
body[data-theme-mode="dark"] .back-button .ui-icon { filter: brightness(0) invert(1); }
body[data-theme-mode="dark"] .player-name small,
body[data-theme-mode="dark"] .score-block > span,
body[data-theme-mode="dark"] .score-block small,
body[data-theme-mode="dark"] .board-legend,
body[data-theme-mode="dark"] .keyboard-note,
body[data-theme-mode="dark"] .difficulty-picker small,
body[data-theme-mode="dark"] .setting-row small { color: var(--theme-muted); }

@media (max-width: 680px) {
  .settings-modal { width: min(100% - 20px, 620px); }
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 440px) {
  .settings-player-name-row { grid-template-columns: 1fr; }
  .settings-player-name-row button { width: 100%; }
}

/* Final homepage composition lock: keep this after all brand layers. */
.hero-copy .eyebrow { gap: 0; }
.hero-copy .eyebrow > span { display: none; }

.hero-meta { align-items: stretch; }
.hero-meta div {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-meta strong {
  grid-row: auto;
  flex: 0 0 auto;
  line-height: 1;
}
.hero-meta span {
  min-height: 2.5em;
  display: flex;
  align-items: center;
}

.hero-stage { perspective: none; }
.preview-board-wrap {
  z-index: 2;
  transform: none;
  transform-style: flat;
  box-shadow: none;
  filter: none;
}

.preview-board {
  --preview-cell: clamp(42px, 6vw, 58px);
  width: calc(var(--preview-cell) * 5);
  height: calc(var(--preview-cell) * var(--preview-rows, 5));
  grid-template-columns: repeat(5, var(--preview-cell));
  grid-template-rows: repeat(var(--preview-rows, 5), var(--preview-cell));
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 18px;
  background: var(--theme-board-bg, rgba(239,233,249,.5));
  -webkit-backdrop-filter: blur(14px) saturate(145%);
  backdrop-filter: blur(14px) saturate(145%);
  box-shadow: inset 0 0 20px rgba(93,10,224,.045), inset 0 1px 0 rgba(255,255,255,.72);
  transform-style: flat;
}

.preview-cell,
.preview-cell:nth-child(odd) {
  border-radius: 0;
  border-right: 1px solid rgba(52,31,71,.09);
  border-bottom: 1px solid rgba(52,31,71,.09);
  background: var(--theme-cell-a, rgba(255,255,255,.72));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.84);
}
.preview-cell:nth-child(odd) { background: var(--theme-cell-b, rgba(223,255,238,.64)); }

.preview-piece {
  inset: 16%;
  border-radius: 24%;
  background: var(--piece);
  box-shadow: 0 5px 13px rgba(52,31,71,.16), inset 0 1px 0 rgba(255,255,255,.26);
  transform: none;
}

.app-shell { padding-bottom: 30px; }
body.is-playing .app-shell { padding-bottom: 0; }
.site-footer { margin-bottom: 0; }

@media (max-width: 700px) {
  .app-shell { padding-bottom: 24px; }
  .preview-score { scale: .86; }
}

/* Final borderless glass polish: keep the blur and depth without pale rims. */
:root {
  --glass-border: transparent;
  --glass-shadow: 0 18px 48px rgba(41,24,55,.13);
}

.header-actions,
.site-footer,
.modal,
.hero-stage,
.back-button,
.turn-pill,
.player-bar,
.game-panel,
.table-actions button,
.leaderboard-profile,
.objective-panel,
.board-grid,
.preview-board,
.preview-score {
  border-color: transparent !important;
  border-width: 0 !important;
}

.header-actions::before { display: none; content: none; }
.header-actions,
.site-footer,
.modal { box-shadow: 0 18px 48px rgba(41,24,55,.13); }
.hero-stage { box-shadow: 0 28px 68px rgba(53,0,128,.18); }
.modal-header { border-bottom-color: transparent; box-shadow: none; }

.icon-button span,
.modal-close {
  border-width: 0;
  border-color: transparent;
  box-shadow: 0 5px 16px rgba(41,24,55,.09);
}

.back-button,
.turn-pill,
.player-bar,
.game-panel,
.table-actions button,
.leaderboard-profile { box-shadow: 0 14px 38px rgba(41,24,55,.1); }

.play-mode-choice,
.difficulty-picker span,
.setting-row select,
.leaderboard-table-wrap,
.theme-group,
.theme-card > span,
.theme-swatch {
  border-width: 0;
  border-color: transparent;
}
.theme-group { box-shadow: none; }
.theme-card > span { box-shadow: 0 5px 14px rgba(41,24,55,.06); }
.theme-group.is-open { box-shadow: 0 8px 24px color-mix(in srgb, var(--theme-secondary, var(--brand-purple)) 8%, transparent); }
.theme-card input:checked + span { box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-secondary, var(--brand-purple)) 18%, transparent); }

.play-mode-choice,
.difficulty-picker span,
.setting-row select,
.research-code-row input,
.player-name-form input,
.settings-player-name-row input,
.invite-link-row input,
.leaderboard-table-wrap { box-shadow: 0 8px 22px rgba(41,24,55,.06); }

.avatar { border: 0; box-shadow: 0 5px 10px rgba(41,24,55,.13); }
body[data-theme] .primary-button { box-shadow: 0 7px 0 var(--theme-primary-dark), 0 18px 34px color-mix(in srgb, var(--theme-primary) 22%, transparent); }

.board-grid,
.preview-board { box-shadow: inset 0 0 20px rgba(93,10,224,.045); }
.cell,
.cell:nth-child(10n+6),
.cell:nth-child(10n+8),
.cell:nth-child(10n+10),
.cell:nth-child(10n+1),
.cell:nth-child(10n+3),
.cell:nth-child(10n+5),
.preview-cell,
.preview-cell:nth-child(odd) { box-shadow: none; }

.piece,
.preview-piece {
  border: 0;
  box-shadow: 0 5px 13px rgba(52,31,71,.16);
}

.cell.has-capture:not(.is-selected) .piece {
  box-shadow: 0 5px 13px rgba(52,31,71,.16), 0 0 0 4px var(--strike-color);
}

/* Borderless theme board: square tiles, softly rounded board corners. */
.board-grid,
.preview-board {
  overflow: hidden;
  border: 0 !important;
  border-radius: 20px;
  background: var(--theme-board-bg, rgba(239,233,249,.5));
  box-shadow: none;
}

body[data-theme] .cell,
body[data-theme] .preview-cell,
body[data-theme] .preview-cell:nth-child(odd) {
  border: 0 !important;
  border-radius: 0;
  background: var(--theme-cell-a) !important;
  box-shadow: none;
}

body[data-theme] .cell:nth-child(even),
body[data-theme] .preview-cell:nth-child(even) {
  background: var(--theme-cell-b) !important;
}

/* Flat controls: color and focus communicate state, never 3D extrusion. */
body[data-theme] .primary-button,
body[data-theme] .primary-button:hover:not(.is-locked),
body[data-theme] .primary-button:active:not(.is-locked) {
  transform: none;
  background: var(--theme-primary);
  box-shadow: none;
}

.secondary-button,
.secondary-button:hover:not(.is-locked),
.play-mode-choice,
.play-mode-choice:hover,
.chapter-card,
.chapter-card:hover:not(:disabled),
.chapter-card.is-current,
.settings-player-name-row button,
.settings-player-name-row button:hover,
.statistics-actions button,
.statistics-actions button:hover,
.statistics-download,
.statistics-download:hover,
.statistics-copy,
.statistics-copy:hover,
.result-replay,
.result-replay:hover,
.theme-card:hover > span,
.difficulty-picker label:hover span {
  transform: none;
  box-shadow: none;
}

.icon-button span,
.modal-close,
.back-button,
.turn-pill,
.table-actions button,
.player-name-input-row button,
.invite-link-row button,
.theme-group,
.theme-card > span,
.difficulty-picker span,
.switch span,
.switch span::after,
.theme-swatch,
.piece,
.preview-piece,
.preview-score,
.board-progress-marker,
.avatar,
.readout-piece b,
.result-medallion {
  box-shadow: none;
}

.cell.has-capture:not(.is-selected) .piece {
  box-shadow: 0 0 0 4px var(--strike-color);
}

.preview-score-ai,
.preview-score-you { transform: none; }
.board-progress-marker { border: 0; }

/* Compact branding, softly themed actions, and one consistent white glass board. */
.brand,
.brand-copy {
  width: 34px;
  height: 34px;
}

.brand-logo,
body.is-playing .brand-logo,
.site-header .brand-logo {
  width: 28px !important;
  height: 28px !important;
}

.site-footer img {
  width: 26px !important;
  height: 26px !important;
}

body[data-theme] .primary-button {
  transition: background .18s ease, color .18s ease;
}

body[data-theme] .primary-button:hover:not(.is-locked) {
  background: color-mix(in srgb, var(--theme-primary) 82%, white 18%);
  filter: none;
}

body[data-theme] .primary-button:hover:not(.is-locked) b {
  background: color-mix(in srgb, var(--theme-secondary) 84%, white 16%);
}

.board-grid,
.preview-board {
  column-gap: 8px;
  row-gap: 8px;
  padding: 0;
  overflow: visible;
  border-radius: 0;
  background: transparent !important;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.board-grid {
  width: 100%;
  height: calc(var(--cell) * var(--board-rows, 8));
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(var(--board-rows, 8), 1fr);
}

.preview-board {
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(var(--preview-rows, 5), 1fr);
}

body[data-theme] .cell,
body[data-theme] .cell:nth-child(even),
body[data-theme] .cell:nth-child(10n+6),
body[data-theme] .cell:nth-child(10n+8),
body[data-theme] .cell:nth-child(10n+10),
body[data-theme] .cell:nth-child(10n+1),
body[data-theme] .cell:nth-child(10n+3),
body[data-theme] .cell:nth-child(10n+5),
body[data-theme] .preview-cell,
body[data-theme] .preview-cell:nth-child(odd),
body[data-theme] .preview-cell:nth-child(even) {
  border: 0 !important;
  border-radius: 14px;
  background: rgba(255,255,255,.86) !important;
  box-shadow: 0 5px 10px -8px rgba(42,30,62,.3);
  outline: 1px solid rgba(52,31,71,.2);
  outline-offset: -1px;
}

.piece,
.piece-one,
.preview-piece {
  border-radius: 30%;
}

.board-progress-ai .board-progress-marker,
.board-progress-human .board-progress-marker {
  border: 0;
  box-shadow: none;
  filter: none;
}

/* Daily Challenge: a compact, share-first bridge into the full table. */
.hero-play-stack {
  display: grid;
  flex: 0 1 304px;
  gap: 12px;
}

.hero-play-stack .primary-button {
  width: 100%;
  min-width: 0;
}

.daily-challenge-button {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 10px 13px;
  border: 0;
  border-radius: 20px;
  color: var(--theme-ink, #2d214f);
  background: rgba(255,255,255,.9);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}

.daily-challenge-button:hover {
  background: white;
  transform: translateY(-2px);
}

.daily-calendar {
  width: 48px;
  min-height: 50px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 14px;
  color: white;
  background: var(--theme-secondary, var(--brand-purple));
  line-height: 1;
}

.daily-calendar small {
  margin-bottom: 3px;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .13em;
}

.daily-calendar strong { font-size: 20px; }
.daily-button-copy { min-width: 0; }
.daily-button-copy strong { display: block; font-size: 14px; }
.daily-button-copy small {
  display: block;
  margin-top: 4px;
  color: var(--theme-muted, #777386);
  font-size: 9px;
  line-height: 1.25;
}

.daily-challenge-button > b {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--theme-secondary, var(--brand-purple));
  background: var(--theme-secondary-soft, #eee7ff);
}

.daily-challenge-button .ui-icon { width: 15px; height: 15px; }

.hero-copy .daily-challenge-button {
  max-width: 304px;
  color: var(--theme-primary-ink, #143425);
  background: var(--theme-primary, var(--brand-green));
}

.hero-copy .daily-challenge-button:hover {
  background: color-mix(in srgb, var(--theme-primary, var(--brand-green)) 84%, white 16%);
}

.hero-copy .daily-button-copy small { color: color-mix(in srgb, var(--theme-primary-ink, #143425) 72%, transparent); }

.hero-copy .hero-actions {
  width: min(304px, 100%);
  display: grid;
  gap: 7px;
}

.hero-copy .learning-complete-play { width: 100%; }

.learning-stage {
  --cell: clamp(42px, 5.7vh, 54px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 24px 30px 28px;
  overflow: hidden;
}

.learning-stage-caption {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--theme-muted, #777386);
  font-size: 11px;
  font-weight: 900;
  justify-content: center;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
}

.learning-stage-caption i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--theme-primary, var(--brand-green));
}

.learning-dismiss-button {
  position: absolute;
  z-index: 12;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #111;
  background: #fff;
  box-shadow: 0 8px 22px rgba(24, 17, 32, .13);
  cursor: pointer;
  transition: background-color 160ms ease;
}

.learning-dismiss-button:hover {
  background: #ececef;
}

.learning-dismiss-button .ui-icon {
  width: 18px;
  height: 18px;
  filter: none !important;
}

.learning-dismiss-button::after {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  padding: 7px 9px;
  border-radius: 7px;
  color: #fff;
  background: rgba(0, 0, 0, .82);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  content: attr(data-tooltip);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity 150ms ease, transform 150ms ease;
  white-space: nowrap;
}

.learning-dismiss-button:hover::after,
.learning-dismiss-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.learning-stage-title {
  position: relative;
  z-index: 3;
  margin: 0 0 10px;
  color: var(--theme-ink, #2d214f);
  font-size: clamp(27px, 2.4vw, 36px);
  line-height: 1.05;
  letter-spacing: -.035em;
  text-align: center;
}

.home-campaign-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(40px, 1fr) minmax(0, calc(var(--cell) * 5)) minmax(40px, 1fr);
  align-items: center;
  column-gap: 0;
}

.home-campaign-content {
  grid-column: 2;
  width: calc(var(--cell) * 5);
  max-width: 100%;
  min-width: 0;
  justify-self: center;
}

.home-campaign-instruction {
  width: max-content;
  max-width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0 auto 14px;
  padding: 9px 14px;
  border-radius: 999px;
  color: var(--theme-ink, #2d214f);
  background: linear-gradient(145deg, var(--theme-glass-strong, rgba(255,255,255,.9)), var(--theme-glass, rgba(248,246,252,.72)));
  box-shadow: 0 14px 38px rgba(41,24,55,.1);
  -webkit-backdrop-filter: blur(22px) saturate(155%);
  backdrop-filter: blur(22px) saturate(155%);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  text-align: center;
}

.home-campaign-instruction i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--theme-primary, var(--brand-green));
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--theme-primary, var(--brand-green)) 16%, transparent);
}

.home-campaign-mount {
  position: relative;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-level-nav {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--theme-secondary, var(--brand-purple));
  background: var(--theme-secondary-soft, #eee7ff);
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}
.home-level-nav:hover {
  color: white;
  background: var(--theme-secondary, var(--brand-purple));
}
.home-level-nav:hover .ui-icon { filter: brightness(0) invert(1) !important; }
.home-level-nav[hidden] { display: none; }
.home-level-previous { grid-column: 1; justify-self: start; }
.home-level-next { grid-column: 3; justify-self: end; }
.home-level-nav .ui-icon { width: 17px; height: 17px; }

.learning-stage .game-experience {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.learning-stage .game-toolbar {
  order: 2;
  width: calc(var(--cell) * 5);
  max-width: 100%;
  min-height: 28px;
  display: flex;
  justify-content: center;
  margin: 14px auto 0;
}
.learning-stage .back-button,
.learning-stage .turn-pill,
.learning-stage .lesson-banner,
.learning-stage .daily-challenge-title,
.learning-stage .daily-moves-pill,
.learning-stage .opponent-bar,
.learning-stage .you-bar,
.learning-stage .board-score-race,
.learning-stage .board-legend { display: none !important; }
.learning-stage .campaign-progress { min-width: 0; }
.learning-stage .campaign-progress i:not(.is-complete):not(.is-current) {
  background: #d8d3df;
  box-shadow: inset 0 1px 2px rgba(43,31,79,.1);
}
.learning-stage .game-layout { order: 1; width: 100%; margin: 0; }
.learning-stage .board-column { width: 100%; }
.learning-stage .board-perspective { padding: 0; }
.learning-stage .board-frame,
.learning-stage .board-grid { width: calc(var(--cell) * 5); }
.learning-stage .table-actions {
  display: none;
}

.preview-play-stack {
  position: relative;
  z-index: 8;
  width: min(330px, calc(100% - 42px));
  display: grid;
  justify-items: center;
  gap: 30px;
  margin-top: 24px;
}

.preview-actions {
  position: static;
  width: min(300px, 100%);
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  transform: none;
}

.preview-actions .primary-button,
.preview-actions .secondary-button {
  width: 100%;
  min-width: 0;
  min-height: 64px;
}

.preview-actions .primary-button { padding-inline: 18px 14px; }
.preview-actions .secondary-button {
  border: 0;
  color: var(--theme-ink, #2d214f);
  background: var(--theme-secondary-soft, #eee7ff);
}

.preview-actions .secondary-button:hover {
  color: var(--theme-secondary-dark, var(--brand-purple-dark));
  background: color-mix(in srgb, var(--theme-secondary-soft, #eee7ff) 78%, white 22%);
}

.preview-actions .secondary-button span { color: var(--theme-secondary, var(--brand-purple)); }
.preview-actions .learn-button-copy small { color: var(--theme-muted, #777386); }
.preview-actions .learn-button-icon {
  color: white !important;
  background: var(--theme-secondary, var(--brand-purple));
}
.preview-actions .learn-button-icon .ui-icon { filter: brightness(0) invert(1) !important; }
.preview-actions .learn-button-copy { justify-content: center; color: var(--theme-secondary-dark, var(--brand-purple-dark)); }
.preview-actions .learn-button { justify-content: center; }

.daily-challenge-title {
  width: calc(var(--cell) * 5);
  display: block;
  margin: 0 auto 14px;
  color: var(--theme-ink, #2d214f);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.25;
  text-align: center;
}

.daily-challenge-title[hidden] { display: none; }
.daily-moves-pill { width: max-content; margin: 0 auto 14px; }
.daily-moves-pill[hidden] { display: none; }

.game-screen.is-daily-challenge .opponent-bar,
.game-screen.is-daily-challenge .board-score-race { display: none; }
.game-screen.is-daily-challenge .you-bar { margin-top: 12px; border-radius: 20px; }
.game-screen.is-daily-challenge .game-toolbar .turn-pill { display: none; }
.game-screen.is-daily-challenge .table-actions { align-items: center; }
.game-screen.is-daily-challenge .table-actions button { width: min(220px, 100%); }

@media (max-width: 700px) {
  .learning-stage { --cell: min(42px, 12vw); }
  .home-campaign-shell {
    grid-template-columns: minmax(30px, 1fr) minmax(0, calc(var(--cell) * 5)) minmax(30px, 1fr);
    column-gap: 0;
  }
  .home-level-nav { width: 30px; height: 30px; }
  .home-level-nav .ui-icon { width: 14px; height: 14px; }
  .hero-play-stack,
  .hero-copy .daily-challenge-button { width: 100%; max-width: none; }
  .hero-copy .hero-actions { width: 100%; }
  .daily-challenge-button:hover { transform: none; }
  .preview-play-stack { width: calc(100% - 32px); gap: 24px; margin-top: 18px; }
  .preview-actions {
    width: min(300px, 100%);
    grid-template-columns: 1fr;
  }
  .preview-actions .primary-button,
  .preview-actions .secondary-button { min-height: 60px; }
  .preview-actions .primary-button { padding-inline: 14px 11px; }
  .preview-actions .primary-button strong { font-size: 13px; }
  .preview-actions .learn-button { padding-inline: 12px; }
  .daily-challenge-title { font-size: 14px; }
  .learning-stage { padding: 30px 20px; }
}

/* Keep the homepage footer below the first desktop viewport. */
@media (min-width: 941px) {
  body:not(.is-playing) .home-screen.is-active {
    min-height: calc(100vh - 76px);
    min-height: calc(100svh - 76px);
  }
}

/* Keep the homepage cards, header controls, and footer on one shared page rail. */
:root {
  --home-page-gutter: 32px;
  --home-page-rail: 1296px;
}

body:not(.is-playing) .site-header,
body:not(.is-playing) .home-screen,
body:not(.is-playing) .site-footer {
  width: min(calc(100% - (var(--home-page-gutter) * 2)), var(--home-page-rail));
  max-width: none;
  margin-inline: auto;
}

body:not(.is-playing) .site-header,
body:not(.is-playing) .home-screen {
  padding-inline: 0;
}

@media (max-width: 940px) {
  :root { --home-page-gutter: 22px; }

  body:not(.is-playing) .hero-stage {
    margin-inline: 0;
  }
}

@media (max-width: 700px) {
  :root { --home-page-gutter: 14px; }
}

/* Keep Settings within the viewport and scroll its content below the fixed header. */
.settings-modal {
  max-height: calc(100vh - 30px);
  max-height: calc(100dvh - 30px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-modal .modal-header { flex: 0 0 auto; }

.settings-modal .settings-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

/* Homepage entry actions before learning starts and after it is complete. */
.learning-complete-card {
  width: 100%;
  min-height: 0;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 28px 20px 52px;
}

.learning-complete-card[hidden] { display: none; }

.learning-complete-panel {
  width: min(270px, 100%);
  display: grid;
  justify-items: center;
  padding: 0;
  color: var(--theme-ink, #2d214f);
  background: none;
  box-shadow: none;
  text-align: center;
}

.learning-complete-play { width: 100%; min-width: 0; }

.learning-again-button {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 0;
  border-radius: 15px;
  color: var(--theme-secondary, var(--brand-purple));
  background: var(--theme-secondary-soft, var(--brand-purple-soft));
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}

.learning-again-button:hover {
  color: white;
  background: var(--theme-secondary, var(--brand-purple));
}

@media (max-width: 700px) {
  .learning-complete-card { padding: 24px 0 36px; }
}

/* Dark-mode contrast compatibility: keep late light-theme rules from leaking through. */
body[data-theme-mode="dark"] {
  color-scheme: dark;
  --theme-primary-soft: color-mix(in srgb, var(--theme-primary) 24%, var(--theme-surface-solid));
  --theme-secondary-soft: color-mix(in srgb, var(--theme-secondary) 26%, var(--theme-surface-solid));
}

body[data-theme-mode="dark"] .site-header .brand-logo {
  filter: brightness(0) invert(1);
}

body[data-theme-mode="dark"] .site-header .brand-text-logo {
  filter: brightness(0) invert(1);
}

body[data-theme-mode="dark"] :is(
  .learning-stage,
  .modal,
  .online-modal-body,
  .settings-body,
  .rules-body,
  .statistics-body,
  .game-panel,
  .player-bar,
  .site-footer
) {
  color: var(--theme-ink);
}

body[data-theme-mode="dark"] :is(
  .learning-stage-title,
  .home-campaign-instruction,
  .modal-header h2,
  .settings-body legend,
  .settings-body label,
  .difficulty-picker b,
  .setting-row strong,
  .play-mode-choice strong,
  .player-name-form label,
  .leaderboard-table td,
  .rules-grid h3,
  .rule-intro h3,
  .result-modal h2
) {
  color: var(--theme-ink);
}

body[data-theme-mode="dark"] :is(
  .learning-stage-caption,
  .theme-help,
  .settings-player-name-form > small,
  .theme-group-heading small,
  .theme-card-copy small,
  .difficulty-picker small,
  .setting-row small,
  .settings-storage-note,
  .play-mode-choice small,
  .online-availability:not(.is-offline),
  .player-name-form p,
  .player-name-form > .name-generator-status,
  .waiting-body > p,
  .waiting-body > small,
  .leaderboard-table th,
  .leaderboard-note,
  .rules-grid p,
  .rule-intro p,
  .capture-equations small,
  .digital-ruling,
  .result-modal > p,
  .result-scores span,
  .result-secondary,
  .statistics-note,
  .site-footer p
) {
  color: var(--theme-muted);
}

body[data-theme-mode="dark"] :is(
  .header-actions .ui-icon,
  .mobile-menu-toggle .ui-icon,
  .modal-close .ui-icon,
  .back-button .ui-icon,
  .turn-pill .ui-icon,
  .table-actions button .ui-icon,
  .home-level-nav .ui-icon,
  .play-mode-choice .ui-icon,
  .player-name-input-row button .ui-icon,
  .statistics-reset .ui-icon,
  .result-replay .ui-icon
) {
  filter: brightness(0) invert(1);
}

body[data-theme-mode="dark"] .daily-challenge-title {
  color: var(--theme-ink);
}

body[data-theme-mode="dark"] :is(
  .statistics-body,
  .rules-grid article
) {
  background: transparent;
}

body[data-theme-mode="dark"] .statistics-header {
  background: linear-gradient(105deg, color-mix(in srgb, var(--theme-secondary) 18%, var(--theme-glass-strong)), color-mix(in srgb, var(--theme-primary) 10%, var(--theme-glass)));
}

body[data-theme-mode="dark"] .leaderboard-table th {
  background: var(--theme-surface-solid);
}

body[data-theme-mode="dark"] :is(
  .statistics-reset,
  .result-replay,
  .player-name-input-row button
) {
  color: var(--theme-ink);
  background: var(--theme-secondary-soft);
}

body[data-theme-mode="dark"] :is(
  .statistics-reset:hover,
  .result-replay:hover,
  .player-name-input-row button:hover
) {
  color: var(--theme-ink);
  background: color-mix(in srgb, var(--theme-secondary) 34%, var(--theme-surface-solid));
}

body[data-theme-mode="dark"] .difficulty-picker input:checked + span {
  color: var(--theme-ink);
  background: color-mix(in srgb, var(--theme-secondary) 28%, var(--theme-surface-solid));
}

body[data-theme-mode="dark"] .difficulty-picker input:checked + span b {
  color: var(--theme-ink);
}

body[data-theme-mode="dark"] .switch span {
  background: color-mix(in srgb, var(--theme-muted) 26%, var(--theme-surface-solid));
}

body[data-theme-mode="dark"] .switch span::after {
  background: var(--theme-muted);
}

body[data-theme-mode="dark"] :is(input, select, textarea)::placeholder {
  color: var(--theme-muted);
  opacity: .82;
}

/* Support page */
.support-screen {
  width: min(calc(100% - (var(--home-page-gutter) * 2)), var(--home-page-rail));
  min-height: calc(100vh - 76px);
  min-height: calc(100svh - 76px);
  margin: 0 auto;
  padding: clamp(52px, 8vh, 92px) 0 92px;
}

.support-screen.is-active {
  display: grid;
  align-content: start;
  justify-items: center;
}

.support-intro {
  width: min(620px, 100%);
  text-align: center;
}

.support-intro .eyebrow {
  justify-content: center;
  margin-bottom: 12px;
  color: var(--theme-secondary, var(--brand-purple));
}

.support-intro h1 {
  margin: 0;
  color: var(--theme-ink, var(--ink));
  font-size: clamp(38px, 5vw, 62px);
  line-height: 1;
  letter-spacing: -.055em;
}

.support-intro > p:last-child {
  max-width: 520px;
  margin: 18px auto 0;
  color: var(--theme-muted, var(--muted));
  font-size: 16px;
  line-height: 1.6;
}

.support-form {
  width: min(620px, 100%);
  display: grid;
  gap: 22px;
  margin-top: 34px;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid var(--theme-border, rgba(255,255,255,.8));
  border-radius: 30px;
  color: var(--theme-ink, var(--ink));
  background: var(--theme-glass-strong, rgba(255,255,255,.82));
  box-shadow: 0 22px 60px color-mix(in srgb, var(--theme-secondary, #5d0ae0) 12%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
}

.support-field { min-width: 0; }

.support-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.support-label-row label {
  font-size: 14px;
  font-weight: 800;
}

.support-label-row small {
  color: var(--theme-muted, var(--muted));
  font-size: 12px;
}

.support-field input,
.support-field textarea {
  width: 100%;
  border: 1px solid var(--theme-line, var(--line));
  border-radius: 16px;
  color: var(--theme-ink, var(--ink));
  background: var(--theme-surface-solid, #fff);
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.support-field input { min-height: 52px; padding: 12px 15px; }
.support-field textarea { min-height: 210px; padding: 14px 15px; resize: vertical; }

.support-field input:focus,
.support-field textarea:focus {
  border-color: var(--theme-secondary, var(--brand-purple));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--theme-secondary, #5d0ae0) 15%, transparent);
}

.support-field :is(input, textarea)[aria-invalid="true"] {
  border-color: var(--theme-strike, #ff716a);
}

.support-field-error {
  min-height: 18px;
  display: block;
  margin: 6px 2px -4px;
  color: var(--theme-strike, #c43d4a);
  font-size: 12px;
  font-weight: 700;
}

.support-submit {
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  border: 0;
  border-radius: 17px;
  color: var(--theme-primary-ink, #13251b);
  background: var(--theme-primary, var(--brand-green));
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: background .18s ease, opacity .18s ease;
}

.support-submit:hover:not(:disabled) {
  background: color-mix(in srgb, var(--theme-primary, #07e274) 82%, white 18%);
}

.support-submit:disabled { cursor: wait; opacity: .72; }
.support-submit .ui-icon { width: 17px; height: 17px; }
.support-submit-spinner { display: none; }

.support-submit.is-loading .ui-icon { display: none; }
.support-submit.is-loading .support-submit-spinner {
  width: 18px;
  height: 18px;
  display: block;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: support-spin .75s linear infinite;
}

@keyframes support-spin { to { transform: rotate(360deg); } }

.support-response {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: start;
  padding: 17px;
  border: 1px solid color-mix(in srgb, var(--theme-primary, #07e274) 30%, transparent);
  border-radius: 18px;
  color: var(--theme-ink, var(--ink));
  background: color-mix(in srgb, var(--theme-primary-soft, #e1faec) 72%, var(--theme-surface-solid, #fff));
}

.support-response[hidden] { display: none; }

.support-response > .ui-icon {
  width: 18px;
  height: 18px;
  margin: 2px auto 0;
  color: var(--theme-primary-dark, #087c45);
}

.support-response strong,
.support-response p { display: block; margin: 0; }
.support-response strong { font-size: 14px; }
.support-response p { margin-top: 3px; color: var(--theme-muted, var(--muted)); font-size: 13px; line-height: 1.45; }

.support-response button {
  grid-column: 2;
  width: max-content;
  padding: 0;
  border: 0;
  color: var(--theme-muted, var(--muted));
  background: none;
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.support-response[data-state="error"] {
  border-color: color-mix(in srgb, var(--theme-strike, #ff716a) 38%, transparent);
  background: color-mix(in srgb, var(--theme-strike, #ff716a) 11%, var(--theme-surface-solid, #fff));
}

.support-response[data-state="error"] > .ui-icon { display: none; }
.support-response[data-state="error"] { grid-template-columns: minmax(0, 1fr); }
.support-response[data-state="error"] button { grid-column: 1; }

body[data-theme-mode="dark"] .support-form {
  border-color: var(--theme-line);
  background: var(--theme-glass-strong);
}

body[data-theme-mode="dark"] .support-submit .ui-icon { filter: none; }

@media (max-width: 700px) {
  .support-screen { padding: 38px 0 64px; }
  .support-form { margin-top: 26px; padding: 22px 18px; border-radius: 24px; }
  .support-field textarea { min-height: 180px; }
}

/* Family gameplay image appears only while the homepage learning menu is shown. */
.learning-stage.is-entry,
body[data-theme] .learning-stage.is-entry {
  background:
    linear-gradient(180deg, rgba(21,14,31,.14) 0%, rgba(21,14,31,.04) 30%, rgba(21,14,31,.42) 50%, rgba(21,14,31,.18) 72%, rgba(21,14,31,.28) 100%),
    url("assets/imagery/battleten-family-mobile-play-v2.png") center 46% / cover no-repeat;
}

.learning-stage.is-entry .learning-stage-caption {
  color: rgba(255,255,255,.94);
  text-shadow: 0 2px 12px rgba(14,8,22,.42);
}

.learning-stage.is-entry .learning-stage-caption i {
  background: var(--theme-primary, var(--brand-green));
  box-shadow: 0 0 0 3px rgba(255,255,255,.2);
}

.learning-stage.is-entry .learning-complete-card {
  place-items: center;
  padding: 28px 20px 52px;
}

.learning-stage-brand {
  display: none;
}

.learning-stage.is-entry .learning-stage-brand {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 18px;
  display: block;
  width: 28px;
  height: 28px;
  filter: brightness(0) invert(1);
  opacity: .96;
  transform: translateX(-50%);
}

/* Join the two homepage cards into one composition at their shared edge. */
@media (min-width: 941px) {
  .home-screen .hero-copy { border-radius: 42px 0 0 42px; }
  .home-screen .hero-stage { border-radius: 0 42px 42px 0; }
}

@media (max-width: 940px) {
  .home-screen .hero-copy { border-radius: 34px 34px 0 0; }
  .home-screen .hero-stage { border-radius: 0 0 34px 34px; }
}

@media (max-width: 700px) {
  .learning-stage.is-entry .learning-complete-card { padding: 28px 20px; }
  .learning-stage.is-entry .learning-stage-brand { display: block; }
}

/* Keep the footer as a simple row on the page background, not a floating card. */
.site-footer,
body[data-theme] .site-footer {
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.site-footer p {
  width: 100%;
  text-align: center;
}

/* Mobile menu: a themed glass panel that floats above the page content. */
.mobile-menu-toggle,
.mobile-menu-scrim { display: none; }

@media (max-width: 700px) {
  body.mobile-menu-open { overflow: hidden; }

  .site-header {
    position: relative;
    z-index: 110;
  }

  .mobile-menu-toggle {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 14px;
    color: var(--theme-ink, #21172f);
    background: linear-gradient(145deg, var(--theme-glass-strong, rgba(255,255,255,.88)), var(--theme-glass, rgba(249,246,255,.68)));
    -webkit-backdrop-filter: blur(var(--glass-blur, 26px)) saturate(165%);
    backdrop-filter: blur(var(--glass-blur, 26px)) saturate(165%);
    box-shadow: 0 10px 28px color-mix(in srgb, var(--theme-secondary, #5d0ae0) 14%, transparent);
    cursor: pointer;
  }

  .mobile-menu-toggle .ui-icon { width: 21px; height: 21px; }

  .mobile-menu-toggle[aria-expanded="true"] {
    color: var(--theme-secondary-ink, white);
    background: var(--theme-secondary, #5d0ae0);
  }

  .mobile-menu-toggle[aria-expanded="true"] .ui-icon { filter: brightness(0) invert(1) !important; }

  .header-actions {
    position: absolute;
    z-index: 2;
    top: calc(100% - 5px);
    right: 14px;
    width: min(294px, calc(100vw - 28px));
    display: none;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px;
    overflow: hidden;
    border: 0;
    border-radius: 22px;
    color: var(--theme-ink, #21172f);
    background: linear-gradient(145deg, var(--theme-glass-strong, rgba(255,255,255,.9)), var(--theme-glass, rgba(249,246,255,.72)));
    -webkit-backdrop-filter: blur(var(--glass-blur, 26px)) saturate(175%);
    backdrop-filter: blur(var(--glass-blur, 26px)) saturate(175%);
    box-shadow: 0 22px 54px color-mix(in srgb, var(--theme-secondary, #5d0ae0) 20%, rgba(20,12,30,.16));
  }

  .header-actions.is-open {
    display: grid;
    animation: mobile-menu-in .2s ease both;
  }

  .header-actions .icon-button {
    width: 100%;
    min-height: 50px;
    justify-content: flex-start;
    gap: 12px;
    padding: 7px 10px;
    border-radius: 14px;
    color: var(--theme-ink, #21172f);
  }

  .header-actions .icon-button span { width: 35px; height: 35px; }
  .header-actions .icon-button em { display: block; }

  .mobile-menu-scrim:not([hidden]) {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: color-mix(in srgb, var(--theme-bg, #f7f8f4) 52%, transparent);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    cursor: default;
  }

  @keyframes mobile-menu-in {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}

/* Keep the two homepage entry actions only as wide as their labels require. */
.hero-copy .hero-actions {
  width: fit-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-copy .learning-complete-play {
  width: fit-content;
  min-width: 0;
}

.learning-again-button {
  width: fit-content;
  white-space: nowrap;
}

.learning-again-button[hidden] { display: none; }

/* Render the supplied spark-shaped Play SVG as an ordinary image, then choose
   black or white from the active surface's theme contrast. */
.ui-icon[data-icon="play"] {
  --play-icon-invert: 0;
  background-color: transparent;
  background-image: var(--icon-file);
  -webkit-mask-image: none;
  mask-image: none;
  filter: brightness(0) invert(var(--play-icon-invert));
}

.primary-button b .ui-icon[data-icon="play"],
.learning-again-button b .ui-icon[data-icon="play"],
.daily-challenge-button b .ui-icon[data-icon="play"],
.result-daily-secondary b .ui-icon[data-icon="play"] {
  --play-icon-invert: var(--theme-secondary-icon-invert, 1);
  filter: brightness(0) invert(var(--play-icon-invert)) !important;
}

body[data-theme-mode="dark"] .header-actions .ui-icon[data-icon="play"] {
  --play-icon-invert: 1;
}

.result-daily-secondary b { color: var(--theme-secondary-ink, white); }

.hero-copy .learning-complete-play b,
body[data-theme] .hero-copy .learning-complete-play b {
  width: 22px;
  height: 22px;
  border-radius: 0;
  color: white;
  background: transparent !important;
  box-shadow: none;
}

.hero-copy .learning-complete-play b .ui-icon {
  --play-icon-invert: var(--theme-primary-icon-invert, 1);
  width: 22px;
  height: 22px;
  opacity: 1;
  filter: brightness(0) invert(var(--play-icon-invert)) !important;
}

.hero-copy .learning-complete-play,
.hero-copy .learning-again-button {
  transform: translate3d(0, 0, 0) !important;
  transition:
    transform 320ms ease-in-out,
    color 180ms ease-in-out,
    background-color 180ms ease-in-out !important;
  will-change: transform;
}

.hero-copy .learning-complete-play:hover,
.hero-copy .learning-again-button:hover {
  transform: translate3d(0, -3px, 0) !important;
}

.hero-copy .learning-complete-play:active,
.hero-copy .learning-again-button:active {
  transform: translate3d(0, -1px, 0) !important;
}

body.reduce-motion .hero-copy .learning-complete-play,
body.reduce-motion .hero-copy .learning-complete-play:hover,
body.reduce-motion .hero-copy .learning-complete-play:active,
body.reduce-motion .hero-copy .learning-again-button,
body.reduce-motion .hero-copy .learning-again-button:hover,
body.reduce-motion .hero-copy .learning-again-button:active {
  transform: translate3d(0, 0, 0) !important;
  transition: none !important;
}

/* High-contrast secondary hover colors follow the active theme palette. */
:is(
  .secondary-button:hover:not(.is-locked),
  .learning-again-button:hover,
  .result-daily-secondary:hover,
  .result-replay:hover
) {
  color: color-mix(in srgb, var(--theme-secondary, #5d0ae0) 24%, white 76%) !important;
  background: color-mix(in srgb, var(--theme-secondary, #5d0ae0) 86%, black 14%) !important;
}

body[data-theme-mode="dark"] .toast {
  border: 1px solid var(--theme-line);
  color: var(--theme-ink);
  background: var(--theme-surface-solid);
  box-shadow: 0 16px 38px rgba(0,0,0,.32);
}

/* Compact game facts on the homepage card. */
.hero-features {
  width: min(455px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  list-style: none;
}

.hero-feature {
  position: relative;
  min-width: 0;
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border: 0;
  border-radius: 0;
  color: white;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.hero-feature + .hero-feature::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 14px;
  bottom: 14px;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,.32) 18%, rgba(255,255,255,.32) 82%, transparent);
  pointer-events: none;
}

.hero-feature-icon {
  position: relative;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  color: white;
  opacity: .8;
  box-sizing: border-box;
}

.hero-feature-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

.hero-feature-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.hero-feature-copy strong {
  color: white;
  font-size: 14px;
  line-height: 1.05;
  white-space: nowrap;
}

.hero-feature-copy small {
  color: rgba(255,255,255,.7);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.1;
  text-transform: uppercase;
}

.hero-feature-players {
  display: grid;
  place-items: center;
}

.hero-feature-age {
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: -.04em;
}

.hero-feature-clock {
  display: grid;
  place-items: center;
}

@media (max-width: 700px) {
  .hero-features { gap: 7px; }

  .hero-feature {
    min-height: 82px;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
    padding: 10px 6px;
    text-align: center;
  }

  .hero-feature-copy strong { font-size: 13px; }
  .hero-feature-copy small { font-size: 8px; }
}

/* Completed learners can replay any rule directly from the homepage image. */
.learning-again-button {
  justify-content: space-between;
}

.learning-again-button b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  border-radius: 50%;
  background: var(--theme-secondary, var(--brand-purple));
}

.learning-again-button b .ui-icon {
  --play-icon-invert: var(--theme-secondary-icon-invert, 1);
  width: 17px;
  height: 17px;
  filter: brightness(0) invert(var(--play-icon-invert)) !important;
}

.learning-complete-card.is-complete .learning-complete-panel,
.learning-complete-card.is-progress .learning-complete-panel {
  width: min(440px, 100%);
}

.learning-level-picker {
  width: min(440px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.learning-level-picker[hidden] { display: none; }

.learning-level-picker.is-partial .learning-level-section-title {
  display: none;
}

.learning-level-picker-title {
  grid-column: 1 / -1;
  margin: 0 0 4px;
  color: white;
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1;
  letter-spacing: -.03em;
  text-align: center;
  text-shadow: 0 3px 16px rgba(18,8,29,.45);
}

.learning-level-section-title {
  grid-column: 1 / -1;
  margin: 6px 0 0;
  color: rgba(255,255,255,.92);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  line-height: 1.2;
  text-align: left;
  text-shadow: 0 2px 10px rgba(18,8,29,.42);
  text-transform: uppercase;
}

.learning-level-button-showcase { grid-column: 1 / -1; }

.learning-level-button[hidden],
.learning-continue-button[hidden] {
  display: none;
}

.learning-level-button {
  min-width: 0;
  min-height: 44px;
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 7px;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 13px;
  color: var(--theme-secondary, var(--brand-purple));
  background: rgba(244,238,255,.9);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  box-shadow: 0 8px 22px rgba(20,10,35,.12);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 220ms ease-in-out, color 180ms ease-in-out, background-color 180ms ease-in-out;
}

.learning-level-button span {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--theme-primary-ink, #143425);
  background: var(--theme-primary, var(--brand-green));
  font-size: 10px;
  font-weight: 900;
}

.learning-level-button strong {
  min-width: 0;
  font-size: 11px;
  line-height: 1.15;
}

.learning-level-button:hover {
  color: white;
  background: color-mix(in srgb, var(--theme-secondary, var(--brand-purple)) 86%, black 14%);
  transform: translate3d(0, -2px, 0);
}

.learning-level-button:active { transform: translate3d(0, 0, 0); }

.learning-continue-button {
  grid-column: 1 / -1;
  min-width: 0;
  min-height: 50px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  padding: 9px 11px 9px 17px;
  border: 0;
  border-radius: 15px;
  color: var(--theme-primary-ink, #222021);
  background: var(--theme-primary, #ffe683);
  box-shadow: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: filter 180ms ease-in-out, transform 180ms ease-in-out;
}

.learning-continue-button strong {
  font-size: 13px;
  font-weight: 900;
}

.learning-continue-button b {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.28);
}

.learning-continue-button .ui-icon {
  width: 17px;
  height: 17px;
  filter: brightness(0) invert(var(--theme-primary-icon-invert, 0));
}

.learning-continue-button:hover {
  filter: brightness(1.04);
  transform: translate3d(0, -2px, 0);
}

.learning-continue-button:active { transform: none; }

body.reduce-motion .learning-level-button,
body.reduce-motion .learning-level-button:hover,
body.reduce-motion .learning-level-button:active,
body.reduce-motion .learning-continue-button,
body.reduce-motion .learning-continue-button:hover,
body.reduce-motion .learning-continue-button:active {
  transform: none;
  transition: none;
}

@media (max-width: 700px) {
  .learning-complete-card.is-complete .learning-complete-panel,
  .learning-complete-card.is-progress .learning-complete-panel,
  .learning-level-picker { width: min(320px, 100%); }

  .learning-level-button {
    min-height: 41px;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 7px;
    padding: 5px 8px 5px 6px;
  }

  .learning-level-button span { width: 28px; height: 28px; }
  .learning-level-button strong { font-size: 10px; }
  .learning-level-picker-title { font-size: 21px; }
  .learning-level-section-title { font-size: 9px; }
}

/* Flat navigation: actions stand on the page without a surrounding card. */
.header-actions,
body[data-theme] .header-actions {
  border: 0 !important;
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
}

.header-actions::before { display: none !important; content: none !important; }

@media (max-width: 700px) {
  .mobile-menu-toggle,
  .mobile-menu-toggle[aria-expanded="true"],
  body[data-theme] .mobile-menu-toggle {
    border: 0;
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
  }

  .mobile-menu-toggle[aria-expanded="true"] { color: var(--theme-secondary, #5d0ae0); }

  .header-actions {
    padding-inline: 0;
    overflow: visible;
  }
}

/* Untouched learning path: a silent, self-playing version of the real game. */
@property --preview-turn-progress {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@property --home-preview-loop-progress {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.home-gameplay-preview[hidden] { display: none; }

.learning-stage.is-preview,
body[data-theme] .learning-stage.is-preview {
  background:
    linear-gradient(180deg, rgba(21,14,31,.12) 0%, rgba(21,14,31,.03) 30%, rgba(21,14,31,.34) 52%, rgba(21,14,31,.14) 74%, rgba(21,14,31,.24) 100%),
    url("assets/imagery/battleten-family-mobile-play-v2.png") center 46% / cover no-repeat;
}

.learning-stage.is-preview .learning-stage-caption,
.learning-stage.is-preview .learning-stage-brand {
  display: none;
}

.home-preview-loop-progress {
  position: absolute;
  z-index: 6;
  inset: 8px;
  display: none;
  padding: 2px;
  border-radius: 50px;
  background:
    conic-gradient(
      from 0deg at 50% 50%,
      rgba(255,255,255,.88) 0deg var(--home-preview-loop-progress),
      rgba(255,255,255,.2) var(--home-preview-loop-progress) 360deg
    );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

.learning-stage.is-preview .home-preview-loop-progress {
  display: block;
  animation: home-preview-loop-fill 41070ms linear infinite;
}

@keyframes home-preview-loop-fill {
  to { --home-preview-loop-progress: 360deg; }
}

body.reduce-motion .learning-stage.is-preview .home-preview-loop-progress {
  --home-preview-loop-progress: 360deg;
  animation: none;
}

.home-gameplay-preview {
  position: relative;
  z-index: 2;
  min-width: 0;
  width: 100%;
  flex: 1;
  display: grid;
  place-items: center;
}

.home-preview-game {
  --cell: clamp(42px, 5.7vh, 54px);
  width: min(100%, calc((var(--cell) * 5) + 132px));
  display: grid;
  grid-template-columns: 48px calc(var(--cell) * 5) 48px;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.learning-stage .home-preview-board-frame {
  position: relative;
  width: calc(var(--cell) * 5);
  height: calc(var(--cell) * 8);
}

.learning-stage .home-preview-board {
  width: calc(var(--cell) * 5);
  height: calc(var(--cell) * 8);
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

.home-preview-cell {
  pointer-events: none;
}

.home-preview-cell.is-preview-impact {
  animation: home-preview-impact 680ms ease-out;
}

.home-preview-cell.is-preview-impact::after {
  content: "";
  position: absolute;
  z-index: 5;
  inset: 12%;
  border: 4px solid var(--theme-strike, #ff716a);
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  animation: home-preview-impact-ring 680ms ease-out;
}

.home-preview-score {
  --preview-score: 0%;
  --preview-score-color: var(--theme-secondary, #5d0ae0);
  --preview-score-ink: #fff;
  --preview-countdown-color: var(--theme-primary, #07e274);
  position: relative;
  width: 48px;
  height: calc((var(--cell) * 8) - 44px);
  margin-block: 22px;
  color: var(--preview-score-color);
}

.home-preview-score-human {
  --preview-score-color: var(--theme-primary, #07e274);
  --preview-score-ink: var(--theme-primary-ink, #143425);
  --preview-countdown-color: var(--theme-secondary, #5d0ae0);
}

.home-preview-score-track {
  position: absolute;
  inset: 0 auto 0 50%;
  width: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--preview-score-color) 14%, #fff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--preview-score-color) 18%, transparent);
  transform: translateX(-50%);
}

/* Center the three direct play choices in a single vertical stack. */
.hero-copy .hero-actions {
  width: min(260px, 100%);
  display: grid;
  grid-template-columns: 1fr;
  align-self: center;
  align-items: stretch;
  justify-items: stretch;
  gap: 10px;
}

.hero-play-options {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.hero-copy .hero-play-option,
body[data-theme] .hero-copy .hero-play-option {
  --mode-accent: var(--theme-primary, var(--brand-green));
  --mode-ink: var(--theme-primary-ink, #fff);
  --mode-icon-invert: var(--theme-primary-icon-invert, 1);
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto;
  gap: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 20px;
  color: var(--mode-ink);
  background: transparent;
  box-shadow: none;
  text-align: left;
  transform: translate3d(0, 0, 0) !important;
  transition: transform 260ms ease, box-shadow 260ms ease, border-color 180ms ease !important;
  will-change: transform;
}

.hero-copy .hero-play-option::before,
.hero-copy .hero-play-option::after {
  position: absolute;
  z-index: 20;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 5px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.hero-copy .hero-play-option::before {
  bottom: calc(100% + 1px);
  border: 6px solid transparent;
  border-top-color: rgba(0,0,0,.84);
  content: "";
}

.hero-copy .hero-play-option::after {
  bottom: calc(100% + 13px);
  width: min(220px, calc(100vw - 32px));
  padding: 8px 10px;
  border-radius: 8px;
  color: #fff;
  background: rgba(0,0,0,.84);
  box-shadow: 0 8px 22px rgba(0,0,0,.2);
  content: attr(data-description);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
}

.hero-copy .hero-play-option:hover,
.hero-copy .hero-play-option:focus-visible {
  z-index: 12;
}

.hero-copy .hero-play-option:hover::before,
.hero-copy .hero-play-option:hover::after,
.hero-copy .hero-play-option:focus-visible::before,
.hero-copy .hero-play-option:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hero-copy .hero-play-live {
  --mode-accent: #fff;
  --mode-ink: var(--theme-ink, #222021);
  --mode-icon-invert: 0;
}

.hero-play-friend {
  --mode-accent: #1675e8;
  --mode-ink: #fff;
  --mode-icon-invert: 1;
}

body[data-theme] .hero-copy .hero-play-option,
body[data-theme] .hero-copy .hero-play-option:hover {
  border-color: transparent;
  color: var(--mode-ink);
  background: transparent;
}

.hero-copy .hero-play-live .hero-mode-footer,
.hero-copy .hero-play-live .hero-mode-footer span {
  color: var(--mode-ink);
}

.hero-copy .hero-play-live .hero-footer-play-icon {
  background: color-mix(in srgb, var(--theme-secondary, #ff3363) 18%, transparent);
}

body[data-theme] .hero-copy .hero-play-option:hover {
  box-shadow: none;
  transform: translate3d(0, -7px, 0) !important;
  filter: none;
}

.hero-copy .hero-play-option:active {
  transform: translate3d(0, -3px, 0) !important;
}

.hero-mode-footer {
  min-width: 0;
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 16px;
  color: var(--mode-ink);
  background: var(--mode-accent);
  border-radius: 20px;
  text-align: left;
}

.hero-mode-footer-invite {
  grid-template-columns: minmax(0, 1fr) 22px;
}

.primary-button.compact .hero-mode-footer > strong {
  grid-column: auto;
  color: inherit;
  font-size: 16px;
  line-height: 1.05;
}

.hero-footer-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.hero-footer-play-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
}

.hero-footer-icon .ui-icon {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(var(--mode-icon-invert)) !important;
}

.hero-action-play {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.learning-again-button .hero-action-play {
  background: var(--theme-secondary, var(--brand-purple));
}

.hero-action-play .ui-icon {
  width: 18px;
  height: 18px;
}

.learning-again-button .hero-action-play .ui-icon {
  --play-icon-invert: var(--theme-secondary-icon-invert, 1);
  filter: brightness(0) invert(var(--play-icon-invert)) !important;
}

.hero-action-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
  text-align: start;
}

.hero-action-copy strong,
.hero-action-copy small {
  display: block;
  grid-column: 1;
  overflow: hidden;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-action-copy strong {
  font-size: 16px;
}

.hero-action-copy small {
  color: currentColor;
  font-size: 12px;
  font-weight: 700;
  opacity: .68;
}

.hero-mode-action-copy {
  align-self: center;
  gap: 2px;
  color: inherit;
}

.hero-mode-action-copy strong {
  color: inherit;
}

.hero-action-copy .hero-live-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  overflow: visible;
  cursor: default;
}

.hero-live-status[hidden] { display: none !important; }

.hero-live-status > i {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--theme-secondary, #ff3363);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-secondary, #ff3363) 18%, transparent);
  animation: online-player-pulse 1.8s ease-in-out infinite;
}

.hero-live-status #homeOnlinePlayerCount {
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent !important;
  box-shadow: none;
  font-size: inherit;
  font-weight: 950;
}

.hero-live-status::after {
  position: absolute;
  z-index: 8;
  top: calc(100% + 7px);
  left: 50%;
  padding: 6px 9px;
  border-radius: 7px;
  color: #fff;
  background: rgba(0, 0, 0, .82);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  content: attr(data-tooltip);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  text-transform: none;
  transform: translate(-50%, -3px);
  transition: opacity 150ms ease, transform 150ms ease;
  white-space: nowrap;
}

.hero-live-status:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.reduce-motion .hero-copy .hero-play-option,
body.reduce-motion .hero-copy .hero-play-option:hover,
body.reduce-motion .hero-copy .hero-play-option:active {
  transform: translate3d(0, 0, 0) !important;
  transition: none !important;
}

.hero-copy .lock-note {
  align-self: center;
  text-align: center;
}

.hero-copy .hero-trust-note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: color-mix(in srgb, var(--theme-secondary-ink, #fff) 78%, transparent);
  font-weight: 700;
}

.hero-copy .hero-trust-note img {
  width: 16px;
  height: 16px;
  display: block;
  flex: 0 0 16px;
  filter: brightness(0) invert(var(--theme-secondary-icon-invert, 1));
  opacity: .72;
}

body[data-theme="tenza-pop"] .hero-copy .hero-trust-note {
  color: rgba(255, 255, 255, .82);
}

body[data-theme="tenza-pop"] .hero-copy .hero-trust-note img {
  filter: brightness(0) invert(1);
}

.learning-stage .stage-rules-button {
  position: relative;
  z-index: 7;
  align-self: center;
  margin: 10px auto 0;
}

.learning-stage .stage-rules-button {
  width: min(190px, calc(100% - 32px));
  justify-content: space-between;
}

@media (max-width: 700px) {
  .hero-play-options {
    gap: 6px;
  }

  .hero-mode-footer {
    min-height: 43px;
    grid-template-columns: minmax(0, 1fr) 26px;
    gap: 4px;
    padding: 7px;
  }
  .hero-mode-footer-invite { grid-template-columns: minmax(0, 1fr) 18px; }
  .primary-button.compact .hero-mode-footer > strong { font-size: 9px; }
  .hero-footer-icon { width: 18px; height: 18px; }
  .hero-footer-play-icon { width: 26px; height: 26px; }
  .hero-footer-icon .ui-icon { width: 15px; height: 15px; }
  .hero-mode-action-copy { gap: 1px; }
  .hero-mode-action-copy strong { font-size: 10px; }
  .hero-mode-action-copy small { font-size: 8px; }
  .hero-live-status > i {
    width: 5px;
    height: 5px;
    flex-basis: 5px;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-secondary, #ff3363) 18%, transparent);
  }
  .hero-copy .hero-actions { width: min(260px, 100%); }
}

.home-preview-score-track i {
  position: absolute;
  inset: auto 0 0;
  height: var(--preview-score);
  border-radius: inherit;
  background: var(--preview-score-color);
  transition: height 500ms cubic-bezier(.16,.82,.25,1);
}

.home-preview-score-ai .home-preview-score-track i {
  inset: 0 0 auto;
}

.home-preview-score-thumb {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: var(--preview-score);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--preview-score-ink);
  background: var(--preview-score-color);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--preview-score-color) 28%, transparent);
  transform: translate(-50%, 50%);
  transition: bottom 500ms cubic-bezier(.16,.82,.25,1);
}

.home-preview-score-ai .home-preview-score-thumb {
  top: var(--preview-score);
  bottom: auto;
  transform: translate(-50%, -50%);
  transition: top 500ms cubic-bezier(.16,.82,.25,1);
}

.home-preview-score-thumb strong {
  position: relative;
  z-index: 2;
  font-size: 14px;
  font-weight: 950;
  line-height: 1;
}

.home-preview-countdown {
  --preview-turn-progress: 0deg;
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  color: var(--preview-countdown-color);
  background: conic-gradient(currentColor var(--preview-turn-progress), rgba(117,104,132,.16) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  opacity: 0;
}

.home-preview-score.is-counting .home-preview-countdown {
  opacity: 1;
  animation: home-preview-countdown-fill 2s linear forwards;
}

.home-preview-move-text {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 50%;
  width: min(calc(var(--cell) * 5), 92vw);
  margin: 0;
  padding: 12px 16px;
  color: #fff;
  background: transparent;
  text-shadow: 0 3px 0 rgba(58,25,135,.45), 0 7px 18px rgba(52,26,110,.3);
  font-size: clamp(24px, 4.2vw, 42px);
  font-weight: 950;
  letter-spacing: .04em;
  line-height: .98;
  text-align: center;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.72);
}

.home-preview-move-text.is-visible {
  animation: move-celebration-pop 1.8s cubic-bezier(.16,.8,.22,1) both;
}

@keyframes home-preview-countdown-fill {
  from { --preview-turn-progress: 0deg; }
  to { --preview-turn-progress: 360deg; }
}

@keyframes home-preview-impact {
  45% { background: color-mix(in srgb, var(--theme-strike, #ff716a) 18%, #fff) !important; }
}

@keyframes home-preview-impact-ring {
  0% { opacity: .9; scale: .55; }
  100% { opacity: 0; scale: 1.35; }
}

body.reduce-motion .home-preview-score.is-counting .home-preview-countdown,
body.reduce-motion .home-preview-move-text.is-visible,
body.reduce-motion .home-preview-cell.is-preview-impact,
body.reduce-motion .home-preview-cell.is-preview-impact::after {
  animation-duration: 1ms;
}

@media (max-width: 700px) {
  .home-preview-game {
    --cell: min(42px, 11.5vw);
    width: min(100%, calc((var(--cell) * 5) + 96px));
    grid-template-columns: 38px calc(var(--cell) * 5) 38px;
    gap: 10px;
  }

  .home-preview-score { width: 38px; }
  .home-preview-score-thumb { width: 38px; height: 38px; }
  .home-preview-score-thumb strong { font-size: 12px; }
  .home-preview-move-text { font-size: clamp(22px, 8vw, 34px); }
}

@keyframes online-player-pulse {
  50% { opacity: .58; transform: scale(.82); }
}

body.reduce-motion .hero-live-status > i {
  animation: none;
}

/* Desktop SVG wordmark beside the compact tenza logo. */
.brand-text-logo {
  display: none;
}

@media (min-width: 701px) {
  .site-header .brand {
    width: auto;
    height: 34px;
    gap: 10px;
  }

  .site-header .brand-copy {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    align-items: center;
    justify-content: center;
    line-height: 0;
  }

  .site-header .brand-text-logo {
    width: auto;
    height: 14px;
    display: block;
    flex: 0 0 auto;
  }
}

/* Pointer drag-and-drop for the shared full-game and learning board. */
.cell.has-human-piece {
  cursor: grab;
  touch-action: none;
}

.board-grid.is-piece-dragging,
body.is-dragging-piece {
  cursor: grabbing;
  user-select: none;
}

.board-grid.is-piece-dragging {
  touch-action: none;
}

.piece.is-drag-source {
  opacity: 0 !important;
}

.drag-piece-ghost {
  position: fixed !important;
  z-index: 1000 !important;
  left: 0;
  top: 0;
  width: var(--drag-size, 40px) !important;
  height: var(--drag-size, 40px) !important;
  margin: 0 !important;
  pointer-events: none !important;
  opacity: .98;
  filter: brightness(1.05);
  transform: translate(-50%, -50%) scale(1.1) !important;
  will-change: left, top, transform, opacity;
}

.drag-piece-ghost.is-returning {
  opacity: .84;
  transform: translate(-50%, -50%) scale(.92) !important;
  transition:
    left 280ms cubic-bezier(.2,.8,.2,1),
    top 280ms cubic-bezier(.2,.8,.2,1),
    transform 280ms cubic-bezier(.2,.8,.2,1),
    opacity 280ms ease;
}

.drag-piece-ghost.is-dropping {
  opacity: 0;
  transform: translate(-50%, -50%) scale(.94) !important;
  transition:
    left 130ms ease-out,
    top 130ms ease-out,
    transform 150ms ease-out,
    opacity 150ms ease-out;
}

.drag-piece-ghost.is-awaiting-drop {
  transform: translate(-50%, -50%) scale(1) !important;
  transition: left 130ms ease-out, top 130ms ease-out, transform 130ms ease-out;
}

/* Portal travel vanishes at the source and materializes at the destination. */
.piece.is-portal-departing {
  z-index: 20;
  pointer-events: none;
  transform-origin: center;
  animation: portal-pawn-depart 320ms ease-out both !important;
  will-change: scale, opacity, filter;
}

.piece.is-portal-arriving {
  pointer-events: none;
  transform-origin: center;
  animation: portal-pawn-arrive 380ms ease-in both !important;
  will-change: scale, opacity, filter;
}

@keyframes portal-pawn-depart {
  from { scale: 1; opacity: 1; filter: brightness(1); }
  to { scale: 0; opacity: 0; filter: brightness(1.3); }
}

@keyframes portal-pawn-arrive {
  from { scale: 0; opacity: 0; filter: brightness(1.35); }
  to { scale: 1; opacity: 1; filter: brightness(1); }
}

body.reduce-motion .piece.is-portal-departing,
body.reduce-motion .piece.is-portal-arriving {
  animation-duration: 1ms !important;
}

/*
 * Shared Spark progress geometry.
 * The 3px stroke sits outside a 2px clear gap around the 68%-wide pawn.
 * Its outer radius resolves to the pawn's 30% radius plus the full 5px offset,
 * so the rounded-square corners remain parallel at every board size.
 */
.portal-charge-ring {
  --portal-gap: 2px;
  --portal-stroke: 3px;
  --portal-outer-offset: calc(var(--portal-gap) + var(--portal-stroke));
  width: calc(68% + var(--portal-outer-offset) + var(--portal-outer-offset));
  height: calc(68% + var(--portal-outer-offset) + var(--portal-outer-offset));
  padding: var(--portal-stroke);
  border-radius: calc(30% + 2px);
}

/*
 * Branded pawn numerals use real image elements so local previews and hosted
 * games render identically. The source artwork is black; theme-aware inversion
 * retains the established dark/white contrast for each player's pawn.
 */
.piece[data-owner="human"] { --pawn-number-invert: 0; }
.piece[data-owner="ai"] { --pawn-number-invert: 1; }

body[data-theme="cv-blue-orange"] .piece[data-owner="human"] { --pawn-number-invert: 1; }
body[data-theme="cv-blue-orange"] .piece[data-owner="ai"],
body[data-theme="cv-cyan-magenta"] .piece[data-owner="ai"] { --pawn-number-invert: 0; }

.pawn-number-icon {
  width: 64%;
  height: 64%;
  display: block;
  flex: 0 0 64%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  filter: brightness(0) invert(var(--pawn-number-invert, 0));
}

.cell.is-drag-target {
  box-shadow:
    inset 0 0 0 4px color-mix(in srgb, var(--theme-primary, #07e274) 78%, white),
    0 0 18px color-mix(in srgb, var(--theme-primary, #07e274) 38%, transparent) !important;
}

.cell.is-drag-invalid {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--theme-strike, #ff716a) 72%, transparent) !important;
}

.home-preview-drag-ghost {
  z-index: 40 !important;
  transition:
    left 650ms cubic-bezier(.22,.72,.2,1),
    top 650ms cubic-bezier(.22,.72,.2,1),
    transform 180ms ease,
    filter 180ms ease;
}

.home-preview-drag-ghost.is-preview-travelling {
  filter: brightness(1.12);
  transform: translate(-50%, -50%) scale(1.16) !important;
}

body.reduce-motion .drag-piece-ghost,
body.reduce-motion .home-preview-drag-ghost {
  transition-duration: 1ms !important;
}

/* Real tables use the same circular score sliders as the homepage demo. */
@property --turn-countdown-progress {
  syntax: "<angle>";
  inherits: false;
  initial-value: 360deg;
}

.board-progress {
  --turn-countdown-progress: 360deg;
  --score-color: var(--theme-secondary, #5d0ae0);
  --score-ink: var(--theme-secondary-ink, #fff);
  --turn-ring-color: var(--theme-primary, #07e274);
  top: 22px;
  bottom: 22px;
  width: 48px;
}

.board-progress-human {
  --score-color: var(--theme-primary, #07e274);
  --score-ink: var(--theme-primary-ink, #143425);
  --turn-ring-color: var(--theme-secondary, #5d0ae0);
  right: -66px;
}

.board-progress-ai {
  left: -66px;
}

.board-progress-track,
.board-progress-ai .board-progress-track,
.board-progress-human .board-progress-track {
  inset: 0 auto 0 50%;
  width: 8px;
  border: 0;
  background: color-mix(in srgb, var(--score-color) 14%, #fff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--score-color) 18%, transparent);
  transform: translateX(-50%);
}

.board-progress-track i,
.board-progress-ai .board-progress-track i,
.board-progress-human .board-progress-track i {
  background: var(--score-color);
  box-shadow: none;
}

.board-progress-marker,
.board-progress-ai .board-progress-marker,
.board-progress-human .board-progress-marker,
body[data-theme] .board-progress-ai .board-progress-marker,
body[data-theme] .board-progress-human .board-progress-marker {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  color: var(--score-ink);
  background: var(--score-color);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--score-color) 28%, transparent);
}

.board-progress-ai .board-progress-marker {
  top: var(--progress);
  bottom: auto;
  transform: translate(-50%, -50%);
}

.board-progress-human .board-progress-marker {
  top: auto;
  bottom: var(--progress);
  transform: translate(-50%, 50%);
}

.board-progress-marker b {
  position: relative;
  z-index: 2;
  font-size: 14px;
  font-weight: 950;
}

.board-turn-countdown {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  color: var(--turn-ring-color);
  background: conic-gradient(currentColor var(--turn-countdown-progress), rgba(117,104,132,.16) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  opacity: 0;
}

.board-progress.is-turn-counting .board-turn-countdown {
  opacity: 1;
  animation: board-turn-countdown var(--turn-countdown-duration, 300000ms) linear forwards;
  animation-delay: var(--turn-countdown-delay, 0ms);
}

@keyframes board-turn-countdown {
  from { --turn-countdown-progress: 360deg; }
  to { --turn-countdown-progress: 0deg; }
}

.learning-stage .board-score-race {
  display: block !important;
}

@media (max-width: 700px) {
  .board-progress {
    top: 19px;
    bottom: 19px;
    width: 38px;
  }

  .board-progress-ai { left: -48px; }
  .board-progress-human { right: -48px; }

  .board-progress-marker,
  .board-progress-ai .board-progress-marker,
  .board-progress-human .board-progress-marker,
  body[data-theme] .board-progress-ai .board-progress-marker,
  body[data-theme] .board-progress-human .board-progress-marker {
    width: 38px;
    height: 38px;
  }

  .board-progress-marker b { font-size: 12px; }

}

/* Keep the brand and navigation controls on one vertical center line. The
   opened mobile navigation is a distinct blurred glass card. */
.site-header {
  align-items: center;
}

.site-header > .brand,
.site-header > .header-actions,
.site-header > .mobile-menu-toggle {
  align-self: center;
  margin-block: 0;
}

.site-header .brand,
.site-header .brand-copy,
.site-header .header-actions {
  align-items: center;
}

.site-header .brand-logo,
.site-header .brand-text-logo,
.site-header .mobile-menu-toggle .ui-icon {
  margin-block: 0;
}

@media (max-width: 700px) {
  .site-header > .brand,
  .site-header > .mobile-menu-toggle {
    height: 44px;
  }

  .site-header .brand-copy {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .site-header .header-actions {
    top: calc(100% + 8px);
    right: 0;
  }

  .site-header .header-actions.is-open,
  body[data-theme] .site-header .header-actions.is-open {
    padding: 10px !important;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, white 56%, transparent) !important;
    background:
      linear-gradient(
        145deg,
        var(--theme-glass-strong, rgba(255,255,255,.9)),
        var(--theme-glass, rgba(249,246,255,.72))
      ) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur, 26px)) saturate(175%) !important;
    backdrop-filter: blur(var(--glass-blur, 26px)) saturate(175%) !important;
    box-shadow:
      0 22px 54px color-mix(in srgb, var(--theme-secondary, #5d0ae0) 22%, rgba(20,12,30,.2)),
      inset 0 1px 0 rgba(255,255,255,.72) !important;
  }
}

/* Desktop homepage cards size to their tallest content instead of stretching
   to the viewport. The page itself still fills the first viewport. */
.home-screen.is-active {
  gap: 5px;
}

@media (min-width: 941px) {
  body:not(.is-playing) .home-screen.is-active {
    grid-template-rows: max-content;
    align-content: center;
    align-items: stretch;
  }

  .home-screen .hero-copy,
  .home-screen .hero-stage {
    height: auto;
    min-height: 0;
    margin: 0;
    border-radius: 58px;
  }
}

@media (max-width: 940px) {
  body:not(.is-playing) .home-screen.is-active {
    gap: 5px;
  }

  .home-screen .hero-copy,
  .home-screen .hero-stage {
    border-radius: 58px;
  }
}

/* The untouched-player preview keeps the same caption and bottom mark as the
   photographed learning entry state. */
.learning-stage.is-preview .learning-stage-caption {
  display: flex;
  color: rgba(255,255,255,.94);
  text-shadow: 0 2px 12px rgba(14,8,22,.42);
}

.learning-stage.is-preview .learning-stage-caption i {
  background: var(--theme-primary, var(--brand-green));
  box-shadow: 0 0 0 3px rgba(255,255,255,.2);
}

.learning-stage.is-preview .learning-stage-brand {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 18px;
  display: block;
  width: 28px;
  height: 28px;
  filter: brightness(0) invert(1);
  opacity: .96;
  transform: translateX(-50%);
}

/* Private invitations receive a backend-generated QR while the host waits. */
.waiting-modal {
  overflow-x: hidden;
  overflow-y: auto;
}

.invite-qr-card {
  width: clamp(188px, 38vw, 220px);
  margin: 0 auto 14px;
  padding: 10px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(34, 32, 33, .14);
}

.invite-qr-card[hidden] {
  display: none;
}

.invite-qr-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
}

@media (max-height: 620px) {
  .invite-qr-card {
    width: 172px;
    padding: 8px;
    border-radius: 20px;
  }

  .waiting-body > p {
    margin-block: 8px 12px;
  }
}

/* Theme-aware mode cards shared visually with the redesigned landing hero. */
.hero-copy .hero-actions {
  width: min(440px, 100%);
}

.hero-copy .hero-play-option,
body[data-theme] .hero-copy .hero-play-option {
  --mode-surface: var(--theme-primary, #ffe683);
  --mode-ink: var(--theme-primary-ink, #222021);
  --mode-border: color-mix(in srgb, var(--theme-ink, #222021) 82%, transparent);
  --mode-icon-surface: color-mix(in srgb, var(--theme-surface-solid, #fff) 40%, transparent);
  --mode-icon-invert: var(--theme-primary-icon-invert, 0);
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  overflow: visible;
  border: 0 !important;
  border-radius: 18px;
  color: var(--mode-ink);
  background: var(--mode-surface);
  box-shadow: none;
  text-align: left;
  transform: translate3d(0, 0, 0) !important;
  transition:
    transform 220ms cubic-bezier(.2, .75, .2, 1),
    border-color 180ms ease,
    background-color 180ms ease !important;
}

.hero-copy .hero-play-solo,
body[data-theme] .hero-copy .hero-play-solo {
  --mode-surface: var(--theme-primary, #ffe683);
  --mode-ink: var(--theme-primary-ink, #222021);
}

.hero-copy .hero-play-live,
body[data-theme] .hero-copy .hero-play-live {
  --mode-surface: var(--theme-surface-solid, #fff);
  --mode-ink: var(--theme-ink, #222021);
  --mode-border: var(--theme-line, rgba(34, 32, 33, .16));
  --mode-icon-surface: color-mix(in srgb, var(--theme-secondary, #ff3363) 10%, var(--theme-surface-solid, #fff));
  --mode-icon-invert: 0;
}

.hero-copy .hero-play-friend,
body[data-theme] .hero-copy .hero-play-friend {
  --mode-surface: var(--theme-ink, #222021);
  --mode-ink: var(--theme-bg, #fff);
  --mode-border: transparent;
  --mode-icon-surface: color-mix(in srgb, var(--theme-bg, #fff) 13%, transparent);
  --mode-icon-invert: 1;
}

body[data-theme-mode="dark"] .hero-copy .hero-play-live {
  --mode-icon-invert: 1;
}

body[data-theme-mode="dark"] .hero-copy .hero-play-friend {
  --mode-icon-invert: 0;
}

.hero-copy .hero-play-option:hover,
.hero-copy .hero-play-option:focus-visible,
body[data-theme] .hero-copy .hero-play-option:hover,
body[data-theme] .hero-copy .hero-play-option:focus-visible {
  color: var(--mode-ink);
  background: color-mix(in srgb, var(--mode-surface) 92%, var(--theme-surface-solid, #fff) 8%);
  box-shadow: none;
  filter: none;
  transform: translate3d(0, -5px, 0) !important;
}

.hero-copy .hero-play-option:active,
body[data-theme] .hero-copy .hero-play-option:active {
  transform: translate3d(0, -2px, 0) !important;
}

.hero-choice-icon,
.hero-choice-arrow {
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--mode-icon-surface);
}

.hero-choice-icon {
  width: 44px;
  height: 44px;
}

.hero-choice-arrow {
  width: 38px;
  height: 38px;
}

.hero-choice-icon img,
.hero-choice-arrow img {
  display: block;
  filter: brightness(0) invert(var(--mode-icon-invert));
}

.hero-copy .hero-play-option .hero-action-copy {
  min-width: 0;
  gap: 3px;
  color: inherit;
}

.hero-copy .hero-play-option .hero-action-copy strong {
  color: inherit;
  font-size: 15px;
  line-height: 1.05;
}

.hero-copy .hero-play-option .hero-action-copy small {
  color: inherit;
  font-size: 10px;
  font-weight: 750;
  opacity: .67;
}

.hero-copy .hero-play-option .hero-live-status {
  opacity: 1;
}

/* Keep tooltip copy in data-description for a future return, but do not render it. */
.hero-copy .hero-play-option::before,
.hero-copy .hero-play-option::after {
  display: none;
}

body.reduce-motion .hero-copy .hero-play-option,
body.reduce-motion .hero-copy .hero-play-option:hover,
body.reduce-motion .hero-copy .hero-play-option:focus-visible,
body.reduce-motion .hero-copy .hero-play-option:active {
  transform: translate3d(0, 0, 0) !important;
  transition: none !important;
}

/* Minimal player labels and a fixed target at the end of each score rail. */
.player-bar,
body[data-theme] .player-bar {
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 48px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none !important;
}

.player-bar .avatar {
  border-radius: 30%;
  box-shadow: none;
}

.player-bar .score-block[hidden] {
  display: none !important;
}

.board-progress-target {
  position: absolute;
  left: 50%;
  z-index: 1;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--score-ink);
  background: var(--score-color);
  box-shadow: none;
  font-variant-numeric: tabular-nums;
}

.board-progress-target b {
  font-size: 14px;
  font-weight: 950;
  line-height: 1;
}

.board-progress-ai .board-progress-target {
  bottom: 0;
  transform: translate(-50%, 50%);
}

.board-progress-human .board-progress-target {
  top: 0;
  transform: translate(-50%, -50%);
}

@media (max-width: 700px) {
  .board-progress-target {
    width: 38px;
    height: 38px;
  }

  .board-progress-target b {
    font-size: 12px;
  }

  .hero-copy .hero-actions {
    width: min(440px, 100%);
  }

  .hero-copy .hero-play-option,
  body[data-theme] .hero-copy .hero-play-option {
    min-height: 62px;
    grid-template-columns: 40px minmax(0, 1fr) 34px;
    gap: 9px;
    padding: 7px 9px;
    border-radius: 17px;
  }

  .hero-choice-icon {
    width: 40px;
    height: 40px;
  }

  .hero-choice-arrow {
    width: 34px;
    height: 34px;
  }
}

/* Make turn ownership immediately visible on the real game board. */
.game-screen .board-grid .piece {
  transition: opacity 180ms ease, filter 180ms ease;
}

.game-screen.is-opponent-turn .board-grid .piece {
  opacity: .42;
  filter: saturate(.38) brightness(1.08);
}

.game-screen.is-opponent-turn .cell.has-human-piece {
  cursor: not-allowed;
}

/*
 * On phones, size the board after reserving room for both score rails.
 * The board, two 38px slider thumbs, rail gaps, and screen padding therefore
 * form one centered unit that never extends beyond the viewport.
 */
@media (max-width: 700px) {
  .game-screen:not(.is-daily-challenge) {
    --mobile-score-rail: 42px;
    --cell: min(
      64px,
      calc(
        (
          100vw
          - 16px
          - env(safe-area-inset-left, 0px)
          - env(safe-area-inset-right, 0px)
          - var(--mobile-score-rail)
          - var(--mobile-score-rail)
        ) / 5
      )
    );
  }

  .game-screen:not(.is-daily-challenge) .board-column {
    width: 100%;
  }

  .game-screen:not(.is-daily-challenge) .board-progress-ai {
    left: calc(0px - var(--mobile-score-rail));
  }

  .game-screen:not(.is-daily-challenge) .board-progress-human {
    right: calc(0px - var(--mobile-score-rail));
  }
}

/* In-game rules stay above the current match and never replace its state. */
.game-rules-button {
  grid-column: 2;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  justify-self: center;
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  color: var(--theme-ink, #23162f);
  background: var(--theme-glass-strong, rgba(255,255,255,.92));
  box-shadow: 0 10px 28px rgba(35,22,47,.08);
  font: inherit;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  cursor: pointer;
}

.game-rules-button[hidden] { display: none !important; }
.game-rules-button:hover { color: var(--theme-secondary, #5d0ae0); }
.game-rules-button .ui-icon { width: 14px; height: 14px; }

.rules-modal {
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: none;
  border-radius: 0;
  animation: fade-in .2s both;
}

.rules-learning-browser {
  position: relative;
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.rules-level-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-content: start;
  gap: 7px;
}

.rules-level-tabs button {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--theme-line, rgba(35,22,47,.1));
  border-radius: 13px;
  color: var(--theme-ink, #23162f);
  background: var(--theme-glass-strong, #fff);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.rules-level-tabs button > span {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--theme-primary-ink, #143425);
  background: var(--theme-primary, #07e274);
  font-size: 9px;
  font-weight: 950;
}

.rules-level-tabs button > strong {
  min-width: 0;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.rules-level-tabs button:hover,
.rules-level-tabs button.is-active {
  border-color: var(--theme-secondary, #5d0ae0);
  color: var(--theme-secondary-ink, #fff);
  background: var(--theme-secondary, #5d0ae0);
}

.rules-level-tabs button:focus-visible,
.rules-learning-panel:focus-within {
  outline: 3px solid color-mix(in srgb, var(--theme-secondary, #5d0ae0) 28%, transparent);
  outline-offset: 2px;
}

.rules-level-tabs button.is-complete > span {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--theme-secondary, #5d0ae0) 42%, transparent);
}

.rules-learning-panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, .72fr) minmax(340px, 1.28fr);
  overflow: auto;
  border: 1px solid var(--theme-line, rgba(35,22,47,.1));
  border-radius: 22px;
  background: var(--theme-bg, #f7f7f3);
}

.rules-learning-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: clamp(22px, 4vw, 52px);
  border-right: 1px solid var(--theme-line, rgba(35,22,47,.1));
  background: var(--theme-surface-solid, #fffdf9);
}

.rules-learning-kicker {
  color: var(--theme-secondary, #5d0ae0);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.rules-learning-copy h3 {
  margin: 10px 0 14px;
  color: var(--theme-ink, #23162f);
  font-size: clamp(34px, 4.2vw, 64px);
  line-height: .95;
  letter-spacing: -.055em;
}

.rules-learning-copy > p {
  max-width: 44ch;
  margin: 0;
  color: var(--theme-muted, #716b7e);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.55;
}

.rules-learning-status {
  width: 100%;
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--theme-secondary, #5d0ae0) 16%, transparent);
  border-radius: 15px;
  color: var(--theme-ink, #23162f);
  background: color-mix(in srgb, var(--theme-secondary, #5d0ae0) 8%, var(--theme-surface-solid, #fffdf9));
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.rules-learning-status[data-state="complete"] {
  border-color: color-mix(in srgb, var(--theme-primary, #07e274) 38%, transparent);
  background: color-mix(in srgb, var(--theme-primary, #07e274) 14%, var(--theme-surface-solid, #fffdf9));
}

.rules-learning-caption {
  margin-top: 14px !important;
  font-size: 12px !important;
}

.rules-learning-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: auto;
  padding-top: 24px;
}

.rules-learning-actions button {
  min-height: 42px;
}

.rules-learning-board-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: clamp(14px, 3vw, 34px);
  container-type: inline-size;
}

.rules-learning-board {
  --cell: min(72px, 16cqi, 8dvh);
  width: calc(var(--cell) * 5);
  height: calc(var(--cell) * var(--board-rows, 8));
  flex: none;
  transition: none;
}

.rules-learning-board[data-rows="4"] { --cell: min(78px, 16cqi, 14dvh); }
.rules-learning-board[data-rows="6"] { --cell: min(74px, 16cqi, 10.5dvh); }

.rules-learning-board .cell:disabled {
  opacity: 1;
}

.rules-learning-board .cell.is-lesson-target:not(.is-selected) .piece {
  animation: lesson-target-jiggle 1.25s ease-in-out infinite;
}

body[data-theme-mode="dark"] .game-rules-button .ui-icon {
  filter: brightness(0) invert(1);
}

/* Keep the player labels subordinate to the board. */
.player-bar,
body[data-theme] .player-bar {
  min-height: 32px;
  gap: 8px;
  padding: 1px 0;
}

.player-bar .avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.player-name span { font-size: 10px; line-height: 1.1; }
.player-name small { margin-top: 1px; font-size: 8px; line-height: 1.1; }
.opponent-bar { margin-bottom: 6px; }
.you-bar { margin-top: 8px; }

@media (max-width: 700px) {
  .game-rules-button {
    min-height: 34px;
    gap: 6px;
    padding: 8px 10px;
    font-size: 9px;
  }

  .rules-modal {
    width: 100vw;
    height: 100dvh;
  }
  .rules-modal .modal-header {
    padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 16px;
  }
  .rules-level-tabs {
    grid-template-columns: repeat(10, minmax(108px, 1fr));
    overflow-x: auto;
    padding: 0 22px 4px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .rules-level-tabs::-webkit-scrollbar { display: none; }
  .rules-level-tabs button { scroll-snap-align: start; }
  .rules-learning-panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .rules-learning-copy {
    flex: none;
    padding: 15px;
    border-right: 0;
    border-bottom: 1px solid var(--theme-line, rgba(35,22,47,.1));
  }
  .rules-learning-copy h3 {
    margin: 5px 0 8px;
    font-size: 30px;
  }
  .rules-learning-copy > p {
    font-size: 12px;
    line-height: 1.4;
  }
  .rules-learning-status {
    margin-top: 10px;
    padding: 10px 12px;
  }
  .rules-learning-caption {
    margin-top: 8px !important;
  }
  .rules-learning-actions {
    margin-top: 0;
    padding-top: 12px;
  }
  .rules-learning-board-stage {
    flex: 1;
    min-height: max-content;
    padding: 12px 8px 18px;
  }
  .rules-learning-board {
    --cell: min(calc((100vw - 54px) / 5), 7dvh);
  }
  .rules-learning-board[data-rows="4"] {
    --cell: min(calc((100vw - 54px) / 5), 11.5dvh);
  }
  .rules-learning-board[data-rows="6"] {
    --cell: min(calc((100vw - 54px) / 5), 8.7dvh);
  }
  .rules-learning-browser::before,
  .rules-learning-browser::after {
    position: absolute;
    z-index: 4;
    top: 14px;
    width: 38px;
    height: 46px;
    content: "";
    pointer-events: none;
  }
  .rules-learning-browser::before {
    left: 14px;
    background: linear-gradient(90deg, var(--theme-surface-solid, #fffdf9), transparent);
  }
  .rules-learning-browser::after {
    right: 14px;
    background: linear-gradient(270deg, var(--theme-surface-solid, #fffdf9), transparent);
  }
}
