/* Chess layout and theme. Piece and board colours live in colors.css. */

:root {
  --red-50:  #fff1f0;
  --red-100: #ffe0dd;
  --red-200: #ffc2bd;
  --red-500: #e0262f;
  --red-600: #d2202a;
  --red-700: #b01119;
  --red-800: #8a0c13;
  --red-900: #5f070d;
  --gold:    #f7b733;
  --gold-600:#d99412;
  --cream:   #fff8f4;
  --ink:     #2b1114;
  --ink-2:   #5c4346;
  --ink-3:   #8c7578;
  --line:    #f0dcd9;
  --green:   #1f8a4c;
  --shadow:  0 18px 50px rgba(95, 7, 13, .28);
  --font: "Poppins", "Segoe UI", system-ui, -apple-system, sans-serif;
  --bs: min(calc(100vw - 32px), calc(100vh - 320px), 660px);   /* board size (phones; larger screens: see the "large layout" block below) */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); color: var(--ink); line-height: 1.5; } /* background, header and footer: ../../assets/site.css */
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- Piece colours (set in colors.css) ---------- */
.pw  { fill: var(--white-piece); }
.pb  { fill: var(--black-piece); }
.pd  { stroke: var(--black-piece-detail); }
.pdf { fill: var(--black-piece-detail); }
.pdb { fill: var(--black-piece-detail); stroke: var(--black-piece-detail); }
svg.pc { display: block; width: 100%; height: 100%; }

/* The header (logos) and background come from ../../assets/site.css.
   J&J sits in the top-left corner on every screen. The right-hand logo (Rybrevant + Lazcluze) shows from the names screen onward. */
body.site .site-header { align-items: flex-start; padding-top: 18px; } /* (body.site: wins over ../../assets/site.css, which is loaded after this file) */
.site-header .logo-rybrevant { display: none; height: clamp(76px, 9.5vw, 132px); }
body[data-screen="names"] .site-header .logo-rybrevant,
body[data-screen="game"] .site-header .logo-rybrevant { display: block; }
.stage { flex: 1; display: grid; place-items: center; padding: 14px 16px 24px; }

/* ---------- Cards ---------- */
.card {
  width: 100%; max-width: 520px; background: rgba(255, 255, 255, .96); border-radius: 24px;
  box-shadow: var(--shadow); padding: 36px 34px 30px; position: relative; overflow: hidden;
  animation: rise .45s cubic-bezier(.2, .8, .2, 1);
}
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 8px; background: linear-gradient(90deg, var(--red-700), var(--red-500) 60%, var(--gold)); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.eyebrow { color: var(--red-600); font-weight: 700; font-size: .78rem; letter-spacing: .2em; text-transform: uppercase; }
.lead { color: var(--ink-2); }

.loading { display: flex; align-items: center; justify-content: center; gap: .8rem; padding: 2rem; color: var(--ink-2); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--red-100); border-top-color: var(--red-600); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Buttons & form ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; border: 0; cursor: pointer;
  font-weight: 600; font-size: 1rem; padding: .85rem 1.6rem; border-radius: 999px; text-decoration: none;
  background: linear-gradient(180deg, var(--red-500), var(--red-700)); color: #fff; box-shadow: 0 6px 16px rgba(176, 17, 25, .35);
  transition: transform .12s, box-shadow .12s, filter .12s, opacity .12s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 9px 20px rgba(176, 17, 25, .42); filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: #fff; color: var(--red-700); box-shadow: inset 0 0 0 2px var(--red-200); }
.btn-ghost:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--red-500); filter: none; }
.btn-sm { padding: .5rem 1rem; font-size: .85rem; }
.btn-big { font-size: 1.15rem; padding: 1rem 2.4rem; }
.btn-block { width: 100%; }

.field { display: grid; gap: .4rem; text-align: left; }
.field label { font-weight: 600; font-size: .9rem; color: var(--ink-2); display: flex; align-items: center; gap: .5rem; }
.field label small { font-weight: 500; color: var(--ink-3); font-size: .78rem; }
.input { width: 100%; padding: .85rem 1rem; font-size: 1.05rem; border-radius: 12px; border: 2px solid var(--line); background: #fff; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--red-500); box-shadow: 0 0 0 4px rgba(224, 38, 47, .14); }
.input.invalid { border-color: var(--red-600); }
.error-text { color: var(--red-700); font-size: .85rem; font-weight: 500; min-height: 1.2em; }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #000; flex: none; }
.swatch.w { background: var(--white-piece); }
.swatch.b { background: var(--black-piece); }

/* ---------- Start & names ---------- */
.start, .names { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Start screen ---------- */
/* The start screen is one picture (assets/chess-start.jpg: logo, card, KV piece, texts). It replaces the page background
   and fills the screen; only the Play button is added on top, right under the text "Chess".
   To change the picture, replace assets/chess-start.jpg (keep it 16:9, and if the text moves, adjust --play-y below). */
body.site:not([data-screen="names"]):not([data-screen="game"]) {
  background: #f3c9b4 url("chess-start.jpg") center / cover no-repeat fixed;
}
body.site:not([data-screen="names"]):not([data-screen="game"]) .site-header { display: none; }   /* the J&J logo is part of the picture */
.start {
  /* size of the picture on screen (it is scaled to cover the window) and where the button goes, in picture proportions */
  --iw: max(100vw, calc(100vh * 16 / 9));
  --play-y: .767;                /* button centre: 76.7 % down the picture, just under "Chess" */
}
.btn-play {
  position: fixed; left: 50vw; top: calc(50vh + var(--iw) * 9 / 16 * (var(--play-y) - .5));
  translate: -50% -50%;   /* centring uses the separate "translate" property, so the shared .btn hover/press transform cannot knock it out of place */
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; overflow: hidden;
  height: calc(var(--iw) * .053); min-height: 40px; padding: 0 calc(var(--iw) * .077); font-size: max(calc(var(--iw) * .024), 20px); letter-spacing: .03em; white-space: nowrap;
  background: linear-gradient(180deg, #c8171f, #8a0c13); box-shadow: inset 0 0 0 2px #e0b04a, 0 6px 14px rgba(138, 12, 19, .4);
  animation: pulse-glow 2.4s ease-in-out infinite;
}
.btn-play:hover:not(:disabled) { filter: brightness(1.1); }
.btn-play .tri { font-size: 1.2em; }
.btn-play::after { content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .45), rgba(255, 255, 255, 0)); transform: skewX(-20deg); animation: shine 3.4s ease-in-out infinite; }
@keyframes shine { 0%, 55% { left: -60%; } 100% { left: 130%; } }
@keyframes pulse-glow { 0%, 100% { box-shadow: inset 0 0 0 2px #e0b04a, 0 6px 14px rgba(138, 12, 19, .4), 0 0 0 0 rgba(224, 176, 74, .6); } 50% { box-shadow: inset 0 0 0 2px #e0b04a, 0 6px 14px rgba(138, 12, 19, .4), 0 0 0 12px rgba(224, 176, 74, 0); } }
/* Tall (portrait) screens: show the whole picture across the width instead of cropping it, with Play as a normal-size button below it */
@media (max-aspect-ratio: 1/1) {
  body.site:not([data-screen="names"]):not([data-screen="game"]) { background-size: 100% auto; background-position: center; background-color: #7a2a3a; }
  .start { --iw: 100vw; }
  .btn-play { top: calc(50vh + 100vw * 9 / 32 + 50px); height: 52px; padding: 0 2.2rem; font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { .btn-play, .btn-play::after { animation: none; } }
.names h2 { font-size: clamp(1.5rem, 5vw, 1.9rem); font-weight: 800; color: var(--red-800); margin: .3rem 0 1.4rem; }
.names form { display: grid; gap: 1.1rem; }
.names .btn-ghost { margin-top: -.3rem; }
/* Names form: a larger card, with bigger text, fields and buttons (easy to read and tap on a kiosk screen) */
.names { max-width: 700px; padding: 34px 52px 30px; }
.names .eyebrow { font-size: .95rem; }
.names h2 { font-size: clamp(1.9rem, 5vw, 2.5rem); margin: .3rem 0 1.3rem; }
.names form { gap: 1.1rem; }
.names .field { gap: .5rem; }
.names .field label { font-size: 1.15rem; gap: .7rem; }
.names .swatch { width: 24px; height: 24px; border-width: 3px; }
.names .input { padding: .95rem 1.25rem; font-size: 1.35rem; border-radius: 16px; }
.names .error-text { font-size: .95rem; min-height: 0; }
.names .btn-block { padding: 1rem 1.5rem; font-size: 1.25rem; }
.names .btn-ghost { font-size: 1.1rem; padding: .85rem 1.5rem; }

/* Names screen: the form fills the whole window (no logos here, so everything gets the room).
   It stays in normal page flow, so the on-screen keyboard can scroll the fields into view. */
body[data-screen="names"] .site-header { display: none; }
body[data-screen="names"] .stage { padding: 0; place-items: stretch; }
body[data-screen="names"] .names {
  max-width: none; width: 100%; min-height: 100vh; border-radius: 0; overflow: hidden; animation: none;
  display: grid; align-content: center; justify-items: center; padding: 4vh 6vw;
  background: linear-gradient(180deg, rgba(255, 255, 255, .62), rgba(255, 241, 228, .78));
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
body[data-screen="names"] .names::before { height: 10px; }
body[data-screen="names"] .names > * { width: min(100%, 920px); }
body[data-screen="names"] .names .eyebrow { font-size: clamp(.9rem, 2.2vh, 1.2rem); }
body[data-screen="names"] .names h2 { font-size: clamp(2.2rem, 7vh, 4rem); margin: .3rem 0 clamp(1rem, 3.6vh, 2.4rem); }
body[data-screen="names"] .names form { gap: clamp(.9rem, 2.6vh, 1.7rem); }
body[data-screen="names"] .names .field { gap: clamp(.4rem, 1vh, .7rem); }
body[data-screen="names"] .names .field label { font-size: clamp(1.15rem, 3vh, 1.7rem); }
body[data-screen="names"] .names .swatch { width: clamp(24px, 3.4vh, 34px); height: clamp(24px, 3.4vh, 34px); }
body[data-screen="names"] .names .input { font-size: clamp(1.3rem, 3.6vh, 2rem); padding: clamp(.9rem, 2.2vh, 1.4rem) 1.5rem; border-radius: 20px; }
body[data-screen="names"] .names .btn-block { font-size: clamp(1.25rem, 3.4vh, 1.8rem); padding: clamp(.9rem, 2.2vh, 1.4rem) 1.5rem; }
body[data-screen="names"] .names .btn-ghost { font-size: clamp(1.1rem, 2.8vh, 1.5rem); padding: clamp(.75rem, 1.8vh, 1.1rem) 1.5rem; }

/* ---------- Game layout ---------- */
.game { width: 100%; display: flex; justify-content: center; align-items: flex-start; gap: 22px; flex-wrap: wrap; }
.board-col { width: var(--bs); display: grid; gap: 10px; }
.board-wrap { position: relative; width: var(--bs); height: var(--bs); }

.pbar {
  display: flex; align-items: center; gap: .7rem; padding: .45rem .8rem; min-height: 54px; border-radius: 16px;
  background: rgba(255, 255, 255, .92); box-shadow: 0 6px 18px rgba(95, 7, 13, .18); border: 3px solid transparent; transition: border-color .2s, box-shadow .2s;
}
.pbar.turn { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(247, 183, 51, .35), 0 6px 18px rgba(95, 7, 13, .18); }
.pbar .chip { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--cream); border: 1px solid var(--line); }
.pbar .chip svg { width: 28px; height: 28px; }
.pbar .who { min-width: 0; line-height: 1.2; }
.pbar .nm { font-weight: 700; color: var(--red-800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbar .sub { font-size: .74rem; color: var(--ink-3); }
.pbar .taken { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; min-height: 24px; }
.pbar .taken svg { width: 22px; height: 22px; margin-left: -7px; }
.pbar .taken .adv { margin-left: .5rem; font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.pbar .resign { flex: none; border: 0; background: var(--red-50); color: var(--red-700); font-weight: 600; font-size: .78rem; padding: .35rem .7rem; border-radius: 999px; cursor: pointer; }
.pbar .resign:hover:not(:disabled) { background: var(--red-100); }
.pbar .resign:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Board ---------- */
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  width: 100%; height: 100%; border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, .9), 0 0 0 8px var(--red-800), 0 18px 40px rgba(60, 5, 9, .4);
  user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none;
}
.sq { position: relative; display: grid; place-items: stretch; cursor: default; }
.sq.light { background: var(--light-square); }
.sq.dark  { background: var(--dark-square); }
.sq.light { --lbl: var(--dark-square); }
.sq.dark  { --lbl: var(--light-square); }
.sq.last::before, .sq.sel::before { content: ""; position: absolute; inset: 0; background: var(--last-move); }
.sq.sel::before { background: var(--selected); }
.sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(224, 38, 47, .95) 0, rgba(224, 38, 47, .55) 45%, rgba(224, 38, 47, 0) 72%); }
.sq.mate::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(176, 17, 25, 1) 0, rgba(176, 17, 25, .7) 55%, rgba(176, 17, 25, 0) 80%); }
.sq .pc-wrap { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.sq.mine { cursor: grab; }
.sq.go { cursor: pointer; }
/* Admin turned the move hints off: no dots / rings on the squares a piece can go to */
body.no-hints .sq.go::after { display: none; }
body.no-hints .sq.go { cursor: default; }
.sq.go::after { content: ""; position: absolute; z-index: 3; left: 50%; top: 50%; width: 28%; height: 28%; transform: translate(-50%, -50%); border-radius: 50%; background: var(--hint-dot); pointer-events: none; }
.sq.go.cap::after { width: 86%; height: 86%; background: none; border: calc(var(--bs) / 8 * .09) solid var(--hint-dot); }
.sq.dragging .pc-wrap { opacity: .25; }
.sq .rk, .sq .fl { position: absolute; z-index: 1; font-size: calc(var(--bs) / 8 * .19); font-weight: 700; color: var(--lbl); line-height: 1; pointer-events: none; }
.sq .rk { left: 4%; top: 5%; }
.sq .fl { right: 5%; bottom: 4%; }

.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; left: 0; top: 0; filter: drop-shadow(0 10px 10px rgba(60, 5, 9, .45)); }

/* ---------- Promotion chooser ---------- */
.promo { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(43, 17, 20, .55); border-radius: 6px; }
.promo-box { background: #fff; border-radius: 18px; padding: 14px 16px 16px; box-shadow: var(--shadow); text-align: center; max-width: 94%; }
.promo-box p { font-weight: 700; color: var(--red-800); margin-bottom: .6rem; }
.promo-opts { display: flex; gap: .5rem; justify-content: center; }
.promo-opts button { width: calc(var(--bs) / 8 * 1.05); height: calc(var(--bs) / 8 * 1.05); max-width: 84px; max-height: 84px; padding: 4px; border-radius: 14px; border: 2px solid var(--line); background: var(--light-square); cursor: pointer; }
.promo-opts button:hover { border-color: var(--red-500); background: var(--selected); }
.promo-cancel { margin-top: .7rem; border: 0; background: none; color: var(--ink-3); font-weight: 600; cursor: pointer; }

/* ---------- Side panel ---------- */
.side { max-width: 330px; width: 330px; padding: 26px 22px 20px; display: grid; gap: .9rem; align-self: stretch; grid-template-rows: auto auto auto minmax(120px, 1fr) auto; max-height: calc(var(--bs) + 128px); }
.status { text-align: center; font-weight: 700; font-size: 1.05rem; color: var(--red-800); line-height: 1.3; }
.status .chk { display: inline-block; margin-top: .25rem; padding: .1rem .7rem; border-radius: 99px; background: var(--red-600); color: #fff; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; animation: pulse .7s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.series { display: flex; justify-content: center; gap: 1.2rem; font-size: .78rem; color: var(--ink-3); text-align: center; }
.series b { display: block; font-size: 1.3rem; color: var(--red-700); line-height: 1.1; }
.moves-head { font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.moves { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; grid-template-columns: 2.2rem 1fr 1fr; align-content: start; font-size: .9rem; font-variant-numeric: tabular-nums; }
.moves li { padding: .18rem .3rem; }
.moves .n { color: var(--ink-3); }
.moves .m.now { background: var(--last-move); border-radius: 6px; font-weight: 700; }
.moves-empty { grid-column: 1 / -1; color: var(--ink-3); font-size: .85rem; padding: .4rem 0; }
.controls { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }

/* ---------- Dialogs ---------- */
.dlg { border: 0; border-radius: 22px; padding: 26px 26px 22px; max-width: min(92vw, 400px); width: 100%; box-shadow: var(--shadow); text-align: center; color: var(--ink); }
.dlg::backdrop { background: rgba(43, 17, 20, .55); }
.dlg h3 { font-size: 1.35rem; font-weight: 800; color: var(--red-800); margin-bottom: .4rem; }
.dlg p { color: var(--ink-2); }
.dlg-actions { display: flex; gap: .6rem; justify-content: center; margin-top: 1.3rem; }
.dlg-actions.col { flex-direction: column; }
.over { overflow: visible; }
.over .eyebrow { margin-top: .2rem; }
.over h3 { font-size: 1.7rem; margin: .2rem 0 .3rem; }
/* Game-over popup: the KV piece stands above the card; while .announce is on, only the piece, result and name show (buttons come after 10 s, see chess.js) */
#over-pieces { width: auto; height: auto; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; margin: calc(var(--over-img) * -.68) auto -6px; }
#over-pieces img { display: block; height: var(--over-img); width: auto; margin: 0 auto; filter: drop-shadow(0 14px 16px rgba(60, 20, 0, .35)); }
#over { --over-img: clamp(240px, 33vh, 420px); max-width: min(92vw, 600px); padding: 30px 40px 30px; border-radius: 28px;
  translate: 0 calc(var(--over-img) * .34); }   /* the piece stands above the card: shift the card down by half of that so the whole group is centred */   /* game-over popup: bigger piece, text and buttons */
#over .eyebrow { font-size: 1.1rem; letter-spacing: .26em; }
#over h3 { font-size: clamp(2.3rem, 5vh, 3.2rem); margin: .3rem 0 .5rem; }
#over p { font-size: 1.2rem; }
#over .dlg-actions { margin-top: 1.6rem; gap: .8rem; }
#over .dlg-actions .btn { font-size: 1.3rem; padding: 1.05rem 1.5rem; }
#over.announce .dlg-actions { display: none; }
#over-text:empty { display: none; }
.over-pieces { width: 84px; height: 84px; margin: -64px auto 6px; padding: 8px; border-radius: 50%; background: var(--cream); border: 4px solid var(--gold); box-shadow: 0 8px 20px rgba(95, 7, 13, .3); }

/* Check popup: same card as the game-over box, with a red alert look */
.check::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 8px; border-radius: 22px 22px 0 0; background: linear-gradient(90deg, var(--red-700), var(--red-500)); }
.check .over-pieces { border-color: var(--red-600); animation: pulse .6s ease-in-out infinite alternate; }
.check h3 { color: var(--red-600); font-size: 2.2rem; letter-spacing: .02em; text-transform: uppercase; }
.check[open] { animation: rise .3s cubic-bezier(.2, .8, .2, 1); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: .75rem 1.2rem; border-radius: 12px; font-size: .9rem; box-shadow: var(--shadow); transition: all .25s ease; z-index: 2000; max-width: calc(100vw - 32px); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red-700); }

/* ---------- Game screen: large layout (full window: no logos, so the board gets the whole height and the side panel the spare width) ---------- */
@media (min-width: 761px) {
  :root { --side: clamp(380px, 26vw, 540px); --bs: min(calc(100vw - var(--side) - 96px), calc(100vh - 174px), 1400px); }   /* board size: width left after the side panel / height left after the player bars */
  body[data-screen="game"] .site-header { display: none; }
  body[data-screen="game"] .stage { padding: 10px 24px; }
  .game { gap: 26px; }
  .board-col { gap: 10px; }
  .pbar { min-height: 56px; padding: .35rem 1rem; gap: .9rem; border-radius: 18px; }
  .pbar .chip { width: 42px; height: 42px; }
  .pbar .chip svg { width: 34px; height: 34px; }
  .pbar .nm { font-size: 1.25rem; }
  .pbar .sub { font-size: .9rem; }
  .pbar .taken svg { width: 28px; height: 28px; margin-left: -9px; }
  .pbar .taken .adv { font-size: .95rem; }
  .pbar .resign { font-size: .95rem; padding: .5rem 1.1rem; }
  .side { width: var(--side); max-width: var(--side); margin-top: 0; padding: 30px 28px 26px; gap: 1.2rem; max-height: none; }
  .status { font-size: 1.4rem; }
  .status .chk { font-size: .9rem; }
  .series { font-size: .95rem; gap: 1.6rem; }
  .series b { font-size: 1.7rem; }
  .moves-head { font-size: .85rem; }
  .moves { font-size: 1.05rem; grid-template-columns: 2.6rem 1fr 1fr; }
  .moves-empty { font-size: 1rem; }
  .controls { gap: .65rem; }
  .side .btn-sm { font-size: 1rem; padding: .7rem 1.2rem; }
}

/* ---------- Game screen on wide windows: three columns across the whole screen ----------
   left: the two player cards (Black at the top, White at the bottom, level with the board's edges)
   middle: the board, as tall as the window allows
   right: status, moves and buttons */
@media (min-width: 1100px) and (min-aspect-ratio: 8/5) {   /* wide, landscape windows only; squarer windows keep the layout above */
  :root { --bs: min(calc(100vh - 40px), calc(100vw - 690px), 1400px); }
  body[data-screen="game"] .stage { padding: 14px 28px; }
  .game { display: grid; grid-template-columns: minmax(260px, 1fr) var(--bs) minmax(300px, 1fr); grid-template-rows: var(--bs); gap: clamp(24px, 2.6vw, 52px); align-items: stretch; justify-content: stretch; flex-wrap: nowrap; }
  .board-col { display: contents; }
  .board-wrap { grid-column: 2; grid-row: 1; }
  #bar-top { grid-column: 1; grid-row: 1; align-self: start; }
  #bar-bottom { grid-column: 1; grid-row: 1; align-self: end; }
  .side { grid-column: 3; grid-row: 1; justify-self: start; width: 100%; max-width: 580px; align-self: stretch; max-height: none; margin-top: 0; }

  /* the player cards: a big card per player */
  .pbar { justify-self: end; width: 100%; max-width: 460px; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .6rem 1rem; padding: 1.2rem 1.4rem; border-radius: 22px; min-height: 0; }
  .pbar .chip { width: clamp(52px, 4vw, 72px); height: clamp(52px, 4vw, 72px); }
  .pbar .chip svg { width: clamp(42px, 3.2vw, 58px); height: clamp(42px, 3.2vw, 58px); }
  .pbar .nm { font-size: clamp(1.25rem, 1.75vw, 2.1rem); white-space: normal; overflow-wrap: break-word; }
  .pbar .sub { font-size: clamp(1rem, 1.2vw, 1.25rem); }
  .pbar .taken { grid-column: 1 / -1; margin-left: 0; justify-content: flex-start; min-height: 50px; padding-left: 20px; }
  .pbar .taken svg { width: 54px; height: 54px; margin-left: -20px; }
  .pbar .taken .adv { font-size: 1.1rem; margin-left: .7rem; }
  .pbar .resign { grid-column: 1 / -1; justify-self: stretch; font-size: 1.15rem; padding: .75rem 1rem; }

  /* the right-hand panel: larger text */
  .side { padding: 34px 30px 28px; }
  .status { font-size: clamp(1.5rem, 1.9vw, 2rem); }
  .series { font-size: clamp(1rem, 1.1vw, 1.2rem); }
  .series b { font-size: clamp(1.8rem, 2.2vw, 2.5rem); }
  .moves-head { font-size: 1rem; }
  .moves { font-size: clamp(1.1rem, 1.3vw, 1.4rem); }
  .moves-empty { font-size: 1.15rem; }
  .side .btn-sm { font-size: clamp(1rem, 1.1vw, 1.2rem); padding: .8rem 1.3rem; }
}

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .card { padding: 30px 20px 24px; }
  .names { padding: 32px 22px 28px; }
  .names .input { font-size: 1.15rem; padding: .95rem 1.1rem; }
  .stage { padding: 12px 16px 22px; }
  :root { --bs: min(calc(100vw - 32px), 560px); }
  .side { width: min(100%, 560px); max-width: 560px; max-height: none; grid-template-rows: auto; }
  .moves { max-height: 140px; }
  .pbar .sub { display: none; }
}
@media (max-width: 420px) {
  .pbar .taken svg { width: 18px; height: 18px; margin-left: -6px; }
  .pbar .resign { padding: .3rem .55rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
