/* ═══════════════════════════════════════════════════════════════════
   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;
}

/* ── 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;
}

