/* ============================================================
   Chess Dream AI — Main Stylesheet
   Place this in: assets/css/style.css
   ============================================================ */

/* ── Fonts ───────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Orbitron:wght@500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

/* ══════════════════════════════════════════════════════════
   CHESS DREAM AI — Professional Dark Theme
   Inspired by: Lichess + Chess.com + Linear.app
   ══════════════════════════════════════════════════════════ */
:root {
  /* ── Background layers (depth system) ── */
  --bg:          #09090b;   /* deepest background */
  --bg2:         #111113;   /* sidebar, panels */
  --bg3:         #18181b;   /* cards */
  --bg4:         #1f1f23;   /* input, elevated */
  --bg5:         #27272b;   /* hover states */

  /* ── Borders ── */
  --border:      #27272a;
  --border2:     #3f3f46;

  /* ── Brand colors ── */
  --gold:        #e8b84b;   /* primary accent — warmer, more vivid */
  --gold2:       #f5d06a;
  --gold-dim:    rgba(232,184,75,.12);
  --gold-glow:   0 0 20px rgba(232,184,75,.2);

  /* ── Status colors ── */
  --green:       #22c55e;
  --green2:      #4ade80;
  --red:         #ef4444;
  --red2:        #f87171;
  --blue:        #3b82f6;
  --blue2:       #60a5fa;
  --orange:      #f97316;
  --purple:      #a855f7;

  /* ── Text ── */
  --text:        #fafafa;
  --text2:       #a1a1aa;
  --text3:       #52525b;

  /* ── UI ── */
  --sidebar-w:   228px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --font-h:      'Space Grotesk', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
  --font-ar:     'Cairo', system-ui, sans-serif;
  --font-tech:   'Orbitron', 'JetBrains Mono', monospace;
  --radius:      6px;
  --radius-lg:   10px;
  --radius-xl:   14px;
  --shadow:      0 4px 32px rgba(0,0,0,.6), 0 1px 4px rgba(0,0,0,.4);
  --shadow-sm:   0 1px 8px rgba(0,0,0,.4);

  /* Unified motion (production polish) */
  --ease-ui:       cubic-bezier(.22, 1, .36, 1);
  --duration-ui:   220ms;
  --duration-enter: 320ms;
  --transition:    color var(--duration-ui) var(--ease-ui),
                   background var(--duration-ui) var(--ease-ui),
                   border-color var(--duration-ui) var(--ease-ui),
                   box-shadow var(--duration-ui) var(--ease-ui),
                   opacity var(--duration-ui) var(--ease-ui),
                   transform var(--duration-ui) var(--ease-ui);

  /* Analysis board (overridden by JS applyBoardColors) */
  --square-light:   #f0d9b5;
  --square-dark:   #b58863;
  --square-border:  #8b6914;
  --theme-active:   #eab308;

  /* Analysis layout — board vs. eval vs. panel harmony */
  --analysis-board-vmax: 55vh;
  --analysis-board-strip-gap: 24px;
  --analysis-eval-lane: 60px;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle noise texture for depth */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: -1;
  opacity: .5;
}

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

img { max-width: 100%; height: auto; display: block; }

/* ── Layout ───────────────────────────────────────────────── */
.app-container {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
  min-width: 0;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 18px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--gold) 0%, #b8860b 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #000;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(232,184,75,.3);
}

.logo-text {
  font-family: var(--font-h);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
  line-height: 1.2;
}
.logo-text small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  font-family: var(--font);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--border2);
  padding: 14px 22px 4px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  margin: 1px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  border-radius: var(--radius);
  border-left: none;
  transition: var(--transition);
}

.nav-item:hover {
  color: var(--text);
  background: var(--bg4);
}

.nav-item.active {
  color: var(--gold);
  background: var(--gold-dim);
  font-weight: 600;
}

.nav-item i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  opacity: .8;
}
.nav-item.active i { opacity: 1; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold) 0%, #92640a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #000;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(232,184,75,.2);
}

.sidebar-username { font-size: 13px; font-weight: 600; color: var(--text); }
.sidebar-usermeta { font-size: 11px; color: var(--green2); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.btn-coffee {
  display: block;
  text-align: center;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--bg3);
  color: var(--text2) !important;
  font-size: 12px;
  border: 1px solid var(--border);
  transition: all .15s;
}
.btn-coffee:hover { background: var(--bg4); color: var(--gold) !important; }

/* ── Typography ───────────────────────────────────────────── */
.page-title {
  font-family: var(--font-h);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
  letter-spacing: -.02em;
  line-height: 1.25;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 24px;
  font-weight: 400;
}

h1, h2, h3 { font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-success { background: rgba(129,182,76,.12); border-color: rgba(129,182,76,.3); color: var(--green); }
.alert-danger   { background: rgba(226,35,18,.12);  border-color: rgba(226,35,18,.3);  color: var(--red); }
.alert-warning  { background: rgba(240,131,58,.12); border-color: rgba(240,131,58,.3); color: var(--orange); }
.alert-info     { background: rgba(91,156,246,.12); border-color: rgba(91,156,246,.3); color: var(--blue); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color .2s;
}
.card:hover { border-color: var(--border2); }
.card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-title i { color: var(--gold); opacity: .8; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--bg4);
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: -.01em;
}
.btn:hover {
  background: var(--bg5);
  color: var(--text);
  border-color: var(--border2);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0,0,0,.28);
}
.btn:active {
  transform: translateY(0) scale(.98);
  box-shadow: none;
}

.btn-primary {
  background: var(--green);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 8px rgba(34,197,94,.25);
}
.btn-primary:hover {
  background: #16a34a;
  box-shadow: 0 2px 14px rgba(34,197,94,.4), 0 8px 20px rgba(0,0,0,.22);
  color: #fff;
}

.btn-gold {
  background: var(--gold);
  border-color: transparent;
  color: #000;
  font-weight: 700;
  box-shadow: 0 1px 8px rgba(232,184,75,.25);
  letter-spacing: -.01em;
}
.btn-gold:hover {
  background: var(--gold2);
  box-shadow: 0 2px 16px rgba(232,184,75,.45), 0 8px 20px rgba(0,0,0,.2);
  color: #000;
}

.btn-danger {
  background: rgba(239,68,68,.1);
  border-color: rgba(239,68,68,.3);
  color: var(--red2);
}
.btn-danger:hover {
  background: rgba(239,68,68,.2);
  border-color: var(--red);
  color: var(--red);
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 13px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--gold);
  background: var(--bg3);
  box-shadow: 0 0 0 3px rgba(232,184,75,.12);
}
.form-control::placeholder { color: var(--text3); }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* ── Auth Pages (premium mesh + analysis-matched glass) ───── */
.auth-page {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  background: var(--bg);
  overflow: hidden;
}

.auth-page__mesh {
  position: absolute;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 85% 55% at 15% 25%, rgba(232, 184, 75, .09), transparent 52%),
    radial-gradient(ellipse 70% 65% at 88% 72%, rgba(59, 130, 246, .07), transparent 48%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(168, 85, 247, .06), transparent 55%),
    linear-gradient(165deg, #0a0a0c 0%, var(--bg) 38%, #08080a 100%);
  filter: saturate(1.05);
}

.auth-page__grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .45;
  background-image:
    linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, #000 20%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, #000 20%, transparent 72%);
}

.auth-page__vignette {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 90% 85% at 50% 50%, transparent 30%, rgba(0, 0, 0, .55) 100%);
}

.auth-page__blur {
  position: absolute;
  width: min(520px, 90vw);
  height: min(520px, 90vw);
  border-radius: 50%;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(232, 184, 75, .08) 0%, transparent 68%);
  filter: blur(60px);
}

.auth-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 38px 34px 36px;
  border-radius: var(--radius-xl);
  background: linear-gradient(150deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .45), 0 0 0 1px rgba(0, 0, 0, .2) inset;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.auth-box::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, .12), transparent 42%);
  opacity: .4;
}

.auth-box > * {
  position: relative;
  z-index: 1;
}

.auth-logo {
  text-align: center;
  margin-bottom: 8px;
  font-size: 40px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 28px rgba(232, 184, 75, .35);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .4));
}

.auth-title {
  font-family: var(--font-h);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -.02em;
}

.auth-title-gold {
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text3);
  text-align: center;
  margin-bottom: 26px;
  line-height: 1.5;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text3);
  font-size: 12px;
  text-transform: lowercase;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .12), transparent);
}

.auth-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text3);
  margin-top: 22px;
}

.auth-footer a {
  color: var(--text2);
}
.auth-footer a:hover {
  color: var(--gold);
}

/* Auth — floating labels */
.form-floating {
  margin-bottom: 18px;
}

.form-floating__field {
  position: relative;
}

.form-floating__field .form-control {
  padding-top: 1.15rem;
  padding-bottom: 0.42rem;
  min-height: 46px;
  background: rgba(24, 24, 27, .65);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius);
}

.form-floating__field .form-control:focus {
  border-color: rgba(232, 184, 75, .75);
  background: rgba(24, 24, 27, .85);
  box-shadow: 0 0 0 3px rgba(232, 184, 75, .14), 0 0 24px rgba(232, 184, 75, .12);
}

.form-floating__field label {
  position: absolute;
  inset-inline-start: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  pointer-events: none;
  transition: transform var(--duration-ui) var(--ease-ui), top var(--duration-ui) var(--ease-ui), font-size var(--duration-ui) var(--ease-ui), color var(--duration-ui) var(--ease-ui);
  transform-origin: left top;
}

[dir="rtl"] .form-floating__field label {
  transform-origin: right top;
}

.form-floating__field:has(.form-control:focus) label,
.form-floating__field:has(.form-control:not(:placeholder-shown)) label {
  top: 9px;
  transform: translateY(0) scale(0.78);
  color: var(--gold);
}

.form-floating__field--suffix .form-control {
  padding-inline-end: 44px;
}

.form-toggle-pass {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 6px;
  border-radius: var(--radius);
  transition: var(--transition);
}
.form-toggle-pass:hover {
  color: var(--gold);
  background: rgba(255, 255, 255, .06);
}

.btn-auth-primary.btn-gold {
  margin-top: 6px;
  min-height: 46px;
  font-size: 14px;
  letter-spacing: .02em;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .12) inset,
    0 1px 10px rgba(232, 184, 75, .35),
    0 0 28px rgba(232, 184, 75, .22);
}
.btn-auth-primary.btn-gold:hover {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .18) inset,
    0 4px 22px rgba(232, 184, 75, .5),
    0 0 36px rgba(232, 184, 75, .3);
}

.auth-box .btn-block:not(.btn-gold) {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
  color: var(--text2);
}
.auth-box .btn-block:not(.btn-gold):hover {
  border-color: rgba(232, 184, 75, .4);
  color: var(--text);
  background: rgba(255, 255, 255, .08);
}

.auth-strength-track {
  margin-top: 8px;
  height: 4px;
  background: rgba(255, 255, 255, .06);
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
}

/* ── Chess Board (index.php) — hero layout ─────────────────── */
.analysis-container {
  display: grid;
  grid-template-columns: var(--analysis-eval-lane) minmax(0, 2.2fr) minmax(280px, 1.8fr);
  grid-template-areas:
    "eval board panel"
    "import import import";
  gap: 24px;
  align-items: start;
  direction: ltr;
}

/* Evaluation lane — own grid column; inner height synced to #chessboard-container in analysis.js */
.eval-lane {
  grid-area: eval;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  min-height: min(62vh, 720px);
  padding: 8px 0 12px;
}

.eval-lane__inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  flex: 0 0 auto;
  width: 100%;
  max-width: var(--analysis-eval-lane);
  min-height: min(240px, 42vh);
}

.eval-lane__bar-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: stretch;
  width: 100%;
  min-height: 0;
  max-height: min(var(--analysis-board-vmax), 85vh);
}

.eval-lane .eval-bar {
  flex: 1 1 auto;
  width: 25px;
  min-height: 120px;
  max-height: min(var(--analysis-board-vmax), 85vh);
  align-self: center;
}

.chess-board-wrapper {
  grid-area: board;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* Vertically center strips + board as one unit within viewport allowance */
.board-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(62vh, 720px);
  padding: 8px 0 12px;
}

.board-hero__assembly {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: var(--analysis-board-strip-gap);
  width: min(var(--analysis-board-vmax), 100%);
  max-width: 100%;
  overflow: visible;
  padding-bottom: min(20px, 3vh);
  margin-bottom: 4px;
}

.board-hero__strip {
  flex-shrink: 0;
}

.board-hero__strip--black {
  order: 1;
}

.board-hero__board {
  order: 2;
}

.board-hero__strip--white {
  order: 3;
}

/* Flip board: swap rails only (board stays centered) */
.board-hero__assembly--rails-swapped .board-hero__strip--white {
  order: 1;
}

.board-hero__assembly--rails-swapped .board-hero__board {
  order: 2;
}

.board-hero__assembly--rails-swapped .board-hero__strip--black {
  order: 3;
}

/* Player strips — board width, glass (Chess.com–style rails) */
.player-strip {
  position: relative;
  flex-shrink: 0;
  border-radius: 12px;
  padding: 16px 18px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: var(--transition);
}

.player-strip__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.player-strip__name {
  font-family: var(--font-h);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-strip__acc {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.player-strip__acc-val {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-h);
  line-height: 1;
}

.player-strip__acc-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

.player-strip--white {
  background: linear-gradient(155deg, rgba(255, 252, 248, 0.94), rgba(235, 228, 216, 0.88));
  color: #0c0c0f;
}

.player-strip--white::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.5), transparent 48%);
  opacity: 0.2;
  pointer-events: none;
}

.player-strip--white .player-strip__name,
.player-strip--white .player-strip__acc-val {
  color: #08080b;
}

.player-strip--white .player-strip__acc-lbl {
  color: #3f3f46;
}

.player-strip--black {
  background: linear-gradient(150deg, rgba(28, 28, 34, 0.92), rgba(10, 10, 14, 0.9));
  color: #f4f4f5;
}

.player-strip--black::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.08), transparent 50%);
  opacity: 0.45;
  pointer-events: none;
}

.player-strip--black .player-strip__name,
.player-strip--black .player-strip__acc-val {
  color: #fafafa;
}

.player-strip--black .player-strip__acc-lbl {
  color: #c8c8d0;
}

.player-strip__head,
.player-strip > .captured-strip {
  position: relative;
  z-index: 1;
}

.player-strip:hover {
  border-color: rgba(232, 184, 75, 0.45);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34), 0 0 20px rgba(232, 184, 75, 0.12);
}

#chessboard-container {
  width: 100%;
  max-width: var(--analysis-board-vmax);
  max-height: var(--analysis-board-vmax);
  aspect-ratio: 1 / 1;
  height: auto;
  position: relative;
  margin: 0;
  background: var(--square-light);
  border: 3px solid var(--square-border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  overflow: hidden;
  direction: ltr !important;
  unicode-bidi: isolate;
}

/* Neon piece set: glow lives only on this frame (box-shadow), not on squares or piece filters */
#chessboard-container[data-piece-theme='neon'] {
  border: none;
  box-shadow:
    inset 0 0 0 3px rgba(56, 189, 248, 0.52),
    inset 0 0 42px rgba(14, 165, 233, 0.09),
    0 0 28px rgba(37, 99, 235, 0.44),
    0 0 58px rgba(14, 165, 233, 0.24),
    var(--shadow);
}

#chessboard-container[data-piece-theme='classic'] img,
#chessboard-container[data-piece-theme='minimal'] img,
#chessboard-container[data-piece-theme='neon'] img {
  filter: none;
}

#chessboard-container[data-piece-theme='vintage'] img {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

/* Vintage wood: walnut (dark) + maple (light) — layered grain over base hue */
#chessboard-container[data-vintage='1'] #chessboard .black-3c85d {
  background-color: #2a1810 !important;
  background-image:
    linear-gradient(105deg, rgba(62, 38, 24, 0.92) 0%, rgba(42, 26, 16, 0.98) 22%, rgba(55, 34, 22, 0.94) 45%, rgba(32, 20, 12, 1) 70%, rgba(48, 30, 18, 0.96) 100%),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0, 0, 0, 0.06) 2px, rgba(0, 0, 0, 0.06) 3px),
    repeating-linear-gradient(0deg, transparent, transparent 1px, rgba(255, 255, 255, 0.03) 1px, rgba(255, 255, 255, 0.03) 4px) !important;
}

#chessboard-container[data-vintage='1'] #chessboard .white-1e1d7 {
  background-color: #e8d4b0 !important;
  background-image:
    linear-gradient(165deg, rgba(255, 248, 235, 0.98) 0%, rgba(232, 212, 176, 0.96) 35%, rgba(218, 190, 148, 0.98) 65%, rgba(240, 224, 198, 0.95) 100%),
    repeating-linear-gradient(88deg, transparent, transparent 3px, rgba(139, 90, 43, 0.045) 3px, rgba(139, 90, 43, 0.045) 4px),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.12) 2px, rgba(255, 255, 255, 0.12) 5px) !important;
}

#chessboard-container[data-vintage='1'] #chessboard .square-55d63.last-move-highlight {
  box-shadow: inset 0 0 0 3px rgba(232, 184, 75, 0.55) !important;
}

#chessboard .board-b72f1,
#chessboard {
  width: 100%;
  height: 100%;
  direction: ltr !important;
  unicode-bidi: isolate;
}

#chessboard .notation-322f9,
#chessboard .alpha-d2270,
#chessboard .numeric-fc462 {
  direction: ltr !important;
  unicode-bidi: isolate;
}

/* Square colors from theme variables (chessboard-js class names) */
#chessboard .white-1e1d7 {
  background-color: var(--square-light) !important;
}

#chessboard .black-3c85d {
  background-color: var(--square-dark) !important;
}

#chessboard .highlight-white {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 0, 0.72) !important;
}

#chessboard .highlight-black {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 0, 0.48) !important;
}

/* Neon piece theme — strip square-level shadow/border/filter (prevents glow bleed); UX rings use outline only */
#chessboard-container[data-piece-theme='neon'] #chessboard .square-55d63,
#chessboard-container[data-piece-theme='neon'] #chessboard .white-1e1d7,
#chessboard-container[data-piece-theme='neon'] #chessboard .black-3c85d {
  box-shadow: none !important;
  border: none !important;
  filter: none !important;
}

#chessboard-container[data-piece-theme='neon'] #chessboard .square-55d63.last-move-highlight {
  outline: 3px solid rgba(232, 184, 75, 0.58);
  outline-offset: -3px;
}

#chessboard-container[data-piece-theme='neon'] #chessboard .highlight-white {
  outline: 3px solid rgba(255, 230, 80, 0.78);
  outline-offset: -3px;
}

#chessboard-container[data-piece-theme='neon'] #chessboard .highlight-black {
  outline: 3px solid rgba(214, 190, 60, 0.58);
  outline-offset: -3px;
}

.eval-bar-container {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 0;
}

/* Last move highlight (dark glass-friendly, works on all board themes) */
#chessboard .square-55d63.last-move-highlight {
  box-shadow: inset 0 0 0 3px rgba(232, 184, 75, 0.45) !important;
  background-image: linear-gradient(
    135deg,
    rgba(232, 184, 75, 0.14) 0%,
    rgba(91, 156, 246, 0.1) 100%
  ) !important;
}

/* Captured pieces strips (under player labels in accuracy cards) */
.captured-strip {
  min-height: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px 5px;
  margin-bottom: 8px;
  padding: 4px 6px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  transition: var(--transition);
}

.accuracy-box.white-box .captured-strip {
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.accuracy-box.black-box .captured-strip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.player-strip--white .captured-strip {
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.player-strip--black .captured-strip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.captured-strip:empty {
  min-height: 0;
  margin-bottom: 0;
  padding: 0;
  border: none;
}

.captured-strip .cp-icon {
  display: inline-flex;
  opacity: 0.92;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.material-advantage {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text2);
  min-height: 1.4em;
  margin-top: 0;
  letter-spacing: 0.02em;
}

.material-advantage.is-white {
  color: #1a1a1f;
  text-shadow: 0 0 12px rgba(232, 184, 75, 0.35);
}

.material-advantage.is-black {
  color: #e8e8ea;
  text-shadow: 0 0 12px rgba(232, 184, 75, 0.25);
}

.material-advantage.is-even {
  color: var(--text3);
  font-weight: 600;
}

.eval-bar {
  width: 25px;
  border-radius: 6px;
  background: #18181b;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.eval-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #f8f9fa;
  border-radius: 5px;
  transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  height: 50%;
}

.nav-controls {
  display: flex;
  gap: 6px;
  justify-content: center;
  background: var(--bg3);
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.nav-controls .btn { padding: 8px 16px; font-size: 13px; }

.game-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.accuracy-row {
  display: flex;
  gap: 12px;
}

.accuracy-box {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
}

.accuracy-box.white-box { background: #f8f9fa; color: #212529; }
.accuracy-box.black-box { background: #212529; color: #f8f9fa; }

.accuracy-value {
  font-size: 22px;
  font-weight: 700;
  display: block;
  line-height: 1;
  margin-bottom: 3px;
}

.accuracy-label { font-size: 11px; opacity: .7; }

/* ── Analysis Panel ───────────────────────────────────────── */
.analysis-panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.import-card {
  grid-area: import;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 11px 8px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text3);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: -.01em;
}

.tab-btn:hover { color: var(--text2); }
.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  font-weight: 600;
}

.tab-content { display: none; padding: 20px 22px; }
.tab-content.active { display: block; }

#move-list {
  max-height: 280px;
  overflow-y: auto;
  direction: ltr;
}

.move-row {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  border-radius: 4px;
  padding: 1px 2px;
}
.move-row:hover { background: var(--bg4); }

.move-num {
  width: 28px;
  color: var(--text3);
  font-size: 13px;
}

.move {
  padding: 3px 8px;
  border-radius: 4px;
  margin-right: 6px;
  min-width: 64px;
  display: inline-block;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s;
  border: 1px solid transparent;
  background: var(--bg3);
  color: var(--text);
}

.move:hover { opacity: .7; }
.move.active-move {
  background: rgba(91,156,246,.2) !important;
  border-color: var(--blue) !important;
  color: var(--blue) !important;
}

.analysis-results {
  background: var(--bg3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 22px;
  text-align: center;
  min-height: 80px;
}

.evaluation {
  font-size: 1.3em;
  font-weight: 700;
  margin: 8px 0;
  direction: ltr;
}

.positive { color: var(--green); }
.negative { color: var(--red); }

.stats-container {
  display: flex;
  gap: 16px;
  direction: ltr;
}

.stats-col { flex: 1; }
.stats-col h4 {
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 8px;
  font-size: 13px;
  border-radius: 4px;
  background: var(--bg4);
  margin-bottom: 4px;
  color: var(--text2);
}

.import-section {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.import-section h3 { font-size: 14px; color: var(--text2); margin-bottom: 10px; }

/* ── Promotion Modal ──────────────────────────────────────── */
.promo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.promo-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}
.promo-box h3 { font-size: 16px; color: var(--text); margin-bottom: 16px; }
.promo-pieces { display: flex; gap: 12px; justify-content: center; }
.promo-piece {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
}
.promo-piece:hover { background: var(--bg4); border-color: var(--gold); transform: scale(1.08); }

/* ── Profile Page ─────────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
  padding: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #8b6914);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-h);
  font-size: 32px;
  color: #000;
  flex-shrink: 0;
}

.profile-name {
  font-family: var(--font-h);
  font-size: 24px;
  color: var(--text);
}

.profile-meta { font-size: 13px; color: var(--text3); margin-top: 4px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 5px;
}
.stat-value.gold { color: var(--gold); }
.stat-value.green { color: var(--green2); }

.stat-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Analyses List ────────────────────────────────────────── */
.analyses-list { display: flex; flex-direction: column; gap: 10px; }

.analysis-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s;
}
.analysis-item:hover { border-color: var(--gold); }

.analysis-date { font-size: 12px; color: var(--text3); min-width: 90px; }
.analysis-preview { flex: 1; font-size: 13px; color: var(--text2); font-family: monospace; direction: ltr; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Puzzles Page ─────────────────────────────────────────── */
.streak-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, rgba(232,184,75,.06) 0%, rgba(232,184,75,.02) 100%);
  border: 1px solid rgba(232,184,75,.15);
  border-radius: var(--radius-xl);
  padding: 18px 22px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.streak-banner::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232,184,75,.3), transparent);
}

.streak-num {
  font-family: var(--font-h);
  font-size: 42px;
  color: var(--gold);
  line-height: 1;
}
.streak-label { font-size: 11px; color: var(--text3); }
.streak-info { flex: 1; }
.streak-title { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.streak-sub { font-size: 13px; color: var(--text3); }

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: inline-block;
}
.filter-pill:hover,
.filter-pill.active { background: var(--gold); color: #000; border-color: var(--gold); font-weight: 600; }

.puzzles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.puzzle-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all .2s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.puzzle-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(201,168,76,.04), transparent);
  opacity: 0;
  transition: opacity .2s;
}
.puzzle-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.puzzle-card:hover::before { opacity: 1; }

.puzzle-diff {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.diff-easy   { color: var(--green2); }
.diff-medium { color: var(--gold); }
.diff-hard   { color: var(--red); }

.puzzle-title { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.puzzle-meta  { font-size: 12px; color: var(--text3); margin-bottom: 12px; }

.puzzle-status {
  font-size: 12px;
  margin-top: 10px;
  font-weight: 500;
}
.ps-solved { color: var(--green2); }
.ps-progress { color: var(--gold); }
.ps-unsolved { color: var(--text3); }

/* ── Courses Page ─────────────────────────────────────────── */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.course-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all .2s;
}
.course-card:hover { border-color: var(--blue); transform: translateY(-2px); }

.course-thumb {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
}

.course-body { padding: 16px; }

.course-level {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 5px;
}
.lv-beginner     { color: var(--green2); }
.lv-intermediate { color: var(--gold); }
.lv-advanced     { color: var(--blue2); }
.lv-pro          { color: var(--red2); }
.lv-master       { color: var(--purple); }
.lv-legendary    {
  color: transparent;
  background: linear-gradient(90deg, var(--gold2), var(--orange), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.course-name { font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.course-desc { font-size: 12px; color: var(--text3); line-height: 1.5; margin-bottom: 12px; }

.progress-row { display: flex; align-items: center; gap: 8px; }
.progress-bar { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .5s; }
.progress-pct { font-size: 11px; color: var(--text3); min-width: 32px; text-align: right; }

.course-lessons { font-size: 11px; color: var(--text3); margin-top: 5px; }

/* ── Shop Page ────────────────────────────────────────────── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all .2s;
}
.product-card:hover { border-color: var(--gold); transform: translateY(-2px); }

.product-image {
  background: var(--bg4);
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  border-bottom: 1px solid var(--border);
}

.product-body { padding: 16px; }
.product-name  { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.product-desc  { font-size: 13px; color: var(--text3); margin-bottom: 12px; line-height: 1.5; }
.product-price { font-size: 20px; font-weight: 700; color: var(--gold); margin-bottom: 12px; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Progress Bar Animation ───────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.fa-spin { animation: spin 1s linear infinite; }


/* ── Scrollbar styling ────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Selection ───────────────────────────────────────────── */
::selection { background: rgba(232,184,75,.25); color: var(--text); }

/* ── Focus visible ───────────────────────────────────────── */
:focus-visible {
  outline: 2px solid rgba(232,184,75,.5);
  outline-offset: 2px;
}

/* ── Improved sidebar user area ──────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  margin: 0 4px;
  border-radius: var(--radius);
  transition: var(--transition);
  cursor: default;
}
.sidebar-user:hover { background: var(--bg3); }
.sidebar-username { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.sidebar-usermeta { font-size: 11px; color: var(--gold); }

/* ── Improved page headers ───────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

/* ── Tag/badge improvements ──────────────────────────────── */
.diff-easy   { color: var(--green);  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.diff-medium { color: var(--gold);   font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.diff-hard   { color: var(--red2);   font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

/* ── Leaderboard improvements ────────────────────────────── */
.leaderboard-rank-1 { color: var(--gold) !important; }
.leaderboard-rank-2 { color: var(--text2) !important; }
.leaderboard-rank-3 { color: #cd7f32 !important; }

/* ── Board container glow on active ─────────────────────── */
#chessboard-container:focus-within {
  box-shadow: 0 0 0 1px rgba(232,184,75,.2), var(--shadow);
}

#chessboard-container[data-piece-theme='neon']:focus-within {
  box-shadow:
    inset 0 0 0 3px rgba(56, 189, 248, 0.58),
    inset 0 0 42px rgba(14, 165, 233, 0.1),
    0 0 0 1px rgba(232, 184, 75, 0.22),
    0 0 32px rgba(37, 99, 235, 0.48),
    0 0 64px rgba(14, 165, 233, 0.26),
    var(--shadow);
}

/* ── Thinking dots animation ─────────────────────────────── */
.thinking-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  background: var(--gold);
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce .9s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: .15s; }
.thinking-dots span:nth-child(3) { animation-delay: .30s; }
@keyframes bounce {
  0%,80%,100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ── Tooltip ─────────────────────────────────────────────── */
[title] { cursor: help; }

/* ── Import section ──────────────────────────────────────── */
#import-tabs button {
  transition: var(--transition) !important;
}


/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Complete System
   ══════════════════════════════════════════════════════════ */

/* ── Mobile bottom navigation bar ───────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.mobile-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text3);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color .15s;
  min-width: 52px;
}
.mobile-nav-item i { font-size: 18px; }
.mobile-nav-item.active { color: var(--gold); }
.mobile-nav-item:hover { color: var(--gold); }

/* ── Mobile hamburger button ─────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: 999;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}
.mobile-header-logo {
  font-family: var(--font-h);
  font-size: 18px;
  color: var(--gold);
  font-weight: 700;
}
.hamburger-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}

/* ── Sidebar overlay for mobile ──────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1001;
}
.sidebar-overlay.show { display: block; }

/* ════════════════════
   TABLET  (≤ 900px)
   ════════════════════ */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }

  .main-content { padding: 20px 16px; }
  .stats-grid   { grid-template-columns: repeat(2,1fr); }

  /* Analysis page — single column; eval lane stacks above board */
  .analysis-container {
    grid-template-columns: 1fr;
    grid-template-areas:
      "eval"
      "board"
      "panel"
      "import";
    gap: 16px;
  }
  .eval-lane {
    min-height: 0;
    padding: 4px 0 10px;
    justify-content: center;
  }
  .eval-lane__inner {
    height: auto !important;
    width: min(var(--analysis-board-vmax), 92vw);
    max-width: 100%;
    min-height: min(200px, 38vh);
  }
  .eval-lane__bar-wrap {
    max-height: min(var(--analysis-board-vmax), 92vw);
  }
  .eval-lane .eval-bar {
    max-height: min(var(--analysis-board-vmax), 92vw);
  }
  .board-hero {
    min-height: 0;
    padding: 4px 0;
  }
  .board-hero__assembly {
    width: 100%;
    max-width: min(var(--analysis-board-vmax), 92vw);
  }
  #chessboard-container {
    max-width: min(var(--analysis-board-vmax), 92vw) !important;
    max-height: min(var(--analysis-board-vmax), 92vw) !important;
    width: 100% !important;
    aspect-ratio: 1 / 1;
    height: auto !important;
  }
  .analysis-panel { min-width: 0; }

  /* Play page */
  .play-layout { grid-template-columns: 1fr !important; }
  #play-board  { width: min(460px, 90vw) !important; }

  /* Puzzles */
  .pz-layout   { grid-template-columns: 1fr !important; }
  #puzzle-board-active {
    width: min(400px, 90vw) !important;
    height: min(400px, 90vw) !important;
  }
}

/* ════════════════════
   MOBILE  (≤ 640px)
   ════════════════════ */
@media (max-width: 640px) {

  /* Hide desktop sidebar, show mobile nav */
  .sidebar        { display: none !important; }
  .mobile-header  { display: flex; }
  .mobile-nav     { display: block; }

  /* Sidebar slides in from left on mobile */
  .sidebar.mobile-open {
    display: flex !important;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1002;
    width: 260px;
    overflow-y: auto;
    animation: slideInLeft .25s ease;
  }
  @keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
  }

  /* Push content down for fixed header, up for bottom nav */
  .app-container  { padding-top: 52px; padding-bottom: 68px; }
  .main-content   { padding: 14px 12px; }

  /* Boards fill screen width */
  #chessboard-container,
  #play-board,
  #puzzle-board-active,
  #daily-board,
  #lp-board {
    width: calc(100vw - 24px) !important;
    height: calc(100vw - 24px) !important;
    max-width: 480px;
    max-height: 480px;
  }

  /* Grids go single column */
  .analysis-container,
  .play-layout,
  .pz-layout,
  .daily-layout,
  .lp-layout,
  .diff-grid        { grid-template-columns: 1fr !important; }

  /* Personality cards wrap nicely */
  .pers-card-grid   { grid-template-columns: repeat(4,1fr) !important; }

  /* Game controls wrap */
  .game-controls    { flex-wrap: wrap; gap: 6px; }
  .game-controls .btn { flex: 1; min-width: 70px; font-size: 12px; }

  /* Cards full width */
  .card { border-radius: 10px; padding: 14px; }

  /* Typography */
  .page-title { font-size: 22px; }
  .page-subtitle { font-size: 13px; }

  /* Puzzles grid */
  .puzzles-grid { grid-template-columns: repeat(2,1fr) !important; gap: 10px; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2,1fr); gap: 8px; }

  /* Import tabs (PGN/Image/FEN) */
  #import-tabs button { font-size: 11px !important; padding: 7px 4px !important; }

  /* Accuracy row */
  .accuracy-row { gap: 8px; }
  .accuracy-box { padding: 10px; }
  .accuracy-value { font-size: 20px; }

  .player-strip__acc-val { font-size: 18px; }
  .player-strip { padding: 12px 12px; }

  /* Move log */
  #move-list { max-height: 160px; }

  /* Hide non-essential elements on small screens */
  .eval-bar-container .eval-bar { display: none; }

  /* Buttons */
  .btn { padding: 8px 12px; font-size: 13px; }
  .btn-block { width: 100%; }

  /* Forms */
  .form-control { font-size: 16px; } /* prevents iOS zoom */

  /* Nav controls (arrows) */
  .nav-controls { gap: 4px; }
  .nav-controls .btn { padding: 8px 14px; }

  /* Clock in play page */
  .clock { font-size: 16px; padding: 5px 10px; }
  .player-bar { padding: 8px 10px; }

  /* Filter pills */
  .filter-bar { flex-wrap: wrap; gap: 6px; }
  .filter-pill { font-size: 12px; padding: 5px 12px; }

  /* Leaderboard */
  .leaderboard-table th:nth-child(4),
  .leaderboard-table td:nth-child(4) { display: none; }

  /* Streak banner */
  .streak-banner { flex-wrap: wrap; gap: 12px; }

  /* Tab buttons */
  .tab-btn { padding: 10px 8px; font-size: 12px; }
}

/* ════════════════════
   SMALL MOBILE (≤ 380px)
   ════════════════════ */
@media (max-width: 380px) {
  .puzzles-grid { grid-template-columns: 1fr !important; }
  .pers-card-grid { grid-template-columns: repeat(3,1fr) !important; }
  .time-grid { grid-template-columns: repeat(2,1fr) !important; }
  .page-title { font-size: 18px; }
}

/* ── Touch improvements ───────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Bigger tap targets */
  .nav-item   { padding: 12px 14px; }
  .btn        { min-height: 40px; }
  .filter-pill{ padding: 8px 14px; }
  .diff-card  { padding: 14px 8px; }
  .pers-card  { padding: 10px 6px; }

  /* Remove hover effects that don't make sense on touch */
  .puzzle-card:hover  { transform: none; }
  .diff-card:hover    { transform: none; }
}

/* ── Safe area for notched phones ────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-nav {
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
}

/* ── Play page setup grid ─────────────────────────────────── */
@media (max-width: 640px) {
  .setup-grid { grid-template-columns: 1fr !important; max-width: 100% !important; }
  .pers-card-grid { grid-template-columns: repeat(4,1fr) !important; }
  .pers-avatar { font-size: 20px; }
  .pers-name   { font-size: 10px; }
  .pers-elo    { font-size: 10px; }
  .pers-desc   { display: none; }
  .diff-grid   { grid-template-columns: repeat(3,1fr) !important; }
  .time-grid   { grid-template-columns: repeat(4,1fr) !important; }
}


/* ══════════════════════════════════════════════════════════
   MOVE CLASSIFICATION — Chess.com Style
   ══════════════════════════════════════════════════════════ */

/* ── Stats panel ─────────────────────────────────────────── */
.review-header {
  padding: 16px 16px 0;
}
.review-header h3 {
  font-family: var(--font-h);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  text-align: center;
  letter-spacing: -.01em;
}
.accuracy-row-review {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.acc-block {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-lg);
  text-align: center;
}
.acc-block.white {
  background: rgba(248,249,250,.07);
  border: 1px solid rgba(248,249,250,.15);
}
.acc-block.black {
  background: rgba(33,37,41,.5);
  border: 1px solid rgba(255,255,255,.08);
}
.acc-value {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-h);
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.acc-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Stats columns ───────────────────────────────────────── */
.stats-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0 8px 12px;
}
.stats-col {
  padding: 0 6px;
}
.stats-player-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 2px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.2);
  flex-shrink: 0;
}
.accuracy-badge {
  margin-left: auto;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
}

/* ── Each stat row ───────────────────────────────────────── */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 2px;
  border-radius: 5px;
  transition: background .1s;
}
.stat-row:hover { background: var(--bg4); }
.stat-row.stat-zero { opacity: .45; }
.stat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}
.stat-row strong {
  font-size: 13px;
  font-weight: 700;
  min-width: 20px;
  text-align: right;
}
.stat-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: -.03em;
}

/* ── Move list badges ────────────────────────────────────── */
.move sup {
  vertical-align: super;
  font-size: 9px;
}

/* ── Brilliant glow animation ────────────────────────────── */
@keyframes brilliantPulse {
  0%,100% { box-shadow: 0 0 6px rgba(0,184,217,.35); }
  50%      { box-shadow: 0 0 14px rgba(0,184,217,.7); }
}
/* ==========================================================
   Chess.com Style Move List & Badges (Square Icons)
   ========================================================== */
#move-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  font-family: 'Inter', 'Segoe UI', sans-serif;
}

.move-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr;
  align-items: center;
  border-radius: 4px;
}

.move-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.03);
}

.move-num {
  color: #8b8b8b;
  font-size: 13px;
  text-align: center;
  font-weight: 500;
}

.move {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 6px 10px;
  border-radius: 6px; 
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #dfdfdf;
  transition: background 0.15s ease;
  margin: 0 2px;
}

.move:hover {
  background: rgba(255, 255, 255, 0.08);
}

.move.active-move {
  background: #3c3c3e !important; 
  color: #ffffff !important;
}

.move-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff !important;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  margin-left: 6px;
  width: 18px;  
  height: 18px; 
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  font-family: 'Inter', sans-serif;
  flex-shrink: 0;
}


/* ══════════════════════════════════════════════════════════════════
   CHESS DREAM AI — GAME REVIEW PANEL (v4 — all 5 fixes applied)
   ══════════════════════════════════════════════════════════════════ */

/* Animations */
@keyframes gr-fadein  { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }
@keyframes gr-bar-grow{ from{width:0} }
@keyframes gr-count-pop{ 0%{transform:scale(1)} 40%{transform:scale(1.35)} 100%{transform:scale(1)} }

/* Wrapper */
.gr-wrap { animation:gr-fadein var(--duration-enter) var(--ease-ui) both; font-family:var(--font,'Inter',sans-serif); }

/* Single-player filter: two columns (label + one count), hide opponent column entirely */
.gr-wrap.gr-player-white .gr-head,
.gr-wrap.gr-player-black .gr-head { grid-template-columns:1fr; }
.gr-wrap.gr-player-white .gr-section-hdr,
.gr-wrap.gr-player-black .gr-section-hdr,
.gr-wrap.gr-player-white .gr-phase-hdr,
.gr-wrap.gr-player-black .gr-phase-hdr,
.gr-wrap.gr-player-white .gr-cls-row,
.gr-wrap.gr-player-black .gr-cls-row,
.gr-wrap.gr-player-white .gr-acpl-row,
.gr-wrap.gr-player-black .gr-acpl-row,
.gr-wrap.gr-player-white .gr-totals-row,
.gr-wrap.gr-player-black .gr-totals-row { grid-template-columns:1fr 44px; }

/* ── 1. Accuracy header ─────────────────────────────── */
.gr-head { display:grid; grid-template-columns:1fr 1fr; border-bottom:1px solid var(--border,#27272a); }
.gr-head-col { padding:14px 16px 12px; display:flex; flex-direction:column; gap:3px; }
.gr-head-col+.gr-head-col { border-left:1px solid var(--border,#27272a); }
.gr-col-title { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--text3,#52525b); display:flex; align-items:center; gap:5px; margin-bottom:2px; }
.gr-piece-w { color:#e4e4e7; font-size:13px; }
.gr-piece-b { color:#71717a; font-size:13px; }
.gr-acc-big { font-size:30px; font-weight:800; font-family:var(--font-h,'Space Grotesk',sans-serif); letter-spacing:-.04em; line-height:1; transition:color .4s; }
.gr-acc-bar { height:3px; border-radius:2px; margin-top:4px; transition:width 1.1s cubic-bezier(.22,1,.36,1); animation:gr-bar-grow 1.1s cubic-bezier(.22,1,.36,1); max-width:100%; }
.gr-game-rating { font-size:11px; color:var(--text3,#52525b); margin-top:1px; }
.gr-game-rating strong { font-family:var(--font-h,'Space Grotesk',sans-serif); font-size:13px; }

/* ── 2. Section headers ─────────────────────────────── */
.gr-section-hdr { display:grid; grid-template-columns:1fr 44px 44px; padding:6px 16px 5px; background:var(--bg3,#18181b); border-bottom:1px solid var(--border,#27272a); border-top:1px solid var(--border,#27272a); font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--text3,#52525b); }
.gr-section-hdr span:not(:first-child) { text-align:center; }

/* ── 3. Phase rows ──────────────────────────────────── */
.gr-phase-hdr { display:grid; grid-template-columns:1fr 44px 44px; align-items:center; padding:7px 16px; border-bottom:1px solid var(--border,#27272a); transition:background .12s; cursor:default; }
.gr-phase-hdr:hover { background:var(--bg4,#1f1f23); }
.gr-phase-name { display:flex; align-items:center; gap:7px; font-size:12px; font-weight:600; color:var(--text2,#a1a1aa); }
.gr-phase-icon { font-size:13px; line-height:1; }

/* ── 4. Classification table ────────────────────────── */

/* FIX R3: NO border-bottom between rows */
.gr-cls-row {
  display:grid;
  grid-template-columns:1fr 44px 44px;
  align-items:center;
  padding:6px 16px;          /* tight as required */
  border-bottom:none;         /* ← FIX R3 */
  transition:background .12s, transform .1s;
  cursor:default;
  position:relative;
}
.gr-cls-row-clickable {
  cursor:pointer;
}
.gr-cls-row-clickable:hover { background:var(--bg4,#1f1f23); transform:translateX(2px); }
.gr-cls-row-clickable:hover .gr-cls-count { animation:gr-count-pop .25s ease both; }
.gr-cls-row-clickable:focus-visible {
  outline:2px solid rgba(232,184,75,.55);
  outline-offset:-2px;
}

.gr-cls-label { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--text2,#a1a1aa); font-weight:500; }

/* FIX R4: Square icons 22×22px, 4px border-radius */
.gr-cls-dot {
  width:22px;              /* ← FIX R4 */
  height:22px;             /* ← FIX R4 */
  border-radius:4px;       /* ← FIX R4 */
  flex-shrink:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:10px;
  font-weight:800;
  color:#fff;
  letter-spacing:-.02em;
}
/* Symbol now lives inside the dot square */
.gr-cls-sym { display:none; }  /* ← FIX R4: hidden, symbol moved to dot */

.gr-cls-count { text-align:center; font-size:14px; font-weight:700; font-family:var(--font-mono,'JetBrains Mono',monospace); transition:color .25s; }

/* ── 5. ACPL PRO row ────────────────────────────────── */
.gr-acpl-row { display:grid; grid-template-columns:1fr 44px 44px; align-items:center; padding:7px 16px; background:rgba(232,184,75,.04); border-bottom:1px solid var(--border,#27272a); }
.gr-acpl-label { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--text2,#a1a1aa); font-weight:500; }
.gr-pro-badge { display:inline-flex; align-items:center; padding:1px 5px; border-radius:3px; font-size:8px; font-weight:800; letter-spacing:.06em; background:linear-gradient(90deg,#f59e0b,#b45309); color:#fff; text-transform:uppercase; margin-left:2px; }
.gr-acpl-val { text-align:center; font-size:13px; font-weight:700; font-family:var(--font-mono,'JetBrains Mono',monospace); }

/* ── 6. Totals row ──────────────────────────────────── */
/* Single separator only above totals row */
.gr-totals-row { display:grid; grid-template-columns:1fr 44px 44px; padding:7px 16px; background:var(--bg3,#18181b); border-top:1px solid var(--border2,#3f3f46); }
.gr-totals-label { font-size:11px; font-weight:700; color:var(--text3,#52525b); text-transform:uppercase; letter-spacing:.06em; }
.gr-totals-val { text-align:center; font-size:12px; font-weight:700; font-family:var(--font-mono,'JetBrains Mono',monospace); color:var(--text2,#a1a1aa); }

/* ── 7. Patterns / Training ─────────────────────────── */
.gr-pattern-item { padding:7px 16px; font-size:12px; color:var(--text2,#a1a1aa); border-bottom:1px solid var(--border,#27272a); line-height:1.55; transition:background .12s; }
.gr-pattern-item:hover { background:var(--bg4,#1f1f23); }
.gr-train-item { padding:6px 16px; font-size:12px; color:var(--text2,#a1a1aa); border-bottom:1px solid var(--border,#27272a); line-height:1.55; }

/* ── 8. AI review section ───────────────────────────── */
.gr-ai-section { margin-top:1px; border-top:2px solid var(--gold,#e8b84b); animation:gr-fadein var(--duration-enter) var(--ease-ui) .12s both; }
.gr-ai-header { display:flex; align-items:center; gap:8px; padding:10px 16px 8px; background:rgba(232,184,75,.06); border-bottom:1px solid var(--border,#27272a); }
.gr-ai-label { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--gold,#e8b84b); }
.gr-ai-badge { margin-left:auto; font-size:9px; padding:2px 6px; border-radius:20px; background:rgba(232,184,75,.12); color:var(--gold,#e8b84b); border:1px solid rgba(232,184,75,.25); font-weight:600; letter-spacing:.04em; }

/* FIX R5: transition on both states so _setAIBody fade works */
.gr-ai-body {
  padding:12px 16px 14px;
  font-size:12.5px;
  color:var(--text2,#a1a1aa);
  line-height:1.75;
  transition:opacity .25s ease;  /* ← FIX R5 */
}
.gr-ai-loading {
  padding:14px 16px;
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  color:var(--text3,#52525b);
  transition:opacity .25s ease;  /* ← FIX R5 */
}

/* ── Analysis UI refresh (glass + motion) ───────────────────── */
.chess-board-wrapper {
  position: relative;
}

.accuracy-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.accuracy-box {
  position: relative;
  overflow: hidden;
  padding: 14px 16px;
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  transition: var(--transition);
}

/* Light “white” card: dark text on opaque cream glass (WCAG-friendly) */
.accuracy-box.white-box {
  background: linear-gradient(155deg, rgba(255,252,248,.94), rgba(235,228,216,.88));
  border: 1px solid rgba(255,255,255,.42);
  color: #0c0c0f;
}

.accuracy-box.white-box::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255,255,255,.55), transparent 48%);
  opacity: .22;
  pointer-events: none;
}

.accuracy-box.white-box .accuracy-value {
  color: #08080b;
  text-shadow: 0 1px 0 rgba(255,255,255,.4);
}

.accuracy-box.white-box .accuracy-label {
  color: #3f3f46;
  opacity: 1;
  font-weight: 600;
}

/* Dark “black” card: light text on deep glass */
.accuracy-box.black-box {
  background: linear-gradient(150deg, rgba(28,28,34,.92), rgba(10,10,14,.9));
  border: 1px solid rgba(255,255,255,.14);
  color: #f4f4f5;
}

.accuracy-box.black-box::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255,255,255,.08), transparent 50%);
  opacity: .5;
  pointer-events: none;
}

.accuracy-box.black-box .accuracy-value {
  color: #fafafa;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}

.accuracy-box.black-box .accuracy-label {
  color: #c8c8d0;
  opacity: 1;
  font-weight: 600;
}

.accuracy-value,
.accuracy-label {
  position: relative;
  z-index: 1;
}

.accuracy-box:hover {
  transform: translateY(-2px);
  border-color: rgba(232,184,75,.5);
  box-shadow: 0 14px 36px rgba(0,0,0,.36), 0 0 22px rgba(232,184,75,.16);
}

.accuracy-box.white-box:hover {
  border-color: rgba(180,140,60,.45);
}

.player-filter-wrap {
  margin-top: 4px;
  display: flex;
  justify-content: center;
}

.player-filter-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  transition: var(--transition);
}

.player-filter-title {
  font-size: 12px;
  color: #c7c7d0;
  font-weight: 600;
}

.player-filter-select {
  width: auto;
  min-width: 150px;
  padding: 6px 30px 6px 11px;
  font-size: 12px;
  border-radius: 999px;
  border-color: rgba(255,255,255,.17);
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)),
    var(--bg4);
  color: var(--text);
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--gold) 50%),
    linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.player-filter-select:focus {
  border-color: rgba(232,184,75,.75);
}

/* Analysis depth control (dark, glassy select) */
.depth-control-wrap {
  display: flex;
  align-items: center;
}

.depth-control-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  transition: var(--transition);
  white-space: nowrap;
}

.depth-control-title {
  font-size: 12px;
  color: #c7c7d0;
  font-weight: 600;
}

.depth-control-select {
  width: auto;
  min-width: 210px;
  padding: 6px 30px 6px 11px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.17);
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)),
    var(--bg4);
  color: var(--text);
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #22d3ee 50%),
    linear-gradient(135deg, #22d3ee 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.depth-control-select:focus {
  border-color: rgba(34,211,238,.75);
  box-shadow: 0 0 0 3px rgba(34,211,238,.12);
  outline: none;
}

.gr-wrap {
  background: linear-gradient(145deg, rgba(255,255,255,.05), rgba(255,255,255,.01));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}

.gr-head-col {
  background: rgba(0,0,0,.18);
}

.gr-cls-row,
.gr-phase-hdr,
.gr-acpl-row,
.gr-pattern-item,
.gr-train-item {
  animation: panelRise var(--duration-enter) var(--ease-ui) both;
}

.gr-cls-row:nth-child(2) { animation-delay: .03s; }
.gr-cls-row:nth-child(3) { animation-delay: .06s; }
.gr-cls-row:nth-child(4) { animation-delay: .09s; }
.gr-cls-row:nth-child(5) { animation-delay: .12s; }

@keyframes panelRise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .accuracy-row {
    grid-template-columns: 1fr;
  }
}

/* ── Glassmorphism pass: analysis panel + tabs ───────────────── */
.analysis-panel {
  position: relative;
  background: linear-gradient(150deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 14px 38px rgba(0,0,0,.32);
}

.analysis-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,.11), transparent 40%);
  opacity: .35;
}

.tabs {
  position: relative;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.16);
  gap: 6px;
}

.tab-btn {
  border-radius: 10px;
  border: 1px solid transparent;
  color: #b4b4bf;
  transition: var(--transition);
}

.tab-btn:hover {
  color: #ececf4;
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.12);
  transform: translateY(-1px);
}

.tab-btn.active {
  color: #111;
  border-bottom-color: transparent;
  border-color: rgba(232,184,75,.85);
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  box-shadow: 0 8px 18px rgba(232,184,75,.28);
}

.tab-content {
  position: relative;
  padding: 20px 22px;
  animation: tabContentIn var(--duration-enter) var(--ease-ui);
}

.analysis-results {
  background: linear-gradient(150deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

/* Move detail — glass card (blunder/mistake/inaccuracy + all badges) */
.move-explain-card {
  position: relative;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(155deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.1);
}
.move-explain-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(125deg, rgba(255,255,255,.12), transparent 42%);
  opacity: .35;
}
.move-explain-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.2);
}
.move-explain-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 28px;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}
.move-explain-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text, #fafafa);
  letter-spacing: .02em;
}
.move-explain-kpi {
  margin-inline-start: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--text3, #a1a1aa);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
}
.move-explain-section {
  position: relative;
  padding: 12px 16px 14px;
}
.move-explain-section + .move-explain-section {
  border-top: 1px solid rgba(255,255,255,.08);
}
.move-explain-section-h {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gold, #e8b84b);
  margin-bottom: 8px;
}
.move-explain-section-t {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text2, #d4d4d8);
}
.move-explain-why .move-explain-section-t strong {
  color: var(--text, #fafafa);
}
.move-explain-best {
  padding: 0;
  background: rgba(129, 182, 76, .08);
  border-top: 1px solid rgba(129, 182, 76, .22) !important;
}
.move-explain-best-inner {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.move-explain-best-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #81b64c;
}
.move-explain-best-san {
  font-size: 1.65rem;
  font-weight: 800;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  color: var(--text, #fafafa);
  text-shadow: 0 1px 0 rgba(0,0,0,.2);
}
.move-explain-best-sub {
  font-size: 12px;
  color: var(--text3, #a1a1aa);
  line-height: 1.5;
}
.move-explain-body .move-explain-section-t {
  font-size: 12.5px;
}

#move-list {
  background: linear-gradient(150deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 10px;
}

.move-row {
  border-radius: 8px;
  transition: var(--transition);
}

.move-row:hover {
  transform: translateX(2px);
}

.move {
  border: 1px solid transparent;
  transition: var(--transition);
}

.move:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.16);
}

.move.active-move {
  background: rgba(232,184,75,.22) !important;
  border-color: rgba(232,184,75,.62) !important;
  color: #fff !important;
  box-shadow: 0 5px 14px rgba(232,184,75,.2);
}

@keyframes tabContentIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .btn:hover,
  .tab-btn:hover,
  .accuracy-box:hover,
  .player-strip:hover,
  .move:hover,
  .move-row:hover {
    transform: none;
  }
  .tab-content,
  .gr-wrap,
  .gr-ai-section,
  .gr-cls-row,
  .gr-phase-hdr,
  .gr-acpl-row,
  .gr-pattern-item,
  .gr-train-item {
    animation: none !important;
  }
  .support-modal-overlay,
  .support-modal {
    transition: none;
  }
  .support-modal-overlay.is-open .support-modal {
    transform: none;
  }
}

/* ── Smart PGN export (analysis page) ───────────────────────── */
.btn-export-pgn {
  background: linear-gradient(135deg, rgba(59, 130, 246, .22) 0%, rgba(96, 165, 250, .12) 50%, rgba(14, 165, 233, .1) 100%);
  border: 1px solid rgba(96, 165, 250, .45);
  color: #dbeafe;
  font-weight: 600;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 4px 18px rgba(37, 99, 235, .22);
}
.btn-export-pgn:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, .35) 0%, rgba(96, 165, 250, .2) 50%, rgba(14, 165, 233, .16) 100%);
  border-color: rgba(147, 197, 253, .65);
  color: #f8fafc;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 6px 22px rgba(37, 99, 235, .35);
}
.btn-export-pgn:active {
  box-shadow: 0 1px 8px rgba(37, 99, 235, .2) inset;
}

/* ── Analysis PDF export (analysis page) ───────────────────── */
.btn-download-pdf {
  background: linear-gradient(135deg, rgba(239, 68, 68, .28) 0%, rgba(220, 38, 38, .14) 45%, rgba(185, 28, 28, .12) 100%);
  border: 1px solid rgba(248, 113, 113, .5);
  color: #fecaca;
  font-weight: 600;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .1) inset, 0 4px 18px rgba(220, 38, 38, .28);
}
.btn-download-pdf:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, .4) 0%, rgba(220, 38, 38, .22) 45%, rgba(185, 28, 28, .18) 100%);
  border-color: rgba(252, 165, 165, .75);
  color: #fff1f2;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .14) inset, 0 6px 22px rgba(220, 38, 38, .4);
}
.btn-download-pdf:active {
  box-shadow: 0 1px 8px rgba(127, 29, 29, .35) inset;
}

/* ── Support / donation modal (glassmorphism) ─────────────── */
.support-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(6, 6, 10, .72);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration-ui) var(--ease-ui), visibility var(--duration-ui) var(--ease-ui);
}

.support-modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.support-modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: min(92vh, 900px);
  overflow-y: auto;
  padding: 28px 22px 20px;
  border-radius: var(--radius-xl);
  background: linear-gradient(155deg, rgba(28, 28, 34, .72), rgba(12, 12, 16, .55));
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, .55),
    0 0 0 1px rgba(0, 0, 0, .35) inset,
    0 1px 0 rgba(255, 255, 255, .06) inset;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform: translateY(10px) scale(0.98);
  transition: transform var(--duration-enter) var(--ease-ui);
}

.support-modal-overlay.is-open .support-modal {
  transform: translateY(0) scale(1);
}

.support-modal::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, .1), transparent 48%);
  opacity: .4;
}

.support-modal__close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .28);
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
}
.support-modal__close:hover {
  color: var(--text);
  border-color: rgba(232, 184, 75, .45);
  background: rgba(232, 184, 75, .1);
}

.support-modal__icon {
  position: relative;
  text-align: center;
  font-size: 34px;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 12px rgba(232, 184, 75, .25));
}

.support-modal__title {
  position: relative;
  font-family: var(--font-h);
  font-size: 19px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -.02em;
  padding-inline: 28px;
}

.support-modal__thank {
  position: relative;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text2);
  text-align: center;
  margin-bottom: 18px;
  padding: 0 6px;
}

.support-modal__cards {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

@media (max-width: 520px) {
  .support-modal__cards {
    grid-template-columns: 1fr;
  }
  .support-modal {
    padding: 26px 16px 16px;
  }
}

.donation-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 14px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, .1);
  background: linear-gradient(160deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .02));
  box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}

.donation-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(140deg, rgba(255, 255, 255, .08), transparent 55%);
  opacity: .5;
}

.donation-card > * {
  position: relative;
  z-index: 1;
}

.donation-card--paypal {
  border-color: rgba(0, 112, 186, .35);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, .28),
    0 0 0 1px rgba(0, 112, 186, .12) inset;
}

.donation-card--baridi {
  border-color: rgba(34, 197, 94, .28);
  background: linear-gradient(165deg, rgba(20, 83, 45, .22), rgba(15, 23, 42, .45));
  box-shadow:
    0 10px 28px rgba(0, 0, 0, .3),
    0 0 0 1px rgba(34, 197, 94, .1) inset;
}

.donation-card__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.donation-card__icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 18px;
}

.donation-card__icon--paypal {
  background: linear-gradient(145deg, #009cde, #003087);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 112, 186, .4);
}

.donation-card__icon--dz {
  background: linear-gradient(145deg, rgba(34, 197, 94, .35), rgba(15, 118, 110, .45));
  color: #d1fae5;
  border: 1px solid rgba(52, 211, 153, .35);
  box-shadow: 0 4px 14px rgba(16, 185, 129, .2);
}

.donation-card__title {
  font-family: var(--font-h);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  margin-bottom: 4px;
  line-height: 1.25;
}

.donation-card__sub {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text2);
}

.donation-card__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: auto;
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, .2);
  cursor: pointer;
  transition: var(--transition);
}

.donation-card__cta--paypal {
  background: linear-gradient(180deg, #0070ba 0%, #003087 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 112, 186, .38), 0 0 0 1px rgba(255, 255, 255, .1) inset;
}

.donation-card__cta--paypal:hover {
  filter: brightness(1.08);
  color: #fff;
  box-shadow: 0 6px 22px rgba(0, 112, 186, .5), 0 0 0 1px rgba(255, 255, 255, .14) inset;
  transform: translateY(-1px);
}

.donation-card__cta--paypal i {
  font-size: 20px;
}

.donation-card__rip-block {
  margin-bottom: 10px;
}

.donation-card__rip-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}

.donation-card__rip {
  font-family: var(--font-mono);
  font-size: clamp(12px, 2.8vw, 14px);
  font-weight: 600;
  letter-spacing: .04em;
  word-break: break-all;
  color: var(--text);
  padding: 10px 10px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .08);
  line-height: 1.35;
}

.donation-card__copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin-top: auto;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06);
  transition: var(--transition);
}

.donation-card__copy:hover {
  border-color: rgba(232, 184, 75, .45);
  background: rgba(232, 184, 75, .1);
  color: var(--gold2);
}

.donation-card__copy.is-copied {
  border-color: rgba(34, 197, 94, .55);
  background: rgba(34, 197, 94, .15);
  color: var(--green2);
}

.support-modal__footer {
  position: relative;
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

.support-modal__btn-close-text {
  width: 100%;
  max-width: 280px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(0, 0, 0, .2);
  transition: var(--transition);
}

.support-modal__btn-close-text:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .06);
}

/* ── Guest conversion modal (auth-matched dark glass) ───────── */
.guest-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(6, 6, 10, .72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.guest-modal-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 38px 34px 34px;
  border-radius: var(--radius-xl);
  text-align: center;
  background: linear-gradient(150deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, .45),
    0 0 0 1px rgba(0, 0, 0, .2) inset,
    0 0 40px rgba(232, 184, 75, .08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.guest-modal-content::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, .12), transparent 42%);
  opacity: .4;
}

.guest-modal-content > * {
  position: relative;
  z-index: 1;
}

.guest-modal__close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .28);
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  padding: 0;
  font-family: inherit;
}

.guest-modal__close:hover {
  color: var(--text);
  border-color: rgba(232, 184, 75, .45);
  background: rgba(232, 184, 75, .1);
}

.guest-modal__icon {
  font-size: 40px;
  line-height: 1;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 0 0 28px rgba(232, 184, 75, .35);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .4));
}

.guest-modal__title {
  font-family: var(--font-h);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.guest-modal__text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text3);
  margin-bottom: 24px;
  max-width: 32em;
  margin-left: auto;
  margin-right: auto;
}

.guest-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.guest-modal__btn {
  flex: 1 1 140px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  border-radius: var(--radius);
  transition: var(--transition);
  text-align: center;
  border: 1px solid transparent;
  font-family: inherit;
  cursor: pointer;
  box-sizing: border-box;
}

.guest-modal__btn--primary {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .12) inset,
    0 1px 10px rgba(232, 184, 75, .35),
    0 0 28px rgba(232, 184, 75, .22);
}

.guest-modal__btn--primary:hover {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .18) inset,
    0 4px 22px rgba(232, 184, 75, .5),
    0 0 36px rgba(232, 184, 75, .3);
  color: #000;
}

.guest-modal__btn--secondary {
  background: rgba(255, 255, 255, .05);
  border-color: rgba(255, 255, 255, .12);
  color: var(--text2);
}

.guest-modal__btn--secondary:hover {
  border-color: rgba(232, 184, 75, .4);
  color: var(--text);
  background: rgba(255, 255, 255, .08);
}

.btn-coffee {
  width: 100%;
  cursor: pointer;
  font-family: inherit;
}

/* ── About page (premium app “About” screen) ───────────────── */
.about-hero {
  position: relative;
  margin-bottom: 28px;
  padding: 36px 32px 32px;
  border-radius: var(--radius-xl);
  text-align: center;
  background: linear-gradient(150deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .32);
  overflow: hidden;
}

.about-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, .1), transparent 50%);
  opacity: .35;
}

.about-hero__logo {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--gold) 0%, #92640a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #000;
  font-weight: 700;
  box-shadow: 0 8px 28px rgba(232, 184, 75, .35);
}

.about-hero__name {
  position: relative;
  font-family: var(--font-h);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text);
  margin-bottom: 6px;
}

.about-hero__tag {
  position: relative;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text3);
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 800px) {
  .about-grid {
    grid-template-columns: 1fr;
  }
}

.about-glass-card {
  position: relative;
  padding: 22px 24px 24px;
  border-radius: var(--radius-xl);
  background: linear-gradient(150deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .015));
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
}

.about-glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, .08), transparent 48%);
  opacity: .3;
}

.about-glass-card > * {
  position: relative;
  z-index: 1;
}

.about-glass-card h2 {
  font-family: var(--font-h);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

.about-glass-card p,
.about-glass-card li {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text2);
}

.about-glass-card p + p {
  margin-top: 12px;
}

.about-version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  font-size: 13px;
}
.about-version-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.about-version-k {
  color: var(--text3);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .06em;
}

.about-version-v {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
  text-align: end;
}

body.light-mode .auth-page__mesh {
  background:
    radial-gradient(ellipse 85% 55% at 15% 25%, rgba(232, 184, 75, .12), transparent 52%),
    radial-gradient(ellipse 70% 65% at 88% 72%, rgba(59, 130, 246, .08), transparent 48%),
    linear-gradient(165deg, #f0f0eb 0%, #fafaf8 50%, #ecece8 100%);
}

body.light-mode .auth-page__grid {
  opacity: .25;
}

body.light-mode .auth-page__vignette {
  background: radial-gradient(ellipse 90% 85% at 50% 50%, transparent 40%, rgba(0, 0, 0, .06) 100%);
}

body.light-mode .auth-box,
body.light-mode .support-modal,
body.light-mode .guest-modal-content,
body.light-mode .about-hero,
body.light-mode .about-glass-card {
  background: linear-gradient(150deg, rgba(255, 255, 255, .85), rgba(248, 248, 244, .75));
  border-color: rgba(0, 0, 0, .1);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .08);
}

body.light-mode .support-modal-overlay,
body.light-mode .guest-modal-overlay {
  background: rgba(15, 15, 18, .45);
}

body.light-mode .guest-modal__title {
  background: linear-gradient(135deg, #b45309, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

body.light-mode .guest-modal__btn--secondary {
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .12);
  color: var(--text2);
}

body.light-mode .guest-modal__btn--secondary:hover {
  border-color: rgba(201, 168, 76, .45);
  color: var(--text);
  background: rgba(232, 184, 75, .1);
}

body.light-mode .guest-modal__close {
  background: rgba(0, 0, 0, .06);
  border-color: rgba(0, 0, 0, .1);
  color: var(--text2);
}

body.light-mode .donation-card {
  background: linear-gradient(160deg, rgba(255, 255, 255, .75), rgba(248, 248, 246, .55));
  border-color: rgba(0, 0, 0, .1);
}

body.light-mode .donation-card--baridi {
  background: linear-gradient(165deg, rgba(220, 252, 231, .55), rgba(248, 250, 252, .75));
  border-color: rgba(22, 163, 74, .25);
}

body.light-mode .donation-card__rip {
  background: rgba(0, 0, 0, .06);
  border-color: rgba(0, 0, 0, .08);
}

body.light-mode .donation-card__copy,
body.light-mode .support-modal__btn-close-text {
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .12);
  color: var(--text2);
}

body.light-mode .donation-card__copy:hover {
  background: rgba(232, 184, 75, .12);
  border-color: rgba(201, 168, 76, .4);
  color: var(--text);
}

body.light-mode .form-floating__field .form-control {
  background: rgba(255, 255, 255, .9);
  border-color: var(--border);
}

body.light-mode .auth-title {
  color: var(--text);
}

/* ════════════════════════════════════════════════════════════
   Admin dashboard — glass layout (dark / gold)
   ════════════════════════════════════════════════════════════ */
.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(17, 17, 19, .98), rgba(9, 9, 11, .95));
  border-right: 1px solid rgba(255, 255, 255, .08);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  z-index: 2;
}

.admin-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.admin-sidebar__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: linear-gradient(135deg, var(--gold) 0%, #b8860b 100%);
  color: #000;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(232, 184, 75, .35);
}

.admin-sidebar__title {
  font-family: var(--font-h);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.admin-sidebar__sub {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-top: 2px;
}

.admin-sidebar__nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-lg);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: var(--transition);
}

.admin-sidebar__link i {
  width: 18px;
  text-align: center;
  color: var(--text3);
  transition: var(--transition);
}

.admin-sidebar__link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .04);
  border-color: rgba(255, 255, 255, .06);
}

.admin-sidebar__link:hover i {
  color: var(--gold);
}

.admin-sidebar__link--active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(232, 184, 75, .14), rgba(232, 184, 75, .04));
  border-color: rgba(232, 184, 75, .28);
  box-shadow: 0 0 24px rgba(232, 184, 75, .08);
}

.admin-sidebar__link--active i {
  color: var(--gold);
}

.admin-sidebar__footer {
  padding: 14px 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.admin-sidebar__back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 600;
  color: #0c0a06;
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 4px 20px rgba(232, 184, 75, .25);
  transition: var(--transition);
}

.admin-sidebar__back:hover {
  color: #000;
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 40px;
  overflow-x: hidden;
}

.glass-panel {
  position: relative;
  border-radius: var(--radius-xl);
  background: linear-gradient(150deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
}

.glass-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, .1), transparent 45%);
  opacity: 0.35;
}

.glass-panel > * {
  position: relative;
  z-index: 1;
}

.glass-panel--gold {
  border-color: rgba(232, 184, 75, .35);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .35), 0 0 40px rgba(232, 184, 75, .08);
}

.admin-welcome {
  padding: 26px 28px;
  margin-bottom: 24px;
}

.admin-welcome__eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-welcome__title {
  font-family: var(--font-h);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.admin-welcome__meta {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text3);
}

.admin-welcome__meta strong {
  color: var(--text2);
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.admin-stat-card {
  padding: 22px 20px;
  text-align: center;
}

.admin-stat-card__icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(232, 184, 75, .12);
  border: 1px solid rgba(232, 184, 75, .22);
  color: var(--gold);
  font-size: 18px;
}

.admin-stat-card__value {
  font-family: var(--font-h);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
}

.admin-stat-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
}

.admin-table-section {
  padding: 22px 24px 24px;
}

.admin-table-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.admin-table-section__title {
  font-family: var(--font-h);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-table-section__title i {
  color: var(--gold);
  opacity: 0.9;
}

.admin-table-section__count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
}

.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(0, 0, 0, .2);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table thead th {
  text-align: left;
  padding: 14px 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  background: rgba(255, 255, 255, .04);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  white-space: nowrap;
}

.admin-table tbody tr {
  transition: background var(--duration-ui) var(--ease-ui);
}

.admin-table tbody tr:hover {
  background: rgba(232, 184, 75, .06);
}

.admin-table tbody td {
  padding: 14px 16px;
  color: var(--text2);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table__mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
}

.admin-role-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .1);
  color: var(--text2);
}

.admin-role-pill--admin {
  background: rgba(232, 184, 75, .15);
  border-color: rgba(232, 184, 75, .4);
  color: var(--gold2);
}

.admin-permission-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid rgba(232, 184, 75, .45);
  background: rgba(232, 184, 75, .14);
  color: var(--gold2);
  white-space: nowrap;
}

.admin-permission-pill--full::before {
  content: "★";
  margin-right: 6px;
  font-size: 9px;
}

.admin-permission-toggle {
  --toggle-height: 30px;
  --toggle-width: 124px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: var(--toggle-width);
  min-height: var(--toggle-height);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06);
  color: var(--text3);
  cursor: pointer;
  padding: 3px 10px 3px 34px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: all var(--duration-ui) var(--ease-ui);
}

.admin-permission-toggle:hover {
  border-color: rgba(232, 184, 75, .35);
}

.admin-permission-toggle.is-on {
  background: rgba(232, 184, 75, .16);
  border-color: rgba(232, 184, 75, .5);
  color: var(--gold2);
}

.admin-permission-toggle.is-loading {
  opacity: .7;
  cursor: wait;
}

.admin-permission-toggle:disabled {
  cursor: not-allowed;
  opacity: .72;
}

.admin-permission-toggle__knob {
  position: absolute;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #8f93a0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .28);
  transition: transform var(--duration-ui) var(--ease-ui), background var(--duration-ui) var(--ease-ui);
}

.admin-permission-toggle.is-on .admin-permission-toggle__knob {
  transform: translateX(94px);
  background: linear-gradient(135deg, #f0cc6e, #b98826);
}

.admin-permission-toggle__label {
  white-space: nowrap;
}

.nav-item--admin {
  background: linear-gradient(90deg, rgba(232, 184, 75, .12), rgba(232, 184, 75, .04));
  border: 1px solid rgba(232, 184, 75, .35);
  margin: 0 10px 6px;
  border-radius: var(--radius-lg);
  color: var(--gold2) !important;
}

.nav-item--admin i {
  color: var(--gold) !important;
}

.nav-item--admin:hover {
  border-color: rgba(232, 184, 75, .55);
  background: linear-gradient(90deg, rgba(232, 184, 75, .2), rgba(232, 184, 75, .08));
}

.nav-item--admin.active {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(232, 184, 75, .15);
}

@media (max-width: 900px) {
  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    height: auto;
    min-height: unset;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0 8px;
  }

  .admin-sidebar__brand {
    flex: 1;
    min-width: 180px;
    border-bottom: none;
    padding: 16px 10px;
  }

  .admin-sidebar__nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1 1 100%;
    padding: 8px 8px 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
  }

  .admin-sidebar__footer {
    width: 100%;
    padding: 10px 8px 16px;
    border-top: none;
  }

  .admin-sidebar__back {
    padding: 10px 14px;
  }

  .admin-main {
    padding: 20px 16px 32px;
  }
}

@media (max-width: 640px) {
  .admin-table thead {
    display: none;
  }

  .admin-table tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, .03);
  }

  .admin-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
  }

  .admin-table tbody td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text3);
    flex-shrink: 0;
  }

  .admin-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .admin-table tbody tr:last-child td:last-child {
    border-bottom: none;
  }
}

body.light-mode .admin-sidebar {
  background: linear-gradient(180deg, rgba(248, 248, 244, .98), rgba(240, 240, 235, .95));
  border-right-color: rgba(0, 0, 0, .08);
}

body.light-mode .admin-sidebar__brand,
body.light-mode .admin-sidebar__footer,
body.light-mode .admin-sidebar__nav {
  border-color: rgba(0, 0, 0, .08);
}

body.light-mode .glass-panel,
body.light-mode .admin-table-section {
  background: linear-gradient(150deg, rgba(255, 255, 255, .88), rgba(248, 248, 244, .78));
  border-color: rgba(0, 0, 0, .1);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .08);
}

body.light-mode .admin-table-wrap {
  background: rgba(255, 255, 255, .5);
  border-color: rgba(0, 0, 0, .08);
}

body.light-mode .admin-table thead th {
  background: rgba(0, 0, 0, .04);
  color: var(--text3);
  border-color: rgba(0, 0, 0, .08);
}

body.light-mode .admin-table tbody td {
  color: var(--text2);
  border-color: rgba(0, 0, 0, .06);
}

body.light-mode .admin-table tbody tr:hover {
  background: rgba(232, 184, 75, .1);
}

body.light-mode .nav-item--admin {
  border-color: rgba(201, 168, 76, .45);
}

body.light-mode .admin-permission-toggle {
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .14);
}

body.light-mode .admin-permission-toggle.is-on {
  background: rgba(201, 168, 76, .18);
  border-color: rgba(201, 168, 76, .5);
  color: #765412;
}

/* RTL support — mirror shell/layout while keeping the chessboard itself LTR */
html[dir="rtl"] .app-container,
[dir="rtl"] .app-container {
  flex-direction: row-reverse;
}

html[dir="rtl"] .app-container > .sidebar,
[dir="rtl"] .app-container > .sidebar {
  order: 2;
}

html[dir="rtl"] .app-container > .main-content,
[dir="rtl"] .app-container > .main-content {
  order: 1;
}

html[dir="rtl"] .sidebar,
[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
}

[dir="rtl"] .sidebar-logo,
[dir="rtl"] .nav-item,
[dir="rtl"] .sidebar-user,
[dir="rtl"] .nav-section-label,
[dir="rtl"] .mobile-header {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .mobile-header {
  flex-direction: row-reverse;
}

html[dir="rtl"] .analysis-container,
[dir="rtl"] .analysis-container {
  grid-template-columns: var(--analysis-eval-lane) minmax(280px, 1.8fr) minmax(0, 2.2fr);
  grid-template-areas:
    "eval panel board"
    "import import import";
}

[dir="rtl"] .analysis-panel,
[dir="rtl"] .chess-board-wrapper,
[dir="rtl"] .eval-lane,
[dir="rtl"] .import-card,
[dir="rtl"] .theme-panel {
  direction: rtl;
}

[dir="rtl"] .tabs,
[dir="rtl"] .nav-controls,
[dir="rtl"] .game-controls,
[dir="rtl"] .player-strip__head,
[dir="rtl"] .player-filter-label,
[dir="rtl"] .depth-control-label,
[dir="rtl"] .gr-ai-header {
  direction: rtl;
}

[dir="rtl"] .player-filter-label,
[dir="rtl"] .depth-control-label,
[dir="rtl"] .gr-phase-name,
[dir="rtl"] .gr-cls-label,
[dir="rtl"] .gr-acpl-label,
[dir="rtl"] .gr-col-title {
  justify-content: flex-start;
}

[dir="rtl"] .player-filter-select,
[dir="rtl"] .depth-control-select {
  padding: 6px 11px 6px 30px;
  background-position:
    16px calc(50% - 2px),
    11px calc(50% - 2px);
  text-align: right;
}

[dir="rtl"] .gr-wrap {
  direction: rtl;
}

[dir="rtl"] .gr-head,
[dir="rtl"] .gr-section-hdr,
[dir="rtl"] .gr-phase-hdr,
[dir="rtl"] .gr-cls-row,
[dir="rtl"] .gr-acpl-row,
[dir="rtl"] .gr-totals-row {
  direction: ltr;
}

[dir="rtl"] .gr-head-col {
  text-align: right;
}

[dir="rtl"] .gr-head-col:first-child {
  grid-column: 2;
}

[dir="rtl"] .gr-head-col:last-child {
  grid-column: 1;
}

[dir="rtl"] .gr-head-col + .gr-head-col {
  border-left: none;
  border-right: 1px solid var(--border, #27272a);
}

[dir="rtl"] .gr-game-rating,
[dir="rtl"] .gr-pattern-item,
[dir="rtl"] .gr-train-item,
[dir="rtl"] .gr-ai-body {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .gr-ai-badge {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .gr-section-hdr,
[dir="rtl"] .gr-phase-hdr,
[dir="rtl"] .gr-cls-row,
[dir="rtl"] .gr-acpl-row,
[dir="rtl"] .gr-totals-row {
  grid-template-columns: 64px 64px minmax(0, 1fr);
  column-gap: 8px;
}

[dir="rtl"] .gr-wrap.gr-player-white .gr-section-hdr,
[dir="rtl"] .gr-wrap.gr-player-black .gr-section-hdr,
[dir="rtl"] .gr-wrap.gr-player-white .gr-phase-hdr,
[dir="rtl"] .gr-wrap.gr-player-black .gr-phase-hdr,
[dir="rtl"] .gr-wrap.gr-player-white .gr-cls-row,
[dir="rtl"] .gr-wrap.gr-player-black .gr-cls-row,
[dir="rtl"] .gr-wrap.gr-player-white .gr-acpl-row,
[dir="rtl"] .gr-wrap.gr-player-black .gr-acpl-row,
[dir="rtl"] .gr-wrap.gr-player-white .gr-totals-row,
[dir="rtl"] .gr-wrap.gr-player-black .gr-totals-row {
  grid-template-columns: 72px minmax(0, 1fr);
  column-gap: 8px;
}

[dir="rtl"] .gr-section-hdr > :first-child,
[dir="rtl"] .gr-phase-hdr > :first-child,
[dir="rtl"] .gr-cls-row > :first-child,
[dir="rtl"] .gr-acpl-row > :first-child,
[dir="rtl"] .gr-totals-row > :first-child {
  grid-column: 3;
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .gr-section-hdr > :nth-child(2),
[dir="rtl"] .gr-phase-hdr > :nth-child(2),
[dir="rtl"] .gr-cls-row > :nth-child(2),
[dir="rtl"] .gr-acpl-row > :nth-child(2),
[dir="rtl"] .gr-totals-row > :nth-child(2) {
  grid-column: 2;
}

[dir="rtl"] .gr-section-hdr > :nth-child(3),
[dir="rtl"] .gr-phase-hdr > :nth-child(3),
[dir="rtl"] .gr-cls-row > :nth-child(3),
[dir="rtl"] .gr-acpl-row > :nth-child(3),
[dir="rtl"] .gr-totals-row > :nth-child(3) {
  grid-column: 1;
}

[dir="rtl"] .gr-wrap.gr-player-white .gr-section-hdr > :first-child,
[dir="rtl"] .gr-wrap.gr-player-black .gr-section-hdr > :first-child,
[dir="rtl"] .gr-wrap.gr-player-white .gr-phase-hdr > :first-child,
[dir="rtl"] .gr-wrap.gr-player-black .gr-phase-hdr > :first-child,
[dir="rtl"] .gr-wrap.gr-player-white .gr-cls-row > :first-child,
[dir="rtl"] .gr-wrap.gr-player-black .gr-cls-row > :first-child,
[dir="rtl"] .gr-wrap.gr-player-white .gr-acpl-row > :first-child,
[dir="rtl"] .gr-wrap.gr-player-black .gr-acpl-row > :first-child,
[dir="rtl"] .gr-wrap.gr-player-white .gr-totals-row > :first-child,
[dir="rtl"] .gr-wrap.gr-player-black .gr-totals-row > :first-child {
  grid-column: 2;
}

[dir="rtl"] .gr-wrap.gr-player-white .gr-section-hdr > :nth-child(2),
[dir="rtl"] .gr-wrap.gr-player-black .gr-section-hdr > :nth-child(2),
[dir="rtl"] .gr-wrap.gr-player-white .gr-phase-hdr > :nth-child(2),
[dir="rtl"] .gr-wrap.gr-player-black .gr-phase-hdr > :nth-child(2),
[dir="rtl"] .gr-wrap.gr-player-white .gr-cls-row > :nth-child(2),
[dir="rtl"] .gr-wrap.gr-player-black .gr-cls-row > :nth-child(2),
[dir="rtl"] .gr-wrap.gr-player-white .gr-acpl-row > :nth-child(2),
[dir="rtl"] .gr-wrap.gr-player-black .gr-acpl-row > :nth-child(2),
[dir="rtl"] .gr-wrap.gr-player-white .gr-totals-row > :nth-child(2),
[dir="rtl"] .gr-wrap.gr-player-black .gr-totals-row > :nth-child(2) {
  grid-column: 1;
}

[dir="rtl"] .gr-cls-row-clickable:hover {
  transform: translateX(-2px);
}

html[dir="rtl"] #chessboard-container,
html[dir="rtl"] #chessboard,
[dir="rtl"] #chessboard-container,
[dir="rtl"] #chessboard {
  direction: ltr !important;
  unicode-bidi: isolate !important;
}

html[dir="rtl"] .analysis-panel .gr-cls-label,
html[dir="rtl"] .analysis-panel .gr-acpl-label,
html[dir="rtl"] .analysis-panel .gr-phase-name,
[dir="rtl"] .analysis-panel .gr-cls-label,
[dir="rtl"] .analysis-panel .gr-acpl-label,
[dir="rtl"] .analysis-panel .gr-phase-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  [dir="rtl"] .sidebar.mobile-open {
    left: auto;
    right: 0;
    animation: slideInRight .25s ease;
  }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* ── Premium SaaS Dark Mode polish (layout-safe + RTL-safe) ── */
:root {
  --bg: #121212;
  --bg2: #171717;
  --bg3: #1e1e1e;
  --bg4: #252525;
  --bg5: #2d2d2d;
  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.12);
  --text: #e0e0e0;
  --text2: #9e9e9e;
  --text3: #7f7f7f;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
}

body {
  background: var(--bg);
  color: var(--text);
  animation: premiumFadeIn .45s ease both;
  text-rendering: optimizeLegibility;
}

/* Smooth premium transitions for interactive elements */
a,
button,
.btn,
[role="button"],
.sidebar,
.analysis-panel,
.chess-board-wrapper,
.import-card,
.theme-panel,
.analysis-item,
.move,
.gr-cls-row,
.move-explain-card {
  transition: all 0.3s ease-out;
}

/* Modern elevated card treatment for key containers */
.sidebar,
.analysis-panel,
.chess-board-wrapper,
.import-card,
.theme-panel {
  background: var(--bg3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.analysis-panel,
.chess-board-wrapper,
.import-card,
.theme-panel {
  padding: 22px;
}

.main-content {
  padding: 34px 36px;
}

/* Keep sidebar structure while softening visuals */
.sidebar {
  background: #161616;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

html[dir="rtl"] .sidebar,
[dir="rtl"] .sidebar {
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

/* Premium hover lift */
.btn:hover,
.sidebar:hover,
.analysis-panel:hover,
.chess-board-wrapper:hover,
.import-card:hover,
.theme-panel:hover,
.analysis-item:hover,
.move-explain-card:hover,
.gr-cls-row-clickable:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(232, 184, 75, 0.25);
}

.btn:hover {
  filter: brightness(1.08);
  box-shadow: 0 8px 20px rgba(232, 184, 75, 0.24);
}

a:hover {
  color: #f2d17d;
}

.btn,
.tab-btn,
.import-tab {
  border-radius: 12px;
}

.analysis-results,
#move-list,
.gr-wrap,
.move-explain-card {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(160deg, rgba(30, 30, 30, 0.94), rgba(22, 22, 22, 0.9));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.move-row {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 4px 6px;
}

.move-row:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.move {
  border-radius: 10px;
  font-weight: 600;
}

.move.move-blunder,
.move.move-mistake,
.move.move-brilliant {
  position: relative;
}

.move.move-blunder::after,
.move.move-mistake::after {
  content: "";
  position: absolute;
  top: 5px;
  inset-inline-end: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f68826;
  box-shadow: 0 0 10px rgba(246, 136, 38, 0.9);
}

.move.move-blunder::after {
  background: #fa412d;
  box-shadow: 0 0 12px rgba(250, 65, 45, 0.95);
}

.move.move-brilliant {
  box-shadow: inset 0 0 0 1px rgba(27, 172, 166, 0.4), 0 0 12px rgba(27, 172, 166, 0.25);
}

.move-explain-card--blunder {
  border-color: rgba(250, 65, 45, 0.35);
  box-shadow: 0 12px 30px rgba(250, 65, 45, 0.12), 0 10px 28px rgba(0, 0, 0, 0.45);
}

.move-explain-card--mistake {
  border-color: rgba(246, 136, 38, 0.35);
  box-shadow: 0 12px 30px rgba(246, 136, 38, 0.1), 0 10px 28px rgba(0, 0, 0, 0.45);
}

.move-explain-card--brilliant {
  border-color: rgba(27, 172, 166, 0.35);
  box-shadow: 0 12px 30px rgba(27, 172, 166, 0.1), 0 10px 28px rgba(0, 0, 0, 0.45);
}

.move-explain-theme-tag {
  margin-inline-start: auto;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text2);
}

/* Arabic typography + technical-number typography */
html[lang="ar"] body,
[dir="rtl"] body {
  font-family: var(--font-ar);
}

#chessboard .notation-322f9,
#chessboard .alpha-d2270,
#chessboard .numeric-fc462,
.move-num,
.evaluation,
.player-strip__acc-val,
#accuracy-white,
#accuracy-black,
.gr-acc-big {
  font-family: var(--font-tech);
  letter-spacing: 0.01em;
}

/* Keep board notation/coordinates LTR in all languages */
html[dir="rtl"] #chessboard .notation-322f9,
[dir="rtl"] #chessboard .notation-322f9,
html[dir="rtl"] #chessboard .alpha-d2270,
[dir="rtl"] #chessboard .alpha-d2270,
html[dir="rtl"] #chessboard .numeric-fc462,
[dir="rtl"] #chessboard .numeric-fc462 {
  direction: ltr !important;
  unicode-bidi: isolate !important;
}

/* Strict RTL analysis order: board right, panel left */
html[dir="rtl"] .analysis-container,
[dir="rtl"] .analysis-container {
  grid-template-columns: var(--analysis-eval-lane) minmax(280px, 1.8fr) minmax(0, 2.2fr) !important;
  grid-template-areas:
    "eval panel board"
    "import import import" !important;
}

/* Dedicated premium stat card for per-side accuracy */
.gr-acc-chip {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11px;
  color: var(--text2);
}

.gr-acc-chip__value {
  font-family: var(--font-tech);
  color: var(--text);
}

/* Stronger micro interactions for analysis diagnostics */
.gr-cls-row[data-cls="blunder"],
.gr-cls-row[data-cls="mistake"],
.gr-cls-row[data-cls="brilliant"] {
  border-inline-start: 2px solid transparent;
}

.gr-cls-row[data-cls="blunder"]:hover { border-inline-start-color: #fa412d; }
.gr-cls-row[data-cls="mistake"]:hover { border-inline-start-color: #f68826; }
.gr-cls-row[data-cls="brilliant"]:hover { border-inline-start-color: #1baca6; }

/* Board move trail effects (driven by analysis.js) */
#chessboard .square-55d63.move-trail-source,
#chessboard .square-55d63.move-trail-target {
  animation: moveTrailPulse .45s ease-out both;
}

#chessboard .square-55d63.move-trail-target {
  box-shadow: inset 0 0 0 2px rgba(232, 184, 75, 0.65), 0 0 22px rgba(232, 184, 75, 0.28) !important;
}

#chessboard .square-55d63.move-trail-source {
  box-shadow: inset 0 0 0 2px rgba(91, 156, 246, 0.5) !important;
}

@keyframes moveTrailPulse {
  0% { transform: scale(0.98); filter: brightness(0.88); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes premiumFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
