/* ═══════════════════════════════════════════════════════════════════
   BATTLE CHESS ONLINE – style.css
   Aesthetic: Dark medieval cinema — obsidian, gold, warm embers
   ═══════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:         #08090d;
  --surface:    #0f1016;
  --surface-2:  #161820;
  --border:     #252632;
  --border-hi:  #3a3c50;
  --gold:       #c9a84c;
  --gold-dim:   #5e4b1e;
  --gold-glow:  rgba(201,168,76,.22);
  --gold-text:  #e0c06a;
  --crimson:    #8b1a1a;
  --text:       #e2d8c0;
  --text-muted: #7a7a90;
  --sq-dark:    #3a1f10;
  --sq-light:   #c2a07a;
  --board-size: min(92vw, 528px);
  --sq:         calc(var(--board-size) / 8);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Cinzel', Georgia, serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════════════════
   LANDING PAGE (index.html)
══════════════════════════════════════════════════════════════════════════ */

body.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle grid background — like a faint chess board */
body.landing::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(201,168,76,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,168,76,.04) 1px, transparent 1px);
  background-size: 66px 66px;
  pointer-events: none;
}

.landing-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 820px;
  padding: 2.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3rem;
}

/* Hero */
.hero { text-align: center; }

.hero-crown {
  font-size: 3.5rem;
  line-height: 1;
  display: inline-block;
  filter: drop-shadow(0 0 24px rgba(201,168,76,.7));
  animation: crownFloat 3s ease-in-out infinite;
}

@keyframes crownFloat {
  0%, 100% { transform: translateY(0)   rotate(-2deg); }
  50%       { transform: translateY(-9px) rotate(2deg); }
}

.hero h1 {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: clamp(1.8rem, 7vw, 3.2rem);
  font-weight: 700;
  color: var(--gold-text);
  letter-spacing: .06em;
  text-shadow: 0 0 50px rgba(201,168,76,.35);
  margin-top: .6rem;
  line-height: 1.15;
}

.hero-sub {
  display: block;
  font-size: .6em;
  letter-spacing: .35em;
  opacity: .6;
  font-weight: 400;
  margin-top: .2em;
}

.hero-tagline {
  margin-top: .9rem;
  color: var(--text-muted);
  font-size: .85rem;
  letter-spacing: .12em;
  font-style: italic;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  transition: border-color .3s, box-shadow .3s;
}

.card:hover        { border-color: var(--border-hi); }
.card.highlighted  { border-color: var(--gold); box-shadow: 0 0 28px var(--gold-glow); }

/* Card header — icon inline with title */
.card-header {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .1rem;
}
.card-header .card-glyph { font-size: 1.3rem; line-height: 1; flex-shrink: 0; }
.card-header h2          { margin: 0; }

.card-glyph { font-size: 1.8rem; line-height: 1; }
.card h2 { font-size: 1.1rem; letter-spacing: .12em; color: var(--gold-text); }
.card p  { color: var(--text-muted); font-size: .82rem; line-height: 1.6; }

/* Landing footer */
.landing-footer {
  width: 100%;
  max-width: 820px;
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
}
.footer-ver  { font-size: 1.15rem; font-weight: 700; letter-spacing: .2em; color: var(--gold-text); font-family: 'Cinzel', serif; margin-bottom: .5rem; }
.footer-link { font-size: .75rem; color: var(--text-muted); letter-spacing: .12em; text-decoration: none; font-family: 'Cinzel', serif; transition: color .2s; }
.footer-link:hover { color: var(--gold); }

/* Buttons */
.btn-gold {
  background: var(--gold);
  color: #07080c;
  border: none;
  padding: .75rem 1.5rem;
  font-family: 'Cinzel', serif;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  cursor: pointer;
  border-radius: 2px;
  transition: background .2s, transform .1s, opacity .2s;
  text-align: center;
  display: inline-block;
  text-decoration: none;
}
.btn-gold:hover   { background: #d9b85c; }
.btn-gold:active  { transform: scale(.98); }
.btn-gold:disabled { opacity: .45; cursor: wait; }

.btn-ghost {
  display: inline-block;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  padding: .6rem 1.2rem;
  font-family: 'Cinzel', serif;
  font-size: .78rem;
  letter-spacing: .1em;
  cursor: pointer;
  border-radius: 2px;
  text-decoration: none;
  transition: border-color .2s, background .2s;
}
.btn-ghost:hover { border-color: var(--gold); background: rgba(201,168,76,.06); }

/* Inputs */
.input-row { display: flex; gap: .5rem; }

input[type="text"] {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: .65rem .8rem;
  color: var(--text);
  font-family: monospace;
  font-size: .82rem;
  outline: none;
  transition: border-color .2s;
}
input[type="text"]:focus  { border-color: var(--gold-dim); }
input[type="text"]::placeholder { color: var(--text-muted); }

.error-msg { color: var(--crimson) !important; font-size: .8rem !important; }

/* Invite area */
.invite-label { font-size: .72rem; color: var(--text-muted); letter-spacing: .06em; }

.invite-row {
  display: flex;
  gap: .5rem;
  align-items: stretch;
}

.invite-row code {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: .45rem .65rem;
  font-size: .72rem;
  color: var(--text-muted);
  word-break: break-all;
  font-family: monospace;
  line-height: 1.4;
  display: flex;
  align-items: center;
}

.invite-row button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .4rem .7rem;
  font-size: .72rem;
  cursor: pointer;
  border-radius: 2px;
  font-family: 'Cinzel', serif;
  letter-spacing: .06em;
  white-space: nowrap;
  transition: border-color .2s, color .2s;
}
.invite-row button:hover { border-color: var(--gold); color: var(--gold); }

/* ══════════════════════════════════════════════════════════════════════════
   GAME PAGE (game.html)
══════════════════════════════════════════════════════════════════════════ */

body.game-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* Top bar */
#topbar {
  width: 100%;
  max-width: 620px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1rem;
  border-bottom: 2px solid var(--border);
  transition: border-bottom-color .5s ease, background .5s ease;
}
#topbar.your-turn, #topbar.turn-yours {
  border-bottom-color: rgba(60,180,90,.65);
  background: rgba(40,140,70,.06);
}
#topbar.opp-turn, #topbar.turn-theirs {
  border-bottom-color: rgba(180,40,40,.55);
  background: rgba(140,30,30,.05);
}
#topbar.turn-danger {
  border-bottom-color: rgba(220,60,60,.8);
  background: rgba(160,20,20,.08);
}

.logo-sm {
  color: var(--gold);
  text-decoration: none;
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: .8rem;
  letter-spacing: .1em;
  white-space: nowrap;
  flex-shrink: 0;
}

#game-status {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
}

#turn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
  transition: background .3s, box-shadow .3s;
}
#turn-dot[data-s="active"]  { background: var(--gold);    box-shadow: 0 0 8px var(--gold-glow);             animation: dotPulse 1.6s ease-in-out infinite; }
#turn-dot[data-s="danger"]  { background: var(--crimson); box-shadow: 0 0 10px rgba(139,26,26,.6);          animation: dotPulse  .7s ease-in-out infinite; }
#turn-dot[data-s="wait"]    { background: var(--text-muted); }
#turn-dot[data-s="over"]    { background: var(--border-hi); }

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}

#status-text {
  font-size: .8rem;
  letter-spacing: .07em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#copy-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: .38rem .85rem;
  font-family: 'Cinzel', serif;
  font-size: .72rem;
  letter-spacing: .07em;
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
  transition: border-color .2s, background .2s;
}
#copy-btn:hover { border-color: var(--gold); background: rgba(201,168,76,.05); }

/* Topbar turn colours */
#topbar { transition: background .5s, border-bottom-color .5s; }
#topbar.turn-yours   { background: rgba(30,100,55,.18);  border-bottom-color: rgba(60,200,100,.4); }
#topbar.turn-theirs  { background: rgba(100,20,20,.18);  border-bottom-color: rgba(200,60,60,.4);  }
#topbar.turn-danger  { background: rgba(140,20,20,.28);  border-bottom-color: rgba(220,50,50,.6);  }

/* Board area */
#board-wrap {
  padding: 1.5rem 1rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Chess Board ─────────────────────────────────────────────────────────── */
#board {
  display: grid;
  grid-template-columns: repeat(8, var(--sq));
  grid-template-rows:    repeat(8, var(--sq));
  width: var(--board-size);
  height: var(--board-size);
  border: 2px solid var(--gold-dim);
  box-shadow:
    0 0 0 1px rgba(201,168,76,.08),
    0 0 50px rgba(201,168,76,.12),
    0 24px 70px rgba(0,0,0,.85);
  position: relative;
}

/* Squares */
.sq {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: filter .12s;
}
.sq.lt { background: var(--sq-light); }
.sq.dk { background: var(--sq-dark); }
.sq:hover { filter: brightness(1.12); }

/* Rank / file coordinate labels — always light tan, always readable */
.sq[data-rank]::before {
  content: attr(data-rank);
  position: absolute;
  top: 2px; left: 3px;
  font-size: calc(var(--sq) * .17);
  font-family: 'Cinzel', serif;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
  color: #e8d5a3;
  text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 6px rgba(0,0,0,.7);
}
.sq[data-file]::after {
  content: attr(data-file);
  position: absolute;
  bottom: 2px; right: 3px;
  font-size: calc(var(--sq) * .17);
  font-family: 'Cinzel', serif;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
  color: #e8d5a3;
  text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 6px rgba(0,0,0,.7);
}

/* Highlights */
.sq.selected { background: rgba(201,168,76,.55) !important; }
.sq.lm-from, .sq.lm-to { background: rgba(201,168,76,.18) !important; }

/* Check — pulsing danger */
.sq.in-check {
  background: rgba(139,26,26,.65) !important;
  animation: checkGlow .75s ease-in-out infinite alternate;
}
@keyframes checkGlow {
  from { box-shadow: inset 0 0  5px rgba(220,30,30,.3); }
  to   { box-shadow: inset 0 0 22px rgba(220,30,30,.8); }
}

/* Move hints — dark dot with gold glow, visible on both light and dark squares */
.sq.hint::before {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%,-50%);
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: rgba(20,12,4,.65);
  border: 2px solid rgba(201,168,76,.9);
  box-shadow: 0 0 8px rgba(201,168,76,.6), 0 2px 6px rgba(0,0,0,.8);
  pointer-events: none;
  z-index: 3;
  animation: hintIn .15s ease-out;
}

/* Capture hints — ring with glow */
.sq.cap-hint::before {
  content: '';
  position: absolute;
  inset: 4px;
  background: transparent;
  border: 3px solid rgba(201,168,76,.9);
  box-shadow: inset 0 0 10px rgba(201,168,76,.3), 0 0 8px rgba(0,0,0,.6);
  pointer-events: none;
  z-index: 3;
  animation: hintIn .15s ease-out;
}

@keyframes hintIn {
  from { opacity: 0; transform: translate(-50%,-50%) scale(.4); } /* only for ::before dot */
  to   { opacity: 1; transform: translate(-50%,-50%) scale(1); }
}

/* Capture flash */
.sq.burst { animation: burst .28s ease-out; }
@keyframes burst {
  0%  { filter: brightness(1); }
  45% { filter: brightness(3.5) saturate(0); }
  100%{ filter: brightness(1); }
}

/* ── Pieces ──────────────────────────────────────────────────────────────── */
.pc {
  font-size: calc(var(--sq) * .72);
  line-height: 1;
  user-select: none;
  pointer-events: none;
  display: block;
  text-align: center;
  position: relative;
  z-index: 1;
  transition: transform .12s ease;
}

/* White pieces: ivory with strong dark shadow */
.pc[data-c="w"] {
  color: #f5eedb;
  text-shadow:
    0 0 3px rgba(0,0,0,.9),
    1px 1px 0 rgba(0,0,0,.8),
    -1px -1px 0 rgba(0,0,0,.6),
    0 2px 6px rgba(0,0,0,.9);
}
/* Black pieces: warm dark brown with golden glow outline — visible on both square colours */
.pc[data-c="b"] {
  color: #1c1005;
  text-shadow:
    0 0 3px rgba(210,165,75,.8),
    1px 1px 0 rgba(180,135,55,.7),
    -1px -1px 0 rgba(180,135,55,.6),
    1px -1px 0 rgba(180,135,55,.5),
    -1px 1px 0 rgba(180,135,55,.5),
    0 2px 6px rgba(0,0,0,.7);
}

.sq:hover .pc    { transform: scale(1.06) translateY(-2px); }
.sq.selected .pc { transform: scale(1.12) translateY(-3px); }

/* Arrive animation (opponent move + your move) */
.pc.arrive {
  animation: pcArrive .28s cubic-bezier(.2,.8,.4,1);
}
@keyframes pcArrive {
  0%  { transform: scale(.45) translateY(-12px); opacity: .5; }
  100%{ transform: scale(1)   translateY(0);     opacity: 1; }
}

/* ── Battle Animations ───────────────────────────────────────────────────── */

/* Flying wrapper — position transitions */
.fly-wrap {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  transition: left .24s cubic-bezier(.4,0,.2,1), top .24s cubic-bezier(.4,0,.2,1);
}

/* Inner glyph — piece-specific transform animations */
.fly-inner {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  line-height: 1;
  text-align: center;
}

/* ── PAWN: low forward headbutt ────────────────────────────────────────── */
.fly-inner.anim-pawn { animation: pawnThrust .22s ease-out forwards; }
@keyframes pawnThrust {
  0%   { transform: translate(-50%,-50%) rotate(0deg)  scale(1); }
  40%  { transform: translate(-50%,-50%) rotate(22deg) scale(1.1); }
  100% { transform: translate(-50%,-50%) rotate(0deg)  scale(1); }
}
.def-fall {
  animation: defFall .32s ease-in forwards;
}
@keyframes defFall {
  0%   { transform: translate(-50%,-50%) rotate(0deg)  scale(1); opacity:1; }
  100% { transform: translate(-50%,-50%) rotate(95deg) translateX(48px) scale(.4); opacity:0; }
}

/* ── KNIGHT: arc through the air ───────────────────────────────────────── */
.fly-inner.anim-knight { animation: knightBounce .28s cubic-bezier(.2,.8,.3,1); }
@keyframes knightBounce {
  0%   { transform: translate(-50%,-50%) translateY(0)     rotate(0deg)   scale(1);    }
  45%  { transform: translate(-50%,-50%) translateY(-90px) rotate(-28deg) scale(1.18); }
  100% { transform: translate(-50%,-50%) translateY(0)     rotate(0deg)   scale(1);    }
}
.def-knocked {
  animation: defKnocked .35s ease-out forwards;
}
@keyframes defKnocked {
  0%   { transform: translate(-50%,-50%) scale(1)   rotate(0deg);  opacity:1; }
  25%  { transform: translate(-50%,-50%) scale(1.2) rotate(-12deg); }
  100% { transform: translate(-50%,-50%) translateX(70px) rotate(-50deg) scale(.2); opacity:0; }
}

/* ── ROOK: drop from sky ────────────────────────────────────────────────── */
.fly-wrap.anim-rook-wrap { transition: left .1s linear, top .28s cubic-bezier(.2,0,1,0.8); }
.fly-inner.anim-rook     { animation: rookDrop .28s ease-in; }
@keyframes rookDrop {
  0%   { transform: translate(-50%,-50%) translateY(-110px) scale(1.25); }
  100% { transform: translate(-50%,-50%) translateY(0)      scale(1); }
}
.def-explode {
  animation: defExplode .28s ease-out forwards;
}
@keyframes defExplode {
  0%   { transform: translate(-50%,-50%) scale(1);   opacity:1; }
  45%  { transform: translate(-50%,-50%) scale(2.2); opacity:.7; }
  100% { transform: translate(-50%,-50%) scale(0);   opacity:0; }
}
/* Shockwave ring */
.shockwave {
  position: fixed; pointer-events: none; z-index: 199;
  border-radius: 50%;
  border: 3px solid rgba(201,168,76,.85);
  width: 20px; height: 20px;
  transform: translate(-50%,-50%) scale(0);
  animation: shockExpand .32s ease-out forwards;
}
@keyframes shockExpand {
  to { transform: translate(-50%,-50%) scale(6); opacity:0; }
}

/* ── BISHOP: diagonal light beam ───────────────────────────────────────── */
.fly-inner.anim-bishop {
  animation: bishopGlide .3s ease-in-out;
  filter: drop-shadow(0 0 14px rgba(180,160,255,.95));
}
@keyframes bishopGlide {
  0%   { transform: translate(-50%,-50%) rotate(-8deg)  scale(.85); }
  50%  { transform: translate(-50%,-50%) rotate(6deg)   scale(1.12); }
  100% { transform: translate(-50%,-50%) rotate(0deg)   scale(1); }
}
.def-dissolve {
  animation: defDissolve .4s ease-out forwards;
}
@keyframes defDissolve {
  0%   { transform: translate(-50%,-50%) scale(1);   opacity:1; filter:blur(0); }
  100% { transform: translate(-50%,-50%) scale(1.4); opacity:0; filter:blur(10px); }
}
/* Spark particles */
.spark {
  position: fixed; pointer-events: none; z-index: 199;
  width: 5px; height: 5px; border-radius: 50%;
  background: #d0c0ff;
  box-shadow: 0 0 6px rgba(200,180,255,.8);
  animation: sparkFly .45s ease-out forwards;
}
@keyframes sparkFly {
  to { opacity:0; }
}

/* ── QUEEN: elegant float + hearts ─────────────────────────────────────── */
.fly-inner.anim-queen {
  animation: queenFloat .36s ease-in-out;
  filter: drop-shadow(0 0 12px rgba(255,170,200,.9));
}
@keyframes queenFloat {
  0%   { transform: translate(-50%,-50%) scale(.8)  rotate(-12deg); }
  50%  { transform: translate(-50%,-50%) scale(1.15) rotate(6deg); }
  100% { transform: translate(-50%,-50%) scale(1)   rotate(0deg); }
}
.def-enchanted {
  animation: defEnchanted .45s ease-out forwards;
}
@keyframes defEnchanted {
  0%   { transform: translate(-50%,-50%) rotate(0deg);   opacity:1; }
  30%  { transform: translate(-50%,-50%) rotate(18deg); }
  65%  { transform: translate(-50%,-50%) rotate(-12deg); }
  100% { transform: translate(-50%,-50%) rotate(85deg) scale(.4); opacity:0; }
}
.heart-float {
  position: fixed; pointer-events: none; z-index: 199;
  font-size: 1.3rem; line-height: 1;
  animation: heartRise .8s ease-out forwards;
}
@keyframes heartRise {
  0%   { transform: translateY(0)    scale(.6); opacity:1; }
  100% { transform: translateY(-72px) scale(1.1); opacity:0; }
}

/* ── KING: majestic & devastating ──────────────────────────────────────── */
.fly-inner.anim-king {
  animation: kingMarch .44s ease-in-out;
  filter: drop-shadow(0 0 18px rgba(255,215,0,.95));
}
@keyframes kingMarch {
  0%   { transform: translate(-50%,-50%) scale(1)    rotate(0deg); }
  30%  { transform: translate(-50%,-50%) scale(1.35) rotate(-6deg); }
  70%  { transform: translate(-50%,-50%) scale(1.35) rotate(6deg); }
  100% { transform: translate(-50%,-50%) scale(1)    rotate(0deg); }
}
.def-epic {
  animation: defEpic .55s ease-in forwards;
}
@keyframes defEpic {
  0%   { transform: translate(-50%,-50%) scale(1)   rotate(0deg);   opacity:1; }
  20%  { transform: translate(-50%,-50%) scale(1.4) rotate(180deg); opacity:.9; }
  100% { transform: translate(-50%,-50%) scale(0)   rotate(720deg); opacity:0; }
}
.lightning-flash {
  position: fixed; inset: 0; z-index: 198; pointer-events: none;
  background: rgba(255,240,150,.18);
  animation: lFlash .3s ease-out forwards;
}
@keyframes lFlash { 0%{opacity:1} 100%{opacity:0} }

.clash-sq { animation: clashFlash .3s ease-out; }
@keyframes clashFlash {
  0%   { filter:brightness(1); }
  30%  { filter:brightness(3.8) saturate(.3); }
  100% { filter:brightness(1); }
}

/* ── TIMER ──────────────────────────────────────────────────────────────── */
#game-timer {
  font-size: .72rem;
  color: var(--gold-text);
  opacity: .65;
  letter-spacing: .12em;
  font-family: monospace;
  flex-shrink: 0;
  transition: opacity .3s;
}
#game-timer.active { opacity: 1; }

/* ── CHAT PANEL ─────────────────────────────────────────────────────────── */
#chat-toggle {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: .38rem .7rem;
  font-family: 'Cinzel', serif;
  font-size: .72rem;
  letter-spacing: .07em;
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
  transition: border-color .2s, background .2s;
  position: relative;
}
#chat-toggle:hover { border-color: var(--gold); background: rgba(201,168,76,.05); }
#chat-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--crimson);
  color: #fff;
  font-size: .55rem;
  font-family: monospace;
  border-radius: 50%;
  width: 14px; height: 14px;
  display: none;
  align-items: center;
  justify-content: center;
}
#chat-badge.show { display: flex; }

#chat-panel {
  position: fixed;
  top: 0; right: 0;
  width: 300px;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: -8px 0 40px rgba(0,0,0,.6);
}
#chat-panel.open { transform: translateX(0); }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-head h3 { font-size: .85rem; letter-spacing: .15em; color: var(--gold-text); }
#chat-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.2rem; cursor: pointer; line-height: 1;
  transition: color .2s;
}
#chat-close:hover { color: var(--text); }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border); }

.chat-msg {
  max-width: 85%;
  padding: .45rem .65rem;
  border-radius: 3px;
  font-size: .78rem;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg.mine {
  align-self: flex-end;
  background: var(--gold-dim);
  color: var(--text);
  border-bottom-right-radius: 0;
}
.chat-msg.theirs {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 0;
}
.chat-name {
  font-size: .62rem;
  letter-spacing: .06em;
  color: var(--gold-text);
  opacity: .7;
  margin-bottom: .2rem;
}

.chat-emojis {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: .5rem .75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-emojis button {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: .2rem .25rem;
  border-radius: 2px;
  transition: background .15s, transform .1s;
  line-height: 1;
}
.chat-emojis button:hover { background: var(--surface-2); transform: scale(1.2); }

.chat-input-row {
  display: flex;
  gap: .4rem;
  padding: .65rem .75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: .5rem .65rem;
  color: var(--text);
  font-family: monospace;
  font-size: .82rem;
  outline: none;
}
#chat-input:focus { border-color: var(--gold-dim); }
#chat-send {
  background: var(--gold);
  border: none;
  border-radius: 2px;
  color: #07080c;
  font-family: 'Cinzel', serif;
  font-size: .72rem;
  font-weight: 700;
  padding: .4rem .7rem;
  cursor: pointer;
  transition: background .2s;
}
#chat-send:hover { background: #d9b85c; }

@media (max-width: 480px) {
  #chat-panel { width: 100vw; }
}

/* ── Captured Pieces Strip ───────────────────────────────────────────────── */
.captures-wrap {
  width: var(--board-size);
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem 0;
  min-height: 2rem;
}

.captures-label {
  font-size: .75rem;
  letter-spacing: .1em;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
}

.captures-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  align-items: center;
  line-height: 1;
}

.captures-pieces span {
  font-size: calc(var(--sq) * .44);
  line-height: 1;
}

/* Capture flash — label glows green briefly */
@keyframes capFlash {
  0%, 10% { color: #6fcf7f; text-shadow: 0 0 12px rgba(111,207,127,.7); }
  100%     { color: var(--text); text-shadow: none; }
}
.captures-wrap.flash .captures-label {
  animation: capFlash 1.8s ease-out forwards;
}

.captures-score {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold-text);
  letter-spacing: .06em;
  margin-left: auto;
  flex-shrink: 0;
}

/* White pieces taken */
.captures-pieces span[data-c="w"] {
  color: #f5eedb;
  text-shadow: 0 1px 3px rgba(0,0,0,.9), 1px 1px 0 rgba(0,0,0,.7);
}
/* Black pieces taken */
.captures-pieces span[data-c="b"] {
  color: #1c1005;
  text-shadow: 0 0 2px rgba(210,165,75,.7), 1px 1px 0 rgba(180,135,55,.6), -1px -1px 0 rgba(180,135,55,.5);
}

/* ── Dialogs ─────────────────────────────────────────────────────────────── */
dialog {
  background: var(--surface-2);
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  padding: 2rem;
  color: var(--text);
  font-family: 'Cinzel', serif;
  box-shadow: 0 24px 70px rgba(0,0,0,.95);
  max-width: 92vw;
}
dialog::backdrop {
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(5px);
}
dialog h2, dialog h3 {
  color: var(--gold-text);
  letter-spacing: .12em;
  text-align: center;
  margin-bottom: 1.25rem;
}

/* Promotion */
#prom-choices { display: flex; gap: .75rem; justify-content: center; }

#prom-choices button {
  width: 72px; height: 72px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  transition: border-color .2s, background .2s, transform .1s;
}
#prom-choices button:hover { border-color: var(--gold); background: var(--surface); transform: translateY(-2px); }

#prom-choices button .prom-pc { font-size: 2.4rem; line-height: 1; }
#prom-choices button small    { font-size: .6rem; color: var(--text-muted); letter-spacing: .06em; }

/* Game over */
#result-icon  { font-size: 3rem; text-align: center; margin-bottom: .5rem; }
#result-title { font-size: 1.6rem; margin-bottom: .4rem; }
#result-sub   { text-align: center; color: var(--text-muted); font-size: .82rem; margin-bottom: 1.75rem; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  :root { --board-size: calc(100vw - 1rem); }
  #prom-choices button { width: 58px; height: 58px; }
  #prom-choices button .prom-pc { font-size: 1.9rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FIGHTING GAME INTRO SCREEN
═══════════════════════════════════════════════════════════════════════════ */
#intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: stretch;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease;
  background: #04050a;
  overflow: hidden;
}
#intro-overlay.show { opacity: 1; pointer-events: all; }
#intro-overlay.hide { opacity: 0; pointer-events: none; }

/* Background texture */
#intro-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(201,168,76,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,168,76,.04) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
}

/* Left side — white player */
#intro-left, #intro-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 2rem;
  position: relative;
}

#intro-left {
  background: linear-gradient(135deg, rgba(245,238,219,.05) 0%, transparent 60%);
  transform: translateX(-100%);
  transition: transform .6s cubic-bezier(.2,.8,.3,1);
}
#intro-right {
  background: linear-gradient(225deg, rgba(28,16,5,.8) 0%, transparent 60%);
  transform: translateX(100%);
  transition: transform .6s cubic-bezier(.2,.8,.3,1);
}
#intro-overlay.show #intro-left,
#intro-overlay.show #intro-right { transform: translateX(0); }

.intro-pieces-row {
  display: flex;
  gap: .2rem;
  flex-wrap: wrap;
  justify-content: center;
}
#intro-left .intro-pieces-row span {
  font-size: clamp(1.4rem, 3.5vw, 2.2rem);
  color: #f5eedb;
  text-shadow: 0 0 4px rgba(0,0,0,.9), 1px 1px 0 rgba(0,0,0,.8);
  animation: pieceBob 2s ease-in-out infinite;
}
#intro-right .intro-pieces-row span {
  font-size: clamp(1.4rem, 3.5vw, 2.2rem);
  color: #1c1005;
  text-shadow: 0 0 4px rgba(210,165,75,.8), 1px 1px 0 rgba(180,135,55,.7), -1px -1px 0 rgba(180,135,55,.6);
  animation: pieceBob 2s ease-in-out infinite;
}
.intro-pieces-row span:nth-child(odd)  { animation-delay: .1s; }
.intro-pieces-row span:nth-child(even) { animation-delay: .3s; }
.intro-pawns span { font-size: clamp(1.1rem, 2.5vw, 1.7rem) !important; }

@keyframes pieceBob {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.intro-name {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: clamp(1.1rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--gold-text);
  text-shadow: 0 0 30px rgba(201,168,76,.4);
  text-align: center;
  max-width: 200px;
  word-break: break-word;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity .5s ease .45s, transform .5s ease .45s;
}
#intro-overlay.show .intro-name { opacity: 1; transform: translateY(0); }

.intro-role {
  font-size: .68rem;
  letter-spacing: .2em;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity .5s ease .6s;
}
#intro-overlay.show .intro-role { opacity: 1; }

/* VS center */
#intro-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 120px;
  position: relative;
  z-index: 1;
}
#intro-vs {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  color: var(--gold);
  text-shadow:
    0 0 40px rgba(201,168,76,.8),
    0 0 80px rgba(201,168,76,.4);
  letter-spacing: .05em;
  opacity: 0;
  transform: scale(.4);
  transition: opacity .4s ease .35s, transform .5s cubic-bezier(.2,.8,.3,1.4) .35s;
}
#intro-overlay.show #intro-vs { opacity: 1; transform: scale(1); }

/* Flash line between the two sides */
#intro-center::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 1px;
  background: linear-gradient(transparent, var(--gold-dim), transparent);
  transform: scaleY(0);
  transition: transform .6s ease .2s;
}
#intro-overlay.show #intro-center::before { transform: scaleY(1); }

@media (max-width: 500px) {
  #intro-center { width: 60px; }
  #intro-vs { font-size: 1.6rem; }
  .intro-pieces-row span { font-size: 1.1rem !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   EPIC VICTORY OVERLAY
═══════════════════════════════════════════════════════════════════════════ */
#victory-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s ease;
}
#victory-overlay.show {
  opacity: 1;
  pointer-events: all;
}

#vic-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(20,12,4,.97) 0%, rgba(4,5,8,.99) 100%);
}

/* Floating particle effect via pseudo */
#vic-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(201,168,76,.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 10%, rgba(201,168,76,.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 70%, rgba(201,168,76,.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 10% 80%, rgba(201,168,76,.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 60%, rgba(201,168,76,.3) 0%, transparent 100%);
  background-size: 300px 300px;
  animation: particleDrift 8s ease-in-out infinite alternate;
}
@keyframes particleDrift {
  from { transform: translateY(0); }
  to   { transform: translateY(-20px); }
}

#vic-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2rem 1.5rem;
  max-width: 600px;
  width: 100%;
  text-align: center;
}

#vic-icon {
  font-size: 4rem;
  line-height: 1;
  animation: vicIconIn .6s cubic-bezier(.2,.8,.3,1.4) both;
  animation-delay: .2s;
}
@keyframes vicIconIn {
  from { transform: scale(0) rotate(-20deg); opacity:0; }
  to   { transform: scale(1) rotate(0deg);  opacity:1; }
}

#vic-title {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 700;
  letter-spacing: .1em;
  line-height: 1.1;
  animation: vicTitleIn .7s ease-out both;
  animation-delay: .35s;
}
@keyframes vicTitleIn {
  from { transform: translateY(30px); opacity:0; }
  to   { transform: translateY(0);    opacity:1; }
}
#vic-title.victory { color: var(--gold-text); text-shadow: 0 0 60px rgba(201,168,76,.5); }
#vic-title.defeat  { color: #c05050; text-shadow: 0 0 60px rgba(180,50,50,.4); }
#vic-title.draw    { color: var(--text); }

#vic-sub {
  color: var(--text-muted);
  font-size: .88rem;
  letter-spacing: .08em;
  font-style: italic;
  animation: vicTitleIn .7s ease-out both;
  animation-delay: .5s;
}

/* ── Battlefield ──────────────────────────────────────────────────────────── */
#vic-battlefield {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  animation: vicTitleIn .6s ease-out both;
  animation-delay: .65s;
}

.vic-army {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  min-height: 2rem;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: rgba(255,255,255,.02);
}

.vic-piece {
  font-size: 1.6rem;
  line-height: 1;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity .3s ease, transform .3s ease;
}
.vic-piece.marched { opacity: 1; transform: translateY(0); }
.vic-piece[data-c="w"] {
  color: #f5eedb;
  text-shadow: 0 0 3px rgba(0,0,0,.9), 1px 1px 0 rgba(0,0,0,.8);
}
.vic-piece[data-c="b"] {
  color: #1c1005;
  text-shadow: 0 0 3px rgba(210,165,75,.8), 1px 1px 0 rgba(180,135,55,.7), -1px -1px 0 rgba(180,135,55,.6);
}

#vic-divider {
  font-size: 1.4rem;
  color: var(--gold);
  text-align: center;
  opacity: .6;
}

/* ── Stats bar ───────────────────────────────────────────────────────────── */
#vic-stats {
  display: flex;
  gap: 2rem;
  animation: vicTitleIn .6s ease-out both;
  animation-delay: .8s;
}
.vic-stat { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.vic-val  { font-size: 1.4rem; font-weight: 700; color: var(--gold-text); }
.vic-lbl  { font-size: .62rem; letter-spacing: .15em; color: var(--text-muted); }

/* ── Action buttons ──────────────────────────────────────────────────────── */
#vic-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: center;
  animation: vicTitleIn .6s ease-out both;
  animation-delay: .95s;
}

