/* =========================================================================
   Gran Ajedrez de Amir Timur — hoja de estilos
   Paleta: lapislázuli, oro viejo, marfil y terracota.
   Fuentes servidas desde el propio dominio (sin CDN ni peticiones externas).
   ========================================================================= */

@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("../assets/fonts/cormorant-garamond-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../assets/fonts/manrope-latin.woff2") format("woff2");
}

:root {
  --bg: #0a111d;
  --bg-deep: #070c15;
  --panel: rgba(18, 30, 48, 0.78);
  --panel-solid: #122033;
  --panel-soft: rgba(28, 44, 68, 0.62);
  --ink: #f4ead7;
  --ink-soft: #d9cbb2;
  --muted: #9cafc7;
  --muted-2: #71839b;
  --gold: #d8b06a;
  --gold-bright: #f4d99c;
  --gold-dim: #8e6a33;
  --line: rgba(216, 176, 106, 0.24);
  --line-soft: rgba(255, 255, 255, 0.08);
  --danger: #e07a66;
  --green: #7bc59c;
  --violet: #b79cf0;

  --board-light: #bda57d;
  --board-dark: #967b55;
  --board-line: rgba(51, 33, 14, 0.3);
  --frame-1: #3c2417;
  --frame-2: #24140d;
  --frame-3: #120a07;
  --frame-edge: #ad8248;
  --sq: clamp(28px, min(calc((100vw - 370px) / 13), calc((100vh - 70px) / 10), 106px), 106px);

  --radius: 18px;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(48, 88, 138, 0.38), transparent 60%),
    radial-gradient(900px 600px at 100% 8%, rgba(140, 96, 35, 0.18), transparent 55%),
    radial-gradient(800px 700px at 50% 110%, rgba(32, 70, 104, 0.24), transparent 60%),
    linear-gradient(180deg, #0b1422 0%, #080e18 55%, #060a12 100%);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.055'/%3E%3C/svg%3E");
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(500px 300px at 20% 30%, rgba(216, 176, 106, 0.05), transparent 70%),
    radial-gradient(500px 300px at 80% 70%, rgba(96, 137, 190, 0.06), transparent 70%);
}

::selection { background: rgba(216, 176, 106, 0.35); color: #fff; }

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
a { color: var(--gold-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

.ico { width: 18px; height: 18px; flex: none; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: relative;
  z-index: 5;
  width: min(100% - 40px, 1620px);
  margin: 0 auto;
  padding: 18px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--gold-bright);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 236, 190, 0.18), rgba(19, 32, 51, 0.8));
  border: 1px solid rgba(216, 176, 106, 0.45);
  box-shadow: 0 0 0 4px rgba(216, 176, 106, 0.06), inset 0 0 18px rgba(216, 176, 106, 0.12);
  flex: none;
}
.brand-mark svg { width: 34px; height: 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-kicker {
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
}
.brand-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.4);
}

.topnav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}
.btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.btn-ghost { border-color: rgba(216, 176, 106, 0.18); }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; border-color: rgba(216, 176, 106, 0.18); }
.btn-icon .ico { width: 19px; height: 19px; }
.btn-icon[aria-pressed="false"] .ico-sound-on { display: none; }
.btn-icon[aria-pressed="true"] .ico-sound-off { display: none; }
.btn-gold {
  color: #241506;
  background: linear-gradient(180deg, #f4d99c 0%, #d8b06a 48%, #bb8c45 100%);
  border-color: #f0d59a;
  box-shadow: 0 8px 24px rgba(213, 170, 95, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  font-weight: 800;
}
.btn-gold:hover { background: linear-gradient(180deg, #ffe9b8, #e3bd77 48%, #c89a50); color: #1b0f04; }
.btn-wide { min-width: 190px; }
.btn-danger { color: #ffd9cf; border-color: rgba(224, 122, 102, 0.45); background: rgba(224, 122, 102, 0.1); }

/* ---------------------------------------------------------------- layout */
.layout {
  position: relative;
  z-index: 2;
  width: min(100% - 24px, 1900px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 300px;
  gap: clamp(16px, 1.7vw, 24px);
  align-items: start;
  justify-content: center;
}

.game-column {
  width: calc(var(--sq) * 13 + 20px);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
#playerBlack { order: 0; }
.turn-banner { order: 1; }
.board-shell { order: 2; }
#playerWhite { order: 3; }
.board-status { order: 4; }
.mobile-actions { order: 5; }
body.flipped #playerWhite { order: 0; }
body.flipped #playerBlack { order: 3; }

.player-bar {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(24, 39, 61, 0.66), rgba(14, 24, 39, 0.5));
  transition: border-color 200ms ease, box-shadow 200ms ease, background 200ms ease;
}
.player-bar.is-active {
  border-color: rgba(216, 176, 106, 0.5);
  background: linear-gradient(180deg, rgba(38, 58, 86, 0.78), rgba(18, 30, 48, 0.62));
  box-shadow: 0 0 0 1px rgba(216, 176, 106, 0.1), 0 8px 24px rgba(0, 0, 0, 0.2);
}
.player-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.player-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.1), rgba(9, 16, 27, 0.6));
  overflow: hidden;
}
.player-avatar .avatar-art { width: 34px; height: 34px; object-fit: contain; display: block; }
.player-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.player-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-captures {
  display: flex;
  align-items: center;
  gap: 1px;
  min-height: 19px;
  flex-wrap: wrap;
}
.cap-piece { width: 19px; height: 19px; min-width: 19px; opacity: 0.8; transform-origin: center; transform-box: fill-box; }
.player-captures .cap-piece.piece { width: 19px; height: 19px; }
.cap-piece.piece-white { --fill: #fbf7ec; --stroke: #6b6458; --accent: #6b6458; }
.cap-piece.piece-black { --fill: #07090a; --stroke: #5a5f5b; --accent: #5a5f5b; }
.cap-plus { font-size: 10px; font-weight: 800; color: var(--gold); margin-left: 3px; }
.player-state { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.state-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  transition: background 200ms ease, box-shadow 200ms ease;
}
.player-bar.is-active .state-dot { background: var(--gold-bright); box-shadow: 0 0 0 4px rgba(216, 176, 106, 0.14), 0 0 12px rgba(244, 217, 156, 0.7); }
.player-bar.is-active .player-state { color: var(--gold-bright); font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }

/* ---------------------------------------------------------------- turn banner */
.turn-banner {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border: 1px solid rgba(216, 176, 106, 0.28);
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(216, 176, 106, 0.12), rgba(16, 27, 43, 0.72) 45%, rgba(13, 23, 38, 0.55));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 20px rgba(0, 0, 0, 0.16);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
.turn-banner-orb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex: none;
  background: #f3e6c9;
  border: 1px solid #3a2a18;
  box-shadow: 0 0 0 4px rgba(243, 230, 201, 0.09), 0 0 16px rgba(243, 230, 201, 0.38);
}
.turn-banner.is-black .turn-banner-orb {
  background: #1e2b3e;
  border-color: #e7c47f;
  box-shadow: 0 0 0 4px rgba(231, 196, 127, 0.09), 0 0 16px rgba(231, 196, 127, 0.38);
}
.turn-banner-main {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink);
}
.turn-banner-sub {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
}
.turn-banner.is-your-turn {
  border-color: rgba(123, 197, 156, 0.55);
  background:
    linear-gradient(90deg, rgba(87, 174, 126, 0.18), rgba(16, 27, 43, 0.75) 48%, rgba(13, 23, 38, 0.55));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(123, 197, 156, 0.1), 0 0 24px rgba(87, 174, 126, 0.12);
}
.turn-banner.is-your-turn .turn-banner-main { color: #c9f7d9; }
.turn-banner.is-your-turn .turn-banner-sub { color: #9ed9b5; }
.turn-banner.is-check {
  border-color: rgba(224, 122, 102, 0.6);
  background: linear-gradient(90deg, rgba(130, 40, 29, 0.34), rgba(20, 26, 38, 0.8));
}
.turn-banner.is-check .turn-banner-main { color: #ffd1c5; }
.turn-banner.is-thinking .turn-banner-orb { animation: turnPulse 1.25s ease-in-out infinite; }
.turn-banner.is-over { border-color: rgba(216, 176, 106, 0.5); }
.turn-banner.is-over .turn-banner-main { color: var(--gold-bright); }
@keyframes turnPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.55; }
}
.turn-banner.turn-flash { animation: turnFlash 650ms ease-out; }
@keyframes turnFlash {
  0% { box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 0 0 0 rgba(244, 217, 156, 0); }
  32% { box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 6px rgba(244, 217, 156, 0.12), 0 0 32px rgba(244, 217, 156, 0.22); }
  100% { box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 0 0 0 rgba(244, 217, 156, 0); }
}

/* ---------------------------------------------------------------- board */
.board-shell { width: 100%; }

.board-frame {
  --pad: 10px;
  position: relative;
  width: 100%;
  padding: var(--pad) calc(var(--sq) + var(--pad));
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255, 231, 184, 0.05), transparent 28%),
    linear-gradient(180deg, var(--frame-1), var(--frame-2) 58%, var(--frame-3));
  border: 1px solid rgba(214, 173, 96, 0.28);
  box-shadow:
    0 26px 60px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    inset 0 0 0 5px rgba(0, 0, 0, 0.22),
    inset 0 0 50px rgba(0, 0, 0, 0.55);
}
.board-frame::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 16px;
  border: 1px solid rgba(216, 176, 106, 0.18);
  pointer-events: none;
}
.board-frame::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.board {
  position: relative;
  width: 100%;
  height: calc(var(--sq) * 10);
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(10, 1fr);
  border: 1px solid #34200f;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(52, 28, 8, 0.34), 0 0 0 2px rgba(0, 0, 0, 0.28);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.square {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 0 0 0.5px var(--board-line);
  transition: background 120ms ease;
}
.square.light { background: var(--board-light); }
.square.dark { background: var(--board-dark); }
.square.light::after, .square.dark::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.06; background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.22), transparent 60%); }
.square .coord { position: absolute; z-index: 3; font-size: calc(var(--sq) * 0.17); font-weight: 700; line-height: 1; color: rgba(45, 28, 10, 0.58); pointer-events: none; letter-spacing: 0.02em; }
.square .coord-file { right: 7%; bottom: 5%; }
.square .coord-rank { left: 7%; top: 5%; }
body.no-coords .square .coord { display: none; }

.square.is-selectable { cursor: pointer; }
.square.is-selectable:hover { box-shadow: inset 0 0 0 2px rgba(216, 176, 106, 0.55); }
.square:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: -2px;
  z-index: 5;
}
.square.can-move, .square.can-capture { cursor: pointer; }
body.no-hints .square.can-move::before,
body.no-hints .square.can-capture::before { display: none; }
.square.is-selected {
  box-shadow:
    inset 0 0 0 3px #ffe8b0,
    inset 0 0 0 5px rgba(91, 55, 15, 0.35),
    inset 0 0 28px rgba(255, 220, 120, 0.4);
  outline: 4px solid #ffe8b0;
  outline-offset: -4px;
  z-index: 3;
}
.square.is-selected:hover {
  box-shadow:
    inset 0 0 0 3px #ffe8b0,
    inset 0 0 0 5px rgba(91, 55, 15, 0.35),
    inset 0 0 28px rgba(255, 220, 120, 0.4);
}
.square.is-selected .piece-wrap { transform: scale(1.07); }
.square.is-selected::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 58%, rgba(255, 231, 158, 0.42), rgba(255, 213, 113, 0.18) 58%, transparent 78%);
  pointer-events: none;
  z-index: 1;
}
.square.is-last { box-shadow: inset 0 0 0 2px rgba(216, 176, 106, 0.4); }
.square.is-last::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(216, 176, 106, 0.18);
  pointer-events: none;
}
.square.is-check {
  background: radial-gradient(circle at center, rgba(224, 86, 66, 0.85), rgba(151, 38, 28, 0.35) 55%, transparent 78%), var(--board-dark);
  animation: checkPulse 1.8s ease-in-out infinite;
}
.square.is-check .piece { filter: drop-shadow(0 0 8px rgba(255, 96, 70, 0.75)); }
.square.can-move::before {
  content: "";
  position: absolute;
  z-index: 4;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(38, 24, 7, 0.62);
  border: 2px solid rgba(255, 246, 214, 0.88);
  box-shadow:
    0 0 0 5px rgba(255, 232, 165, 0.16),
    0 2px 6px rgba(28, 16, 4, 0.35);
  pointer-events: none;
  animation: moveDotIn 150ms cubic-bezier(.2, .9, .3, 1.2) both;
  transition: transform 120ms ease, background 120ms ease;
}
.square.can-move:hover::before {
  transform: scale(1.14);
  background: rgba(34, 20, 5, 0.8);
}
.square.can-capture::before {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 4%;
  border-radius: 50%;
  border: 4px solid rgba(163, 45, 27, 0.9);
  background: rgba(178, 60, 38, 0.06);
  box-shadow:
    0 0 0 2px rgba(255, 239, 199, 0.6),
    inset 0 0 24px rgba(163, 45, 27, 0.28),
    0 0 18px rgba(163, 45, 27, 0.22);
  pointer-events: none;
  animation: captureRingIn 140ms ease both;
}
.square.can-capture:hover::before {
  border-color: rgba(186, 51, 30, 1);
  box-shadow:
    0 0 0 3px rgba(255, 244, 210, 0.8),
    inset 0 0 28px rgba(163, 45, 27, 0.4),
    0 0 22px rgba(163, 45, 27, 0.34);
}
@keyframes moveDotIn {
  from { opacity: 0; transform: scale(0.2); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes captureRingIn {
  from { opacity: 0; transform: scale(1.3); }
  to { opacity: 1; transform: scale(1); }
}
.square.is-hint-from { box-shadow: inset 0 0 0 3px rgba(123, 197, 156, 0.9); }
.square.is-hint-to { box-shadow: inset 0 0 0 3px rgba(123, 197, 156, 0.9), inset 0 0 26px rgba(123, 197, 156, 0.45); }
.square.is-swap-target { box-shadow: inset 0 0 0 3px rgba(183, 156, 240, 0.9), inset 0 0 22px rgba(183, 156, 240, 0.3); cursor: pointer; }

@keyframes checkPulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(255, 120, 90, 0); }
  50% { box-shadow: inset 0 0 0 3px rgba(255, 120, 90, 0.65); }
}

/* ---------------------------------------------------------------- pieces */
.piece-wrap {
  position: absolute;
  inset: 0.5%;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: transform 140ms ease;
}
.piece-wrap::before {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: 1%;
  height: 8%;
  border-radius: 50%;
  background: rgba(18, 9, 2, 0.4);
  filter: blur(2px);
  z-index: 0;
  pointer-events: none;
}
.piece {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  overflow: visible;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.55)) drop-shadow(0 1px 0 rgba(255, 255, 255, 0.08));
}
.piece-white { --fill: #fbf7ec; --stroke: #6b6458; --accent: #6b6458; }
.piece-black { --fill: #07090a; --stroke: #5a5f5b; --accent: #5a5f5b; }
.square.is-selectable:hover .piece-wrap { transform: translateY(-2px) scale(1.035); }

.piece-badge {
  position: absolute;
  right: 3%;
  bottom: 1%;
  min-width: max(11px, calc(var(--sq) * 0.17));
  height: max(11px, calc(var(--sq) * 0.17));
  padding: 0 2px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-family: var(--font-body);
  font-size: clamp(6.5px, calc(var(--sq) * 0.12), 10px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  z-index: 3;
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.piece-white .piece-badge { background: #2b1c0d; color: #f6d99a; border-color: #150d05; }
.piece-black .piece-badge { background: #efcf8b; color: #152238; border-color: #ffe9b6; }
body.no-piece-labels .piece-badge { display: none; }
/* El príncipe y el rey adventicio comparten el dibujo del shah: su letra
   sigue visible aunque el jugador apague las etiquetas. */
body.no-piece-labels .piece-badge.badge-essential { display: grid; }

.piece-ghost {
  position: absolute;
  z-index: 30;
  pointer-events: none;
  display: grid;
  place-items: center;
  will-change: transform, opacity;
}

.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.08);
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.5));
  will-change: left, top;
}
.drag-ghost .piece-wrap { position: absolute; inset: 1.5%; }
.square.is-drag-source .piece-wrap { opacity: 0.16; }
.square.is-drop-hover {
  box-shadow: inset 0 0 0 4px #ffe8b0, inset 0 0 24px rgba(255, 224, 140, 0.45);
  z-index: 4;
}
body.is-dragging { cursor: grabbing; user-select: none; }
body.is-dragging .square { cursor: grabbing; }
.piece-ghost .piece { width: 100%; height: 100%; filter: drop-shadow(0 8px 7px rgba(0, 0, 0, 0.45)); }
.piece-ghost.is-flying .piece { filter: drop-shadow(0 18px 16px rgba(0, 0, 0, 0.5)); }
.piece-ghost.captured-ghost { opacity: 0.9; }
.piece-ghost.is-cemetery-flight { z-index: 34; }
.capture-particle {
  position: absolute;
  z-index: 41;
  pointer-events: none;
  border: 0;
  will-change: transform, opacity;
}
.capture-ring {
  position: absolute;
  z-index: 40;
  border: 3px solid rgba(240, 212, 155, 0.9);
  border-radius: 50%;
  background: rgba(198, 90, 67, 0.12);
  pointer-events: none;
  box-sizing: border-box;
  will-change: transform, opacity;
}
.capture-flash {
  position: absolute;
  z-index: 39;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(239, 226, 201, 0.65), rgba(198, 90, 67, 0.22) 42%, transparent 70%);
  will-change: transform, opacity;
}
.move-shadow {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.42), transparent 70%);
  filter: blur(3px);
  will-change: transform, opacity;
}

/* Efectos de la Evasión del Shah (teletransportación). */
.square.is-teleporting {
  box-shadow: inset 0 0 0 3px rgba(231, 196, 127, 0.9), inset 0 0 30px rgba(191, 153, 255, 0.35);
  z-index: 6;
}
.landing-flash {
  position: absolute;
  z-index: 22;
  border-radius: 50%;
  border: 2px solid rgba(255, 238, 191, 0.9);
  pointer-events: none;
  box-sizing: border-box;
  animation: landingPulse 480ms ease-out forwards;
}
.landing-flash.is-capture { border-color: rgba(224, 122, 102, 0.95); }
@keyframes landingPulse {
  from { opacity: 0.95; transform: scale(0.35); }
  to { opacity: 0; transform: scale(1.25); }
}
.swap-beam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 25;
}
.swap-beam-path {
  fill: none;
  stroke: #7b5bd6;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 12 9;
  filter: drop-shadow(0 0 4px rgba(255, 238, 191, 1)) drop-shadow(0 0 16px rgba(170, 125, 255, 0.85));
  animation: swapBeam 680ms ease-out forwards;
}
.swap-beam-orb {
  fill: #f4d99c;
  stroke: #8e6a33;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 8px rgba(244, 217, 156, 0.9));
  animation: swapOrb 680ms ease-out forwards;
}
@keyframes swapBeam {
  0% { opacity: 0; stroke-dashoffset: 80; }
  25% { opacity: 1; }
  75% { opacity: 1; stroke-dashoffset: -30; }
  100% { opacity: 0; stroke-dashoffset: -70; }
}
@keyframes swapOrb {
  0% { opacity: 0; transform: scale(0.2); transform-origin: center; }
  30% { opacity: 1; transform: scale(1.3); }
  100% { opacity: 0; transform: scale(0.8); }
}
.swap-flash {
  position: absolute;
  z-index: 26;
  border-radius: 50%;
  border: 3px solid rgba(244, 217, 156, 0.95);
  box-shadow: 0 0 26px rgba(244, 217, 156, 0.55), inset 0 0 30px rgba(183, 156, 240, 0.45);
  pointer-events: none;
  box-sizing: border-box;
  animation: swapRing 700ms ease-out forwards;
}
@keyframes swapRing {
  0% { opacity: 0; transform: scale(0.3); }
  22% { opacity: 1; transform: scale(0.92); }
  100% { opacity: 0; transform: scale(1.55); }
}
.swap-label {
  position: absolute;
  z-index: 27;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 12px;
  border: 1px solid rgba(244, 217, 156, 0.75);
  border-radius: 10px;
  background: rgba(10, 18, 30, 0.95);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 24px rgba(183, 156, 240, 0.18);
  pointer-events: none;
  white-space: nowrap;
  animation: swapLabel 700ms ease-out forwards;
}
.swap-label strong {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: #f4d99c;
}
.swap-label span {
  font-size: 9.5px;
  color: #cbb9ff;
}
@keyframes swapLabel {
  0% { opacity: 0; transform: translate(-50%, -35%) scale(0.85); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -65%) scale(0.98); }
}
.teleport-ghost { z-index: 24; }
.teleport-arrival { z-index: 25; }

/* ---------------------------------------------------------------- citadels */
.citadel {
  position: absolute;
  width: calc(var(--sq) - 2px);
  height: calc(var(--sq) - 2px);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 5px;
  color: rgba(244, 217, 156, 0.82);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 40%),
    linear-gradient(180deg, #6b4a2d, #3d2716 70%, #25150c);
  border: 1px solid rgba(226, 186, 116, 0.48);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.22), inset 0 0 14px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: default;
  overflow: hidden;
}
.citadel::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px dashed rgba(240, 210, 150, 0.28);
  border-radius: 3px;
  pointer-events: none;
}
.citadel svg { width: 48%; height: 48%; max-width: 26px; max-height: 26px; position: relative; z-index: 1; }
.citadel span {
  position: relative;
  z-index: 1;
  font-size: 6.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 800;
  writing-mode: vertical-rl;
  display: none;
}
.citadel--black { left: calc(var(--pad) - 3px); top: calc(var(--pad) + var(--sq)); }
.citadel--white { right: calc(var(--pad) - 3px); top: calc(var(--pad) + var(--sq) * 8); }
body.flipped .citadel--black {
  left: auto;
  right: calc(var(--pad) - 3px);
  top: calc(var(--pad) + var(--sq) * 8);
}
body.flipped .citadel--white {
  right: auto;
  left: calc(var(--pad) - 3px);
  top: calc(var(--pad) + var(--sq));
}
.citadel.can-move {
  cursor: pointer;
  color: #fff3d0;
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(244, 217, 156, 0.28), 0 0 26px rgba(244, 217, 156, 0.4), inset 0 0 18px rgba(244, 217, 156, 0.2);
  animation: citadelGlow 2s ease-in-out infinite;
}
.citadel.is-hint { box-shadow: 0 0 0 2px rgba(123, 197, 156, 0.8), 0 0 24px rgba(123, 197, 156, 0.5); }
.citadel .piece-wrap { position: absolute; inset: 6%; }
@keyframes citadelGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.22); }
}

@media (min-width: 900px) {
  .citadel span { display: block; }
  .citadel { gap: 1px; }
  .citadel svg { width: 42%; height: 42%; }
}

/* ---------------------------------------------------------------- status */
.board-status {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 6px 14px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  border-radius: 12px;
  background: rgba(10, 18, 30, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.status-ornament { color: var(--gold); font-size: 11px; }
.board-status.is-check { color: #ffd1c5; border-color: rgba(224, 122, 102, 0.4); background: rgba(96, 30, 22, 0.26); }
.board-status.is-over { color: var(--gold-bright); border-color: rgba(216, 176, 106, 0.4); background: rgba(80, 58, 20, 0.2); }

.mobile-actions { display: none; gap: 8px; }
.mobile-actions .btn { flex: 1; }

/* ---------------------------------------------------------------- sidebar */
.sidebar { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 18px;
  background:
    linear-gradient(160deg, rgba(40, 63, 94, 0.42), transparent 52%),
    linear-gradient(180deg, rgba(18, 30, 48, 0.92), rgba(12, 21, 35, 0.9));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 18px; right: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 217, 156, 0.55), transparent);
  opacity: 0.55;
}
.card-eyebrow {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--gold);
  font-weight: 800;
}
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.15;
  margin: 2px 0 8px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.turn-card { padding-top: 19px; }
.turn-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 8px; }
.turn-badges { display: flex; align-items: center; justify-content: flex-end; gap: 4px; flex-wrap: wrap; }
.turn-side { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1; }
.turn-orb {
  width: 15px; height: 15px; border-radius: 50%;
  background: #f3e6c9;
  border: 1px solid #3a2a18;
  box-shadow: 0 0 0 4px rgba(243, 230, 201, 0.1), 0 0 18px rgba(243, 230, 201, 0.35);
  flex: none;
}
.turn-orb.is-black { background: #1e2b3e; border-color: #e7c47f; box-shadow: 0 0 0 4px rgba(231, 196, 127, 0.1), 0 0 18px rgba(231, 196, 127, 0.35); }
.badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-bright);
  border: 1px solid rgba(216, 176, 106, 0.38);
  background: rgba(216, 176, 106, 0.08);
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-main { margin: 0 0 3px; font-size: 14px; font-weight: 700; color: var(--ink); }
.status-sub { margin: 0; font-size: 12px; color: var(--muted); min-height: 18px; }
.thinking {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--gold);
}
.thinking-dots { display: inline-flex; gap: 3px; }
.thinking-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); animation: dotBounce 1.2s infinite ease-in-out; }
.thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

.actions-card { padding: 13px; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.action-btn svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.action-btn:hover:not(:disabled) { background: rgba(216, 176, 106, 0.1); border-color: rgba(216, 176, 106, 0.34); color: var(--ink); }
.action-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.action-btn--danger:hover:not(:disabled) { background: rgba(224, 122, 102, 0.12); border-color: rgba(224, 122, 102, 0.4); color: #ffd9cf; }
.action-btn--swap { border-color: rgba(183, 156, 240, 0.35); color: #d9c9ff; background: rgba(183, 156, 240, 0.08); grid-column: 1 / -1; justify-content: center; }
.action-btn--wide { grid-column: 1 / -1; justify-content: center; }

.moves-card { min-height: 210px; display: flex; flex-direction: column; }
.move-count {
  min-width: 28px; height: 24px; padding: 0 8px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: rgba(216, 176, 106, 0.1);
  border: 1px solid rgba(216, 176, 106, 0.25);
  color: var(--gold-bright);
  font-size: 11px; font-weight: 800;
}
.moves-scroll { margin-top: 8px; max-height: 250px; overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(216, 176, 106, 0.3) transparent; }
.moves-scroll::-webkit-scrollbar { width: 6px; }
.moves-scroll::-webkit-scrollbar-thumb { background: rgba(216, 176, 106, 0.26); border-radius: 4px; }
.moves-empty { text-align: center; padding: 18px 8px 10px; color: var(--muted-2); }
.moves-empty .empty-glyph { font-size: 27px; color: rgba(216, 176, 106, 0.32); display: block; line-height: 1; margin-bottom: 8px; }
.moves-empty p { margin: 0; font-size: 12px; color: var(--muted); }
.moves-empty small { font-size: 10.5px; color: var(--muted-2); font-style: italic; }

.moves-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.move-row {
  display: grid;
  grid-template-columns: 30px 1fr 1fr;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border-radius: 6px;
  font-size: 12.5px;
}
.move-row:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }
.move-num { color: var(--muted-2); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.move-san { font-weight: 700; color: var(--ink-soft); font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; font-size: 12px; padding: 1px 3px; border-radius: 4px; }
.move-san.is-last { color: var(--gold-bright); background: rgba(216, 176, 106, 0.12); }
.move-san.is-empty { color: transparent; }
.move-san .move-check { color: var(--danger); }
.move-san .move-glyph { color: var(--gold); }

.lore-card { background: linear-gradient(180deg, rgba(28, 40, 58, 0.8), rgba(13, 22, 35, 0.88)); }
.lore-card p { margin: 0 0 11px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.lore-card em { color: var(--ink-soft); }
.lore-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.lore-facts span { font-size: 10px; color: var(--muted); border: 1px solid var(--line-soft); border-radius: 999px; padding: 4px 8px; }
.lore-facts b { color: var(--gold-bright); font-weight: 800; }
.text-link { border: 0; background: none; padding: 0; color: var(--gold-bright); font-size: 11.5px; font-weight: 700; cursor: pointer; }
.text-link:hover { text-decoration: underline; }
.text-link--lobby { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; color: var(--muted); }
.text-link--lobby:hover { color: var(--gold-bright); }
.footer-lobby { color: var(--gold); font-weight: 700; }
.footer-lobby::before { content: "·"; margin-right: 9px; color: var(--gold-dim); }

/* ---------------------------------------------------------------- footer */
.footer {
  position: relative;
  z-index: 2;
  width: min(100% - 40px, 1620px);
  margin: 30px auto 0;
  padding: 18px 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--muted-2);
  font-size: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.footer-sep { color: var(--gold-dim); }
.footer em { color: var(--muted); }

/* ---------------------------------------------------------------- modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 13, 0.74);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  animation: fadeIn 180ms ease both;
}
.modal-panel {
  position: relative;
  width: min(100%, 900px);
  max-height: min(90dvh, 920px);
  overflow: auto;
  padding: 28px 30px 24px;
  border-radius: 22px;
  border: 1px solid rgba(216, 176, 106, 0.4);
  background:
    radial-gradient(800px 300px at 20% -10%, rgba(71, 111, 162, 0.3), transparent 65%),
    linear-gradient(180deg, #15253b, #0e1929 55%, #0b1421);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: modalIn 240ms cubic-bezier(.2, .8, .25, 1) both;
  scrollbar-width: thin;
  scrollbar-color: rgba(216, 176, 106, 0.35) transparent;
}
.modal-panel::-webkit-scrollbar { width: 8px; }
.modal-panel::-webkit-scrollbar-thumb { background: rgba(216, 176, 106, 0.3); border-radius: 5px; }
.modal-panel--narrow { width: min(100%, 560px); }
.modal-panel--tiny { width: min(100%, 420px); text-align: center; }
.modal-panel--wide { width: min(100%, 940px); }
.modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: -10px -12px 0 12px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: rgba(8, 15, 25, 0.6);
  color: var(--muted);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  z-index: 8;
}
.modal-close:hover { color: var(--ink); border-color: var(--line); }
.modal-eyebrow { font-size: 9.5px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold); font-weight: 800; }
.modal-title { font-family: var(--font-display); font-size: clamp(30px, 4vw, 42px); font-weight: 600; line-height: 1.05; margin: 3px 0 8px; }
.modal-lead { color: var(--muted); font-size: 13px; margin: 0 0 20px; max-width: 62ch; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 22px; flex-wrap: wrap; }
.modal-actions--sticky { position: sticky; bottom: -24px; background: linear-gradient(180deg, transparent, #0b1421 35%); padding: 14px 0 4px; margin-bottom: -4px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.field { margin-bottom: 18px; }
.field-label { display: block; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 800; margin-bottom: 7px; }
.seg { display: flex; padding: 3px; gap: 3px; border-radius: 12px; background: rgba(4, 9, 16, 0.42); border: 1px solid var(--line-soft); }
.seg button {
  flex: 1;
  padding: 9px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 150ms ease;
}
.seg button:hover { color: var(--ink); }
.seg button.is-active { color: #231506; background: linear-gradient(180deg, #f4d99c, #d3a95f); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3); }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; }

.confirm-glyph {
  width: 54px; height: 54px; margin: 2px auto 12px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(224, 122, 102, 0.45);
  background: rgba(224, 122, 102, 0.1);
  color: #ffc2b4;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
}

/* ---------------------------------------------------------------- rules */
.rules-nav {
  position: sticky;
  top: -1px;
  z-index: 6;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 7px;
  margin: 0 -6px 18px;
  border-radius: 13px;
  background: rgba(9, 16, 27, 0.92);
  border: 1px solid var(--line-soft);
  backdrop-filter: blur(10px);
  scrollbar-width: none;
}
.rules-nav::-webkit-scrollbar { display: none; }
.rules-nav a { white-space: nowrap; padding: 6px 11px; border-radius: 8px; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.rules-nav a:hover { text-decoration: none; background: rgba(216, 176, 106, 0.1); color: var(--gold-bright); }
.rules-section { padding: 4px 0 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.055); scroll-margin-top: 70px; }
.rules-section:last-child { border-bottom: 0; }
.rules-section h3 { font-family: var(--font-display); font-size: 27px; font-weight: 600; margin: 0 0 9px; color: var(--gold-bright); }
.rules-section p { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; }
.rules-section p b, .rule-list b { color: var(--gold-bright); }
.rule-cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; }
.rule-note { border-left: 2px solid rgba(216, 176, 106, 0.45); padding: 2px 0 2px 14px; background: rgba(216, 176, 106, 0.04); border-radius: 0 8px 8px 0; }
.rule-note > b { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); margin-bottom: 5px; }
.rule-note p { font-size: 12px; color: var(--muted); }
.rule-list { margin: 0 0 12px; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.rule-list li { font-size: 12.5px; color: var(--ink-soft); }
.rule-list li::marker { color: var(--gold); }
.rules-source { font-size: 10.5px !important; color: var(--muted-2) !important; font-style: italic; }

.piece-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.piece-rule {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.055);
}
.piece-rule .piece { width: 44px; height: 44px; }
.piece-rule .pr-name { display: flex; align-items: baseline; gap: 6px; font-weight: 800; font-size: 12px; color: var(--ink); }
.piece-rule .pr-name em { font-style: normal; font-size: 9px; color: var(--gold); letter-spacing: 0.08em; }
.piece-rule .pr-move { font-size: 10.5px; color: var(--muted); line-height: 1.45; }

.pawn-table { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 12px; margin-top: 10px; }
.pawn-row { display: flex; align-items: center; gap: 8px; font-size: 10.8px; padding: 5px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.07); }
.pawn-row .pb { width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; background: #3a2a18; color: #f3d798; font-size: 9px; font-weight: 800; flex: none; }
.pawn-row .pn { color: var(--muted); flex: 1; min-width: 0; }
.pawn-row .pa { color: var(--gold-bright); font-weight: 700; white-space: nowrap; }
.pawn-row .arr { color: var(--gold-dim); }

/* ---------------------------------------------------------------- settings */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}
.setting-row--stack { display: block; }
.setting-name { display: block; font-size: 13px; font-weight: 700; }
.setting-help { display: block; font-size: 10.5px; color: var(--muted-2); margin-top: 1px; }
.setting-actions { display: flex; align-items: center; gap: 9px; flex: none; }
.sound-test {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid rgba(216, 176, 106, 0.35);
  background: rgba(216, 176, 106, 0.08);
  color: var(--gold-bright);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.sound-test:hover { background: rgba(216, 176, 106, 0.16); }
.switch { position: relative; width: 44px; height: 25px; flex: none; display: inline-block; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.12); transition: all 180ms ease; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%; background: #cfd8e4; left: 3px; top: 3px; transition: transform 180ms ease, background 180ms ease; }
.switch input:checked + span { background: rgba(216, 176, 106, 0.3); border-color: rgba(216, 176, 106, 0.55); }
.switch input:checked + span::after { transform: translateX(19px); background: var(--gold-bright); }
.switch input:focus-visible + span { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

.theme-picker { display: flex; gap: 7px; margin-top: 10px; }
.theme-picker button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.theme-picker button.is-active { border-color: var(--gold); color: var(--gold-bright); background: rgba(216, 176, 106, 0.08); }
.swatch { width: 40px; height: 24px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, 0.35); }
.swatch--timur { background: linear-gradient(135deg, #bda57d 0 50%, #967b55 50% 100%); }
.swatch--lapis { background: linear-gradient(135deg, #b6c6da 0 50%, #7d92b0 50% 100%); }
.swatch--parchment { background: linear-gradient(135deg, #e1d0ac 0 50%, #c1a77c 50% 100%); }

/* ---------------------------------------------------------------- game over */
.gameover-panel { text-align: center; padding-top: 24px; overflow: visible; }
.gameover-ornament { color: var(--gold); letter-spacing: 0.6em; font-size: 11px; margin-bottom: 10px; }
.gameover-crown {
  width: 96px; height: 96px; margin: 0 auto 8px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(216, 176, 106, 0.4);
  background: radial-gradient(circle at 38% 28%, rgba(255, 240, 200, 0.16), rgba(14, 25, 41, 0.8));
  box-shadow: 0 0 0 8px rgba(216, 176, 106, 0.04), 0 0 60px rgba(216, 176, 106, 0.16);
}
.gameover-crown .gameover-art { width: 82px; height: 82px; object-fit: contain; display: block; }
.gameover-crown.is-loss { background: radial-gradient(circle at 38% 28%, rgba(255, 255, 255, 0.12), #2a3030 78%); }
/* La derrota invierte el shah blanco: cuerpo negro y contorno claro, como
   el antiguo rey de luto. */
.gameover-crown.is-loss .gameover-art { filter: invert(1); }
.gameover-panel .modal-lead { margin-left: auto; margin-right: auto; }
.gameover-stats { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; padding: 12px 0 0; color: var(--muted); font-size: 11px; border-top: 1px solid var(--line-soft); }
.gameover-stats b { color: var(--gold-bright); font-size: 15px; display: block; font-family: var(--font-display); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  z-index: 120;
  max-width: min(90vw, 460px);
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid rgba(216, 176, 106, 0.45);
  background: rgba(12, 21, 35, 0.96);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  animation: toastIn 220ms ease both;
  text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(14px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

body.modal-open { overflow: hidden; }

.boot-notice {
  position: fixed;
  z-index: 300;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: min(92vw, 760px);
  padding: 10px 15px;
  border: 1px solid rgba(216, 176, 106, 0.55);
  border-radius: 12px;
  background: rgba(10, 18, 30, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
}
.boot-notice strong { color: var(--gold-bright); font-size: 12.5px; }
.boot-notice code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-soft);
  font-size: 10.5px;
}
.boot-notice a { color: var(--gold-bright); font-weight: 700; }
body.js-ready .boot-notice { display: none; }

.noscript {
  position: relative;
  z-index: 5;
  max-width: 700px;
  margin: 16px auto;
  padding: 12px 18px;
  border: 1px solid rgba(224, 122, 102, 0.5);
  border-radius: 12px;
  background: rgba(90, 30, 22, 0.4);
  color: #ffd9cf;
  text-align: center;
  font-size: 13px;
}

/* ---------------------------------------------------------------- themes */
body.theme-lapis {
  --board-light: #b6c6da;
  --board-dark: #7d92b0;
  --board-line: rgba(18, 32, 52, 0.3);
  --frame-1: #233b5c;
  --frame-2: #14243b;
  --frame-3: #0a1422;
  --frame-edge: #91a8c6;
}
body.theme-parchment {
  --board-light: #e1d0ac;
  --board-dark: #c1a77c;
  --board-line: rgba(80, 52, 20, 0.28);
  --frame-1: #5d3d23;
  --frame-2: #382312;
  --frame-3: #1d1008;
  --frame-edge: #c39a58;
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1500px) {
  :root { --sq: clamp(26px, min(calc((100vw - 56px) / 13), calc((100vh - 70px) / 10), 90px), 90px); }
  .layout {
    grid-template-columns: 1fr;
    justify-items: center;
    width: calc(100% - 28px);
  }
  .sidebar {
    width: min(100%, calc(var(--sq) * 13 + 20px));
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .turn-card { grid-column: 1 / -1; }
  .moves-card { grid-column: 1 / -1; }
  .lore-card { grid-column: 1 / -1; }
  .actions-card { grid-column: auto; }
  .moves-scroll { max-height: 180px; }
  .mobile-actions { display: flex; }
}

@media (max-width: 860px) {
  :root { --sq: clamp(24px, min(calc((100vw - 32px) / 13), calc((100vh - 70px) / 10), 66px), 66px); }
  .topbar { width: calc(100% - 28px); flex-wrap: wrap; gap: 10px; padding-top: 12px; }
  .brand-mark { width: 42px; height: 42px; }
  .brand-mark svg { width: 29px; height: 29px; }
  .brand-title { font-size: 23px; }
  .brand-kicker { font-size: 8px; }
  .topnav { gap: 5px; }
  .topnav .btn span { display: none; }
  .topnav .btn-gold span { display: inline; }
  .topnav .btn { padding: 8px 11px; }
  .topnav .btn-gold { padding: 9px 14px; }
  .layout { width: calc(100% - 12px); gap: 14px; }
  .sidebar { grid-template-columns: 1fr; width: 100%; }
  .turn-card, .moves-card, .lore-card, .actions-card { grid-column: auto; }
  .footer { width: calc(100% - 28px); }
  .rule-cols { grid-template-columns: 1fr; }
  .piece-grid { grid-template-columns: 1fr; }
  .pawn-table { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  :root { --sq: clamp(22px, min(calc((100vw - 32px) / 13), calc((100vh - 70px) / 10), 46px), 46px); }
  body { font-size: 14px; }
  .topbar { width: calc(100% - 20px); justify-content: center; }
  .brand { width: 100%; justify-content: center; }
  .brand-text { align-items: center; }
  .brand-kicker { font-size: 7.5px; letter-spacing: 0.16em; }
  .brand-title { font-size: 21px; white-space: normal; text-align: center; }
  .topnav { width: 100%; justify-content: center; }
  .topnav .btn-icon { width: 36px; height: 36px; }
  .layout { width: calc(100% - 12px); }
  .game-column { width: calc(var(--sq) * 13 + 20px); max-width: 100%; }
  .board-frame { --pad: 8px; padding: var(--pad) calc(var(--sq) + var(--pad)); border-radius: 14px; }
  .citadel--black { left: calc(var(--pad) - 3px); top: calc(var(--pad) + var(--sq)); }
  .citadel--white { right: calc(var(--pad) - 3px); top: calc(var(--pad) + var(--sq) * 8); }
  .citadel span { display: none; }
  .citadel svg { width: 54%; height: 54%; }
  .player-bar { min-height: 46px; padding: 4px 8px; }
  .player-avatar { width: 33px; height: 33px; }
  .player-avatar .avatar-art { width: 29px; height: 29px; }
  .player-name { font-size: 12.5px; }
  .turn-banner { min-height: 38px; padding: 6px 10px; gap: 8px; }
  .turn-banner-main { font-size: 11px; letter-spacing: 0.07em; }
  .turn-banner-sub { font-size: 10px; }
  .mobile-actions { display: flex; }
  .board-status { font-size: 11.5px; padding: 6px 10px; min-height: 34px; }
  .sidebar { width: 100%; }
  .actions-grid { grid-template-columns: 1fr 1fr; }
  .modal { padding: 10px; }
  .modal-panel { padding: 22px 18px 18px; border-radius: 17px; max-height: 92dvh; }
  .modal-title { font-size: 30px; }
  .modal-actions { justify-content: stretch; }
  .modal-actions .btn { flex: 1; }
  .piece-rule { grid-template-columns: 38px 1fr; }
  .piece-rule .piece { width: 38px; height: 38px; }
  .rules-nav { top: -22px; margin-top: -4px; }
  .footer { font-size: 10px; text-align: center; }
}

@media (max-width: 390px) {
  :root { --sq: clamp(22px, min(calc((100vw - 32px) / 13), calc((100vh - 70px) / 10), 38px), 38px); }
  .brand-title { font-size: 19px; }
  .theme-picker { flex-direction: column; }
  .theme-picker button { flex-direction: row; justify-content: flex-start; }
}

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

/* Modo sin animaciones (ajuste) */
body.no-anim .piece-wrap,
body.no-anim .citadel,
body.no-anim .player-bar { transition: none !important; }
body.no-anim .square.is-check { animation: none !important; }
body.no-anim .citadel.can-move { animation: none !important; }


/* Crédito de la versión pública */
.footer-credit { color: var(--gold); font-weight: 700; }
.footer-credit::before { content: "·"; margin-right: 9px; color: var(--gold-dim); }
