/* SmartCrypt — échecs. Sombre, monospace, un seul accent. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;

  --bg: #07080a;
  --panel: rgb(11 12 15 / 0.72);
  --ink: #ece8df;
  --ink-2: #9a9da6;
  --ink-3: #5d616b;
  --line: rgb(236 232 223 / 0.08);
  --line-2: rgb(236 232 223 / 0.16);
  --sq-light: #272c35;
  --sq-dark: #181b21;
  --obsidian: #0a0b0e;

  --accent: #f7931a;
  --accent-rgb: 247 147 26;
  --danger-rgb: 255 86 78;

  --mono: ui-monospace, 'SF Mono', SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  --bar: 2.25rem;
  --gap: 0.75rem;
  --panel-w: 21rem;
  --board: clamp(17.5rem, min(100dvh - 13.5rem, 100vw - var(--panel-w) - 7rem), 44rem);
}

:root[data-accent='mint'] {
  --accent: #35e0a1;
  --accent-rgb: 53 224 161;
  --wdl-2: #258f6a;
  --wdl-3: #1b5d46;
}

:root[data-accent='violet'] {
  --accent: #9b8cff;
  --accent-rgb: 155 140 255;
  --wdl-2: #6a60ad;
  --wdl-3: #474274;
}

/* Victoires / nulles / défaites : une seule teinte, trois pas de clarté —
   lisible sans distinguer les couleurs. Chaque rampe est validée sur le fond
   sombre (pas monotones, écart de clarté suffisant, contraste ≥ 2:1). */
:root {
  --wdl-1: var(--accent);
  --wdl-2: #9d6016;
  --wdl-3: #653f13;
}

[hidden] {
  display: none !important;
}

/* La page reste cachée le temps que app.js la mette dans la langue du joueur :
   on ne voit jamais l'autre langue passer. */
html:not([data-lang]) .app {
  visibility: hidden;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(52rem 34rem at 32% 46%, rgb(var(--accent-rgb) / 0.055), transparent 62%),
    radial-gradient(rgb(236 232 223 / 0.06) 1px, transparent 1px);
  background-size: auto, 24px 24px;
  background-attachment: fixed;
  color: var(--ink);
  font: 0.8125rem/1.5 var(--mono);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.label {
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- Structure ----------------------------------------------------------- */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand__mark {
  width: 0.9375rem;
  height: 0.9375rem;
  color: var(--accent);
}

.brand__name {
  font-weight: 600;
}

.brand__sep {
  color: var(--ink-3);
}

.brand__sub {
  color: var(--ink-2);
}

.top__right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
}

.chain {
  font-size: 0.75rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chain b {
  font-weight: 500;
  color: var(--ink-2);
}

.chain__hash {
  color: var(--accent);
}

.accents {
  display: flex;
  gap: 0.5rem;
  flex: none;
}

.accents button {
  width: 0.75rem;
  height: 0.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--dot);
  opacity: 0.4;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
}

.accents button:hover {
  opacity: 0.8;
}

.accents button[aria-checked='true'] {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--dot);
}

/* Pastille « mon compte » : avatar et pseudo. */
.me {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 12rem;
  height: 1.875rem;
  padding: 0 0.75rem 0 0.25rem;
  font-size: 0.75rem;
  color: var(--ink-2);
  background: none;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.me:hover,
.me[aria-pressed='true'] {
  color: var(--ink);
  border-color: rgb(var(--accent-rgb) / 0.6);
}

.me[aria-pressed='true'] {
  background: rgb(var(--accent-rgb) / 0.08);
}

.me__avatar {
  flex: none;
  display: grid;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  overflow: hidden;
  color: var(--accent);
  background: rgb(var(--accent-rgb) / 0.14);
}

.me__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  padding: 1.5rem 1.75rem 2rem;
}

.play {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: var(--board);
  flex: none;
}

/* --- Joueurs ------------------------------------------------------------- */

.player {
  height: var(--bar);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0 0.125rem;
  white-space: nowrap;
}

.player__chip {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  flex: none;
}

.player--w .player__chip {
  background: var(--ink);
}

.player--b .player__chip {
  background: var(--obsidian);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.player__name {
  color: var(--ink-2);
  transition: color 0.2s;
}

.player__role {
  color: var(--ink-3);
  font-size: 0.75rem;
}

.player.is-active .player__name {
  color: var(--ink);
}

.player.is-active .player__chip {
  animation: pulse 1.8s ease-out infinite;
}

.player--b.is-active .player__chip {
  animation-name: pulse-inset;
}

.player__caps {
  margin-left: auto;
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.cap {
  position: relative;
  width: 1.125rem;
  height: 1.125rem;
  margin-left: -0.3125rem;
  flex: none;
}

.cap:first-child {
  margin-left: 0;
}

.cap svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.player__diff {
  min-width: 1.5rem;
  text-align: right;
  font-size: 0.75rem;
  color: var(--ink-2);
}

/* Pendule d'une partie en ligne. */
.player__clock {
  flex: none;
  min-width: 4.25rem;
  padding: 0.125rem 0.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.player__clock.is-running {
  color: var(--ink);
  border-color: var(--line-2);
  background: rgb(236 232 223 / 0.07);
}

.player__clock.is-running.is-low {
  color: rgb(var(--danger-rgb));
  border-color: rgb(var(--danger-rgb) / 0.55);
  background: rgb(var(--danger-rgb) / 0.1);
}

/* --- Échiquier ----------------------------------------------------------- */

.board {
  position: relative;
  width: var(--board);
  height: var(--board);
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--line-2), 0 2.5rem 5rem -1.5rem rgb(0 0 0 / 0.9);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.board:focus-visible {
  box-shadow: 0 0 0 1px var(--line-2), 0 0 0 4px rgb(var(--accent-rgb) / 0.35), 0 2.5rem 5rem -1.5rem rgb(0 0 0 / 0.9);
}

.squares {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template: repeat(8, 1fr) / repeat(8, 1fr);
  border-radius: inherit;
  overflow: hidden;
}

.rank {
  display: contents;
}

.sq {
  position: relative;
  background-color: var(--sq-dark);
}

.sq--light {
  background-color: var(--sq-light);
}

.sq.can-move {
  cursor: grab;
}

.sq.is-target {
  cursor: pointer;
}

.sq__coord {
  position: absolute;
  font-size: clamp(0.5625rem, var(--board) / 60, 0.6875rem);
  line-height: 1;
  color: var(--ink-3);
  pointer-events: none;
}

.sq__coord--file {
  right: 0.3125rem;
  bottom: 0.25rem;
}

.sq__coord--rank {
  left: 0.3125rem;
  top: 0.25rem;
}

/* Dernier coup : cases teintées. */
.sq.is-last {
  background-image: linear-gradient(rgb(var(--accent-rgb) / 0.14) 0 0);
}

/* Pièce sélectionnée : teinte + équerres aux quatre coins. */
.sq.is-selected {
  background-image: linear-gradient(rgb(var(--accent-rgb) / 0.22) 0 0);
}

.sq.is-selected::after,
.board:focus-visible .sq.is-cursor::after {
  content: '';
  position: absolute;
  inset: 4px;
  --t: 2px;
  --l: 22%;
  --c: var(--accent);
  background:
    linear-gradient(var(--c) 0 0) top left / var(--l) var(--t),
    linear-gradient(var(--c) 0 0) top left / var(--t) var(--l),
    linear-gradient(var(--c) 0 0) top right / var(--l) var(--t),
    linear-gradient(var(--c) 0 0) top right / var(--t) var(--l),
    linear-gradient(var(--c) 0 0) bottom left / var(--l) var(--t),
    linear-gradient(var(--c) 0 0) bottom left / var(--t) var(--l),
    linear-gradient(var(--c) 0 0) bottom right / var(--l) var(--t),
    linear-gradient(var(--c) 0 0) bottom right / var(--t) var(--l);
  background-repeat: no-repeat;
  pointer-events: none;
}

.board:focus-visible .sq.is-cursor:not(.is-selected)::after {
  --c: var(--ink);
}

/* Destinations possibles : point pour un coup calme, anneau pour une prise. */
.sq.is-target::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgb(var(--accent-rgb) / 0.6);
  transition: transform 0.12s ease-out;
  pointer-events: none;
}

.sq.is-target.is-capture::before {
  width: 88%;
  height: 88%;
  background: none;
  border: 2px solid rgb(var(--accent-rgb) / 0.7);
}

@media (hover: hover) {
  .sq.is-target:hover::before {
    transform: scale(1.35);
  }

  .sq.is-target.is-capture:hover::before {
    transform: scale(1.06);
  }
}

.sq.is-check {
  background-image: radial-gradient(circle, rgb(var(--danger-rgb) / 0.6) 0%, rgb(var(--danger-rgb) / 0.16) 55%, transparent 74%);
}

/* --- Pièces -------------------------------------------------------------- */

.pieces {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.piece {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
  transition: transform 0.2s cubic-bezier(0.22, 0.8, 0.26, 1), opacity 0.18s ease-out;
  will-change: transform;
}

.piece svg {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
  overflow: visible;
  filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.5));
  transition: transform 0.15s ease-out;
}

.piece.is-moving {
  z-index: 3;
}

.piece.is-dragging {
  z-index: 6;
  transition: none;
}

.piece.is-dragging svg {
  transform: scale(1.14);
  filter: drop-shadow(0 8px 10px rgb(0 0 0 / 0.6));
}

.piece.is-leaving {
  opacity: 0;
  z-index: 1;
}

.piece.is-new {
  animation: fade 0.22s ease-out;
}

/* Blancs : ivoire plein. Noirs : obsidienne, liseré à la couleur d'accent. */
.piece--w {
  --pc-edge: var(--ink);
  --pc-body: var(--ink);
  --pc-detail: #1b1e24;
}

.piece--b {
  --pc-edge: var(--accent);
  --pc-body: var(--obsidian);
  --pc-detail: var(--accent);
}

.pc-edge {
  fill: var(--pc-edge);
  stroke: var(--pc-edge);
  stroke-width: 7;
  stroke-linejoin: round;
}

.pc-body {
  fill: var(--pc-body);
  stroke: var(--pc-body);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.pc-detail {
  fill: none;
  stroke: var(--pc-detail);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Promotion et fin de partie ------------------------------------------ */

.promo {
  position: absolute;
  inset: 0;
  z-index: 20;
  border-radius: inherit;
  background: rgb(7 8 10 / 0.6);
  animation: fade 0.15s ease-out;
}

.promo__menu {
  position: absolute;
  top: 0;
  width: 12.5%;
  display: flex;
  flex-direction: column;
  background: #0e1013;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgb(var(--accent-rgb) / 0.7), 0 1rem 2.5rem rgb(0 0 0 / 0.7);
  overflow: hidden;
}

.promo__menu--up {
  top: auto;
  bottom: 0;
  flex-direction: column-reverse;
}

.promo__opt {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.promo__opt:hover,
.promo__opt:focus-visible {
  background: rgb(var(--accent-rgb) / 0.18);
  outline: none;
}

.promo__opt svg {
  position: absolute;
  inset: 9%;
  width: 82%;
  height: 82%;
  overflow: visible;
}

.verdict {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  border-radius: inherit;
  background: rgb(7 8 10 / 0.62);
  animation: fade 0.35s ease-out;
}

.verdict__card {
  max-width: 86%;
  padding: 1.5rem 1.75rem;
  text-align: center;
  background: rgb(11 12 15 / 0.96);
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--line-2), 0 1.5rem 3rem rgb(0 0 0 / 0.6);
}

.verdict__title {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.verdict__sub {
  margin: 0 0 1.125rem;
  color: var(--ink-2);
}

.verdict__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

/* --- Panneau ------------------------------------------------------------- */

.panel {
  width: var(--panel-w);
  height: calc(var(--board) + 2 * var(--bar) + 2 * var(--gap));
  min-height: 31rem;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.block {
  padding: 1rem 1.125rem;
  border-bottom: 1px solid var(--line);
}

.block:last-child {
  border-bottom: 0;
}

.block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.status__main {
  margin: 0;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}

.status__sub {
  margin: 0.25rem 0 0;
  min-height: 1.125rem;
  font-size: 0.75rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.caret {
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 0.35em;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: blink 1s steps(2, start) infinite;
}

.ticker__val {
  font-size: 0.875rem;
}

.ticker__val.is-muted {
  font-size: 0.6875rem;
  color: var(--ink-3);
}

.spark {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.spark__zero {
  stroke: var(--line-2);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.spark__area {
  fill: rgb(var(--accent-rgb) / 0.12);
}

.spark__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark__dot {
  fill: var(--accent);
}

.ledger {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.6875rem;
  color: var(--ink-3);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line-2);
  text-underline-offset: 3px;
  transition: color 0.15s;
}

.link:hover {
  color: var(--accent);
}

.ledger__rows {
  flex: 1;
  min-height: 0;
  margin: 0 -0.5rem;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.ledger__row {
  display: grid;
  grid-template-columns: 2.25rem 1fr 1fr 4.5rem;
  align-items: baseline;
  padding: 0.1875rem 0.5rem;
  border-radius: 4px;
}

.ledger__row:hover {
  background: rgb(236 232 223 / 0.04);
}

.ledger__n {
  color: var(--ink-3);
}

.ledger__mv {
  color: var(--ink-2);
}

.ledger__mv.is-head {
  color: var(--accent);
}

.ledger__row--genesis .ledger__mv {
  grid-column: span 2;
  color: var(--ink-3);
}

.ledger__hash {
  text-align: right;
  font-size: 0.6875rem;
  color: var(--ink-3);
}

.ledger__note {
  margin: 0.625rem 0 0;
  font-size: 0.625rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.actions > :first-child {
  flex: 1;
}

/* Commandes d'une partie en ligne : invitation, propositions, indications. */
.online {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.online:empty {
  display: none;
}

.invite {
  display: flex;
  gap: 0.5rem;
}

.invite__url {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.625rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--accent);
  background: rgb(236 232 223 / 0.04);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  text-overflow: ellipsis;
}

.hint {
  margin: 0;
  font-size: 0.6875rem;
  color: var(--ink-3);
}

.actions > .hint {
  align-self: center;
}

.offer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.375rem 0.375rem 0.375rem 0.625rem;
  font-size: 0.75rem;
  border: 1px solid rgb(var(--accent-rgb) / 0.5);
  border-radius: 6px;
  animation: fade 0.25s ease-out;
}

.offer__btns {
  display: flex;
  gap: 0.375rem;
}

.offer .btn {
  padding: 0.3125rem 0.5rem;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: opacity 0.2s;
}

.setting.is-off {
  opacity: 0.3;
  pointer-events: none;
}

.btn {
  appearance: none;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s, filter 0.15s;
}

.btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: rgb(var(--accent-rgb) / 0.6);
}

.btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn.is-confirm {
  color: var(--accent);
  border-color: var(--accent);
}

.btn--accent,
.btn--accent:hover:not(:disabled) {
  color: #0a0a0a;
  font-weight: 600;
  background: var(--accent);
  border-color: var(--accent);
}

.btn--accent:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn--icon {
  display: inline-grid;
  place-items: center;
  padding: 0.5rem 0.625rem;
}

.btn--icon svg {
  width: 0.875rem;
  height: 0.875rem;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  overflow: hidden;
}

.seg button {
  padding: 0.3125rem 0.625rem;
  font-size: 0.75rem;
  color: var(--ink-3);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.seg button + button {
  border-left: 1px solid var(--line);
}

.seg button:hover {
  color: var(--ink-2);
}

.seg button[aria-pressed='true'] {
  color: var(--ink);
  background: rgb(236 232 223 / 0.08);
}

.seg button:focus-visible {
  outline-offset: -2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 50;
  transform: translateX(-50%);
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
  color: var(--bg);
  background: var(--ink);
  border-radius: 6px;
  box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.5);
  animation: toast-in 0.2s ease-out;
}

/* --- Compte ---------------------------------------------------------------- */

.account {
  flex: 1;
  padding: 1.5rem 1.75rem 3rem;
}

.account__inner {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 58rem;
  margin: 0 auto;
}

.account__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.btn--back {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding-left: 0.5rem;
}

.btn--back svg {
  width: 0.875rem;
  height: 0.875rem;
}

.badge {
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1px dashed rgb(var(--accent-rgb) / 0.6);
  border-radius: 999px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 0;
}

.identity__avatar {
  flex: none;
  display: grid;
  width: 4rem;
  height: 4rem;
  border-radius: 14px;
  overflow: hidden;
  color: var(--accent);
  background: rgb(var(--accent-rgb) / 0.1);
  box-shadow: 0 0 0 1px rgb(var(--accent-rgb) / 0.35);
}

.identity__text {
  min-width: 0;
}

.identity__name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
}

.identity__name h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.identity__meta {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--ink-3);
}

.identity__meta .link {
  font-size: inherit;
}

.identity__form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}

.field {
  width: 14rem;
  min-width: 0;
  padding: 0.4375rem 0.625rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: rgb(236 232 223 / 0.04);
  border: 1px solid var(--line-2);
  border-radius: 6px;
}

.field[aria-invalid='true'] {
  border-color: rgb(var(--danger-rgb) / 0.7);
}

.hint.is-error {
  color: rgb(var(--danger-rgb));
}

/* Mode d'emploi de la connexion, pour un invité. */
.guide {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.125rem 1.25rem 1.25rem;
  background: var(--panel);
  border: 1px solid rgb(var(--accent-rgb) / 0.28);
  border-radius: 10px;
}

.guide p {
  margin: 0;
}

.guide__lead,
.guide__status {
  max-width: 46rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.guide__status {
  color: var(--ink);
}

.guide__ways {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.25rem 2rem;
  align-self: stretch;
}

.guide__way {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.guide__action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.guide__problem {
  font-size: 0.75rem;
  color: rgb(var(--danger-rgb));
}

.guide .hint {
  max-width: 46rem;
  line-height: 1.5;
}

.guide__safe {
  align-self: stretch;
  padding-top: 0.75rem;
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--ink-3);
  border-top: 1px solid var(--line);
}

/* Étapes numérotées : une étape faite est cochée, celle en cours prend l'accent. */
.steps {
  display: grid;
  gap: 0.5rem;
  max-width: 46rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  position: relative;
  min-height: 1.375rem;
  padding-left: 2rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--ink-2);
  counter-increment: step;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  top: -0.0625rem;
  left: 0;
  display: grid;
  place-items: center;
  width: 1.375rem;
  height: 1.375rem;
  font-size: 0.6875rem;
  color: var(--ink-3);
  border: 1px solid var(--line-2);
  border-radius: 50%;
}

.steps > li.is-current {
  color: var(--ink);
}

.steps > li.is-current::before {
  color: var(--accent);
  border-color: var(--accent);
}

.steps > li.is-done {
  color: var(--ink-3);
}

.steps > li.is-done::before {
  content: '✓';
  color: var(--accent);
  background: rgb(var(--accent-rgb) / 0.12);
  border-color: rgb(var(--accent-rgb) / 0.45);
}

.steps a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.steps .link {
  font-size: inherit;
}

/* Solde, mises en jeu, résultat net. */
.tiles {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: 0.75rem;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
  padding: 1rem 1.125rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.tile__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.375rem;
}

.tile__value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
  margin: 0.125rem 0 0;
  font-size: 1.75rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* Le solde est le chiffre que la page met en avant : un seul, en grand. */
.tile__value--hero {
  font-size: clamp(2.25rem, 8vw, 3rem);
}

.tile__value.is-empty {
  font-size: 1.75rem;
  color: var(--ink-3);
}

.tile__unit {
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  color: var(--ink-2);
}

.tile__sub {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-3);
}

.tile__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.875rem;
  margin-top: auto;
  padding-top: 0.625rem;
  font-size: 0.75rem;
}

.tile .hint {
  margin-top: 0.25rem;
}

.addr {
  color: var(--ink-2);
}

.tag {
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  color: var(--ink-2);
  white-space: nowrap;
  border: 1px solid var(--line-2);
  border-radius: 999px;
}

.tag--warn {
  color: rgb(var(--danger-rgb));
  border-color: rgb(var(--danger-rgb) / 0.5);
}

/* Un montant signé porte son sens dans le signe ; la couleur ne fait qu'appuyer. */
.is-down {
  color: rgb(var(--danger-rgb));
}

/* Statistiques : chiffres, puis leur répartition en une barre fine. */
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem 0.75rem;
  padding: 1rem 1.125rem 1.125rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.stat .label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}

.stat__value {
  font-size: 1.375rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.stat__share {
  margin-left: 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0;
  color: var(--ink-3);
}

.stats__note {
  grid-column: 1 / -1;
}

.swatch {
  flex: none;
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 2px;
}

.swatch--1,
.wdl__seg--1 {
  background: var(--wdl-1);
}

.swatch--2,
.wdl__seg--2 {
  background: var(--wdl-2);
}

.swatch--3,
.wdl__seg--3 {
  background: var(--wdl-3);
}

.wdl {
  grid-column: 1 / -1;
  display: flex;
  gap: 2px;
  height: 8px;
}

.wdl__seg {
  position: relative;
  flex: 1 1 0;
  min-width: 3px;
  transition: filter 0.15s;
}

.wdl__seg:first-child {
  border-radius: 4px 0 0 4px;
}

.wdl__seg:last-child {
  border-radius: 0 4px 4px 0;
}

.wdl__seg:only-child {
  border-radius: 4px;
}

/* Zone de survol plus haute que le trait lui-même. */
.wdl__seg::after {
  content: '';
  position: absolute;
  inset: -0.625rem 0;
}

.wdl__seg:hover {
  filter: brightness(1.25);
}

/* Historique des parties. */
.history {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.history__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  padding: 1rem 1.125rem 0.75rem;
}

/* Parties jouées en invité sur cet appareil, à verser au compte. */
.history__import {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin: 0 1.125rem 0.75rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.75rem;
  color: var(--ink-2);
  border: 1px dashed var(--line-2);
  border-radius: 8px;
}

.history__import p {
  margin: 0;
}

.history__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  padding: 1.75rem 1.125rem 2.25rem;
  color: var(--ink-3);
  text-align: center;
}

.history__empty p {
  margin: 0;
}

.history__more {
  display: flex;
  justify-content: center;
  padding: 0.875rem;
  border-top: 1px solid var(--line);
}

.games {
  margin: 0;
  padding: 0;
  list-style: none;
}

.games__cols,
.game__row {
  display: grid;
  grid-template-columns: 8.25rem minmax(0, 1.3fr) minmax(0, 1.2fr) 4.75rem 1rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5625rem 1.125rem;
}

.history--stakes .games__cols,
.history--stakes .game__row {
  grid-template-columns: 8.25rem minmax(0, 1.3fr) minmax(0, 1.2fr) 4.75rem 4.25rem 4.5rem 1rem;
}

.games__cols {
  padding-top: 0;
  padding-bottom: 0.5rem;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}

.game + .game {
  border-top: 1px solid var(--line);
}

.game__row {
  width: 100%;
  font: inherit;
  color: var(--ink-2);
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
  transition: background-color 0.15s;
}

.game__row:hover,
.game.is-open .game__row {
  background: rgb(236 232 223 / 0.035);
}

.game__row:focus-visible {
  outline-offset: -2px;
}

.game__date {
  font-size: 0.75rem;
  color: var(--ink-3);
  white-space: nowrap;
}

.game__who,
.game__result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  white-space: nowrap;
}

.game__who {
  color: var(--ink);
}

.game__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.game__result {
  gap: 0.375rem;
  overflow: hidden;
}

.game__who em,
.game__result em {
  font-size: 0.75rem;
  font-style: normal;
  color: var(--ink-3);
}

.game__num {
  text-align: right;
  white-space: nowrap;
}

.game__plies {
  font-size: 0.75rem;
  color: var(--ink-3);
}

.game__gain.is-up {
  color: var(--ink);
}

.game__chev {
  color: var(--ink-3);
  text-align: center;
  transition: transform 0.15s;
}

.game.is-open .game__chev {
  transform: rotate(90deg);
}

/* Camp joué : même code que sur l'échiquier (ivoire plein, obsidienne liserée). */
.chip {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
}

.chip--w {
  background: var(--ink);
}

.chip--b {
  background: var(--obsidian);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.game__detail {
  display: flex;
  gap: 1.125rem;
  padding: 0.625rem 1.125rem 1.125rem;
  background: rgb(236 232 223 / 0.035);
  animation: fade 0.2s ease-out;
}

.mini {
  flex: none;
  display: grid;
  grid-template: repeat(8, 1fr) / repeat(8, 1fr);
  width: 10rem;
  height: 10rem;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line-2);
}

.mini__sq {
  position: relative;
  background: var(--sq-dark);
}

.mini__sq.is-light {
  background: var(--sq-light);
}

.mini__sq svg {
  position: absolute;
  inset: 7%;
  width: 86%;
  height: 86%;
  overflow: visible;
}

.game__info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.625rem;
  min-width: 0;
}

.game__moves {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.game__hash {
  margin: 0;
  font-size: 0.6875rem;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.account__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--ink-3);
}

.account__links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.link.is-confirm {
  color: rgb(var(--danger-rgb));
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch__track {
  position: relative;
  width: 1.75rem;
  height: 1rem;
  background: rgb(236 232 223 / 0.12);
  border-radius: 999px;
  transition: background-color 0.15s;
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.75rem;
  height: 0.75rem;
  background: var(--ink-2);
  border-radius: 50%;
  transition: transform 0.15s, background-color 0.15s;
}

.switch input:checked + .switch__track {
  background: rgb(var(--accent-rgb) / 0.35);
}

.switch input:checked + .switch__track::after {
  background: var(--accent);
  transform: translateX(0.75rem);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Message plein écran quand le jeu ne peut pas démarrer (pas de JS, file://). */
.notice {
  position: fixed;
  inset: 0;
  z-index: 100;
  margin: 0;
  padding: 2rem;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 2;
  background: rgb(7 8 10 / 0.94);
}

.notice code {
  padding: 0.125rem 0.375rem;
  color: var(--accent);
  border: 1px solid var(--line-2);
  border-radius: 4px;
}

/* --- Animations ---------------------------------------------------------- */

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 0.5rem);
  }
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgb(236 232 223 / 0.5);
  }
  100% {
    box-shadow: 0 0 0 0.5rem rgb(236 232 223 / 0);
  }
}

@keyframes pulse-inset {
  0% {
    box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 0 rgb(var(--accent-rgb) / 0.6);
  }
  100% {
    box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 0.5rem rgb(var(--accent-rgb) / 0);
  }
}

/* --- Écrans étroits : le panneau passe sous l'échiquier -------------------- */

@media (max-width: 54rem) {
  :root {
    --board: min(100vw - 2rem, 36rem);
  }

  .top {
    padding: 0.875rem 1rem;
  }

  .stage {
    flex-direction: column;
    justify-content: flex-start;
    gap: 1.25rem;
    padding: 1rem 1rem 2rem;
  }

  .panel {
    width: var(--board);
    height: auto;
    min-height: 0;
  }

  .ledger__rows {
    flex: none;
    max-height: 13rem;
  }
}

@media (max-width: 30rem) {
  .chain {
    display: none;
  }

  .top__right {
    gap: 0.75rem;
  }

  .me {
    padding: 0 0.25rem;
  }

  .me__name {
    display: none;
  }
}

/* Page Compte sur écran étroit : tuiles empilées, parties sur deux lignes. */
@media (max-width: 46rem) {
  .account {
    padding: 1rem 1rem 2.5rem;
  }

  .tiles {
    grid-template-columns: 1fr 1fr;
  }

  .tile--wallet {
    grid-column: 1 / -1;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .games__cols {
    display: none;
  }

  .game__row,
  .history--stakes .game__row {
    grid-template-columns: minmax(0, 1fr) auto 1rem;
    grid-template-areas:
      'who side chev'
      'result date chev';
    gap: 0.125rem 0.75rem;
    padding: 0.6875rem 1rem;
  }

  .game__who {
    grid-area: who;
  }

  .game__who em {
    display: none;
  }

  .game__result {
    grid-area: result;
    font-size: 0.75rem;
  }

  .game__date {
    grid-area: date;
    text-align: right;
  }

  .game__chev {
    grid-area: chev;
  }

  /* À droite de l'adversaire : le gain s'il y a des mises, sinon le nombre de coups. */
  .game__plies {
    grid-area: side;
  }

  .history--stakes .game__plies,
  .game__stake {
    display: none;
  }

  .game__gain {
    grid-area: side;
  }

  .history__head,
  .game__detail {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .game__detail {
    flex-direction: column;
  }

  .mini {
    width: min(100%, 14rem);
    height: auto;
    aspect-ratio: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Shogi --------------------------------------------------------------- */

/* Choix du jeu, dans l'en-tête. */
.gameswitch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Choix de la langue, dans l'en-tête : « fr · en », la langue active soulignée. */
.langswitch {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.langswitch button {
  padding: 0.125rem 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--ink-3);
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.langswitch button:hover {
  color: var(--ink-2);
}

.langswitch button[aria-checked='true'] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.langswitch button:focus-visible {
  outline: 2px solid rgb(var(--accent-rgb) / 0.6);
  outline-offset: 3px;
  border-radius: 2px;
}

.gameswitch button {
  padding: 0.125rem 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--ink-3);
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.gameswitch button:hover {
  color: var(--ink-2);
}

.gameswitch button[aria-checked='true'] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.gameswitch button:focus-visible {
  outline: 2px solid rgb(var(--accent-rgb) / 0.6);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Deux rangées de plus qu'aux échecs : les pièces en main de chaque camp. */
.stage--shogi {
  --hand: 2.5rem;
  --board: clamp(17.5rem, min(100dvh - 20rem, 100vw - var(--panel-w) - 7rem), 44rem);
}

.stage--shogi .panel {
  height: calc(var(--board) + 2 * var(--bar) + 2 * var(--hand) + 4 * var(--gap));
}

.squares--shogi {
  grid-template: repeat(9, 1fr) / repeat(9, 1fr);
}

/* Plateau uni, quadrillé d'un trait fin. */
.ssq {
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 0.5px var(--line-2);
}

.ssq.can-move,
.ssq.is-target {
  cursor: pointer;
}

/* Les quatre repères du plateau, posés sur les croisements. */
.ssq--hoshi:not(.is-selected, .is-cursor)::after {
  content: '';
  position: absolute;
  right: -0.15625rem;
  bottom: -0.15625rem;
  z-index: 1;
  width: 0.3125rem;
  height: 0.3125rem;
  border-radius: 50%;
  background: var(--ink-3);
  pointer-events: none;
}

/* Repères hors du plateau, pour ne pas passer sous les pièces. */
.scoords {
  position: absolute;
  display: grid;
  font-size: 0.5625rem;
  line-height: 1;
  color: var(--ink-3);
  text-align: center;
  pointer-events: none;
}

.scoords--files {
  left: 0;
  right: 0;
  top: -0.8125rem;
  grid-template-columns: repeat(9, 1fr);
}

.scoords--ranks {
  top: 0;
  bottom: 0;
  right: -0.75rem;
  grid-template-rows: repeat(9, 1fr);
  align-items: center;
}

/* Pièces : Sente en ivoire, Gote en obsidienne à liseré d'accent, pointe
   tournée vers l'adversaire. Une pièce promue s'écrit en couleur. */
.koma {
  display: block;
  width: 88%;
  height: 88%;
  pointer-events: none;
}

.koma svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.5));
}

.koma--w {
  --koma-edge: var(--ink);
  --koma-body: var(--ink);
  --koma-ink: #1b1e24;
  --koma-promoted: #b3261e;
}

.koma--b {
  --koma-edge: var(--accent);
  --koma-body: var(--obsidian);
  --koma-ink: var(--ink);
  --koma-promoted: var(--accent);
}

/* Les pièces du camp affiché en haut regardent vers le bas. */
.koma.is-far svg {
  transform: rotate(180deg);
}

.koma__edge {
  fill: var(--koma-edge);
  stroke: var(--koma-edge);
  stroke-width: 6;
  stroke-linejoin: round;
}

.koma__body {
  fill: var(--koma-body);
  stroke: var(--koma-body);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.koma__glyph {
  fill: var(--koma-ink);
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif CJK JP', 'Songti SC', serif;
  font-size: 50px;
  font-weight: 600;
}

.koma__glyph.is-promoted {
  fill: var(--koma-promoted);
}

.koma--latin .koma__glyph {
  font-family: var(--mono);
  font-size: 46px;
}

.koma--latin .koma__glyph.is-wide {
  font-size: 34px;
  letter-spacing: -2px;
}

/* Jeu international : la lettre reste droite, seule la pièce se retourne. */
.koma--latin.is-far .koma__glyph {
  transform: rotate(180deg);
  transform-box: fill-box;
  transform-origin: center;
}

/* Pièces en main. */
.hand {
  height: var(--hand);
  display: flex;
  align-items: center;
  gap: 0.125rem;
  min-width: 0;
  padding: 0 0.125rem;
}

.hand__empty {
  font-size: 0.75rem;
  color: var(--ink-3);
}

.hand__pc {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: var(--hand);
  height: var(--hand);
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  transition: background-color 0.12s;
}

.hand__pc:disabled {
  cursor: default;
}

.hand__pc:not(:disabled):hover {
  background: rgb(var(--accent-rgb) / 0.12);
}

.hand__pc.is-selected {
  background: rgb(var(--accent-rgb) / 0.22);
  box-shadow: inset 0 0 0 1px rgb(var(--accent-rgb) / 0.7);
}

.hand__pc:focus-visible {
  outline: 2px solid rgb(var(--accent-rgb) / 0.6);
  outline-offset: 1px;
}

.hand__n {
  position: absolute;
  right: -0.0625rem;
  bottom: -0.0625rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.1875rem;
  border-radius: 0.5rem;
  background: var(--obsidian);
  box-shadow: 0 0 0 1px var(--line-2);
  color: var(--ink);
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1rem;
  text-align: center;
}

.player__clock--end {
  margin-left: auto;
}

/* Choix de promotion. */
.sprompt {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  border-radius: inherit;
  background: rgb(7 8 10 / 0.6);
  animation: fade 0.15s ease-out;
}

.sprompt__card {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #0e1013;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgb(var(--accent-rgb) / 0.7), 0 1rem 2.5rem rgb(0 0 0 / 0.7);
}

.sprompt__opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  width: 6rem;
  padding: 0.625rem 0.5rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.sprompt__opt:hover,
.sprompt__opt:focus-visible {
  background: rgb(var(--accent-rgb) / 0.18);
  color: var(--ink);
  outline: none;
}

.sprompt__opt .koma {
  width: 3.5rem;
  height: 3.5rem;
}

/* Position finale d'une partie de shogi, dans l'historique. */
.mini--shogi {
  grid-template: repeat(9, 1fr) / repeat(9, 1fr);
}

.mini--shogi .mini__sq {
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 0.5px var(--line);
}

.mini--shogi .koma {
  width: 92%;
  height: 92%;
}

.mini--shogi .koma svg {
  position: static;
  width: 100%;
  height: 100%;
  filter: none;
}

.mini__hands {
  margin: 0.375rem 0 0;
  font-size: 0.6875rem;
  color: var(--ink-2);
}

@media (max-width: 54rem) {
  .stage--shogi {
    --board: min(100vw - 2rem, 36rem);
  }

  .stage--shogi .panel {
    height: auto;
  }
}

/* Écran étroit : le nom du site laisse sa place au choix du jeu. */
@media (max-width: 30rem) {
  .brand__name,
  .brand__sep {
    display: none;
  }
}

/* --- Salon : parties publiques qui attendent un adversaire ----------------- */

.lobby {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.lobby__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.lobby__count {
  font-size: 0.6875rem;
  color: var(--ink-3);
}

.lobby__list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  max-height: 15rem;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.lobby__game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'who join'
    'meta join';
  align-items: center;
  gap: 0.125rem 0.625rem;
  padding: 0.4375rem 0.4375rem 0.4375rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.lobby__who {
  grid-area: who;
  overflow: hidden;
  font-size: 0.8125rem;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby__rating {
  color: var(--ink-3);
}

.lobby__meta {
  grid-area: meta;
  font-size: 0.6875rem;
  color: var(--ink-3);
}

.lobby__game .btn {
  grid-area: join;
  padding: 0.3125rem 0.625rem;
}

.lobby__ranking {
  align-self: flex-start;
}

/* Fin d'une partie classée : les points gagnés ou perdus. */
.verdict__rating {
  margin: -0.75rem 0 1.125rem;
  font-size: 0.8125rem;
  color: var(--ink);
}

/* --- Page Classement ------------------------------------------------------- */

.ranking__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ranking__head h1 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.ranking__intro {
  max-width: 44rem;
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.ranking {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.ranking > .hint,
.ranking__place {
  margin: 0;
  padding: 1rem 1.125rem 0.75rem;
}

.ranking__place {
  font-size: 0.8125rem;
  color: var(--ink);
}

.ranking__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking__cols,
.ranking__row {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) 7rem 4.5rem 7rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5625rem 1.125rem;
}

.ranking__cols {
  padding-top: 0;
  padding-bottom: 0.5rem;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}

.ranking__row + .ranking__row,
.ranking__gap + .ranking__row {
  border-top: 1px solid var(--line);
}

.ranking__row.is-you {
  background: rgb(var(--accent-rgb) / 0.07);
}

.ranking__rank {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.ranking__player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  white-space: nowrap;
}

.ranking__player em {
  font-style: normal;
  color: var(--ink-3);
}

.ranking__avatar {
  flex: none;
  display: grid;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  overflow: hidden;
  color: var(--accent);
  background: rgb(var(--accent-rgb) / 0.14);
}

.ranking__num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ranking__wdl {
  font-size: 0.75rem;
  color: var(--ink-3);
}

.ranking__prov {
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.ranking__gap {
  padding: 0.125rem 1.125rem;
  color: var(--ink-3);
  text-align: center;
}

/* Page Compte : la place au classement, et les points de chaque partie. */
.standing {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 1rem 1.125rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.standing__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.standing__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  color: var(--ink);
}

.standing__line.is-empty {
  color: var(--ink-3);
}

.game__elo {
  font-size: 0.75rem;
  color: var(--ink-2);
}

.game__elo.is-up {
  color: var(--ink);
}

/* Classement sur écran étroit : rang, joueur et points seulement. */
@media (max-width: 46rem) {
  .ranking__cols,
  .ranking__row {
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    gap: 0.625rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .ranking__cols > :nth-child(n + 4),
  .ranking__row > :nth-child(n + 4) {
    display: none;
  }

  .ranking > .hint,
  .ranking__place,
  .standing {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
