/* ============================================================
   Chess BZH — thème sombre premium
   ============================================================ */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:root {
  --bg: #0b0a08;
  --bg-elevated: #131110;
  --bg-card: #18150f;
  --bg-card-hover: #1e1a13;
  --border: #2b2419;
  --border-soft: #221d15;
  --gold: #c9a765;
  --gold-bright: #e6c98a;
  --cream: #f3ead9;
  --text: #ece3d2;
  --text-muted: #a89a80;
  --text-faint: #766a56;
  --green: #6f9c76;
  --green-bg: rgba(111, 156, 118, 0.14);
  --red: #c1685f;
  --red-bg: rgba(193, 104, 95, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 20px 60px -30px rgba(0, 0, 0, 0.7);
  --serif: "Playfair Display", "Cormorant Garamond", Georgia, serif;
  --body-font: "Cormorant Garamond", "Inter", Georgia, serif;
  --ui-font: "Inter", "Cormorant Garamond", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body-font);
  font-size: 18px;
  line-height: 1.55;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(201, 167, 101, 0.07), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(201, 167, 101, 0.05), transparent 55%);
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); }

h1, h2, h3 { font-family: var(--serif); color: var(--cream); font-weight: 600; margin: 0 0 0.4em; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 28px; }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 10, 8, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 76px; position: relative; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.4rem; color: var(--cream); }
.brand-mark { color: var(--gold); font-size: 1.7rem; }
.main-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 22px; font-family: var(--ui-font); }
.nav-link { color: var(--text-muted); font-size: 0.95rem; letter-spacing: 0.02em; }
.nav-link:hover, .nav-link.active { color: var(--gold-bright); }
.nav-user { color: var(--text-faint); font-size: 0.9rem; }

.nav-toggle {
  display: none; flex-direction: column; justify-content: space-between;
  width: 26px; height: 19px; padding: 0; background: none; border: none; cursor: pointer; z-index: 60;
}
.nav-toggle span { display: block; width: 100%; height: 2px; background: var(--text); border-radius: 2px; transition: transform 0.2s ease, opacity 0.2s ease; }
.nav-toggle.is-active span:nth-child(1) { transform: translateY(8.5px) rotate(45deg); }
.nav-toggle.is-active span:nth-child(2) { opacity: 0; }
.nav-toggle.is-active span:nth-child(3) { transform: translateY(-8.5px) rotate(-45deg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--ui-font); font-size: 0.92rem; font-weight: 600;
  padding: 12px 22px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; transition: all 0.18s ease; letter-spacing: 0.01em;
}
.btn-gold { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: #201804; }
.btn-gold:hover { filter: brightness(1.08); color: #201804; box-shadow: 0 8px 22px -8px rgba(201, 167, 101, 0.6); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold-bright); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { color: var(--gold-bright); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: rgba(193, 104, 95, 0.35); }
.btn-danger:hover { background: rgba(193, 104, 95, 0.25); }
.btn-lg { padding: 15px 32px; font-size: 1rem; }
.btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* ---------- Flash messages ---------- */
.flash-stack { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.flash { padding: 12px 18px; border-radius: var(--radius-sm); font-family: var(--ui-font); font-size: 0.92rem; border: 1px solid var(--border); }
.flash-success { background: var(--green-bg); color: var(--green); border-color: rgba(111,156,118,0.3); }
.flash-danger { background: var(--red-bg); color: var(--red); border-color: rgba(193,104,95,0.3); }
.flash-warning { background: rgba(201,167,101,0.14); color: var(--gold-bright); border-color: rgba(201,167,101,0.3); }
.flash-info { background: rgba(255,255,255,0.05); color: var(--text-muted); }

/* ---------- Main / layout ---------- */
.site-main { flex: 1; padding: 40px 0 80px; }
.site-footer { border-top: 1px solid var(--border-soft); padding: 26px 0; color: var(--text-faint); font-size: 0.85rem; font-family: var(--ui-font); }
.footer-inner { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 14px; text-align: center; }
.footer-link { color: var(--text-faint); }
.footer-link:hover { color: var(--gold-bright); }
.site-footer a { color: var(--text-faint); text-decoration: underline; text-decoration-color: var(--border); }
.site-footer a:hover { color: var(--gold-bright); text-decoration-color: var(--gold); }

.eyebrow { font-family: var(--ui-font); text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.76rem; color: var(--gold); margin: 0 0 10px; }
.eyebrow.center { text-align: center; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin: 8px 0 30px; flex-wrap: wrap; gap: 16px; }
.page-head h1 { font-size: 2rem; margin: 0; }
.head-actions { display: flex; gap: 10px; }

/* ---------- Hero (landing) ---------- */
.hero { padding: 70px 0 40px; position: relative; overflow: hidden; }
.hero-inner { max-width: 680px; }
.hero-title { font-size: 3.2rem; line-height: 1.12; margin-bottom: 22px; }
.hero-sub { color: var(--text-muted); font-size: 1.15rem; max-width: 560px; margin-bottom: 34px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.hero-board { position: absolute; right: -60px; top: 40px; opacity: 0.5; pointer-events: none; }
.mini-board {
  width: 380px; height: 380px; display: grid;
  grid-template-columns: repeat(8, 1fr); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border); transform: rotate(8deg);
  box-shadow: var(--shadow);
}
.mini-sq.light { background: #2a2317; }
.mini-sq.dark { background: #16130d; }

.features { padding: 50px 0 20px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }
.feature-card { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 26px; }
.feature-icon { font-size: 1.6rem; color: var(--gold); }
.feature-card h3 { font-size: 1.15rem; margin: 12px 0 8px; }
.feature-card p { color: var(--text-muted); font-size: 0.98rem; margin: 0; }

/* ---------- Auth ---------- */
.auth-section { display: flex; justify-content: center; padding: 30px 0; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 40px 36px; box-shadow: var(--shadow);
}
.auth-title { text-align: center; font-size: 1.8rem; margin-bottom: 26px; }
.auth-lead { text-align: center; margin: -10px 0 26px; color: var(--text-muted); font-family: var(--ui-font); font-size: 0.92rem; line-height: 1.5; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--text-muted); font-family: var(--ui-font); font-size: 0.9rem; }
.auth-forgot { text-align: right; margin: -8px 0 18px; font-family: var(--ui-font); font-size: 0.85rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field-label { display: block; font-family: var(--ui-font); font-size: 0.82rem; color: var(--text-muted); margin-bottom: 7px; letter-spacing: 0.02em; }
.field-input {
  width: 100%; background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 12px 14px; font-family: var(--ui-font); font-size: 0.95rem;
  transition: border-color 0.15s ease;
}
.field-input:focus { outline: none; border-color: var(--gold); }
.field-hint { color: var(--red); font-size: 0.8rem; margin: 6px 0 0; font-family: var(--ui-font); }
.field-error .field-input { border-color: var(--red); }

.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-pill {
  display: flex; align-items: center; gap: 8px; background: var(--bg-elevated); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 999px; font-family: var(--ui-font); font-size: 0.88rem; cursor: pointer;
}
.radio-pill input { accent-color: var(--gold); }

/* ---------- Stat tiles ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-bottom: 34px; }
.stat-tile {
  background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 22px; text-align: center;
}
.stat-value { display: block; font-family: var(--serif); font-size: 2rem; color: var(--gold-bright); }
.stat-label { font-family: var(--ui-font); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }

/* ---------- Panels / tables ---------- */
.panel { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 28px; margin-bottom: 26px; }
.panel-narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.panel-tight { padding: 20px; }
.panel-title { font-size: 1.25rem; margin-bottom: 18px; }
.panel-title-sm { font-family: var(--ui-font); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: 0 0 14px; }

.empty-state { color: var(--text-faint); font-style: italic; }

.guide-toc { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 26px; padding: 16px 20px; background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.guide-toc a { font-family: var(--ui-font); font-size: 0.85rem; color: var(--text-muted); }
.guide-toc a:hover { color: var(--gold-bright); }

.panel p { color: var(--text-muted); line-height: 1.7; }
.panel p + p { margin-top: 10px; }
.guide-list { color: var(--text-muted); line-height: 1.7; padding-left: 22px; margin: 12px 0; }
.guide-list li { margin-bottom: 6px; }
.guide-list strong { color: var(--cream); }

.admin-subnav { display: flex; gap: 22px; border-bottom: 1px solid var(--border-soft); margin-bottom: 26px; font-family: var(--ui-font); font-size: 0.9rem; }
.admin-subnav a { color: var(--text-muted); padding: 0 0 12px; border-bottom: 2px solid transparent; }
.admin-subnav a:hover { color: var(--gold-bright); }
.admin-subnav a.active { color: var(--gold-bright); border-bottom-color: var(--gold); }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }

.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-family: var(--ui-font); font-size: 0.9rem; }
.data-table th { text-align: left; color: var(--text-faint); font-weight: 500; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 0 12px 10px; border-bottom: 1px solid var(--border-soft); }
.data-table td { padding: 12px; border-bottom: 1px solid var(--border-soft); color: var(--text); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); cursor: pointer; }
.actions-cell { display: flex; gap: 8px; flex-wrap: wrap; }
.actions-cell form { display: inline; }

.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-family: var(--ui-font); font-size: 0.76rem; background: rgba(201,167,101,0.14); color: var(--gold-bright); }
.pill-muted { background: rgba(255,255,255,0.06); color: var(--text-muted); }
.pill-win { background: var(--green-bg); color: var(--green); }
.pill-loss { background: var(--red-bg); color: var(--red); }

.search-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; max-width: 420px; }
.search-bar .field-input { flex: 1; min-width: 160px; }

.sortable-th { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.sortable-th:hover { color: var(--gold-bright); }
.sortable-th-active { color: var(--gold-bright); }
.sort-arrow { font-size: 0.7em; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
.pagination-status { font-family: var(--ui-font); font-size: 0.82rem; color: var(--text-faint); }
.pagination-disabled { opacity: 0.35; pointer-events: none; }

/* ---------- Player dashboard game cards ---------- */
.game-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.game-card {
  display: block; background: var(--bg-elevated); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 18px; transition: border-color 0.15s ease, transform 0.15s ease;
}
.game-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.game-card-top { display: flex; gap: 8px; margin-bottom: 10px; }
.game-card-vs { font-family: var(--serif); font-size: 1.15rem; color: var(--cream); margin: 0 0 6px; }
.game-card-meta { font-family: var(--ui-font); font-size: 0.78rem; color: var(--text-faint); margin: 0; }

/* ---------- Game page ---------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 620px) 320px; gap: 30px; align-items: start; }
@media (max-width: 980px) { .game-layout { grid-template-columns: 1fr; } }

.board-column { display: flex; flex-direction: column; gap: 10px; }
.player-strip { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; font-family: var(--ui-font); }
.player-name { color: var(--cream); font-weight: 600; }

.board-frame {
  display: grid;
  grid-template-columns: 24px 1fr;
  grid-template-rows: 1fr 22px;
  column-gap: 8px;
  row-gap: 8px;
}
.chessboard {
  grid-column: 2; grid-row: 1;
  aspect-ratio: 1 / 1; display: grid; grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.rank-labels { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; }
.rank-labels span, .file-labels span {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-family: var(--ui-font); font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
}
.rank-labels-spacer { grid-column: 1; grid-row: 2; }
.file-labels { grid-column: 2; grid-row: 2; display: flex; }

.sq { display: flex; align-items: center; justify-content: center; position: relative; font-size: min(6vw, 46px); -webkit-user-select: none; user-select: none; cursor: default; }
.sq.light { background: #acacac; }
.sq.dark { background: #585858; }
.sq.selectable { cursor: pointer; }
.sq.selected { box-shadow: inset 0 0 0 3px var(--gold); }
.sq.legal-target::after { content: ""; position: absolute; width: 26%; height: 26%; border-radius: 50%; background: rgba(21,21,21,0.45); }
.sq.legal-target.has-piece::after { width: 100%; height: 100%; border-radius: 0; background: transparent; box-shadow: inset 0 0 0 4px rgba(21,21,21,0.45); }
.sq.last-move { animation: last-move-pulse 1.8s ease-in-out infinite; }
@keyframes last-move-pulse {
  0%, 100% { background-color: rgba(201, 167, 101, 0.18); }
  50% { background-color: rgba(201, 167, 101, 0.62); }
}
.piece-white { color: #f5f4ef; }
.piece-black { color: #151515; }

.game-status { text-align: center; font-family: var(--ui-font); color: var(--text-muted); font-size: 0.92rem; padding: 6px 0; }
.game-status.result-blink { font-size: 1.05rem; font-weight: 600; animation: result-blink 0.6s ease-in-out infinite; }
@keyframes result-blink {
  0%, 100% { color: var(--gold); opacity: 0.6; }
  50% { color: var(--gold-bright); opacity: 1; }
}
#resign-btn { align-self: center; }

.side-column { display: flex; flex-direction: column; gap: 18px; }
.captures-group + .captures-group { margin-top: 10px; }
.captures-label { display: block; font-family: var(--ui-font); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 2px; }
.captures-row { display: flex; flex-wrap: wrap; gap: 2px; min-height: 1.6rem; align-items: center; }
.captures-row:empty::after { content: "—"; color: var(--text-faint); font-family: var(--ui-font); font-size: 0.8rem; }
.captures-row span { font-size: 1.3rem; line-height: 1; }
/* Le panneau a un fond sombre : sans ce liseré, les pièces noires
   (couleur quasi noire) y deviennent invisibles. Sur l'échiquier ce n'est
   pas un problème (cases claires/sombres alternées), donc ce liseré reste
   local aux prises. */
.captures-row .piece-black { -webkit-text-stroke: 1px #f5f4ef; }
.moves-list {
  margin: 0; padding-left: 20px; max-height: 180px; overflow-y: auto; overflow-x: hidden;
  font-family: var(--ui-font); font-size: 0.88rem; color: var(--text-muted);
  display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-flow: row; column-gap: 14px;
}
.moves-list li { margin-bottom: 4px; }
.moves-panel-tall .moves-list { max-height: 460px; }

.chat-panel { display: flex; flex-direction: column; }
.chat-log { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; padding-right: 4px; }
.chat-msg { background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 8px 12px; font-family: var(--ui-font); font-size: 0.86rem; }
.chat-msg.mine { background: rgba(201,167,101,0.12); }
.chat-author { display: block; font-size: 0.72rem; color: var(--gold); margin-bottom: 2px; }
.chat-time { display: block; font-size: 0.68rem; color: var(--text-faint); margin-top: 2px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text); font-family: var(--ui-font); }
.chat-form input:focus { outline: none; border-color: var(--gold); }

/* ---------- Errors ---------- */
.error-page { text-align: center; padding: 90px 0; }
.error-code { display: block; font-family: var(--serif); font-size: 5rem; color: var(--gold); }

@media (max-width: 760px) {
  .nav-toggle { display: flex; }
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 4px;
    background: var(--bg-elevated); border: 1px solid var(--border-soft); border-top: none;
    border-radius: 0 0 var(--radius) var(--radius); padding: 18px 24px; box-shadow: var(--shadow);
  }
  .main-nav.is-open { display: flex; }
  .main-nav .nav-link, .main-nav .nav-user { width: 100%; padding: 6px 0; }
  .main-nav .btn { width: 100%; margin-top: 4px; }
}

@media (max-width: 800px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 40px 0 20px; }
  .hero-title { font-size: 2.2rem; }
  .hero-board { display: none; }
  .page-head h1 { font-size: 1.6rem; }
  .auth-card { padding: 28px 22px; }
  .panel { padding: 20px; }
  .game-layout { gap: 20px; }
  .board-frame { grid-template-columns: 18px 1fr; grid-template-rows: 1fr 18px; column-gap: 6px; row-gap: 6px; }
  .rank-labels span, .file-labels span { font-size: 0.66rem; }
}
