/* Alice's Chess (ADR-0111). The board's colours come from the skin
   (skins.js) as custom properties; everything else is her site's tokens. */

/* ---- tabs, who, which bot ------------------------------------------------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-bottom: var(--space-3); }
.tabs button, #who button {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--tap);
  border: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line);
  font: 700 var(--step-0)/1.1 var(--font-ui); cursor: pointer; touch-action: manipulation;
}
.tabs button > span:first-child, #who button > span:first-child { font-size: 1.4rem; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, #000); }
#who { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); width: min(100%, 36rem); margin: 0 auto var(--space-2); }
#who button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent-2) 22%, var(--surface)); box-shadow: inset 0 0 0 3px var(--accent-2); }
.levels { width: min(100%, 36rem); margin: 0 auto var(--space-3); }
.bots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }
.bots button {
  display: grid; justify-items: center; gap: 2px; min-height: 64px; padding: var(--space-1); border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); cursor: pointer; touch-action: manipulation;
  font: 600 var(--step--1)/1.1 var(--font-ui); transition: transform .12s;
}
.bots .ico { font-size: 1.7rem; line-height: 1.1; }
.bots .nm { overflow-wrap: anywhere; }
.bots button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent-3) 30%, var(--surface)); box-shadow: inset 0 0 0 3px var(--accent-3); transform: scale(1.04); }
.bots button:disabled:not([aria-pressed="true"]) { opacity: .35; }
.lv-note { margin: var(--space-1) 0 0; text-align: center; font-size: var(--step--1); color: var(--ink-soft); max-width: none; }

/* ---- the stage --------------------------------------------------------------- */
.stage { position: relative; --board: min(100%, 36rem, calc(100dvh - 14rem)); }
.stage .table { width: max(min(var(--board), 100%), min(18rem, 100%)); margin-inline: auto; }
.board-box { position: relative; }
.board {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 16px; isolation: isolate;
  box-shadow: 0 0 0 5px var(--edge), 0 10px 0 5px color-mix(in srgb, var(--edge) 55%, #000), 0 18px 30px rgb(59 42 32 / .25);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.board .squares { position: absolute; inset: 0; display: grid; grid-template: repeat(8, 1fr) / repeat(8, 1fr); border-radius: 16px; overflow: hidden; }
.sq { position: relative; background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.stage[data-skin="crayon"] .sq.dark { background: repeating-linear-gradient(-35deg, var(--sq-dark) 0 5px, color-mix(in srgb, var(--sq-dark) 75%, #e8a33a) 5px 7px); }
.stage[data-skin="crayon"] .sq:not(.dark) { background: radial-gradient(circle at 30% 30%, #fff, var(--sq-light)); }
.stage[data-skin="sweets"] .sq.dark { background: radial-gradient(circle at 30% 30%, #fff8 0 8%, transparent 9%), radial-gradient(circle at 75% 70%, #fff8 0 6%, transparent 7%), var(--sq-dark); }
.stage[data-skin="animals"] .sq.dark { background: radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--sq-dark) 80%, #2d6a1e) 0 40%, var(--sq-dark) 41%); }
.sq::before, .sq::after { content: ''; position: absolute; pointer-events: none; }
.sq.last::before { inset: 0; background: var(--last); }
.sq.picked::before { inset: 0; background: color-mix(in srgb, var(--pick) 30%, transparent); box-shadow: inset 0 0 0 4px var(--pick); }
.sq.over::before { inset: 0; background: color-mix(in srgb, var(--pick) 22%, transparent); box-shadow: inset 0 0 0 4px var(--pick); }
.sq.target::after { left: 34%; top: 34%; width: 32%; height: 32%; border-radius: 50%; background: var(--dot); animation: dot-in .2s ease-out; }
.sq.takes::after { left: 6%; top: 6%; width: 88%; height: 88%; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 5px var(--dot); }
.sq.check::before { inset: 0; background: radial-gradient(circle, var(--check) 0%, color-mix(in srgb, var(--check) 45%, transparent) 45%, transparent 75%); animation: pulse 1.1s ease-in-out infinite; }
/* danger: a little red badge with "!" on a piece that can be taken */
.sq.threat::after { right: 2%; top: 2%; width: 30%; height: 30%; border-radius: 50%; background: var(--check); box-shadow: 0 0 0 2px #fff; animation: pulse 1s ease-in-out infinite; z-index: 3; }
.sq.hinted::before { inset: 6%; border-radius: 50%; box-shadow: 0 0 0 5px var(--arrow), 0 0 18px var(--arrow); animation: pulse 1s ease-in-out infinite; }
@keyframes dot-in { from { transform: scale(0); } }
@keyframes pulse { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }
.co { position: absolute; font: 800 clamp(9px, 2.6vw, 13px)/1 var(--font-ui); color: var(--coord-on-light); pointer-events: none; opacity: .85; }
.sq.dark .co { color: var(--coord-on-dark); }
.co.file { right: 5%; bottom: 4%; }
.co.rank { left: 5%; top: 5%; }
/* face to face: the top player's pieces and bar turn round to face them */
.board[data-facing="on"] .piece.b svg, .board[data-facing="on"] .piece-btn.b svg { rotate: 180deg; }
.stage[data-facing="on"] #bar-top { rotate: 180deg; }

.pieces, .fx { position: absolute; inset: 0; pointer-events: none; }
.piece { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; will-change: transform; }
.piece svg { width: 100%; height: 100%; transition: transform .16s ease; filter: drop-shadow(0 2px 0 rgb(0 0 0 / .18)); }
.pc.w { --fill: var(--w-fill); --fill2: var(--w-fill2); --line: var(--w-line); --detail: var(--w-detail); --mark: var(--w-mark); }
.pc.b { --fill: var(--b-fill); --fill2: var(--b-fill2); --line: var(--b-line); --detail: var(--b-detail); --mark: var(--b-mark); }
.piece.lifted svg { transform: translateY(-6%) scale(1.1); }
.piece.dragging { z-index: 5; }
.piece.dragging svg { transform: translateY(-16%) scale(1.35); filter: drop-shadow(0 10px 8px rgb(0 0 0 / .3)); }
.piece.gone svg { animation: gone .4s ease-in forwards; }
.piece.fresh svg { animation: fresh .3s cubic-bezier(.3,1.6,.5,1); }
@keyframes gone { 40% { transform: scale(1.2) rotate(-10deg); } to { transform: scale(.1) rotate(60deg); opacity: 0; } }
@keyframes fresh { from { transform: scale(.3); opacity: 0; } }
.ring, .burst { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; }
.ring::before { content: ''; position: absolute; inset: 10%; border-radius: 50%; box-shadow: 0 0 0 4px var(--pick); opacity: 0; animation: ring-out .5s ease-out both; animation-delay: inherit; }
@keyframes ring-out { from { transform: scale(.4); opacity: .9; } to { transform: scale(1.4); opacity: 0; } }
.burst i { position: absolute; left: 50%; top: 50%; width: 18%; height: 18%; border-radius: 50%; }
.burst i.w { background: var(--w-fill2); } .burst i.b { background: var(--b-fill2); }
.burst b { position: absolute; inset: -10%; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--pick) 80%, transparent), transparent 65%); }
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.arrow line { stroke: var(--arrow); stroke-linecap: round; opacity: .9; }
.arrow polygon { fill: var(--arrow); opacity: .9; }
.veil { position: absolute; inset: 0; z-index: 8; background: rgb(0 0 0 / .35); border-radius: 16px; }
.promo { position: absolute; z-index: 9; width: 12.5%; display: grid; grid-auto-rows: 1fr; height: 50%; background: var(--sq-light); box-shadow: 0 0 0 3px var(--pick), 0 10px 30px rgb(0 0 0 / .4); border-radius: 10px; overflow: hidden; }
.piece-btn { border: 0; padding: 0; background: transparent; cursor: pointer; min-height: 0; }
.piece-btn svg { width: 100%; height: 100%; }

/* the end of a game, and the "think first" question */
.over, .warn {
  position: absolute; z-index: 7; left: 50%; top: 50%; translate: -50% -50%; width: min(86%, 22rem);
  padding: var(--space-4); border-radius: var(--radius-lg); text-align: center; background: var(--surface); color: var(--ink);
  box-shadow: 0 0 0 4px var(--edge), var(--shadow); animation: pop .4s cubic-bezier(.2,.9,.3,1.3) both;
}
.over { animation-delay: .3s; }
.over .big { font-size: 3rem; margin: 0; line-height: 1.1; }
.over h3 { margin: var(--space-1) 0 var(--space-3); font-size: var(--step-1); }
.over .row, .warn .row { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.warn { top: auto; bottom: 8%; translate: -50% 0; box-shadow: 0 0 0 4px var(--check), var(--shadow); }
.warn p { margin: 0 0 var(--space-3); font-weight: 700; font-size: var(--step-1); }
@keyframes pop { from { scale: .6; opacity: 0; } }

/* the two players' bars */
.bar { display: flex; align-items: center; gap: var(--space-2); min-height: 2.8rem; padding: var(--space-1) 0; }
#bar-top { margin-bottom: 10px; }
#bar-bottom { margin-top: 18px; }
.bar .taken { display: flex; flex-wrap: wrap; align-items: center; min-width: 0; flex: 1 1 auto; justify-content: flex-end; }
.bar .taken svg { width: 1.6rem; height: 1.6rem; margin-left: -.45rem; }
.bar .taken .plus { margin-left: var(--space-1); font-size: var(--step--1); color: var(--ink-soft); }
.bar .pl { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; min-width: 0; white-space: nowrap; padding-left: 4px; }
.bar .pl > span { overflow: hidden; text-overflow: ellipsis; }
.bar .avatar { flex: 0 0 auto; display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: 50%; background: var(--sq-dark); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--line); transition: box-shadow .25s; }
.bar .avatar svg { width: 2rem; height: 2rem; }
.bar .pl.moving .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--pick); }
.bar .dots { color: var(--ink-soft); letter-spacing: 2px; animation: pulse 1s infinite; }

.status { min-height: 2.6rem; width: fit-content; max-width: 100%; margin: var(--space-3) auto 0; padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); text-align: center; font-weight: 700; }
.status:empty { visibility: hidden; }
.actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--space-2); width: min(100%, 36rem); margin: var(--space-3) auto 0; }
.act {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tap); min-width: var(--tap);
  padding: var(--space-1); border: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line), 0 3px 0 var(--line); font: 700 var(--step--1)/1.1 var(--font-ui); cursor: pointer; touch-action: manipulation; text-align: center;
}
.act > span:first-child { font-size: 1.4rem; line-height: 1; }
.act > span:last-child { max-width: 100%; overflow-wrap: anywhere; }
.act:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 0 0 2px var(--line); }
.act:disabled { opacity: .4; cursor: default; }
.act[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--accent-2); }
.act.sm { font-size: var(--step-0); }

/* ---- big screen --------------------------------------------------------------- */
body.big { overflow: hidden; }
body.big > :not(.wrap) { display: none; }
body.big .wrap > :not(.stage):not(dialog) { display: none; }
body.big .wrap { width: 100%; padding: 0; }
body.big .stage {
  position: fixed; inset: 0; z-index: 60; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(var(--space-3), var(--app-top)) max(var(--space-3), env(safe-area-inset-right)) max(var(--space-3), env(safe-area-inset-bottom)) max(var(--space-3), env(safe-area-inset-left));
  background: var(--scene); --board: min(calc(100vw - 2rem), calc(100dvh - 14rem));
}
body.big .stage[data-scene="dark"] { --ink: #f6ece2; --ink-soft: #c4ab9a; --surface: #2f2521; --line: #4a3a32; color: var(--ink); }
body.big .stage .table, body.big .actions { width: var(--board); }
.exit {
  position: absolute; z-index: 61; top: max(var(--space-3), var(--app-top)); right: max(var(--space-3), env(safe-area-inset-right));
  width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: var(--radius-full); background: var(--surface); color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--line); font: 400 28px/1 var(--font-ui); cursor: pointer;
}
@media (orientation: landscape) {
  body.big .stage { display: grid; align-content: center; justify-content: center; column-gap: var(--space-6);
    grid-template-columns: min(calc(100dvh - 2rem), calc(100vw - 16rem)) minmax(12rem, 18rem); grid-template-rows: auto auto 1fr auto;
    --board: min(calc(100dvh - 2rem), calc(100vw - 16rem)); }
  body.big .stage .table { display: contents; }
  body.big .board-box { grid-column: 1; grid-row: 1 / -1; align-self: center; width: var(--board); }
  body.big #bar-top { grid-column: 2; grid-row: 1; padding-top: calc(var(--tap) + var(--space-2)); }
  body.big .status { grid-column: 2; grid-row: 2; }
  body.big .actions { grid-column: 2; grid-row: 3; align-self: center; width: 100%; grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  body.big #bar-bottom { grid-column: 2; grid-row: 4; }
}
/* the stars behind the board on a night skin */
body.big .stage[data-scene="dark"]::before { content: ''; position: absolute; inset: 0; z-index: -1; opacity: .7;
  background: radial-gradient(2px 2px at 20% 30%, #fff, transparent), radial-gradient(2px 2px at 70% 15%, #fff, transparent), radial-gradient(1.5px 1.5px at 85% 60%, #fff, transparent), radial-gradient(2px 2px at 40% 80%, #fff, transparent), radial-gradient(1.5px 1.5px at 10% 70%, #fff, transparent); }

/* ---- the panel under the board -------------------------------------------------- */
.panel { margin-top: var(--space-6); display: grid; gap: var(--space-4); width: min(100%, 36rem); margin-inline: auto; }
.panel .card { padding: var(--space-4); }
.panel h2 { font-size: var(--step-1); margin: 0 0 var(--space-2); }
.panel h3 { font-size: var(--step-0); margin: var(--space-4) 0 0; }
.panel p { color: var(--ink-soft); }
.panel .task { color: var(--ink); font-weight: 700; font-size: var(--step-1); }
.panel .tip { background: var(--surface-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius); color: var(--ink); }
.cat-p { margin: var(--space-1) 0 var(--space-2); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chips button { min-height: var(--tap); padding: 0 var(--space-4); border: 0; border-radius: var(--radius-full); background: var(--surface-2); color: var(--ink); font: 700 var(--step-0)/1 var(--font-ui); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--accent-2); color: #fff; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.steps { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.steps button {
  width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line); font: 800 var(--step-1)/1 var(--font-ui); cursor: pointer; touch-action: manipulation;
}
.steps button.done { background: var(--accent-2); color: #fff; box-shadow: none; }
.steps button.done::after { content: '✓'; font-size: .7em; margin-left: 1px; }
.steps button[aria-current="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--accent); }

/* ---- the skins sheet ----------------------------------------------------------- */
.sheet {
  width: min(100vw, 36rem); max-width: 100vw; max-height: 88dvh; margin: auto auto 0; padding: 0 var(--space-4) max(var(--space-6), env(safe-area-inset-bottom));
  border: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: var(--surface); color: var(--ink); overflow-y: auto; overscroll-behavior: contain;
}
@media (min-width: 40rem) { .sheet { margin: auto; border-radius: var(--radius-lg); } }
.sheet::backdrop { background: rgb(59 42 32 / .45); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) 0 var(--space-2); background: var(--surface); }
.sheet-head h2 { margin: 0; }
.sheet section { padding: var(--space-3) 0; border-top: 2px dashed var(--line); }
.sheet h3 { margin: 0 0 var(--space-2); }
.sheet p { color: var(--ink-soft); margin: 0 0 var(--space-2); }
.switch { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); cursor: pointer; }
.switch input { width: 28px; height: 28px; accent-color: var(--accent-2); flex: 0 0 auto; }
.switch em { display: block; font-style: normal; font-size: var(--step--1); color: var(--ink-soft); }
.skins { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.skins button { display: grid; gap: var(--space-1); padding: var(--space-2); border: 0; border-radius: var(--radius); background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); cursor: pointer; font: 700 var(--step-0)/1.1 var(--font-ui); }
.skins button[aria-pressed="true"] { box-shadow: inset 0 0 0 4px var(--accent); }
.skins .prev { display: grid; grid-template-columns: repeat(4, 1fr); border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 3px var(--edge); }
.skins .prev i { aspect-ratio: 1; display: grid; place-items: center; background: var(--sq-light); }
.skins .prev i.d { background: var(--sq-dark); }
.skins .prev svg { width: 100%; height: 100%; }

/* Settings in tabs (ADR-0113): every part one tap from the top */
.sheet-tabs { position: sticky; top: 4.4rem; z-index: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); padding: var(--space-2) 0 var(--space-3); background: var(--surface); }
.sheet-tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; padding: var(--space-1);
  border: 0; border-radius: var(--radius); background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line);
  font: 700 var(--step--1)/1.1 var(--font-ui); cursor: pointer; touch-action: manipulation;
}
.sheet-tabs .ico { font-size: 1.4rem; line-height: 1; }
.sheet-tabs button > span:last-child { overflow-wrap: anywhere; min-width: 0; text-align: center; }
.sheet-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.sheet section[hidden] { display: none; }
.sheet section[role="tabpanel"] { border-top: 0; }
/* the sound button by the title */
.room-top .snd { flex: 0 0 auto; width: var(--tap); font-size: 1.4rem; }
.room-top .snd[aria-pressed="false"] { opacity: .6; }
.sheet section[role="tabpanel"] > h3:first-child { display: none; }
