/* ═══════════════════════════════════════════════════════════════════════════
   Capivarada Design System
   ─────────────────────────────────────────────────────────────────────────
   Tokens
     --color-bg         #1C1C1C  Page background
     --color-surface    #252525  Card / panel surface
     --color-surface-2  #2E2E2E  Input bg, hover fills
     --color-border     #3A3A3A  Borders, dividers
     --color-text       #DBDBDB  Primary text
     --color-text-muted #888888  Secondary / meta text
     --color-accent     #FF4141  CTA, blunders, highlights
   ═══════════════════════════════════════════════════════════════════════════ */

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

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --color-bg:           #0E0E0E;
  --color-surface:      #161616;
  --color-surface-2:    #1F1F1F;
  --color-border:       #2A2A2A;
  --color-text:         #DBDBDB;
  --color-text-muted:   #888888;
  --color-accent:       #FF4141;
  --color-accent-hover: #E03232;

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-full: 9999px;

  --shadow-card: 0 2px 8px rgba(0,0,0,.45);

  --font-base:      'Roboto Mono', 'Courier New', monospace;
  --font-size-xs:   .72rem;
  --font-size-sm:   .82rem;
  --font-size-base: .94rem;
  --font-size-lg:   1.05rem;

  --transition: 150ms ease;

  /* Layout */
  --sidenav-width:   240px;
  --bottomnav-h:     60px;
  --topbar-h:        52px;
  --bp-mobile:       768px;   /* below this → mobile layout */
}

/* ── Base ────────────────────────────────────────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  /* Disable the native pull-to-refresh / top-of-page bounce on mobile */
  overscroll-behavior: none;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overscroll-behavior: none;
}

/*
 * Chess-grid background texture.
 * Two diagonal lines form an X pattern (like a chessboard rotated 45°).
 * The mask fades it out from top (~60vh) to nothing, keeping the rest
 * of the page clean. A subtle accent glow sits at the very top.
 *
 * Layers (bottom → top):
 *  1. solid bg color
 *  2. diagonal cross grid
 *  3. radial accent glow (top-center, red-tinted)
 *  4. fade-to-bg gradient (masks the grid so it disappears smoothly)
 */
body::before {
  content: '';
  position: fixed;         /* fixed so it doesn't scroll with content */
  inset: 0;
  z-index: 0;
  pointer-events: none;

  /* Diagonal cross grid — same colour as border so it's very subtle */
  background-image:
    linear-gradient( 45deg, transparent 49%, var(--color-border) 49%, var(--color-border) 51%, transparent 51%),
    linear-gradient(-45deg, transparent 49%, var(--color-border) 49%, var(--color-border) 51%, transparent 51%);
  background-size: 32px 32px;

  /* Fade the grid: fully visible at top, gone by ~65vh */
  -webkit-mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 30%, transparent 100%);
          mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 30%, transparent 100%);

  opacity: 0.35;
}

/* Accent glow — separate pseudo so it sits on top of the grid mask */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;

  background: radial-gradient(
    ellipse 70% 40% at 50% 0%,
    rgba(255, 65, 65, 0.07) 0%,
    transparent 70%
  );
}

/* Everything inside app-shell must sit above the pseudo layers */
#app-shell {
  position: relative;
  z-index: 1;
}

a    { color: inherit; text-decoration: none; }
img  { display: block; max-width: 100%; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar             { width: 6px; }
::-webkit-scrollbar-track       { background: var(--color-bg); }
::-webkit-scrollbar-thumb       { background: var(--color-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ══════════════════════════════════════════════════════════════════════════
   APP SHELL
   ══════════════════════════════════════════════════════════════════════════ */

#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Desktop sidebar ─────────────────────────────────────────────────────── */
.sidenav {
  width: var(--sidenav-width);
  flex-shrink: 0;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 0 0 20px;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

.sidenav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidenav__logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

.sidenav__wordmark {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidenav__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  flex: 1;
}

.sidenav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: color var(--transition), background var(--transition);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.sidenav__link:hover,
.sidenav__link--active {
  color: var(--color-text);
  background: var(--color-surface-2);
}

.sidenav__link--active { color: var(--color-accent); }

.sidenav__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Profile block at bottom of sidebar */
.sidenav__profile {
  padding: 12px 12px 0;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidenav__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.sidenav__user:hover { background: var(--color-surface-2); }

.sidenav__user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  overflow: hidden;   /* clip children to circle */
}

.sidenav__user-info { min-width: 0; }

.sidenav__user-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidenav__user-sub {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ── Shell body (right of sidebar on desktop, full width on mobile) ──────── */
.shell-body {
  flex: 1;
  margin-left: var(--sidenav-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Mobile top bar (hidden on desktop) ──────────────────────────────────── */
.topbar {
  display: none; /* shown via media query */
  height: var(--topbar-h);
  background: rgba(14,14,14,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.topbar__wordmark {
  font-size: var(--font-size-base);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.topbar__auth {
  display: flex;
  align-items: center;
  gap: 8px;
  /* always empty on mobile — hidden so it takes no space */
  display: none;
}

/* Rounded avatar in topbar */
.topbar__avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1px solid var(--color-border);
  overflow: hidden;
  display: block;
  flex-shrink: 0;
}

/* ── Page content area ───────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ── Mobile bottom tab bar ───────────────────────────────────────────────── */
.bottomnav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  grid-template-columns: repeat(6, 1fr);
  align-items: stretch;
}

.bottomnav__tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: var(--color-text-muted);
  transition: color var(--transition);
  padding-top: 4px;
  overflow: visible;
}

/* Hide text labels — icons only */
.bottomnav__tab span:not(.bottomnav__avatar-wrap) {
  display: none;
}

.bottomnav__tab svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* Rounded avatar inside profile tab */
.bottomnav__tab img {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1.5px solid var(--color-border);
  flex-shrink: 0;
  display: block;
}

.bottomnav__tab:hover,
.bottomnav__tab--active { color: var(--color-text); }
.bottomnav__tab--active  { color: var(--color-accent); }

@media (max-width: 768px) {
  .sidenav    { display: none; }
  .shell-body { margin-left: 0; }
  .topbar     { display: flex; }

  .bottomnav  { display: grid; }

  .page-content {
    padding: 16px 12px;
    padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 16px);
    overflow: hidden; /* prevent double scroll — inner containers handle their own overflow */
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   COMPONENTS
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: none;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}

.btn:active { transform: scale(.97); }

.btn--primary                    { background: var(--color-accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--color-accent-hover); }

.btn--ghost {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-accent);
}
.btn--ghost:hover:not(:disabled) { background: var(--color-surface-2); }

.btn--full { width: 100%; }
.btn--sm   { padding: 5px 12px; font-size: var(--font-size-xs); }

.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card__title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 14px;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.badge--blunder {
  background: rgba(255,65,65,.15);
  color: var(--color-accent);
  border: 1px solid rgba(255,65,65,.4);
}

.badge--platform {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* ── Feed page ───────────────────────────────────────────────────────────── */

.feed-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
}

@media (max-width: 768px) {
  .feed-page { height: calc(100vh - 52px); }
}

.feed-columns {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

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

  /* ── Mobile aside drawer ── */
  /* The aside slides in from the right as an overlay */
  .feed-aside {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(300px, 85vw);
    z-index: 200;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    box-shadow: -4px 0 24px rgba(0,0,0,.5);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    /* drawer is always present in DOM, just off-screen */
  }

  .feed-aside.feed-aside--open {
    transform: translateX(0);
  }

  /* Scrim behind drawer */
  .feed-aside-scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0,0,0,.45);
  }

  .feed-aside-scrim--visible {
    display: block;
  }
}

.feed-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.feed-main__composer {
  flex-shrink: 0;
  padding-bottom: 12px;
}

.feed-main__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 4px 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.feed-main__body::-webkit-scrollbar { width: 4px; }
.feed-main__body::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }

#feed-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Feed aside — sticky within its grid cell */
.feed-aside {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  scrollbar-width: none;
}
.feed-aside::-webkit-scrollbar { display: none; }

/* ── Composer ────────────────────────────────────────────────────────────── */
.composer__input {
  width: 100%;
  background: var(--color-surface-2);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
  padding: 10px 12px;
  resize: none;
  outline: none;
  margin-bottom: 8px;
  transition: background var(--transition), color var(--transition);
  /* Fixed height + scroll for textarea */
  min-height: 80px;
  overflow-y: auto;
}

.composer__input:focus {
  background: #222;
  color: var(--color-text);
}
.composer__input::placeholder { color: rgba(136,136,136,.5); }

/* base text also slightly muted until focused */
.composer__input { color: var(--color-text-muted); }
.composer__input:focus { color: var(--color-text); }

.composer__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px; /* default */
}

@media (max-width: 768px) {
  .composer__row {
    margin-top: 16px; /* more breathing room on mobile */
  }
}

/* ── Composer tabs ───────────────────────────────────────────────────────── */
.composer__tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
}

.composer__tab {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-family: var(--font-base);
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.composer__tab:hover { background: var(--color-surface-2); color: var(--color-text); }
.composer__tab--active { background: var(--color-surface-2); color: var(--color-accent); }

.composer__panel { margin-bottom: 10px; }

.composer__hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex: 1;
}

.composer-analyzed-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
  flex: 1;
}

/* ── Composer collapsible title/description ──────────────────────────────── */
.composer__details {
  margin-bottom: 10px;
}

.composer__details-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 0;
  cursor: pointer;
  list-style: none;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--color-border);
  transition: color var(--transition);
  user-select: none;
}

.composer__details-toggle::-webkit-details-marker { display: none; }
.composer__details-toggle::marker { display: none; }

.composer__details-toggle:hover { color: var(--color-text); }

.composer__details-chevron {
  display: flex;
  align-items: center;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.composer__details[open] .composer__details-chevron {
  transform: rotate(180deg);
}

.composer__details-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease;
  overflow: hidden;
}

.composer__details[open] .composer__details-body {
  grid-template-rows: 1fr;
}

/* Inner wrapper needed for grid-template-rows animation trick */
.composer__details-body > * {
  overflow: hidden;
  padding-top: 8px;
}

/* ── Composer trigger button ─────────────────────────────────────────────── */
.composer-trigger {
  width: 100%;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  border: 1px dashed var(--color-border);
  color: var(--color-text-muted);
  transition: border-color var(--transition), color var(--transition);
}

.composer-trigger:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

/* ── Composer header (tabs + close) ─────────────────────────────────────── */
.composer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
}

.composer__header .composer__tabs {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.composer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.composer__close:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}

/* ── Feed mobile bar — replaced by swipe gesture ───────────────────────── */
.feed-mobile-bar { display: none; }

/* ── Feed swipe hint (mobile only, fades out) ───────────────────────────── */
.feed-swipe-hint {
  display: none;
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: right;
  padding: 2px 0 6px;
  opacity: 0.5;
}

@media (max-width: 900px) {
  .feed-swipe-hint { display: block; }
}

/* ── Feed aside header (mobile close button) ────────────────────────────── */
.feed-aside__header {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.feed-aside__title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text);
}

.feed-aside__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.feed-aside__close:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}

@media (max-width: 900px) {
  .feed-aside__header { display: flex; }
}

/* ── Composer game preview (board + scrubber timeline) ───────────────────── */
.composer-preview {
  display: grid;
  grid-template-columns: 1fr;  /* always stacked: board top, graph below */
  gap: 10px;
  margin-top: 10px;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 10px;
  align-items: start;
}

.composer-preview__board-col {
  display: flex;
  flex-direction: row;  /* board left, range label right on same row */
  align-items: center;
  gap: 12px;
}

.composer-preview__board {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  position: relative;
  flex-shrink: 0;
}

.composer-preview__board.cg-wrap {
  width: 140px !important;
  height: 140px !important;
}

@media (max-width: 520px) {
  .composer-preview__board,
  .composer-preview__board.cg-wrap {
    width: 100px !important;
    height: 100px !important;
  }
}

.composer-preview__scrubber-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.composer-preview__range-label {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  font-weight: 600;
  min-height: 1.2em;
  flex: 1;  /* fills remaining space next to the board */
}

/* ── SVG scrubber — eval graph with draggable cursors ───────────────────── */
.composer-scrubber {
  user-select: none;
  touch-action: none;  /* prevent page scroll when touching the graph */
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface);
  height: 80px;
  flex-shrink: 0;
}

.composer-graph-svg {
  width: 100%;
  height: 80px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.composer-graph-handle {
  cursor: ew-resize;
}

.composer-graph-nodata {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* post-card game header row */
.post-card__game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

/* ── Form input (select/text in composer) ───────────────────────────────── */
.form-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
  padding: 10px 2px;
  outline: none;
  transition: border-color var(--transition);
}

.form-input:focus { border-bottom-color: var(--color-accent); }

/* ── Post card ───────────────────────────────────────────────────────────── */
.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition);
}

.post-card:hover { border-color: var(--color-text-muted); }

/* Two-column grid: left = text/actions, right = board */
.post-card__body-grid {
  display: block;
}

.post-card__body-grid--has-board {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 14px;
  align-items: start;
}

@media (max-width: 600px) {
  .post-card__body-grid--has-board {
    grid-template-columns: 1fr 140px;
    gap: 10px;
  }
}

@media (max-width: 400px) {
  .post-card__body-grid--has-board {
    grid-template-columns: 1fr 110px;
    gap: 8px;
  }
}

.post-card__left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.post-card__right {
  flex-shrink: 0;
}

.post-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.post-card__avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  overflow: hidden;
}

.post-card__meta         { flex: 1; min-width: 0; }
.post-card__author       { font-size: var(--font-size-sm); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-card__time         { font-size: var(--font-size-xs); color: var(--color-text-muted); }
.post-card__title        { font-size: var(--font-size-lg); font-weight: 700; margin-bottom: 6px; }
.post-card__body         { font-size: var(--font-size-sm); color: var(--color-text-muted); margin-bottom: 14px; }
.post-card__blunders     { margin-left: auto; }

.post-card__board {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
  cursor: pointer;
  background: var(--color-surface-2);
}

.post-card__board canvas { width: 100%; height: 100%; display: block; }

.post-card__board-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.3);
  opacity: 0;
  transition: opacity var(--transition);
}

.post-card__board:hover .post-card__board-overlay { opacity: 1; }

.post-card__board-overlay span {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,.6);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.post-card__actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

.post-card__action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition);
}

.post-card__action-btn:hover              { color: var(--color-text); }
.post-card__action-btn--liked             { color: var(--color-accent); }
.post-card__action-btn--liked:hover       { color: var(--color-accent); }

/* ── Post card game meta ─────────────────────────────────────────────────── */
.post-card__game-meta {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.post-card__game-opening {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-card__analysis-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 4px;
}

.post-card__accuracy-player {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Small color dots (white/black pieces indicator) */
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.dot--white { background: #f0f0f0; border: 1px solid rgba(255,255,255,.3); }
.dot--black { background: #2a2a2a; border: 1px solid rgba(255,255,255,.2); }

/* ── Skeleton loaders ────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-border) 50%, var(--color-surface-2) 75%);
  background-size: 1200px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}

.skeleton--avatar      { width: 40px; height: 40px; border-radius: var(--radius-full); flex-shrink: 0; }
.skeleton--lines       { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.skeleton--line        { height: 14px; }
.skeleton--line-long   { width: 70%; }
.skeleton--line-short  { width: 40%; }
.skeleton--board       { height: 220px; width: 100%; margin-top: 6px; }
.post-card--skeleton   { display: flex; gap: 12px; pointer-events: none; }

/* ── Blunder list ────────────────────────────────────────────────────────── */
.blunder-list { display: flex; flex-direction: column; gap: 10px; }

.blunder-list__item {
  font-size: var(--font-size-sm);
  padding: 10px 12px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-accent);
}

.blunder-list__item--empty { border-left-color: var(--color-border); color: var(--color-text-muted); }

/* ── Link accounts ───────────────────────────────────────────────────────── */
.link-accounts { display: flex; flex-direction: column; gap: 8px; }

/* ══════════════════════════════════════════════════════════════════════════
   CHESS BOARD MODAL
   ══════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 540px;
  width: 100%;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
}

.modal__close {
  position: absolute;
  top: 14px; right: 14px;
  background: transparent;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-size-base);
  transition: color var(--transition), border-color var(--transition);
}

.modal__close:hover { color: var(--color-text); border-color: var(--color-text-muted); }

.board-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;  /* space below board */
  margin-bottom: 10px;
}

/* Prev/next in game modal — solid accent */
.board-controls .btn {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  flex-shrink: 0; /* buttons never change size */
}
.board-controls .btn:hover:not(:disabled) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* Fixed width on label so buttons don't shift when text changes */
.board-controls__move {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  width: 90px;
  text-align: center;
  flex-shrink: 0;
  /* Single line always — never wrap or expand */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 1.4em;
  line-height: 1.4em;
}

.blunder-commentary {
  background: rgba(255,65,65,.08);
  border: 1px solid rgba(255,65,65,.25);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.blunder-commentary[hidden] { display: none; }
.blunder-commentary p { font-size: var(--font-size-sm); color: var(--color-text); line-height: 1.7; }

/* ── JS-generated HTML helpers ───────────────────────────────────────────── */
/* These classes are applied by app.js innerHTML — no inline styles allowed   */

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.logout-form {
  margin: 0;
}

.feed-empty {
  text-align: center;
  padding: 40px 20px;
}

.feed-empty__msg {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.7;
}

/* Post card title and ply badge */
.post-card__title {
  font-size: var(--font-size-base);
  font-weight: 700;
  margin-bottom: 4px;
}

.post-card__ply-badge {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,.07);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

/* Post comments */
.post-card__comments {
  border-top: 1px solid var(--color-border);
  padding-top: 10px;
  margin-top: 6px;
}

.post-card__comments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.post-comment {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.post-comment__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.post-comment__body {
  flex: 1;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.post-comment__author {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text);
  display: block;
  margin-bottom: 2px;
}

.post-comment__text {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.post-card__comment-form {
  display: flex;
  gap: 8px;
}

.post-card__comment-form .form-input {
  flex: 1;
  padding: 6px 10px;
  font-size: var(--font-size-xs);
}

/* Composer game select — matches input style */
.composer__select {
  width: 100%;
  background: var(--color-surface-2);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
  padding: 10px 12px;
  outline: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 8px;
  -webkit-appearance: none;
  appearance: none;
}

.composer__select:focus { background: #222; color: var(--color-text); }
.composer__select option { background: var(--color-surface); color: var(--color-text); }
.composer-game-board {
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

/* Composer ply range */
.composer__ply-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.composer__ply-range {
  flex: 1;
  accent-color: var(--color-accent);
}

.composer__ply-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

/* Feed highlights sidebar */
.feed-highlight-post {
  padding: 10px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.feed-highlight-post__author {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 2px;
}

.feed-highlight-post__title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.feed-highlight-post__game {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.feed-highlight-post__meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  font-weight: 700;
}
  line-height: 1.7;
}

/* Community stat row in feed aside */
.community-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid var(--color-border);
}
.community-stat:last-child { border-bottom: none; }
.community-stat__val { font-size: 1.2rem; font-weight: 700; color: var(--color-text); }
.community-stat__lbl { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* Top active users in feed aside */
.feed-top-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text);
  transition: background var(--transition);
}
.feed-top-user:hover { background: var(--color-surface-2); }
.feed-top-user__medal { font-size: .9rem; flex-shrink: 0; }
.feed-top-user__avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--color-border); }
.feed-top-user__name { flex: 1; font-size: var(--font-size-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-top-user__count { font-size: var(--font-size-xs); color: var(--color-text-muted); flex-shrink: 0; }

/* card title row (title + link side by side) */
.card__title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0; }
  line-height: 1.7;
}
/* ── Chessground board layout ────────────────────────────────────────────── */

/* Modal full board */
.board-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
  /* Chessground needs explicit size on its container */
  width: 100%;
  aspect-ratio: 1;
  position: relative;
}

.board-wrap .cg-wrap {
  width: 100%;
  height: 100%;
  display: block;
}

/* Game card thumbnail board */
.game-card__board {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.game-card__cg {
  width: 100%;
  height: 100%;
  display: block;
}

.game-card__cg .cg-wrap {
  width: 100%;
  height: 100%;
}

/* Post card board */
.post-card__board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,.45);
}

@media (max-width: 480px) {
  .post-card__board-wrap {
    width: 120px;
    height: 120px;
  }
}

.post-card__cg-board {
  width: 100%;
  height: 100%;
  display: block;
}

.post-card__cg-board .cg-wrap,
.post-card__cg-board.cg-wrap {
  width: 100% !important;
  height: 100% !important;
  border-radius: var(--radius-sm);
}
}

.post-card__board-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.3);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.post-card__board-wrap:hover .post-card__board-overlay { opacity: 1; }

.post-card__board-overlay span {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,.6);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

/* Bottomnav avatar (from JS injection) */
.bottomnav__avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1.5px solid var(--color-border);
  display: block;
  flex-shrink: 0;
}

/* ── Import bar ──────────────────────────────────────────────────────────── */
.import-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.import-bar[hidden] { display: none; }

.import-bar__label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}

.import-bar__status {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-left: auto;
}

.import-bar__status--loading { color: var(--color-text); }
.import-bar__status--done    { color: #4ade80; }
.import-bar__status--error   { color: var(--color-accent); }

/* ── Game card ───────────────────────────────────────────────────────────── */
.game-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  transition: border-color var(--transition);
  box-shadow: var(--shadow-card);
}

.game-card:hover { border-color: var(--color-text-muted); }

.game-card__board {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
}

.game-card__board canvas { width: 100%; height: 100%; display: block; }

.game-card__info { min-width: 0; display: flex; flex-direction: column; gap: 6px; }

.game-card__title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}

.game-card__vs {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  flex-shrink: 0;
}

.game-card__meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.game-card__chip {
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
}

.game-card__chip--win  { color: #4ade80; }
.game-card__chip--loss { color: var(--color-accent); }
.game-card__chip--draw { color: var(--color-text-muted); }

.game-card__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

/* ── Games section header ────────────────────────────────────────────────── */
.games-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.games-section__title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
}

.games-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.games-section__empty {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  padding: 8px 0;
}

.footer {
  text-align: center;
  padding: 32px 20px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  margin-top: 40px;
}

/* ══════════════════════════════════════════════════════════════════════════
   MONITOR PAGE
   ══════════════════════════════════════════════════════════════════════════ */

.monitor-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 860px;
}

.monitor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.monitor-header__name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
}

.monitor-header__sub {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card--skeleton {
  height: 72px;
  animation: shimmer 1.5s infinite linear;
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-border) 50%, var(--color-surface-2) 75%);
  background-size: 1200px 100%;
}

.stat-card__label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  font-weight: 700;
}

.stat-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.stat-card__value--win  { color: #4ade80; }
.stat-card__value--loss { color: var(--color-accent); }

/* W/D/L bar */
.monitor-wdl-card { display: flex; flex-direction: column; gap: 14px; }

.wdl-bar {
  display: flex;
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--color-surface-2);
}

.wdl-bar__seg { height: 100%; transition: width .4s ease; }
.wdl-bar__seg--win  { background: #4ade80; }
.wdl-bar__seg--draw { background: var(--color-text-muted); }
.wdl-bar__seg--loss { background: var(--color-accent); }

/* Monitor section */
.monitor-section { display: flex; flex-direction: column; gap: 12px; }

.monitor-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.monitor-section__title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
}

.monitor-section__link {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  text-decoration: none;
  transition: opacity var(--transition);
}

.monitor-section__link:hover { opacity: .75; }

.monitor__empty {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  padding: 16px 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   PARTIDAS PAGE
   ══════════════════════════════════════════════════════════════════════════ */

.partidas-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  gap: 0;
  min-width: 0;
  overflow: hidden;
}

@media (max-width: 768px) {
  .partidas-page {
    height: calc(100vh - 52px);
    overflow-x: hidden; /* belt-and-suspenders: no horizontal overflow */
  }
}

.partidas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.partidas-header__title { font-size: 1.2rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.partidas-header__sub   { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: 2px; }

.sync-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.sync-bar[hidden] { display: none; }

.sync-bar__status {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Two-column layout: games left, stats right */
.partidas-columns {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  flex: 1;
  min-height: 0;
  min-width: 0; /* prevent columns from blowing out parent width */
}

@media (max-width: 960px) {
  .partidas-columns {
    grid-template-columns: 1fr;
  }
  .partidas-col--stats {
    display: none;
  }
}

.partidas-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0; /* critical — grid children must opt-in to shrinking */
  overflow: hidden; /* clip overflowing content within each column */
}

/* Left: filter bar + scrollable list */
.partidas-col--games {
  gap: 0;
  overflow: visible; /* allow filter bar shadow to show */
}

.partidas-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 4px 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.partidas-body::-webkit-scrollbar { width: 4px; }
.partidas-body::-webkit-scrollbar-track { background: transparent; }
.partidas-body::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }

.partidas-body .games-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Right: stats panel — scrollable with fade edges */
.partidas-col--stats {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
  /* Initial mask — no top fade, bottom fade always shown */
  -webkit-mask-image: linear-gradient(to bottom, #000 0px, #000 calc(100% - 48px), transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0px, #000 calc(100% - 48px), transparent 100%);
}

.partidas-col--stats::-webkit-scrollbar { width: 4px; }
.partidas-col--stats::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }

/* ── Stats panel ──────────────────────────────────────────────────────────── */
.gs-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 0 16px 48px;
}

.gs-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}

.gs-section:last-child {
  border-bottom: none;
}

.gs-section__title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.gs-kpi-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.gs-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 48px;
}

.gs-kpi__val {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text);
}

.gs-kpi__lbl {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* W/D/L bar */
.gs-bar {
  display: flex;
  height: 5px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--color-surface-2);
  margin-top: 10px;
}

.gs-bar__seg { height: 100%; }
.gs-bar__seg--win  { background: #4ade80; }
.gs-bar__seg--draw { background: var(--color-text-muted); }
.gs-bar__seg--loss { background: var(--color-accent); }

/* Color breakdown */
.gs-color-row {
  display: flex;
  gap: 12px;
}

.gs-color-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.gs-color-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
}

.gs-color-pct {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.gs-color-games {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Streak / single-line stats */
.gs-streak {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.gs-streak-current {
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.gs-streak-records {
  display: flex;
  gap: 10px;
}

.gs-streak-record {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.gs-streak-record__val {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.gs-streak-record__lbl {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Terminations */
.gs-term-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.gs-term-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  min-width: 96px;
  flex-shrink: 0;
}

.gs-term-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.gs-term-bar {
  display: block;
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width .4s ease;
}

.gs-term-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  min-width: 24px;
  text-align: right;
}

/* Opponents */
.gs-opp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-xs);
}

.gs-opp-row:last-child { border-bottom: none; }

.gs-opp-name {
  flex: 1;
  color: var(--color-text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-opp-games {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.gs-opp-wdl {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

/* Day of week bars */
.gs-dow-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.gs-dow-day {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  width: 28px;
  flex-shrink: 0;
}

.gs-dow-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.gs-dow-bar {
  display: block;
  height: 100%;
  background: #4ade80;
  border-radius: var(--radius-full);
  transition: width .4s ease;
}

.gs-dow-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  min-width: 20px;
  text-align: right;
}

/* ══════════════════════════════════════════════════════════════════════════
   MONITOR — full layout
   ══════════════════════════════════════════════════════════════════════════ */

.monitor {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1000px;
  width: 100%;
}

/* ── Profile header ──────────────────────────────────────────────────────── */
.monitor-profile {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}

.monitor-profile__avatar-wrap {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
}

.monitor-profile__avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.monitor-profile__info { flex: 1; min-width: 0; }

.monitor-profile__name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}

.monitor-profile__accounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.account-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.account-row:last-child { border-bottom: none; }

.account-row__left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.account-row__platform {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
}

.account-row__username {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-row__username:hover { color: var(--color-accent); }

.account-row__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.account-row__count {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.account-row__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.account-row__badge {
  font-size: var(--font-size-xs);
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--color-bg-alt, rgba(255,255,255,.06));
  color: var(--color-text);
  white-space: nowrap;
}

.account-row__badge--empty {
  color: var(--color-text-muted);
  background: transparent;
}

.monitor-profile__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.monitor-meta-sep { color: var(--color-border); }

.monitor-profile__actions { margin-left: auto; }

/* ── Rating cards ────────────────────────────────────────────────────────── */
.monitor-ratings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 14px;
}

.rating-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition);
  box-shadow: var(--shadow-card);
}

.rating-card__label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-text-muted);
}

.rating-card__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  letter-spacing: -.02em;
}

/* Dual-platform layout (both platforms connected) */
.rating-card__dual { display: flex; flex-direction: column; gap: 6px; }

.rating-card__row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.rating-card__plat {
  font-size: 9px;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: .05em;
  width: 10px;
  flex-shrink: 0;
}

.rating-card__value--sm {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  letter-spacing: -.01em;
}

/* Accounts card total line */
.monitor-accounts-total {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  padding-top: 10px;
  margin-top: 4px;
}

/* Extra-small button variant */
.btn--xs {
  font-size: 11px;
  padding: 3px 10px;
  height: auto;
}

/* ── Two-column grid ─────────────────────────────────────────────────────── */
.monitor-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.monitor-col { display: flex; flex-direction: column; gap: 16px; }

.monitor-card { display: flex; flex-direction: column; gap: 14px; }

.monitor-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.monitor-link {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  text-decoration: none;
  transition: opacity var(--transition);
}
.monitor-link:hover { opacity: .75; }

.monitor-empty {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  padding: 8px 0;
}

/* ── TC table ────────────────────────────────────────────────────────────── */
.tc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.tc-table th {
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  padding: 0 6px 10px;
  border-bottom: 1px solid var(--color-border);
}

.tc-table td {
  padding: 9px 6px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

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

.tc-table__num  { text-align: right; width: 60px; color: var(--color-text-muted); }
.tc-table__bar  { width: 140px; }
.tc-table__pct  { text-align: right; width: 42px; font-size: var(--font-size-xs); color: var(--color-text-muted); }
.tc-table__pct--win  { color: #4ade80; }
.tc-table__pct--loss { color: var(--color-accent); }

/* ── Opening table ───────────────────────────────────────────────────────── */
.opening-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.opening-table th {
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  padding: 0 6px 10px;
  border-bottom: 1px solid var(--color-border);
}

.opening-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

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

.opening-eco {
  font-weight: 700;
  color: var(--color-accent);
  white-space: nowrap;
  width: 40px;
}

.opening-name {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
}

/* ── Activity heatmap ────────────────────────────────────────────────────── */
.heatmap { overflow: hidden; }

.heatmap-cal { width: 100%; }

/* Month labels row — mirrors the weeks grid layout */
.heatmap-month-row {
  padding-left: 26px;  /* DOW col (22px) + gap (4px) */
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  margin-bottom: 3px;
}

.heatmap-month-lbl {
  font-size: 9px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: visible;
  line-height: 1;
}

/* Grid body: DOW labels + weeks */
.heatmap-grid-body {
  display: flex;
  gap: 4px;
  align-items: stretch; /* DOW col stretches to match weeks height */
}

.heatmap-dow-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 22px;
  flex-shrink: 0;
}

.heatmap-dow-lbl {
  flex: 1;
  font-size: 9px;
  color: var(--color-text-muted);
  text-align: right;
  padding-right: 2px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  line-height: 1;
}

/* Weeks: responsive CSS grid, columns fill available width */
.heatmap-weeks {
  flex: 1;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, auto);
  grid-auto-columns: 1fr;
  gap: 3px;
}

/* Each week div is transparent; its 7 cells flow into the parent grid */
.heatmap-week { display: contents; }

.heatmap-cell {
  display: block;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  border-radius: 2px;
  cursor: default;
  transition: opacity .1s;
}

.heatmap-cell--empty { background: transparent; pointer-events: none; }
.heatmap-cell--0 { background: rgba(255,255,255,.05); }
.heatmap-cell--1 { background: hsl(0, 50%, 22%); }
.heatmap-cell--2 { background: hsl(0, 70%, 36%); }
.heatmap-cell--3 { background: hsl(0, 88%, 52%); }
.heatmap-cell--4 { background: hsl(0, 100%, 67%); }

.heatmap-cell:hover { opacity: .75; }

/* JS-driven tooltip — positioned via mousemove */
.hm-tooltip {
  display: none;
  position: fixed;
  z-index: 1000;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 5px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 8px;
}

.heatmap-legend .heatmap-cell {
  width: 12px;
  height: 12px;
  aspect-ratio: unset;
  flex-shrink: 0;
  cursor: default;
}

/* ── Latest games rows ───────────────────────────────────────────────────── */
.latest-game-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
  border-radius: var(--radius-sm);
}

.latest-game-row:last-child { border-bottom: none; }
.latest-game-row:hover { background: var(--color-surface-2); padding-left: 6px; }

.latest-game-row__board {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.latest-game-row__cg {
  width: 100%;
  height: 100%;
}

.latest-game-row__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.latest-game-row__result {
  font-size: var(--font-size-xs);
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.latest-game-row__result--win  { background: rgba(74,222,128,.2); color: #4ade80; }
.latest-game-row__result--loss { background: rgba(255,65,65,.2);  color: var(--color-accent); }
.latest-game-row__result--draw { background: var(--color-surface-2); color: var(--color-text-muted); }

.latest-game-row__info {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.latest-game-row__opponent {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.latest-game-row__meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.latest-game-row__opening {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .monitor-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .monitor-profile { flex-direction: column; align-items: flex-start; }
  .monitor-profile__actions { margin-left: 0; }
}


/* ══════════════════════════════════════════════════════════════════════════
   PERFIL PAGE
   ══════════════════════════════════════════════════════════════════════════ */

.perfil-page {
  max-width: 960px;
  margin: 0 auto;
}

.perfil-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Two-column grid for the main content row */
.perfil-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* Each column stacks its sections vertically */
.perfil-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* On mobile: single column */
@media (max-width: 680px) {
  .perfil-columns {
    grid-template-columns: 1fr;
  }
}

.perfil-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.perfil-section--danger {
  border-color: rgba(255, 65, 65, 0.3);
}

/* ── Sound pack selector ── */
.sound-pack-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sound-pack-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.sound-pack-option:hover {
  border-color: var(--color-text-muted);
}

.sound-pack-option--active {
  border-color: var(--color-accent);
  background: rgba(220, 30, 30, 0.07);
}

.sound-pack-option input[type="radio"] {
  accent-color: var(--color-accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Preview play button — solid accent, square, right-aligned */
.sound-pack-preview-btn {
  margin-left: auto;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent) !important;
  color: #fff !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
  font-size: .9rem;
  line-height: 1;
  transition: background var(--transition), transform var(--transition);
}
.sound-pack-preview-btn:hover:not(:disabled) {
  background: var(--color-accent-hover) !important;
}

.sound-pack-option__label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sound-pack-option__name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.sound-pack-option__desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.section-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

/* ── Avatar Upload ───────────────────────────────────────────────────────── */
.avatar-upload-area {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.avatar-preview {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.text-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ── Global JS-driven tooltip ────────────────────────────────────────────── */
/* Single #g-tooltip div managed by JS — follows mouse/finger */
[data-tooltip] { cursor: help; }

#g-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  max-width: 240px;
  padding: 7px 11px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.55;
  white-space: pre-wrap;
  box-shadow: 0 6px 20px rgba(0,0,0,.55), 0 1px 4px rgba(0,0,0,.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s, visibility 0.12s;
}

#g-tooltip.visible {
  opacity: 1;
  visibility: visible;
}

/* ── Display Name Form ───────────────────────────────────────────────────── */
.perfil-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.form-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
  outline: none;
  transition: border-color var(--transition);
}

.form-input:focus {
  border-color: var(--color-accent);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

/* ── Connected Accounts ──────────────────────────────────────────────────── */
.connected-accounts {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.account-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.account-card__header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.account-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.account-card__icon svg {
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
}

.account-card__info {
  flex: 1;
  min-width: 0;
}

.account-card__title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  margin-bottom: 2px;
}

.account-card__status {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.account-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
  /* When wrapped on mobile, span full width so buttons don't overlap the header */
  min-width: min-content;
}

@media (max-width: 480px) {
  .account-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .account-card__actions {
    width: 100%;
  }
  .account-card__actions .btn {
    flex: 1;
    justify-content: center;
  }
}

/* ── Stats Preview ───────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px 14px;
  text-align: center;
}

.stat-card h3 {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
}

/* ── Danger Zone ─────────────────────────────────────────────────────────── */
.btn--danger {
  background: rgba(255, 65, 65, 0.15);
  color: var(--color-accent);
  border: 1px solid rgba(255, 65, 65, 0.4);
}

.perfil-logout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.perfil-data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}

.perfil-data-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.perfil-logout-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

/* ── Capivara rank bar ───────────────────────────────────────────────────── */
.capi-rank {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: default;
}

.capi-rank__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.capi-rank__badge {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: .01em;
}

.capi-rank__days {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.capi-rank__bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.capi-rank__bar {
  height: 100%;
  background: linear-gradient(to right, var(--color-accent), #ff8c42);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
  min-width: 4px;
}

.capi-rank__next {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.capi-rank__next em {
  font-style: normal;
  color: var(--color-text);
  font-weight: 600;
}

/* Inline in monitor profile — more compact */
.monitor-profile__info .capi-rank {
  background: transparent;
  border: none;
  padding: 6px 0 0;
  gap: 5px;
}

.monitor-profile__info .capi-rank__bar-wrap {
  height: 4px;
}

.btn--danger:hover:not(:disabled) {
  background: rgba(255, 65, 65, 0.25);
  border-color: var(--color-accent);
}

@media (max-width: 640px) {
  .avatar-upload-area {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .form-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .form-group .btn {
    width: 100%;
  }
}

/* ── Toast notification ───────────────────────────────────────────────────── */

#app-toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 5rem);
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--color-surface-2, #1e1e1e);
  color: var(--color-text, #f0f0f0);
  padding: 0.6rem 1.2rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
  border: 1px solid rgba(255,255,255,0.1);
}

#app-toast.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Borderless aesthetic ────────────────────────────────────────────────── */
/* Structural panels rely on background colour + shadow, not borders */
.sidenav              { border-right: none; }
.sidenav__brand       { border-bottom: none; }
.sidenav__profile     { border-top: 1px solid var(--color-accent); }
.sidenav__user-avatar { border: none; }
.topbar               { border-bottom: none; }
.topbar__avatar       { border: none; }
.card,
.post-card,
.game-card,
.rating-card          { border: none; }


/* ── Opening Board Tooltip ───────────────────────────────────────────────── */
.opening-tooltip {
  position: fixed;
  z-index: 300;
  width: 240px;
  height: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  padding: 8px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms ease;
}

.opening-tooltip--visible {
  opacity: 1;
  visibility: visible;
}

.opening-tooltip__board {
  width: 224px;
  height: 224px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.opening-tooltip__board cg-container,
.opening-tooltip__board .cg-wrap {
  width: 224px !important;
  height: 224px !important;
}

.opening-row {
  cursor: default;
  transition: background var(--transition);
}

.opening-row:hover {
  background: var(--color-surface-2);
}

/* Hide tooltip on mobile (no hover) */
@media (max-width: 768px) {
  .opening-tooltip { display: none; }
}


/* ══════════════════════════════════════════════════════════════════════════
   WELCOME / LANDING PAGE
   ══════════════════════════════════════════════════════════════════════════ */

.welcome {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

.wlc-section-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--color-text);
}

.wlc-section-sub {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-align: center;
}

.wlc-btn-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 32px;
  font-size: var(--font-size-base);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(220,50,50,.35);
  transition: box-shadow var(--transition), transform var(--transition);
}
.wlc-btn-main:hover {
  box-shadow: 0 6px 28px rgba(220,50,50,.5);
  transform: translateY(-1px);
}

/* ── Hero ──────────────────────────────────────────────────────────────────── */
.wlc-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  padding: 72px 40px 64px;
  min-height: 80vh;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 768px) {
  .wlc-hero {
    grid-template-columns: 1fr;
    padding: 40px 20px 32px;
    min-height: unset;
    text-align: center;
    gap: 32px;
  }
}

/* Badge — solid, no border, no translucency */
.wlc-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  padding: 5px 14px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: #fff;
  margin-bottom: 20px;
  width: fit-content;
  letter-spacing: .02em;
}
@media (max-width: 768px) { .wlc-hero__badge { margin: 0 auto 20px; } }

.wlc-hero__title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: 16px;
}
.wlc-hero__title--accent { color: var(--color-accent); }

.wlc-hero__sub {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  line-height: 1.7;
  max-width: 440px;
  margin-bottom: 32px;
}
@media (max-width: 768px) { .wlc-hero__sub { margin-left: auto; margin-right: auto; } }

.wlc-hero__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
@media (max-width: 768px) { .wlc-hero__actions { align-items: center; } }

.wlc-hero__hint { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* Decorative board — 3D tilt via JS */
.wlc-hero__board {
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 800px;
}
@media (max-width: 768px) { .wlc-hero__board { display: none; } }

.wlc-board-grid {
  display: grid;
  grid-template-columns: repeat(6, 72px);
  grid-template-rows: repeat(6, 72px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.7), 0 4px 16px rgba(220,50,50,.2);
  transform: rotateX(4deg) rotateY(-6deg) rotate(-2deg);
  transition: transform 0.08s ease-out, box-shadow 0.12s ease;
  will-change: transform;
}

/* Slow ease-back when mouse leaves */
.wlc-board-grid--returning {
  transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.4s ease;
}

.wlc-board-grid:hover {
  box-shadow: 0 32px 80px rgba(0,0,0,.75), 0 6px 24px rgba(220,50,50,.3);
}

.wlc-board-cell--light  { background: #f0d9b5; }
.wlc-board-cell--dark   { background: var(--color-accent); opacity: 0.88; }
.wlc-board-cell--hl     { background: rgba(74,222,128,.6); }
.wlc-board-cell--hl2    { background: rgba(74,222,128,.35); }

/* ── Features ──────────────────────────────────────────────────────────────── */
.wlc-features {
  padding: 72px 40px;
}
.wlc-features__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 960px;
  margin: 36px auto 0;
}
@media (max-width: 900px) { .wlc-features__grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) {
  .wlc-features { padding: 48px 20px; }
  .wlc-features__grid { grid-template-columns: 1fr; }
}

/* Feature card — system card style */
.wlc-feat {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
}
.wlc-feat:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.55);
}

.wlc-feat__icon {
  width: 42px;
  height: 42px;
  background: rgba(220,50,50,.1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  flex-shrink: 0;
}

.wlc-feat__title { font-size: var(--font-size-sm); font-weight: 700; color: var(--color-text); }
.wlc-feat__desc  { font-size: var(--font-size-xs); color: var(--color-text-muted); line-height: 1.65; }

/* ── Rank teaser ───────────────────────────────────────────────────────────── */
.wlc-ranks {
  padding: 64px 40px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 560px) { .wlc-ranks { padding: 48px 20px; } }

.wlc-ranks__card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
@media (max-width: 560px) { .wlc-ranks__card { padding: 28px 18px; } }

.wlc-ranks__sub {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: 28px;
  margin-top: 6px;
}

.wlc-ranks__strip { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.wlc-rank-pill {
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  transition: color var(--transition), background var(--transition);
}
.wlc-rank-pill:hover { background: var(--color-border); color: var(--color-text); }
.wlc-rank-pill--accent { background: rgba(220,50,50,.15); color: var(--color-accent); }
.wlc-rank-pill--gold   { background: rgba(245,158,11,.15); color: #f59e0b; }

/* ── Final CTA ─────────────────────────────────────────────────────────────── */
.wlc-final {
  padding: 80px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
@media (max-width: 560px) { .wlc-final { padding: 56px 20px; } }

.wlc-final__logo {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  object-fit: contain;
  opacity: 0.9;
}

.wlc-final__title {
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  max-width: 480px;
}

/* Legacy */
.btn--lg { padding: 14px 32px; font-size: var(--font-size-base); border-radius: var(--radius-md); }
.welcome__btn { box-shadow: 0 4px 16px rgba(255,65,65,.3); }
.welcome__hint { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* ── Welcome footer ─────────────────────────────────────────────────────────── */
.wlc-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 24px 20px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.wlc-footer__sep { opacity: 0.4; }

.wlc-footer__link {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.wlc-footer__link:hover { color: var(--color-text); }

/* ── Legal pages ─────────────────────────────────────────────────────────────── */
.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.legal-back {
  display: inline-block;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-decoration: none;
  margin-bottom: 32px;
  transition: color var(--transition);
}

.legal-back:hover { color: var(--color-text); }

.legal-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
  color: var(--color-text);
}

.legal-date {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: 40px;
}

.legal-section {
  margin-bottom: 32px;
}

.legal-section h2 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.legal-section h3 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text);
  margin: 16px 0 8px;
}

.legal-section p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: 1.75;
  margin-bottom: 10px;
}

.legal-section ul {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legal-section ul li {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: 1.65;
  padding-left: 16px;
  position: relative;
}

.legal-section ul li::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: var(--color-accent);
}



/* ── Partidas Filters & Sync ─────────────────────────────────────────────── */
.sync-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.sync-bar[hidden] { display: none; }

.sync-bar__status {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.filters-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--color-accent);
  /* border-radius and box-shadow live on .filters-bar-outer so they aren't
     clipped by overflow:hidden — the outer owns the visual pill shape */
  border-radius: 0;
  box-shadow: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  flex-wrap: wrap;
  margin-bottom: 0; /* moved to outer */
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  width: 100%;
}

.filters-bar::-webkit-scrollbar { display: none; }

@media (max-width: 768px) {
  .filters-bar {
    flex-wrap: nowrap;
  }
}

/* ── Filter bar outer wrapper — owns the pill shape, shadow, and fades ──── */
.filters-bar-outer {
  position: relative;
  display: block;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.55), 0 2px 8px rgba(255,65,65,.18);
  margin-bottom: 12px; /* was on .filters-bar */
}

.filters-bar-outer::before,
.filters-bar-outer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 72px;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.18s;
}

.filters-bar-outer::before {
  left: 0;
  background: linear-gradient(to right,
    var(--color-accent) 0%,
    var(--color-accent) 25%,
    transparent 100%);
  opacity: 0;
}

.filters-bar-outer::after {
  right: 0;
  background: linear-gradient(to left,
    var(--color-accent) 0%,
    var(--color-accent) 25%,
    transparent 100%);
  opacity: 1;
}

.filters-bar-outer--has-left::before  { opacity: 1; }
.filters-bar-outer--at-end::after     { opacity: 0; }

/* --analyzed variant */
.filters-bar-outer:has(.filters-bar--analyzed)::before {
  background: linear-gradient(to right, var(--color-surface-2) 0%, var(--color-surface-2) 15%, transparent 100%);
}
.filters-bar-outer:has(.filters-bar--analyzed)::after {
  background: linear-gradient(to left, var(--color-surface-2) 0%, var(--color-surface-2) 15%, transparent 100%);
}

/* Scroll arrow */
.filters-bar-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,.95);
  pointer-events: none;
  z-index: 3;
  display: flex;
  align-items: center;
  transition: opacity 0.18s;
  animation: arrow-pulse 1.6s ease-in-out infinite;
}

@keyframes arrow-pulse {
  0%, 100% { transform: translateY(-50%) translateX(0);   opacity: .9; }
  50%       { transform: translateY(-50%) translateX(3px); opacity: 1;  }
}

.filters-bar-outer--at-end .filters-bar-arrow { opacity: 0; animation: none; }

/* Rankings: no scroll needed */
.rankings-col .filters-bar-outer::before,
.rankings-col .filters-bar-outer::after,
.rankings-col .filters-bar-arrow { display: none; }
.rankings-col .filters-bar { flex-wrap: wrap; overflow-x: visible; }


.filter-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.filter-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: rgba(255,255,255,.85);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.filter-select {
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-base);
  font-size: var(--font-size-xs);
  padding: 5px 10px;
  outline: none;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
}

.filter-select:hover {
  background: rgba(0,0,0,.38);
  border-color: rgba(255,255,255,.45);
}

.filter-select:focus {
  background: rgba(0,0,0,.38);
  border-color: #fff;
}

.filter-select option {
  background: var(--color-surface);
  color: var(--color-text);
}

input[type="date"].filter-select {
  appearance: auto;
  -webkit-appearance: auto;
  color-scheme: dark;
  cursor: pointer;
}


/* ── Mobile optimizations for Monitor & Partidas ─────────────────────────── */
@media (max-width: 768px) {
  /* Lock the entire layout chain to viewport width */
  #app-shell,
  .shell-body,
  .page-content,
  .monitor,
  .partidas-layout {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .page-content {
    min-width: 0;
    width: 100%;
  }

  /* Cards: constrain width, allow internal scroll for wide content */
  .card {
    max-width: calc(100vw - 24px);
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    word-break: break-word;
  }
  .card::-webkit-scrollbar { display: none; }

  /* Monitor grid: single column */
  .monitor-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    min-width: 0;
  }

  /* Rating cards: 2x2 grid, compact */
  .monitor-ratings {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .rating-card { padding: 12px; }
  .rating-card__label { font-size: .6rem; }
  .rating-card__value { font-size: 1.2rem; }
  .rating-card__value--sm { font-size: .85rem; }

  /* Tables: keep table display, let card scroll */
  .tc-table,
  .openings-table,
  table {
    width: max-content;
    min-width: 100%;
  }

  .tc-table th, .tc-table td,
  .openings-table th, .openings-table td,
  table th, table td {
    white-space: nowrap;
  }

  /* Heatmap: scroll inside card */
  .heatmap-cal {
    width: max-content;
    min-width: 100%;
  }

  /* Game cards */
  .game-card {
    grid-template-columns: 72px 1fr;
    gap: 10px;
    padding: 12px;
    max-width: calc(100vw - 24px);
  }

  .game-card__board { width: 72px; height: 72px; }
  .game-card__meta { flex-wrap: wrap; }
  .games-list { min-width: 0; }

  /* Monitor profile */
  .monitor-profile {
    padding: 16px;
    gap: 12px;
    max-width: calc(100vw - 24px);
  }

  .monitor-profile__actions {
    margin-left: 0;
    width: 100%;
  }

  /* Partidas */
  .partidas-layout { gap: 12px; }
  .sync-bar { padding: 8px 0; }
}


/* ── Game Viewer Modal ───────────────────────────────────────────────────── */
.modal--game-viewer {
  max-width: 820px;
  padding: 20px;
}

.modal-game-info {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-game-info[hidden] { display: none; }

/* Analisar button — compact, secondary style */
.modal-analyze-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  flex-shrink: 0;
  white-space: nowrap;
}

.modal-analyze-link:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
  background: var(--color-text-muted);
}

.modal-info__players {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text);
}

.modal-info__detail {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.modal__body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.modal__board-col {
  flex-shrink: 0;
}

.modal__moves-col {
  flex: 1;
  min-width: 0;
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  line-height: 1.8;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.modal__moves-col[hidden] { display: none; }

.move-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  margin-right: 4px;
}

.move-num {
  color: var(--color-text-muted);
  font-weight: 600;
  min-width: 20px;
}

.move-btn {
  background: transparent;
  border: none;
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: var(--font-size-xs);
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.move-btn:hover {
  background: var(--color-border);
}

.move-btn--active {
  background: var(--color-accent);
  color: #fff;
}

/* Game card clickable */
.game-card[data-game-id] {
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  box-shadow: var(--shadow-card);
}

.game-card[data-game-id]:hover {
  border-color: var(--color-text-muted);
}

.game-card[data-game-id]:active {
  transform: scale(0.99);
}

/* Mobile: stack board and moves vertically */
@media (max-width: 768px) {
  .modal--game-viewer {
    padding: 14px;
    max-width: 100%;
  }

  .modal__body {
    flex-direction: column;
    gap: 12px;
  }

  .modal__board-col {
    width: 100%;
  }

  .modal__moves-col {
    max-height: 180px;
    width: 100%;
  }

  .board-wrap {
    max-width: 100%;
  }
}


/* ── Custom Chessground Board Colors ─────────────────────────────────────── */
/* White squares: #DBDBDB, Dark squares: #A03030 (brighter red from FF4141) */
cg-board {
  background-color: #DBDBDB !important;
  background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4IDgiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyI+PHJlY3Qgd2lkdGg9IjgiIGhlaWdodD0iOCIgZmlsbD0iI0RCREJEQiIvPjxnIGZpbGw9IiNBMDMwMzAiPjxyZWN0IHg9IjEiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIzIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNSIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjciIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIwIiB5PSIxIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iMiIgeT0iMSIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjQiIHk9IjEiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI2IiB5PSIxIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iMSIgeT0iMiIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjMiIHk9IjIiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI1IiB5PSIyIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNyIgeT0iMiIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjAiIHk9IjMiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIyIiB5PSIzIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNCIgeT0iMyIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjYiIHk9IjMiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIxIiB5PSI0IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iMyIgeT0iNCIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjUiIHk9IjQiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI3IiB5PSI0IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iMCIgeT0iNSIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjIiIHk9IjUiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI0IiB5PSI1IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNiIgeT0iNSIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjEiIHk9IjYiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIzIiB5PSI2IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iNSIgeT0iNiIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjciIHk9IjYiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSIwIiB5PSI3IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PHJlY3QgeD0iMiIgeT0iNyIgd2lkdGg9IjEiIGhlaWdodD0iMSIvPjxyZWN0IHg9IjQiIHk9IjciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiLz48cmVjdCB4PSI2IiB5PSI3IiB3aWR0aD0iMSIgaGVpZ2h0PSIxIi8+PC9nPjwvc3ZnPg==') !important;
}

/* Last move highlight — green */
cg-board square.last-move {
  background-color: rgba(74, 222, 128, 0.4) !important;
}

/* Check highlight — bright red glow using accent FF4141 */
cg-board square.check {
  background: radial-gradient(ellipse at center, rgba(255, 65, 65, 1) 0%, rgba(255, 65, 65, 0.6) 25%, rgba(255, 65, 65, 0.2) 60%, transparent 90%) !important;
}

/* Selected piece square — green */
cg-board square.selected {
  background-color: rgba(74, 222, 128, 0.5) !important;
}

/* Move destinations — green dots */
cg-board square.move-dest {
  background: radial-gradient(rgba(74, 222, 128, 0.5) 22%, rgba(74, 222, 128, 0.8) 0, rgba(0, 0, 0, 0.2) 0, transparent 0) !important;
}

/* Coordinates — bold, high contrast */
.cg-wrap coords {
  font-size: 10px !important;
  font-weight: 700 !important;
  font-family: sans-serif !important;
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,1), 0 0 4px rgba(0,0,0,.9) !important;
  opacity: 1 !important;
  z-index: 3 !important;
  pointer-events: none !important;
}

/* Override the default text-align: center on files */
.cg-wrap coords.files {
  text-align: left !important;
}

/* Files (a-h along bottom): align to left corner of each cell, bottom edge */
.cg-wrap coords.files coord {
  text-align: left !important;
  padding-left: 3px !important;
  transform: none !important;
}

/* Ranks (1-8 along left): push to bottom of each cell — default translateY(39%) handles this */
.cg-wrap coords.ranks coord {
  transform: translateY(39%) !important;
  padding-left: 1px;
}

/* Modal close button — borderless */
.modal__close {
  border: none !important;
  background: rgba(255,255,255,.08);
}

.modal__close:hover {
  background: rgba(255,255,255,.15);
  color: var(--color-text);
}

/* ── Fixed board size in modal to prevent resizing ───────────────────────── */
.modal__board-col .board-wrap {
  width: 400px;
  height: 400px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.35);
}

.modal__board-col .board-wrap .cg-wrap {
  width: 400px !important;
  height: 400px !important;
  border-radius: var(--radius-md);
}

/* ── Modal board coordinates ─────────────────────────────────────────────────
   Lichess-style inside-corner labels — same as the analysis board.
   Uses coordinatesOnSquares: true so labels render inside each square. */

/* container-type needed so cqi units scale with the board element's own size */
.board-wrap {
  container-type: size;
}

/* Hide the floating edge ranks/files — we use per-square labels instead */
.board-wrap .cg-wrap coords.ranks,
.board-wrap .cg-wrap coords.files {
  display: none;
}

/* Per-square coordinate labels */
.board-wrap .cg-wrap coords.squares coord {
  font-family: var(--font-base), sans-serif;
  font-size: max(9px, 1.8cqi);
  font-weight: 600;
  text-shadow: none;
  opacity: 0.85;
  padding: 3% 4%;
  line-height: 1;
}

@supports not (font-size: 1cqi) {
  .board-wrap .cg-wrap coords.squares coord {
    font-size: 11px;
  }
}

/* No shadow override — brown theme alternating colors apply via
   coords.squares:nth-of-type selectors already in chessground.brown.css */
.board-wrap .cg-wrap coords coord {
  text-shadow: none !important;
}

@media (max-width: 768px) {
  .modal__board-col .board-wrap {
    width: calc(100vw - 60px);
    height: calc(100vw - 60px);
    max-width: 360px;
    max-height: 360px;
  }

  .modal__board-col .board-wrap .cg-wrap {
    width: 100% !important;
    height: 100% !important;
  }
}


/* ── Game card termination chip ──────────────────────────────────────────── */
.game-card__chip--term {
  color: var(--color-text-muted);
  font-style: italic;
}

.game-card__title strong {
  color: var(--color-text);
}

/* ── Analysis picker game cards ──────────────────────────────────────────── */
/* Analyzed cards get a green left border accent */
.game-card--analyzed {
  box-shadow: var(--shadow-card);
}

/* Accuracy arcs + blunder count row inside picker cards */
.game-card__analysis-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* One player: dot + name + arc */
.game-card__accuracy-player {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.game-card__accuracy-name {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.game-card__analysis-stats .analysis-dash-blunders {
  margin-left: auto;
}


/* ── Platform logos ──────────────────────────────────────────────────────── */
.platform-logo {
  display: inline-block;
  vertical-align: -2px;
  flex-shrink: 0;
}

.platform-logo--lichess {
  /* Lichess logo has its own circle background — no filter needed */
  border-radius: 50%;
}

/* Platform chip on game cards */
.game-card__chip--platform {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ── Compact game card — monitor widget ──────────────────────────────────── */
.game-card--compact {
  padding: 10px 12px;
  gap: 10px;
}

.game-card--compact .game-card__board {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.game-card--compact .game-card__cg {
  width: 64px;
  height: 64px;
}

.game-card--compact .game-card__title {
  font-size: var(--font-size-xs);
}

.game-card--compact .game-card__meta {
  gap: 4px;
}

/* Gap between cards in the monitor latest-games widget */
#monitor-latest-games {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.analysis-dashboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analysis-accuracy {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.accuracy-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 80px;
}

.accuracy-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
}

.accuracy-col--white .accuracy-value { color: #eee; }
.accuracy-col--black .accuracy-value { color: var(--color-accent); }

.accuracy-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: .04em;
}

.accuracy-acpl {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.analysis-graph {
  position: relative;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-2);
  cursor: crosshair;
}

.advantage-chart {
  width: 100%;
  height: 100%;
  display: block;
}

.advantage-chart__labels {
  position: absolute;
  top: 0;
  right: 4px;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  font-size: 8px;
  color: var(--color-text-muted);
  opacity: .6;
}

.analysis-stats-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.classification-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cls-badge {
  font-size: .6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.cls-badge--best      { background: rgba(74,222,128,.15); color: #4ade80; }
.cls-badge--excellent { background: rgba(74,222,128,.1);  color: #86efac; }
.cls-badge--good      { background: rgba(74,222,128,.07); color: #a7f3d0; }
.cls-badge--inaccuracy { background: rgba(255,215,0,.12); color: #FFD700; }
.cls-badge--mistake   { background: rgba(255,140,0,.12);  color: #FF8C00; }
.cls-badge--blunder   { background: rgba(255,65,65,.15);  color: #FF4141; }

/* Move classification colors in move list */
.move-btn--best { color: #4ade80 !important; }
.move-btn--inaccuracy { color: #FFD700 !important; }
.move-btn--mistake { color: #FF8C00 !important; font-weight: 700; }
.move-btn--blunder { color: #FF4141 !important; font-weight: 700; text-decoration: underline; }


/* ══════════════════════════════════════════════════════════════════════════
   ANALYSIS PAGE
   ══════════════════════════════════════════════════════════════════════════ */

.analysis-page {
  /* Stretch flush to edge of page-content, fill full height */
  margin: -24px -20px;
  padding: 0;
  min-height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
}

.analysis-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.analysis-loading__text {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* Main layout: board left, sidebar right */
.analysis-layout {
  display: grid;
  grid-template-columns: auto minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
  padding: 20px;
  flex: 1;
  min-width: 0;
}

/* Board section: eval bar + board side by side */
.analysis-board-section {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* Board column: board + controls below */
.analysis-board-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* Board wrap — fixed square, no resize */
.analysis-board-wrap {
  width: clamp(340px, 36vw, 560px);
  height: clamp(340px, 36vw, 560px);
  flex-shrink: 0;
  position: relative;
  border-radius: 12px;
  overflow: hidden; /* clips the board to rounded corners */
  background: var(--color-bg);
  box-shadow:
    0 12px 40px rgba(0,0,0,.65),
    0 4px 12px rgba(0,0,0,.45),
    0 0 0 1px rgba(255,255,255,.05);
}

/* No resize handle */
.analysis-board-resize-handle { display: none; }

/* cg-wrap sized explicitly in JS — CSS just ensures display:block */
.analysis-board-wrap .cg-wrap,
.analysis-board {
  display: block !important;
}

/* Eval bar — JS keeps height in sync with board via ResizeObserver */
.analysis-eval-bar {
  width: 28px;
  height: clamp(340px, 36vw, 560px);
  background: #333;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  align-self: flex-start;
}

.analysis-eval-bar__white {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: #eee;
  transition: height 300ms ease;
}

.analysis-eval-bar__label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  z-index: 2;
  text-shadow: 0 0 3px rgba(0,0,0,.8);
  white-space: nowrap;
}

/* Sidebar — fills the same height as the board section */
.analysis-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  height: clamp(400px, calc(100vh - 112px), 900px);
  overflow: visible;
  /* Horizontal padding so shadows on cards don't get clipped */
  padding: 0 6px;
  margin: 0 -6px;
}

/* ── 1. Header: game info left, stacked actions right ── */
.analysis-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.analysis-header__top {
  display: flex;
  align-items: center;
}

/* Back button — ghost style, matches the nav pattern */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 6px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-base);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.btn-back:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
  background: var(--color-surface-2);
}

.analysis-header__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.analysis-header__game-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

/* Stack selector + button vertically */
.analysis-header__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex-shrink: 0;
  min-width: 148px;
}

/* Engine depth selector fills the actions column */
.analysis-engine-select {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-base);
  font-size: var(--font-size-xs);
  padding: 5px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

.analysis-engine-select:hover,
.analysis-engine-select:focus {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.analysis-engine-select option {
  background: var(--color-surface);
  color: var(--color-text);
}

/* Analyse button fills the column too */
.analysis-header__actions .btn {
  width: 100%;
}

.analysis-header__players {
  font-size: var(--font-size-base);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-header__detail {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Stats — give the grid a little vertical padding so shadows escape */
.analysis-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex-shrink: 0;
  padding: 4px 0;
}

.analysis-stats[hidden] { display: none; }

.analysis-stats__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 8px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  min-width: 0;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.analysis-stats__accuracy {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-text);
}

.analysis-stats__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

/* White/black color dot next to player name */
.analysis-stats__color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.analysis-stats__color-dot--white { background: #f0f0f0; border: 1px solid rgba(255,255,255,.3); }
.analysis-stats__color-dot--black { background: #2a2a2a; border: 1px solid rgba(255,255,255,.2); }

.analysis-stats__acpl {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.analysis-stats__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.analysis-badge {
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ── 3. Badges — muted, high-contrast against dark surface ── */
.analysis-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
}

/* Icons inside badges — slightly larger */
.analysis-badge .cls-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Dark pill background + lighter text — no borders */
.analysis-badge--best      { background: rgba(255,255,255,.06); color: #a3e4b8; }
.analysis-badge--excellent { background: rgba(255,255,255,.06); color: #8ecba6; }
.analysis-badge--good      { background: rgba(255,255,255,.06); color: #72b58c; }
.analysis-badge--inaccuracy { background: rgba(255,255,255,.06); color: #c9b44a; }
.analysis-badge--mistake   { background: rgba(255,255,255,.06); color: #c0804a; }
.analysis-badge--blunder   { background: rgba(255,255,255,.06); color: #c05050; }

/* Advantage graph — taller now that the sidebar has more room */
.analysis-graph-wrap {
  height: 120px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface);
  cursor: crosshair;
  box-shadow: var(--shadow-card);
}

.analysis-graph-wrap[hidden] { display: none; }

.analysis-graph {
  width: 100%;
  height: 100%;
}

.analysis-chart-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.analysis-chart__area-white { fill: rgba(255,255,255,0.12); }
.analysis-chart__area-black { fill: rgba(255,65,65,0.12); }
.analysis-chart__zero { stroke: rgba(255,255,255,0.15); stroke-width: 0.3; }
.analysis-chart__line { fill: none; stroke: var(--color-text); stroke-width: 0.8; vector-effect: non-scaling-stroke; }
.analysis-chart__cursor { stroke: var(--color-accent); stroke-width: 0.5; opacity: 0.8; }

/* Side labels inside the graph SVG */
.analysis-chart__side-label {
  font-size: 5px;
  fill: rgba(255,255,255,0.35);
  font-family: var(--font-mono, monospace);
  font-weight: 500;
  /* SVG text isn't affected by preserveAspectRatio="none" distortion because
     we use vector-effect on text to keep it readable */
  vector-effect: non-scaling-stroke;
}
.analysis-chart__side-label--black {
  fill: rgba(255,100,100,0.4);
}

/* ── 4. Move list — takes all remaining vertical space ── */
.analysis-moves {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  line-height: 2.0;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
  /* min-height: 0 lets flex: 1 actually shrink down and fill remaining space */
  min-height: 0;
}

.analysis-move-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  margin-right: 4px;
}

.analysis-move-num {
  color: var(--color-text-muted);
  font-weight: 600;
  min-width: 26px;
  font-size: var(--font-size-sm);
}

.analysis-move-btn {
  background: transparent;
  border: none;
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  min-height: 28px;
}

.analysis-move-btn:hover { background: var(--color-border); }
.analysis-move-btn--active { background: var(--color-accent); color: #fff; }

/* Classification colors on moves */
.analysis-move-btn--best { color: #4ade80; }
.analysis-move-btn--inaccuracy { color: #c9b44a; }
.analysis-move-btn--mistake { color: #c0804a; font-weight: 700; }
.analysis-move-btn--blunder { color: #c05050; font-weight: 700; }
.analysis-move-btn--miss { color: #9B59B6; }
.analysis-move-btn--book { color: var(--color-text-muted); }

/* Active state always wins — white text over accent background */
.analysis-move-btn--active,
.analysis-move-btn--active:is(.analysis-move-btn--blunder,
                              .analysis-move-btn--mistake,
                              .analysis-move-btn--inaccuracy,
                              .analysis-move-btn--best,
                              .analysis-move-btn--miss,
                              .analysis-move-btn--book) {
  color: #fff !important;
}

/* Classification dot before move */
.analysis-move-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
}

.analysis-move-dot--inaccuracy { background: #FFD700; }
.analysis-move-dot--mistake { background: #FF8C00; }
.analysis-move-dot--blunder { background: #FF4141; }
.analysis-move-dot--miss { background: #9B59B6; }

/* ── 2 & 3. Feedback slot — always a fixed-height card, muted palette ── */

/* Feedback slot: min-height so it never causes layout jumps but expands for banter */
.analysis-feedback-slot {
  flex-shrink: 0;
  min-height: 52px;
}

/* The inner feedback card */
.analysis-feedback {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  box-shadow: var(--shadow-card);
}

/* Tinted left border instead of screaming background */
.analysis-feedback--book       { border-left: 3px solid #64748b; }
.analysis-feedback--best       { border-left: 3px solid #4ade80; }
.analysis-feedback--excellent  { border-left: 3px solid #86efac; }
.analysis-feedback--good       { border-left: 3px solid #a7f3d0; }
.analysis-feedback--inaccuracy { border-left: 3px solid #b8972a; color: #c9a83c; }
.analysis-feedback--mistake    { border-left: 3px solid #b05e10; color: #c46b1a; }
.analysis-feedback--blunder    { border-left: 3px solid #992929; color: #b03030; }
.analysis-feedback--miss       { border-left: 3px solid #6b3fa0; color: #7a4db5; }

.analysis-feedback__text {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  /* Inherit the per-classification color */
  color: inherit;
}

/* LLM banter commentary — shown below the technical classification line */
.analysis-feedback__banter {
  font-size: var(--font-size-sm);
  font-weight: 400;
  font-style: italic;
  color: var(--color-text);
  line-height: 1.55;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,.07);
  margin-top: 4px;
}

.analysis-feedback__banter--pending {
  color: var(--color-text-muted);
  font-style: italic;
  opacity: 0.45;
  font-size: .62rem;
}

.analysis-feedback__line {
  color: var(--color-text-muted);
  font-size: .68rem;
  opacity: 0.8;
  padding-left: 28px; /* indent past icon */
}

/* Board column: board + controls below it */
.analysis-board-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.analysis-board-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}

/* ── Coordinate labels — Lichess style: inside corners, no shadow ────── */
/* Hide the old floating coords outside the board */
.analysis-board-wrap .cg-wrap coords.ranks,
.analysis-board-wrap .cg-wrap coords.files {
  display: none;
}

/* Square-level coordinates (coordinatesOnSquares: true) */
.analysis-board-wrap .cg-wrap coords.squares coord {
  font-family: var(--font-base), sans-serif;
  font-size: clamp(9px, 0.65vw, 13px);
  font-weight: 600;
  text-shadow: none;
  opacity: 0.85;
  padding: 3% 4%;
  line-height: 1;
}

@supports not (font-size: 1cqi) {
  .analysis-board-wrap .cg-wrap coords.squares coord {
    font-size: 11px;
  }
}

/* The brown theme already sets alternating colors correctly via
   coords.squares:nth-of-type — we just ensure no shadow overrides it */
.analysis-board-wrap .cg-wrap coords coord {
  text-shadow: none !important;
}

/* ── 5. Flip button — proper size, not tiny ── */
#btn-flip {
  min-width: 44px;
  min-height: 34px;
  font-size: 1.1rem;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

#btn-flip:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
  background: var(--color-surface);
}

.analysis-current-eval {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-muted);
  min-width: 50px;
}

.analysis-current-eval.eval--white { color: #eee; }
.analysis-current-eval.eval--black { color: var(--color-accent); }

/* Classification icons — SVG glyphs */
.cls-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 3px;
  flex-shrink: 0;
}

/* Larger in the feedback banner */
.analysis-feedback .cls-icon {
  width: 22px;
  height: 22px;
  margin-right: 6px;
}

/* In badges (stats header) */
.analysis-badge .cls-icon {
  width: 13px;
  height: 13px;
  margin-right: 2px;
  vertical-align: middle;
}

/* Move row layout (table-like) */
.analysis-move-row {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 1px 0;
}

.analysis-move-row .analysis-move-btn {
  flex: 1;
  min-width: 0; /* allow flex child to shrink below content size */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  text-align: left;
  overflow: hidden;
}

.analysis-move-san {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-move-eval {
  font-size: .7rem;
  color: var(--color-text-muted);
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.analysis-move-eval--blunder    { color: #c05050; }
.analysis-move-eval--mistake    { color: #c0804a; }
.analysis-move-eval--inaccuracy { color: #c9b44a; }
.analysis-move-eval--best       { color: #4ade80; }

/* Navigation controls — now lives below the board in .analysis-board-col */
.analysis-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 0;
  flex-shrink: 0;
}

.analysis-nav__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  min-width: 70px;
  text-align: center;
}

.analysis-nav .btn {
  min-width: 36px;
  min-height: 36px;
  font-size: 1.1rem;
  padding: 6px 10px;
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.analysis-nav .btn:hover:not(:disabled) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* Game picker / Analysis Dashboard */
.analysis-picker {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 20px 0 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Two-column side-by-side layout */
.picker-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  /* Fill remaining height */
  flex: 1;
  min-height: 0;
  /* Stretch both columns to same height */
  align-items: stretch;
}

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

.picker-col {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  min-height: 0;
  height: calc(100vh - 72px);
  /* No overflow:hidden — let filter bar and card shadows overflow freely */
}

/* Sticky column header: title + filter bar */
.picker-col__header {
  flex-shrink: 0;
  padding: 0 0 8px 0;
}

/* Scrollable list area */
.picker-col__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Horizontal padding so card box-shadows aren't clipped by the scroll container */
  padding: 4px 8px 48px 8px;
  margin: 0 -8px; /* cancel out the extra padding so layout stays aligned */
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.picker-col__body::-webkit-scrollbar { width: 4px; }
.picker-col__body::-webkit-scrollbar-track { background: transparent; }
.picker-col__body::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }

/* Direct list containers inside body — need gap for the cards */
.picker-col__body > div {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Load more button — sits at bottom of body scroll area */
.picker-load-more {
  flex-shrink: 0;
  margin-top: 4px;
}

/* Filter bar variant for analyzed column — uses surface-2 instead of accent red */
.filters-bar--analyzed {
  background: var(--color-surface-2);
}

/* Outer shadow for analyzed variant — softer, no accent glow */
.filters-bar-outer:has(.filters-bar--analyzed) {
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}

/* Fades match the surface-2 background for the analyzed variant */
@media (max-width: 768px) {
  .filters-bar--analyzed::before {
    background: linear-gradient(to right, var(--color-surface-2), transparent);
  }
  .filters-bar--analyzed::after {
    background: linear-gradient(to left, var(--color-surface-2), transparent);
  }
}
.filters-bar--analyzed .filter-label {
  color: var(--color-text-muted);
}

.filters-bar--analyzed .filter-select {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

.filters-bar--analyzed .filter-select:hover {
  background: var(--color-border);
}

.filters-bar--analyzed .filter-select:focus {
  border-color: var(--color-accent);
}

  @media (max-width: 860px) {
  .picker-col {
    height: 60vh;
  }
}

.analysis-picker__title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.analysis-dash-count {
  font-size: var(--font-size-xs);
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

/* Analyzed games — two-column grid */
.analysis-dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 600px) {
  .analysis-dash-grid { grid-template-columns: 1fr; }
}

.analysis-dash-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  transition: background var(--transition), border-color var(--transition);
}

.analysis-dash-card:hover {
  background: var(--color-surface-2);
  border-color: var(--color-text-muted);
}

.analysis-dash-card--done {
  border-left: 3px solid #4ade80;
}

.analysis-dash-card__players {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.analysis-dash-card__vs {
  font-size: var(--font-size-sm);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-dash-card__meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stats row: accuracy arcs + blunder count */
.analysis-dash-card__stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.analysis-dash-accuracy {
  flex-shrink: 0;
}

.accuracy-arc {
  display: block;
}

.analysis-dash-blunders {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: #c05050;
  margin-left: auto;
}

.analysis-dash-blunders .cls-icon {
  width: 14px;
  height: 14px;
}

/* Unanalyzed list — same as before */
.analysis-picker__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.analysis-picker__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: background var(--transition), border-color var(--transition);
  text-decoration: none;
  color: var(--color-text);
  cursor: pointer;
}

.analysis-picker__item:hover {
  background: var(--color-surface-2);
  border-color: var(--color-accent);
}

.analysis-picker__players {
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.analysis-picker__meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.analysis-picker__source {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.picker-source {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Mobile responsive */
@media (max-width: 900px) {
  .analysis-layout {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
    align-items: start;
  }

  .analysis-board-wrap {
    width: min(calc(100vw - 80px), 480px);
    height: min(calc(100vw - 80px), 480px);
  }

  .analysis-eval-bar {
    height: min(calc(100vw - 80px), 480px) !important;
    width: 20px;
  }

  .analysis-sidebar {
    height: auto;
    max-height: none;
  }

  .analysis-graph-wrap {
    height: 80px;
  }

  .analysis-moves {
    max-height: 300px;
  }

  .analysis-header__actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }

  .analysis-engine-select {
    max-width: 140px;
  }
}

@media (max-width: 768px) {
  .analysis-page {
    margin: -16px -12px;
    min-height: calc(100vh - 52px);
  }

  .analysis-picker {
    padding: 16px 12px;
  }
}

/* ── Rankings ────────────────────────────────────────────────────────────── */

.rankings-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  /* Flush to viewport edges — same trick as analysis page */
  margin: -24px -20px;
  padding: 24px 20px 0;
  gap: 0;
}

@media (max-width: 768px) {
  .rankings-page { margin: -16px -12px; padding: 16px 12px 0; height: calc(100vh - 52px); }
}

.rankings-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 0 0 16px;
  flex-shrink: 0;
}

.rankings-header__title { font-size: 1.2rem; font-weight: 700; }
.rankings-header__period { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* Three equal columns */
.rankings-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
  /* Allow box-shadows from filter bars to escape */
  padding: 4px 4px 0;
  margin: 0 -4px;
}

@media (max-width: 900px) {
  .rankings-columns {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

.rankings-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rankings-col__header {
  flex-shrink: 0;
  padding-bottom: 8px;
}

.rankings-col__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  line-height: 1;          /* prevent icon/text baseline drift */
  white-space: nowrap;     /* keep on one line */
}

/* Icons inside the title — prevent distortion */
.rankings-col__title svg,
.rankings-col__title img {
  flex-shrink: 0;
  display: block;          /* remove inline baseline gap */
}

/* Hall da Capivara gets amber filter bar */
.rankings-col--funny .rankings-col__title {
  color: #f59e0b;
}

.rankings-col--funny .filters-bar {
  background: rgba(245,158,11,0.9);
  /* box-shadow on the outer wrapper to avoid overflow bleed */
}

.rankings-col--funny .filters-bar-outer {
  box-shadow: 0 8px 24px rgba(0,0,0,.45), 0 2px 8px rgba(245,158,11,.13);
}

.rankings-col--funny .filter-label {
  color: rgba(255,255,255,.75);
}

.rankings-col--funny .filter-select {
  background: rgba(0,0,0,.25);
  border-color: rgba(255,255,255,.2);
  color: #fff;
}

.rankings-col__body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 4px 32px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.rankings-col__body::-webkit-scrollbar { width: 4px; }
.rankings-col__body::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }

/* Ranking rows — solid card background, medal borders for top 3 */
.rankings-col__body .ranking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: background var(--transition), border-color var(--transition);
  text-decoration: none;
  color: inherit;
}

.rankings-col__body .ranking-row:hover {
  background: var(--color-surface-2);
  border-color: var(--color-text-muted);
}

/* Top 3 get a highlighted border, same solid background */
.rankings-col__body .ranking-row--gold   { border-color: rgba(245,158,11,.55); }
.rankings-col__body .ranking-row--silver { border-color: rgba(148,163,184,.4); }
.rankings-col__body .ranking-row--bronze { border-color: rgba(180,120,80,.4); }

.rankings-col__body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 4px 32px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.rankings-col__body::-webkit-scrollbar { width: 4px; }
.rankings-col__body::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }

.rankings-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.rankings-header__title { font-size: 1.2rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.rankings-header__period { font-size: var(--font-size-xs); color: var(--color-text-muted); }

.rankings-period-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: .03em;
}

.rankings-section { display: flex; flex-direction: column; }
.rankings-section__title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.rankings-section__sub { font-size: var(--font-size-sm); color: var(--color-text-muted); margin-top: -12px; margin-bottom: 16px; }
.rankings-section--funny .rankings-section__title { color: #f59e0b; }

.rankings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.rankings-grid--2 { grid-template-columns: repeat(2, 1fr); }
.rankings-grid--1 { grid-template-columns: 1fr; max-width: 50%; }

@media (max-width: 768px) {
  .rankings-grid,
  .rankings-grid--2,
  .rankings-grid--1 { grid-template-columns: 1fr; max-width: 100%; }
}

.ranking-board {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.ranking-board--funny {
  background: rgba(245,158,11,.03);
}

.ranking-board__title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ranking-board__list { display: flex; flex-direction: column; gap: 6px; }

.ranking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.ranking-row:hover { background: var(--color-surface-2); }

.ranking-row--gold   { background: rgba(245,158,11,.08); }
.ranking-row--silver { background: rgba(148,163,184,.06); }
.ranking-row--bronze { background: rgba(180,120,80,.06); }

.ranking-row__rank {
  width: 20px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: center;
  flex-shrink: 0;
}

.ranking-row--gold   .ranking-row__rank { color: #f59e0b; }
.ranking-row--silver .ranking-row__rank { color: #94a3b8; }
.ranking-row--bronze .ranking-row__rank { color: #b47850; }

.ranking-row__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}

.ranking-row__name {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-row__stat {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text);
  flex-shrink: 0;
}

.ranking-row__label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* Right side of a row: stat + optional label/badge */
.ranking-row__right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

/* Section header: SVG icon + title inline */
.rankings-section__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--color-text-muted);
}

.rankings-section__header .rankings-section__title {
  margin-bottom: 0;
}

/* Platform badges on rating rows */
.ranking-platform {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: .62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.ranking-platform.lichess {
  background: rgba(255,255,255,.06);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.ranking-platform.chesscom {
  background: rgba(120,200,100,.08);
  color: #7bc87a;
  border: 1px solid rgba(120,200,100,.2);
}

.rankings-loading { padding: 32px 0; text-align: center; }

/* ── Monitor profile badges ──────────────────────────────────────────────── */
.monitor-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.monitor-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px 3px 6px;
  border-radius: var(--radius-full);
  font-size: .65rem;
  font-weight: 700;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: default;
  transition: border-color var(--transition);
}

.monitor-badge:hover { border-color: var(--color-text-muted); }

/* Rank 1 = gold tint */
.monitor-badge .monitor-badge__rank:first-of-type { font-size: .7rem; }

.monitor-badge__month {
  opacity: 0.6;
  font-size: .6rem;
}

/* Special tint for capivara badges */
.monitor-badge--capivara {
  background: rgba(245,158,11,.08);
  border-color: rgba(245,158,11,.2);
  color: #f59e0b;
}

.monitor-badge--skull {
  background: rgba(100,116,139,.08);
  border-color: rgba(100,116,139,.2);
}
