/* ChessPlayer — tema «tablero nocturno»: oscuro elegante con acentos dorados */
:root {
  --bg: #12141a;
  --bg2: #1b1e27;
  --bg3: #232836;
  --bg4: #2c3242;
  --border: #2e3444;
  --border-soft: #262c3a;
  --text: #eceae4;
  --text-dim: #9aa1b2;
  --gold: #e0aa3e;
  --gold2: #f0c56a;
  --gold-deep: #b9862c;
  --good: #81b64c;
  --good-deep: #5d8f38;
  --bad: #d05b5b;
  --light-sq: #ebecd0;
  --dark-sq: #739552;
  /* temas de tablero (Ajustes): se activan con body[data-board="…"] */
  --sel: rgba(255, 205, 80, 0.55);
  --mark: rgba(20, 85, 30, 0.45);
  --hint: rgba(20, 60, 20, 0.35);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --glow-gold: 0 0 0 1px rgba(224, 170, 62, 0.35), 0 6px 24px rgba(224, 170, 62, 0.18);
}
/* ---- temas del tablero (Ajustes del perfil) ---- */
body[data-board="blue"]  { --light-sq: #dee3e6; --dark-sq: #5a7a99; }
body[data-board="brown"] { --light-sq: #f0d9b5; --dark-sq: #b58863; }
body[data-board="grey"]  { --light-sq: #e8e8e8; --dark-sq: #7d7d7d; }
body[data-board="sand"]  { --light-sq: #f5e9c8; --dark-sq: #c19a5b; }

/* ---- modo claro (Ajustes › Modo): mismas variables, superficies claras ---- */
body[data-mode="light"] {
  --bg: #f3f1ea;
  --bg2: #ffffff;
  --bg3: #eae7dc;
  --bg4: #dcd8ca;
  --border: #d3cec0;
  --border-soft: #e3dfd3;
  --text: #262a33;
  --text-dim: #67707f;
  /* el dorado de texto se oscurece: el claro original no se lee sobre blanco */
  --gold: #b9862c;
  --gold2: #8a6413;
  --shadow: 0 10px 26px rgba(60, 50, 20, 0.14);
  --sel: rgba(255, 195, 60, 0.6);
  --mark: rgba(20, 85, 30, 0.35);
  --hint: rgba(20, 60, 20, 0.3);
}
/* superficies que en oscuro llevan color fijo */
body[data-mode="light"] #topbar { background: rgba(250, 249, 245, 0.85); }
body[data-mode="light"] .card,
body[data-mode="light"] .panel { background: linear-gradient(160deg, var(--bg2), #f4f1e8); }
body[data-mode="light"] .hero { background: linear-gradient(150deg, #ffffff 0%, #f4f1e8 70%); }
body[data-mode="light"] .auth-wrap,
body[data-mode="light"] .modal { background: linear-gradient(165deg, #ffffff, #f4f1e8); }
body[data-mode="light"] .modal { box-shadow: 0 24px 60px rgba(60, 50, 20, 0.25); }
body[data-mode="light"] .board-wrap {
  box-shadow:
    0 0 0 6px #d8cfc0,
    0 0 0 7px rgba(224, 170, 62, 0.45),
    0 18px 44px rgba(60, 50, 20, 0.28);
}
body[data-mode="light"] .pc-ava { background: linear-gradient(145deg, #ece8db, #d9d4c4); }
body[data-mode="light"] ::-webkit-scrollbar-thumb:hover { background: #c6c0ae; }
/* textos que en oscuro van en blanco sobre dorado/translúcido */
body[data-mode="light"] .game-moves .mv.active { color: var(--text); }
body[data-mode="light"] .pc-clock.active { color: var(--text); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(224, 170, 62, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(129, 182, 76, 0.06), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  line-height: 1.45;
}
.hidden { display: none !important; }
h1, h2, h3 { font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
a { color: var(--gold2); }
::selection { background: rgba(224, 170, 62, 0.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #39415a; }

/* animación de entrada de las vistas */
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#view.view-anim { animation: viewIn .28s ease both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.94) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- topbar ---------- */
#topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  background: rgba(22, 25, 33, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 50;
}
#topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(224, 170, 62, 0.45), transparent);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.brand .brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; color: #1d1608;
  background: linear-gradient(145deg, var(--gold2), var(--gold-deep));
  box-shadow: 0 3px 10px rgba(224, 170, 62, 0.35);
}
.brand .brand-name { font-family: Georgia, "Times New Roman", serif; letter-spacing: 0.01em; }
.brand .brand-name b { color: var(--gold); font-weight: 700; }

#mainnav {
  display: flex; gap: 3px; flex: 1; flex-wrap: wrap;
  align-items: center;
}
#mainnav a {
  color: var(--text-dim); text-decoration: none;
  padding: 8px 15px; border-radius: 999px; font-size: 14px;
  position: relative; white-space: nowrap;
  transition: color .18s ease, background .18s ease, transform .12s ease, box-shadow .18s ease;
}
#mainnav a:hover {
  background: var(--bg3); color: var(--text);
  transform: translateY(-1px);
}
#mainnav a:active { transform: translateY(0) scale(.98); }
/* activa: píldora dorada con brillo interior y sombra suave */
#mainnav a.active {
  background: linear-gradient(150deg, rgba(224,170,62,.26), rgba(224,170,62,.11));
  color: var(--gold2); font-weight: 600;
  box-shadow:
    inset 0 0 0 1px rgba(224, 170, 62, 0.45),
    inset 0 1px 0 rgba(255, 225, 160, 0.20),
    0 2px 10px rgba(224, 170, 62, 0.16);
}
/* punto indicador bajo la pestaña activa */
#mainnav a.active::after {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 3px; width: 14px; height: 2.5px; border-radius: 2px;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  box-shadow: 0 0 6px rgba(224, 170, 62, 0.7);
}
.userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); }
.locale-picker { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.locale-picker select { width: auto; min-width: 106px; padding: 6px 24px 6px 8px; font-size: 12px; }
.locale-picker-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.auth-locale { justify-content: flex-end; margin: -12px 0 18px; }
.auth-locale select { max-width: 150px; }
#user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  padding: 5px 12px 5px 6px; border-radius: 999px; font-weight: 600; color: var(--text);
}
#user-chip .chip-ava {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(145deg, var(--gold2), var(--gold-deep));
  color: #1d1608; font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
#user-chip .chip-img {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border);
}
#user-chip .chip-elo { color: var(--gold2); font-variant-numeric: tabular-nums; }
#user-chip .chip-gem { color: #7fd4ff; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
#view { max-width: 1100px; margin: 0 auto; padding: 28px 20px 70px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 16px; margin-top: 18px; }
/* separadores del Inicio: agrupan las tarjetas por tema sin tocarlas */
.home-sec {
  margin: 26px 0 -8px; font-size: 14px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .07em;
  display: flex; align-items: center; gap: 10px;
}
.home-sec::after { content: ''; flex: 1; height: 2px; border-radius: 1px; background: var(--border-soft); }
.card {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--bg2), #191c25);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 20px; cursor: pointer;
  transition: border-color .15s, transform .12s, box-shadow .2s;
  animation: cardIn .3s ease both;
}
/* barra de acento en la parte superior de cada tarjeta: da identidad de
   color sin depender solo del icono */
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent, linear-gradient(90deg, var(--gold2), var(--gold)));
  opacity: .75;
  transition: opacity .2s, height .2s;
}
.card:hover::before { opacity: 1; }
.card:hover {
  border-color: rgba(224, 170, 62, 0.55);
  transform: translateY(-3px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(224, 170, 62, 0.15);
}
.card h3 { margin: 12px 0 6px; font-size: 16.5px; }
.card p { margin: 0; color: var(--text-dim); font-size: 14px; }
.card .badge-done { color: var(--good); font-size: 13px; font-weight: 600; }
/* acentos por tarjeta (se eligen en el markup con style="--accent:…") */
.card-icon {
  width: 46px; height: 46px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  background: linear-gradient(145deg, rgba(224, 170, 62, 0.22), rgba(224, 170, 62, 0.08));
  border: 1px solid rgba(224, 170, 62, 0.30);
  box-shadow: 0 4px 14px rgba(224, 170, 62, 0.12);
  transition: transform .18s cubic-bezier(.34,1.56,.64,1);
}
.card:hover .card-icon { transform: scale(1.1) rotate(-4deg); }
/* flecha que entra al hover (indica que es clickable) */
.card .card-go {
  position: absolute; right: 16px; bottom: 16px;
  font-size: 18px; color: var(--gold);
  opacity: 0; transform: translateX(-8px);
  transition: opacity .18s, transform .18s;
}
.card:hover .card-go { opacity: 1; transform: translateX(0); }
.panel {
  background: linear-gradient(160deg, var(--bg2), #191c25);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 22px; margin-top: 18px;
}
.panel h3 { margin-top: 0; }
.muted { color: var(--text-dim); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

/* ---------- hero (inicio) ---------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, #20242f 0%, #181b24 70%);
  border: 1px solid var(--border-soft);
  border-radius: 18px; padding: 28px 28px 24px;
  box-shadow: var(--shadow);
}
.hero::before {
  content: '♞'; position: absolute; right: -18px; top: -38px;
  font-size: 190px; line-height: 1; color: rgba(224, 170, 62, 0.07);
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif;
  pointer-events: none;
}
.hero h1 { margin: 0 0 4px; font-size: 28px; }
.hero .hero-sub { color: var(--text-dim); margin: 0 0 16px; }
.stat-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px; font-size: 13.5px;
}
.chip .chip-label { color: var(--text-dim); }
.chip.chip-elo {
  background: linear-gradient(145deg, rgba(224, 170, 62, 0.22), rgba(224, 170, 62, 0.10));
  border-color: rgba(224, 170, 62, 0.45);
  font-weight: 700;
}
.chip.chip-elo .chip-value { color: var(--gold2); font-size: 15px; font-variant-numeric: tabular-nums; }
.chip .chip-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.chip.chip-good .chip-value { color: var(--good); }
.chip.chip-bad .chip-value { color: #e08080; }

/* filtros por tema (puzzles): chips pulsables, opcionales */
.theme-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; }
.chip-btn {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chip-btn:hover { border-color: var(--gold2); }
.chip-btn.active {
  background: linear-gradient(145deg, rgba(224, 170, 62, 0.25), rgba(224, 170, 62, 0.12));
  border-color: var(--gold2); font-weight: 700;
}

/* ---------- forms ---------- */
input, select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 13px; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224, 170, 62, 0.18);
}
label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 5px; }
.btn {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 16px; font-size: 14px; cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, background .15s, transform .08s, box-shadow .15s;
  /* sin doble-toque-zoom al pulsar rápido (◀ ▶ ◀ ▶…): en móvil dos toques
     seguidos hacían zoom de página y «se veía menos el tablero». manipulation
     lo evita SIN quitar el zoom de accesibilidad de la página */
  touch-action: manipulation;
}
/* mismo blindaje para cualquier control interactivo (los que no son .btn:
   fichas de aperturas, chips de tema, lista de rivales, menú…) */
button, a, input, select, textarea, label { touch-action: manipulation; }
.btn:hover { border-color: var(--gold); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(224, 170, 62, 0.30); }
.btn.primary {
  background: linear-gradient(160deg, var(--gold2), var(--gold) 55%, var(--gold-deep));
  border-color: var(--gold-deep); color: #211804; font-weight: 700;
  box-shadow: 0 4px 14px rgba(224, 170, 62, 0.28);
}
.btn.primary:hover { filter: brightness(1.06); border-color: var(--gold); }
.btn.danger { background: linear-gradient(160deg, #c65a5a, #a63f3f); border-color: #8f3535; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.form-error { color: #e88; font-size: 14px; margin-top: 10px; min-height: 18px; }

/* ---------- auth ---------- */
.auth-wrap {
  max-width: 410px; margin: 7vh auto 0;
  background: linear-gradient(165deg, #20242f, #171a22);
  border: 1px solid var(--border-soft);
  border-radius: 20px; padding: 36px 34px 30px;
  box-shadow: var(--shadow);
  animation: popIn .35s ease both;
  position: relative; overflow: hidden;
}
.auth-wrap::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.auth-logo {
  width: 66px; height: 66px; margin: 0 auto 14px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; font-size: 38px;
  color: #1d1608;
  background: linear-gradient(145deg, var(--gold2), var(--gold-deep));
  box-shadow: 0 8px 22px rgba(224, 170, 62, 0.35);
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif;
}
.auth-wrap h1 { text-align: center; margin: 0 0 4px; font-family: Georgia, "Times New Roman", serif; }
.auth-wrap h1 b { color: var(--gold); }
.auth-wrap .sub { text-align: center; color: var(--text-dim); margin: 0 0 10px; font-size: 14.5px; }
.auth-wrap input { width: 100%; }
/* campo de contraseña con ojito 👁 para ver lo escrito */
.pass-wrap { position: relative; }
.pass-wrap input { width: 100%; padding-right: 44px; }
.pass-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 17px;
  padding: 6px; line-height: 1; opacity: 0.75; border-radius: 6px;
}
.pass-toggle:hover, .pass-toggle:focus-visible { opacity: 1; background: var(--border-soft); outline: none; }
.auth-wrap .btn.primary { width: 100%; margin-top: 20px; padding: 12px; font-size: 15px; }
.auth-toggle { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-dim); }
.auth-toggle button { background: none; border: none; color: var(--gold2); cursor: pointer; font-size: 14px; font-weight: 600; }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px; color: var(--text-dim); font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.btn.google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #3c4043; border-color: #dadce0;
  font-weight: 600; padding: 11px;
}
.btn.google:hover { border-color: #a7a7a7; filter: none; }
/* botón de acción principal: «Comenzar partida» debe destacar */
.btn-lg { font-size: 17px; padding: 14px 32px; border-radius: 14px; font-weight: 700; }
.auth-features { margin: 20px 0 0; padding: 14px 0 0; border-top: 1px dashed var(--border); }
.auth-features div { font-size: 13.5px; color: var(--text-dim); padding: 3px 0; }
.auth-features div b { color: var(--text); font-weight: 600; }
/* acceso con Google como método principal: botón grande y nota */
#auth-google .btn.google { width: 100%; padding: 12px; font-size: 15.5px; justify-content: center; margin-top: 8px; }
.auth-google-note { text-align: center; font-size: 13px; color: var(--text-dim); margin: 8px 0 0; }
/* acceso clásico (cuentas locales anteriores a Google): plegado y discreto */
.auth-alt { text-align: center; margin-top: 14px; }
.auth-alt button { background: none; border: none; color: var(--gold2); cursor: pointer; font-size: 13.5px; font-weight: 600; text-decoration: underline; }
/* pantalla «elige tu nombre» (primer acceso con Google) */
.cu-hint { min-height: 20px; font-size: 13.5px; margin-top: 6px; }
.cu-hint.ok { color: #7bc47f; }
.cu-hint.warn { color: var(--gold2); }
.cu-hint.bad { color: #e88; }

/* ---------- board ---------- */
.board-wrap { width: min(92vw, 560px); margin: 0 auto; }
.board {
  position: relative; width: 100%; aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  border-radius: 8px; overflow: hidden; touch-action: pan-y;
  box-shadow:
    0 0 0 6px #2a2118,
    0 0 0 7px rgba(224, 170, 62, 0.35),
    0 18px 44px rgba(0, 0, 0, 0.55);
  user-select: none; -webkit-user-select: none;
}
.sq { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
/* las casillas sangran 1px a la derecha y abajo sobre la vecina (z-index 1,
   por encima del fondo de la vecina pero bajo piezas y marcas): las costuras
   sub-píxel del grid desaparecen y el tablero deja de tener «líneas más
   finas que otras». El fondo se hereda (incluidos .last/.sel); el sobrante
   lo recorta el overflow del tablero. OJO: .hint::before comparte este
   pseudo (solo cambia la imagen de fondo, más específica) */
.sq::before { content: ''; position: absolute; top: 0; left: 0; right: -1px; bottom: -1px; background: inherit; z-index: 1; }
/* casilla CON pieza: al tocarla la página NO se desliza (estás arrastrando
   la pieza, no quieres que «se mueva la imagen»); las vacías conservan el
   pan-y del tablero para poder deslizar la página desde el tablero */
.sq.has-piece { touch-action: none; }
.sq.light { background: var(--light-sq); }
.sq.dark { background: var(--dark-sq); }
/* resaltado de la última jugada/selección: DEGRADADO SUTIL (no opaco): si
   fuera un color sólido, dos casillas seguidas resaltadas (capturas cxd4,
   exd5…) se veían «del mismo color» y parecía que el tablero fallaba */
.sq.last { background-image: linear-gradient(rgba(255, 205, 80, 0.30), rgba(255, 205, 80, 0.30)); }
.sq.sel { background-image: linear-gradient(rgba(255, 205, 80, 0.42), rgba(255, 205, 80, 0.42)); }
.sq.mark::after {
  content: ''; position: absolute; width: 28%; height: 28%; border-radius: 50%;
  background: var(--mark); z-index: 2;
}
.sq.target::after {
  content: ''; position: absolute; width: 26%; height: 26%; border-radius: 50%;
  background: rgba(20, 50, 20, 0.4); z-index: 2;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}
.sq.hint::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(20, 60, 20, 0.35), rgba(20, 60, 20, 0.35));
}
.sq.check::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(230, 60, 60, 0.85) 12%, rgba(230, 60, 60, 0.25) 55%, transparent 75%);
}
.board-arrow { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }

/* ---------- barra de evaluación ---------- */
.board-area { display: flex; gap: 12px; align-items: stretch; }
.board-area .board-wrap { flex: 1; margin: 0; }
.eval-bar {
  width: 20px; border-radius: 10px; background: #22252e; overflow: hidden;
  position: relative; display: flex; flex-direction: column-reverse; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px var(--border), 0 6px 16px rgba(0, 0, 0, 0.3);
}
.eval-bar.flipped { flex-direction: column; }
.eval-fill { background: linear-gradient(180deg, #fff, #d9d9d9); width: 100%; height: 50%; transition: height .35s ease; }
.eval-num {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 9px; font-weight: 700; color: #fff; mix-blend-mode: difference;
  writing-mode: vertical-rl; pointer-events: none; white-space: nowrap;
}
.piece {
  font-size: calc(var(--bsq, min(92vw, 560px) / 8) * 0.78);
  line-height: 1; z-index: 2; pointer-events: none;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif;
  transition: transform .1s;
}
.piece.white { color: #fafafa; text-shadow: 0 0 2px #333, 1px 1px 0 #333, -1px -1px 0 #555; }
.piece.black { color: #1c1c1c; text-shadow: 0 0 2px #888, 1px 1px 0 #555; }
.coord { position: absolute; bottom: 2px; right: 3px; font-size: calc(var(--bsq, 70px) * 0.15); opacity: .85; font-weight: 700; pointer-events: none; z-index: 3; }
.sq.light .coord { color: var(--dark-sq); }
.sq.dark .coord { color: var(--light-sq); }
.drag-ghost {
  position: absolute; z-index: 10; pointer-events: none;
  color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.6);
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif;
}
.drag-src .piece { opacity: .35; }
.promo-chooser { position: absolute; z-index: 20; display: flex; flex-direction: column; width: 12.5%; box-shadow: 0 6px 24px rgba(0,0,0,.5); border-radius: 6px; overflow: hidden; }
.promo-chooser.up { flex-direction: column-reverse; }
.promo-btn {
  flex: 1; border: 1px solid var(--gold-deep); background: var(--bg2); cursor: pointer;
  font-size: calc(var(--bsq, min(92vw, 560px) / 8) * 0.6); color: var(--text);
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif;
}
.promo-btn:hover { background: var(--gold); color: #211804; }

/* ---------- entrenador ---------- */
.coach {
  background: linear-gradient(160deg, var(--bg2), #191c25);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--gold);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.coach.good { border-left-color: var(--good); background: linear-gradient(160deg, rgba(129,182,76,.10), #191c25 60%); }
.coach.meh { border-left-color: var(--gold); background: linear-gradient(160deg, rgba(224,170,62,.10), #191c25 60%); }
.coach.bad { border-left-color: var(--bad); background: linear-gradient(160deg, rgba(208,91,91,.12), #191c25 60%); }
.coach-head { display: flex; align-items: center; gap: 10px; }
.coach-ava {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: linear-gradient(145deg, var(--gold2), var(--gold-deep));
  box-shadow: 0 3px 8px rgba(224, 170, 62, 0.3);
}
.coach.good .coach-ava { background: linear-gradient(145deg, #9ed06a, var(--good-deep)); }
.coach.bad .coach-ava { background: linear-gradient(145deg, #e08080, #a04040); }
.coach-title { font-weight: 700; font-size: 14px; flex: 1; }
.coach.good .coach-title { color: var(--good); }
.coach.bad .coach-title { color: #e08080; }
.coach.meh .coach-title { color: var(--gold2); }
.coach-msg { margin-top: 9px; font-size: 15px; line-height: 1.5; }
.coach-history { margin-top: 9px; font-size: 12px; color: var(--text-dim); max-height: 76px; overflow-y: auto; }
.coach-history div { padding: 2px 0; border-top: 1px dashed var(--border); }

/* ---------- game layout ---------- */
.game-layout {
  display: grid; grid-template-columns: 230px 1fr 230px; gap: 22px; align-items: start;
}
@media (max-width: 940px) { .game-layout { grid-template-columns: 1fr; } }
.game-side { display: flex; flex-direction: column; gap: 12px; }
.player-card {
  background: linear-gradient(160deg, var(--bg2), #191c25);
  border: 1px solid var(--border-soft); border-radius: 12px; padding: 13px 15px;
  transition: border-color .2s, box-shadow .2s;
}
.player-card.active {
  border-color: rgba(224, 170, 62, 0.55);
  box-shadow: 0 0 0 1px rgba(224, 170, 62, 0.25), 0 6px 18px rgba(224, 170, 62, 0.10);
}
.player-card.active .pc-name::after {
  content: '●'; color: var(--gold); font-size: 10px; margin-left: 7px; vertical-align: middle;
}
.pc-name { font-weight: 650; display: block; }
.pc-sub { color: var(--text-dim); font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pc-elo-tag {
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold2); font-size: 12.5px;
  background: rgba(224, 170, 62, 0.12); border: 1px solid rgba(224, 170, 62, 0.30);
  padding: 1px 8px; border-radius: 999px;
}
.pc-mat { display: block; margin-top: 6px; font-size: 16px; min-height: 20px; line-height: 1; }
/* reloj de partida (opcional): aparece en la tarjeta del jugador */
.pc-clock {
  display: inline-block; margin-top: 7px; padding: 2px 10px;
  font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--bg3); border: 1px solid var(--border-soft); border-radius: 8px;
  color: var(--text-dim); transition: color .2s, border-color .2s, background .2s;
}
.pc-clock.active { color: #f2f2f2; border-color: rgba(224, 170, 62, 0.55); background: rgba(224, 170, 62, 0.10); }
.pc-clock.low { color: #e05c5c; border-color: rgba(224, 92, 92, 0.6); }
.pc-clock.low.active { background: rgba(224, 92, 92, 0.12); }
.tp-setup { margin: 12px 0 4px; }
.tp-setup label { margin-bottom: 4px; }
/* revisión post-partida: ⏮ ◀ ▶ ⏭ + resaltado de la jugada en la lista */
.replay-bar { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.replay-label { font-size: 12px; color: var(--text-dim); margin-right: 2px; }
.replay-bar .btn { padding: 6px 10px; font-size: 14px; }
.replay-bar .btn:disabled { opacity: 0.35; cursor: default; }
.game-moves .mv { padding: 1px 5px; border-radius: 4px; margin-right: 2px; font-weight: 600; }
.game-moves .mv.active { background: rgba(224, 170, 62, 0.32); color: #fff; }
.game-moves .mv-num { color: var(--text-dim); margin-right: 5px; }
/* ---- revisión de partida (Perfil): modal ancho, categorías y progreso ---- */
.modal.wide { max-width: 900px; width: 94vw; }
/* el tablero tiene ancho fijo (min(92vw,560px)) y DESBORDARÍA su columna
   tapando la lista: en la revisión se acota al 100% de ella */
.rev-layout { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 18px; margin-top: 12px; align-items: start; }
#rev-board { width: 100%; max-width: 400px; margin: 0; }
.rev-moves { min-width: 0; }
@media (max-width: 720px) {
  .rev-layout { grid-template-columns: 1fr; }
  #rev-board { max-width: 100%; }
}
.rev-moves ol { max-height: 420px; overflow-y: auto; }
.rev-progress { position: relative; background: var(--bg3); border: 1px solid var(--border-soft); border-radius: 10px; height: 30px; margin-top: 8px; overflow: hidden; }
.rev-progress.hidden { display: none; }
#rev-progress-fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: rgba(224, 170, 62, 0.25); transition: width .2s; }
#rev-progress-txt { position: relative; display: flex; align-items: center; justify-content: center; height: 100%; font-size: 13px; color: var(--text-dim); }
.rev-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; min-height: 26px; }
.rev-chip { font-size: 12.5px; font-weight: 650; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border-soft); background: var(--bg3); }
/* colores de categoría (SAN de la lista y chips). TODAS llevan border-color
   translúcido a juego con el texto: si solo algunas lo tienen (como antes),
   en el resumen unas chips muestran la raya de color brillante y otras el
   borde gris por defecto → "una raya más pequeña que otra". */
.cat-brilliant  { color: #6fd6ff; border-color: rgba(111, 214, 255, 0.5) !important; }
.cat-best       { color: #9ece6a; border-color: rgba(158, 206, 106, 0.5) !important; }
.cat-great      { color: #7ee0b8; border-color: rgba(126, 224, 184, 0.5) !important; }
.cat-excellent  { color: #a9d18e; border-color: rgba(169, 209, 142, 0.45) !important; }
.cat-inaccuracy { color: #e8c56b; border-color: rgba(232, 197, 107, 0.45) !important; }
.cat-mistake    { color: #e8975c; border-color: rgba(232, 151, 92, 0.5) !important; }
.cat-blunder    { color: #e05c5c; border-color: rgba(224, 92, 92, 0.5) !important; }
.cat-book       { color: var(--text-dim); border-color: rgba(148, 158, 175, 0.35) !important; }
/* en la lista de movimientos el grosor es UNIFORME (antes la pésima pesaba
   700 y la activa 650: "líneas más finas que otras"); la pésima se distingue
   por subrayado y la activa por el fondo dorado */
.game-moves .mv.cat-blunder { font-weight: 600; text-decoration: underline; text-decoration-color: rgba(224, 92, 92, 0.55); text-underline-offset: 2px; }
.cat-book       { color: var(--text-dim); }
.game-moves .mv.cat-brilliant, .game-moves .mv.cat-best, .game-moves .mv.cat-great,
.game-moves .mv.cat-excellent, .game-moves .mv.cat-inaccuracy, .game-moves .mv.cat-mistake,
.game-moves .mv.cat-blunder, .game-moves .mv.cat-book { border-radius: 4px; }
.game-moves .mv.active { color: #fff; }
.mat-piece { font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif; margin-right: -2px; }
.mat-piece.white { color: #fafafa; text-shadow: 0 0 2px #333, 1px 1px 0 #333; }
.mat-piece.black { color: #1c1c1c; text-shadow: 0 0 2px #999, 1px 1px 0 #777; }
.mat-score { font-size: 12px; font-weight: 700; margin-left: 7px; font-variant-numeric: tabular-nums; }
.mat-score.up { color: var(--good); }
.mat-score.down { color: #e88; }
.game-status {
  background: var(--bg3); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 12px 15px; font-size: 14px; min-height: 44px;
}
.game-actions { display: flex; flex-direction: column; gap: 8px; }
.game-moves {
  background: linear-gradient(160deg, var(--bg2), #191c25);
  border: 1px solid var(--border-soft); border-radius: 12px; padding: 13px 15px;
  max-height: 480px; overflow-y: auto;
}
.game-moves h3 { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.game-moves ol { margin: 0; padding-left: 22px; font-size: 14px; line-height: 1.75; font-variant-numeric: tabular-nums; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; }
.clock.low { color: #e88; }

/* ---------- lessons ---------- */
.lesson-layout { display: grid; grid-template-columns: 1fr 330px; gap: 22px; align-items: start; }
@media (max-width: 940px) { .lesson-layout { grid-template-columns: 1fr; } }
.lesson-text {
  background: linear-gradient(160deg, var(--bg2), #191c25);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 22px; min-height: 200px;
}
.lesson-text h2 { margin-top: 0; }
.lesson-text .task {
  background: var(--bg3); border-left: 3px solid var(--gold);
  padding: 11px 15px; border-radius: 8px; margin-top: 14px; font-size: 14.5px;
}
.lesson-text .task.bad { border-left-color: var(--bad); background: rgba(208, 91, 91, 0.10); }
.lesson-text .task.good { border-left-color: var(--good); background: rgba(129, 182, 76, 0.10); }
.lesson-nav { display: flex; justify-content: space-between; margin-top: 18px; gap: 10px; }
.progressbar {
  height: 8px; background: var(--bg3); border-radius: 5px; margin-top: 12px;
  overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
}
.progressbar > div {
  height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold2));
  transition: width .35s ease;
}

/* «Repasa tus errores»: espera del análisis EN GRANDE (con barra de progreso) */
.me-analyzing { text-align: center; padding: 64px 20px 34px; }
.me-analyzing-title {
  font-size: 27px; font-weight: 700; letter-spacing: -0.01em;
  animation: mePulse 1.6s ease-in-out infinite;
}
.me-analyzing .me-bar { max-width: 440px; height: 12px; margin: 20px auto 0; }
@keyframes mePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- selector de rival ---------- */
.player-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 10px; margin-top: 14px; max-height: 430px; overflow-y: auto; padding: 2px 4px 2px 2px;
}
/* bandas de ELO dentro de la lista de rivales: cabecera a todo lo ancho */
.pg-band { grid-column: 1 / -1; margin: 12px 0 -4px; }
.pg-band:first-child { margin-top: 2px; }
.pg-band .band-sub { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: var(--gold2); }
/* meses dentro de la biblioteca: cabecera pegada a su primera partida */
.lb-month { margin: 18px 0 -2px; }
.lb-month:first-child { margin-top: 4px; }
.player-cell {
  display: flex; align-items: center; gap: 11px; text-align: left;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-soft); border-radius: 12px; padding: 10px 13px;
  cursor: pointer; font-size: 14px; font-family: inherit;
  transition: border-color .12s, background .12s, transform .1s, box-shadow .15s;
}
.player-cell:hover { border-color: var(--gold); transform: translateY(-1px); }
.player-cell.selected {
  border-color: var(--gold); background: linear-gradient(160deg, rgba(224,170,62,.14), var(--bg3));
  box-shadow: 0 0 0 1px var(--gold), 0 6px 16px rgba(224, 170, 62, 0.15);
}
.pc-ava {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(145deg, #39415a, #232836);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: var(--gold2);
}
.player-cell.selected .pc-ava { border-color: var(--gold); color: #211804; background: linear-gradient(145deg, var(--gold2), var(--gold-deep)); }
.pc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pc-top { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-flag { color: var(--text-dim); font-size: 12px; }
.pc-bottom { color: var(--text-dim); font-size: 12px; }
.pc-title { color: var(--text); }
.pc-elo {
  font-weight: 800; font-variant-numeric: tabular-nums; color: var(--gold2); font-size: 15px;
  background: rgba(224, 170, 62, 0.12); border: 1px solid rgba(224, 170, 62, 0.30);
  padding: 3px 9px; border-radius: 999px;
}

/* ---------- listas ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: 12px;
  padding: 12px 16px; margin-top: 10px;
}
.list-item .grow { flex: 1; min-width: 0; }
/* análisis por fases: la fase más débil resaltada + consejo del entrenador */
.list-item.phase-weak { border-color: rgba(224, 170, 62, 0.55); background: linear-gradient(145deg, rgba(224, 170, 62, 0.10), rgba(224, 170, 62, 0.04)); }
.phase-flag { color: var(--gold2); font-size: 12.5px; font-weight: 700; }
.coach-tip-line {
  margin-top: 12px; padding: 10px 14px;
  background: var(--bg3); border: 1px dashed var(--border);
  border-radius: 10px; color: var(--text-dim); line-height: 1.5;
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.on { background: var(--good); box-shadow: 0 0 6px rgba(129, 182, 76, 0.8); }
.dot.off { background: #5a6070; }
.elo-delta.up { color: var(--good); font-weight: 700; font-variant-numeric: tabular-nums; }
.elo-delta.down { color: #e88; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- modal ---------- */
#modal-root {
  position: fixed; inset: 0;
  background: rgba(8, 10, 14, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  position: relative;
  background: linear-gradient(165deg, #222633, #181b23);
  border: 1px solid var(--border);
  border-radius: 18px; padding: 30px; max-width: 470px; width: 92vw;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: popIn .22s ease both;
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 15px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.modal-close:hover { color: var(--text); border-color: var(--gold); }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(160deg, var(--bg4), var(--bg3));
  border: 1px solid var(--gold-deep); color: var(--text);
  padding: 11px 22px; border-radius: 12px; z-index: 200; font-size: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  animation: toastIn .25s ease both;
}

/* ---- logros ---- */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 10px; }
.ach { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border-soft); background: var(--bg2); }
.ach.got { border-color: rgba(224, 170, 62, 0.45); box-shadow: 0 0 0 1px rgba(224, 170, 62, 0.15); }
.ach.locked { opacity: 0.55; filter: grayscale(0.6); }
.ach-icon { font-size: 24px; }
.ach-title { font-weight: 700; font-size: 14px; }
.ach-desc { font-size: 12.5px; color: var(--text-dim); }

/* ---- gráfica de ELO ---- */
.elo-graph { width: 100%; height: 120px; display: block; margin-top: 10px; background: var(--bg3); border: 1px solid var(--border-soft); border-radius: 10px; }
.elo-line { fill: none; stroke: var(--gold); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.elo-dot { fill: var(--gold); }
.elo-grid { stroke: var(--border-soft); stroke-width: 1; stroke-dasharray: 4 5; }
.elo-lbl { fill: var(--text-dim); font-size: 11px; }

/* ---- tarjeta desafío diario ---- */
.daily-card { border-color: rgba(224, 170, 62, 0.5); background: linear-gradient(160deg, rgba(224, 170, 62, 0.12), var(--bg2) 55%); }

/* ---- explorador de aperturas ---- */
.open-layout { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 18px; margin-top: 16px; align-items: start; }
@media (max-width: 860px) { .open-layout { grid-template-columns: 1fr; } }
.open-list { display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow-y: auto; }
.open-item { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-soft); background: var(--bg3); cursor: pointer; font-size: 13.5px; }
/* familias de aperturas dentro de la lista (1.e4 / 1.d4 / 1.c4 / otras) */
.open-group { display: flex; align-items: center; gap: 8px; margin: 12px 0 2px; font-size: 11.5px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .07em; }
.open-group:first-child { margin-top: 0; }
/* línea divisora: 2 px SIEMPRE (con 1 px el redondeo de píxeles pintaba
   algunas de 1 y otras de 2 según la posición: «más finas que otras») */
.open-group::after { content: ''; flex: 1; height: 2px; border-radius: 1px; background: var(--border-soft); }
/* aperturas propias: botón + ✕ de borrado a su lado */
.open-item-wrap { display: flex; gap: 4px; align-items: stretch; }
.open-item-wrap .open-item { flex: 1; min-width: 0; }
.open-del {
  flex: none; width: 30px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-soft); background: var(--bg3); color: var(--text-dim);
  font-size: 13px; line-height: 1;
}
.open-del:hover { border-color: #e05c5c; color: #e08080; }
/* línea en vivo del creador de aperturas */
.ob-line {
  background: var(--bg); border: 1px dashed var(--border); border-radius: 10px;
  padding: 10px 12px; min-height: 40px; font-size: 13.5px; line-height: 1.6; word-break: break-word;
}
.open-item span { font-size: 12px; }
.open-item:hover { border-color: var(--gold-deep); }
.open-item.selected { border-color: var(--gold); background: rgba(224, 170, 62, 0.10); }
.open-detail #open-board { width: 100%; max-width: 380px; margin: 0; }

/* ---- torneo de bots ---- */
.tn-seeds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tn-seeds label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 3px; }
.tn-seeds select { width: 100%; }
.tn-bracket { display: flex; gap: 18px; margin-top: 16px; overflow-x: auto; padding-bottom: 6px; }
.tn-round { display: flex; flex-direction: column; gap: 10px; min-width: 170px; }
.tn-round h4 { margin: 0 0 4px; font-size: 13px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.4px; }
.tn-match { border: 1px solid var(--border-soft); border-radius: 10px; padding: 8px 10px; background: var(--bg3); font-size: 13.5px; }
.tn-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.tn-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.tn-row.win { color: var(--gold); font-weight: 700; }
.tn-elo { color: var(--text-dim); font-size: 11.5px; }
.tn-champ { text-align: center; font-size: 15px; font-weight: 700; padding: 14px 10px; border: 1px solid rgba(224, 170, 62, 0.55); border-radius: 12px; background: rgba(224, 170, 62, 0.10); }

/* ---- base móvil de cabecera, modal y listas; la navegación inferior y la
   hoja Explorar se definen en la sección final, sin pestañas desplazables ---- */
@media (max-width: 720px) {
  #topbar { gap: 10px; padding: 8px 12px; flex-wrap: nowrap; overflow-x: auto; }
  #mainnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #mainnav::-webkit-scrollbar { display: none; }
  #mainnav a { white-space: nowrap; padding: 8px 12px; font-size: 13.5px; }
  .brand-name { display: none; }
  .modal { padding: 18px; }
  .game-moves ol, .game-moves li { overflow-wrap: anywhere; }
  .rev-layout { grid-template-columns: 1fr; }
  .userbox .btn { padding: 6px 8px; }
}

/* ---- novedades: flechas/racha/clasificación/aperturas/rush/emotes ---- */
.chip-streak { color: #ff9d3c; font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-row .lb-rank { width: 34px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.lb-row.me { background: rgba(129, 182, 76, 0.10); border: 1px solid rgba(129, 182, 76, 0.35); border-radius: 10px; padding: 6px 8px; margin: 2px -8px; }
.mini-bar { display: inline-block; width: 90px; height: 8px; border-radius: 4px; background: var(--bg3, #2a2f36); overflow: hidden; }
.mini-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #6fbf4a, #b7e07f); }
textarea { background: var(--bg2); border: 1px solid var(--border-soft); color: var(--text); border-radius: 10px; padding: 10px; font: inherit; font-size: 13.5px; resize: vertical; }
textarea:focus { outline: none; border-color: var(--gold); }

/* Puzzle Rush */
.rush-hud { display: flex; align-items: center; gap: 18px; padding: 10px 14px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--bg2); flex-wrap: wrap; }
.rush-clock { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rush-clock.low { color: #e05c5c; }
.rush-lives { font-size: 17px; letter-spacing: 2px; }
.rush-score { font-size: 16px; }
.rush-menu .btn, .rush-over .btn { padding: 12px 18px; }
.rush-card { border-color: rgba(224, 170, 62, 0.5); background: linear-gradient(180deg, rgba(224, 170, 62, 0.10), transparent); }

/* emotes en online */
.emote-bar { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.emote-btn { font-size: 19px; padding: 4px 8px; background: var(--bg2); border: 1px solid var(--border-soft); border-radius: 10px; cursor: pointer; line-height: 1; }
.emote-btn:hover { border-color: var(--gold); }
.emote-float { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); font-size: 64px; pointer-events: none; z-index: 6; animation: emote-pop 2.2s ease forwards; text-shadow: 0 2px 14px rgba(0,0,0,.55); }
.emote-float.mine { font-size: 44px; top: 62%; opacity: .85; }
.board-area { position: relative; }
@keyframes emote-pop {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  12% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  22% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -56%) scale(1); opacity: 0; }
}

/* «¿Y si...?» y «a ciegas»: botones activos */
.game-actions .btn.primary { border-color: var(--gold); }

/* chat en la partida online */
.og-chat h4 { margin: 0; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.og-chat-log { margin-top: 6px; max-height: 170px; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; background: var(--bg2); border: 1px solid var(--border-soft); border-radius: 10px; padding: 8px 10px; }
.og-chat-msg { font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
.og-chat-msg .who { font-weight: 700; color: var(--gold); margin-right: 6px; }
.og-chat-msg.mine .who { color: #7ec8ff; }
.og-chat-form { display: flex; gap: 6px; margin-top: 6px; }
.og-chat-form input[type="text"] { flex: 1; min-width: 0; }

/* a ciegas: los puntitos de destino siguen viéndose para jugar legal */

/* ---- pestañas nuevas: Adivina / Estadísticas / Biblioteca ---- */
.guess-hud { display: flex; gap: 22px; padding: 10px 14px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--bg2); font-size: 15px; flex-wrap: wrap; }
.guess-hud b { color: var(--gold2, #e0aa3e); font-variant-numeric: tabular-nums; }

/* puntos de resultado (estadísticas y biblioteca) */
.result-dots { display: flex; gap: 5px; flex-wrap: wrap; margin: 6px 0 4px; }
.rdot { width: 18px; height: 18px; border-radius: 50%; display: inline-block; flex: none; }
.rdot.w { background: linear-gradient(135deg, #7ed957, #4a9e2f); }
.rdot.d { background: linear-gradient(135deg, #cfd8dc, #90a4ae); }
.rdot.l { background: linear-gradient(135deg, #e57373, #c62828); }

.lb-game { align-items: center; gap: 10px; }
.lb-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: rgba(129, 182, 76, 0.14); border: 1px solid rgba(129, 182, 76, 0.4); font-size: 12px; margin: 0 4px; }

/* ---- estadísticas: barra de distribución V/T/D y datos clave ---- */
.dist-bar { display: flex; height: 28px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-soft); margin: 4px 0 10px; }
.dist-bar > span { display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; color: #12141a; min-width: 0; }
.dist-bar .seg-w { background: linear-gradient(180deg, #8fce5f, #6aab3e); }
.dist-bar .seg-d { background: linear-gradient(180deg, #e3d285, #c9b25e); }
.dist-bar .seg-l { background: linear-gradient(180deg, #e58a7a, #cf5f56); }
.hl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.hl-item { background: var(--bg3); border: 1px solid var(--border-soft); border-radius: 12px; padding: 16px 12px; text-align: center; }
.hl-item .hl-num { font-size: 27px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hl-item .hl-num.up { color: var(--good); }
.hl-item .hl-num.down { color: var(--bad); }
.hl-item .hl-num.flat { color: var(--text-dim); }
.hl-item .hl-num.gold { color: var(--gold2); }
.hl-item .hl-lbl { font-size: 12.5px; color: var(--text-dim); margin-top: 6px; line-height: 1.4; }

/* ---- entrenador de finales ---- */
.eg-hud { display: flex; gap: 20px; padding: 10px 14px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--bg2); font-size: 14.5px; flex-wrap: wrap; margin-top: 8px; }
.eg-hud b { color: var(--gold2); font-variant-numeric: tabular-nums; }

/* ---- modo espectador ---- */
.sp-layout { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 16px; margin-top: 10px; align-items: start; }
.sp-moves ol { max-height: 320px; overflow-y: auto; }
.badge-ingame { display: inline-block; padding: 1px 8px; border-radius: 999px; background: rgba(129, 182, 76, 0.14); border: 1px solid rgba(129, 182, 76, 0.4); font-size: 12px; margin-left: 6px; }
@media (max-width: 720px) { .sp-layout { grid-template-columns: 1fr; } }

/* ---- modo zen: insignia informativa en la barra de acciones ---- */
.zen-badge { display: flex; flex-direction: column; gap: 2px; padding: 8px 14px; border-radius: 12px; background: linear-gradient(150deg, rgba(111, 214, 255, 0.14), rgba(111, 214, 255, 0.05)); border: 1px solid rgba(111, 214, 255, 0.4); font-weight: 700; color: #8fd8f2; font-size: 14px; }
.zen-badge .zen-sub { font-weight: 400; font-size: 11.5px; color: var(--text-dim); }

/* ---- tarjeta alargada (retos): a todo lo ancho, más fina ---- */
.card-wide { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 14px 20px; }
.card-wide h3 { margin: 0 0 3px; font-size: 16px; }
.card-wide .card-icon { width: 40px; height: 40px; font-size: 21px; border-radius: 11px; flex-shrink: 0; }
.card-wide .card-go { position: static; opacity: 1; transform: none; margin-left: auto; font-size: 20px; }
@media (max-width: 720px) {
  .card-wide { padding: 12px 16px; gap: 12px; }
}

/* ---- estadísticas: gráfica de precisión ---- */
.acc-chart { width: 100%; height: 110px; display: block; background: var(--bg3); border: 1px solid var(--border-soft); border-radius: 10px; }

/* Portada de acceso e identidad de cuenta */
#view:has(.auth-page) { max-width: none; padding: 0; }
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); max-width: 1240px; margin: 0 auto; }
.auth-showcase { display: flex; flex-direction: column; justify-content: center; padding: clamp(36px, 7vw, 86px); position: relative; overflow: hidden; }
.auth-showcase::after { content: '♞'; position: absolute; right: -45px; bottom: -85px; font-size: 330px; line-height: 1; color: rgba(224,170,62,.045); pointer-events: none; }
.auth-brand { display: flex; align-items: center; gap: 14px; font: 700 27px Georgia, serif; margin-bottom: 48px; position: relative; z-index: 1; }
.auth-brand b { color: var(--gold); }
.auth-brand .auth-logo { margin: 0; width: 54px; height: 54px; font-size: 31px; }
.auth-kicker { color: var(--gold2); font-size: 11px; font-weight: 800; letter-spacing: .18em; margin: 0 0 12px; }
.auth-showcase h1 { font: 600 clamp(40px, 5vw, 65px)/1.04 Georgia, serif; letter-spacing: -.035em; margin: 0 0 22px; position: relative; z-index: 1; }
.auth-showcase h1 em { color: var(--gold2); font-weight: 500; }
.auth-lead { color: var(--text-dim); max-width: 570px; font-size: 17px; line-height: 1.65; margin: 0 0 30px; }
.auth-showcase .auth-features { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; border: 0; padding: 0; margin: 0; position: relative; z-index: 1; }
.auth-showcase .auth-features div { display: grid; grid-template-columns: 25px 1fr; padding: 0; }
.auth-showcase .auth-features b { font-size: 14px; }
.auth-showcase .auth-features span { grid-column: 2; color: var(--text-dim); font-size: 12.5px; line-height: 1.45; margin-top: 4px; }
.auth-card { align-self: center; margin: 30px; padding: clamp(26px, 4vw, 44px); background: linear-gradient(160deg, #222631, #171a22); border: 1px solid var(--border); border-radius: 24px; box-shadow: 0 26px 80px rgba(0,0,0,.38); }
.auth-card h2 { font: 600 29px Georgia, serif; margin: 0 0 8px; }
.auth-card .sub { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin: 0 0 24px; }
.auth-card input, .auth-card select { width: 100%; }
.auth-card .btn.primary { width: 100%; margin-top: 16px; }
.auth-mobile-logo { display: none; }
.google-mark { width: 21px; height: 21px; flex: none; }
.google-main { min-height: 52px; border-radius: 12px; text-decoration: none; font-size: 15px; }
.google-main:disabled { opacity: .7; }
.auth-setup { color: var(--text-dim); background: var(--bg3); border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.5; margin-top: 10px; }
.auth-setup strong { color: var(--gold2); }
.legacy-access { margin-top: 20px; border-top: 1px solid var(--border-soft); padding-top: 14px; }
.legacy-access summary { cursor: pointer; color: var(--text-dim); font-size: 13px; text-align: center; }
.legacy-access[open] summary { margin-bottom: 12px; }
.auth-card .auth-toggle { margin-top: 12px; }
.auth-card .auth-divider { margin: 20px 0 12px; }
.auth-card #a-guest { width: 100%; }
.guest-levels { margin-top: 10px; text-align: center; }
.guest-levels p { font-size: 12px; }
.guest-levels .row { justify-content: center; gap: 6px; }
.auth-legal { text-align: center; font-size: 11.5px; color: var(--text-dim); margin-top: 24px; }
.auth-legal a { color: var(--text-dim); }
.verify-code { text-align: center; font-size: 22px; letter-spacing: 8px; width: 100%; }
.nickname-wrap { margin-bottom: 30px; }
.identity-panel { display: flex; align-items: center; gap: 14px; }
.identity-panel h3 { margin: 0 0 3px; }
.identity-panel p { margin: 0; }
.identity-avatar { width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(145deg, var(--gold2), var(--gold-deep)); color: #211804; display: flex; align-items: center; justify-content: center; font-weight: 800; overflow: hidden; flex: none; }
.identity-avatar img { width: 100%; height: 100%; object-fit: cover; }
.identity-badge { display: inline-block; color: var(--good); border: 1px solid rgba(129,182,76,.35); border-radius: 999px; padding: 1px 7px; font-size: 11px; margin-left: 5px; }
#network-status { position: fixed; z-index: 100; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #6f3d24; color: #fff; border: 1px solid #ba794e; border-radius: 999px; padding: 8px 16px; box-shadow: var(--shadow); font-size: 13px; }
#install-btn[hidden] { display: none !important; }
body[data-mode="light"] .auth-card { background: linear-gradient(160deg, #fff, #f4f1e8); }
body { min-height: 100dvh; }
@media (max-width: 850px) {
  .auth-page { grid-template-columns: 1fr; min-height: auto; }
  .auth-showcase { padding: 34px 28px 18px; }
  .auth-brand { margin-bottom: 30px; }
  .auth-showcase h1 { font-size: 40px; }
  .auth-lead { margin-bottom: 20px; }
  .auth-card { margin: 20px auto 35px; width: min(100% - 32px, 480px); }
}
@media (max-width: 520px) {
  .auth-showcase { padding: 24px 22px 8px; }
  .auth-brand { margin-bottom: 24px; font-size: 23px; }
  .auth-showcase h1 { font-size: 34px; margin-bottom: 14px; }
  .auth-showcase .auth-features { display: none; }
  .auth-lead { font-size: 14px; line-height: 1.5; }
  .auth-card { margin-top: 16px; padding: 25px 22px; }
  .identity-panel { align-items: flex-start; flex-wrap: wrap; }
  .identity-panel .grow { min-width: 180px; }
}
@media (display-mode: standalone) {
  #topbar { padding-top: max(10px, env(safe-area-inset-top)); }
  #view { padding-bottom: max(70px, env(safe-area-inset-bottom)); }
}

/* ---- navegación principal y Explorar ---- */
.brand { color: var(--text); text-decoration: none; flex: none; border-radius: 10px; }
.brand:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
#mainnav { flex-wrap: nowrap; min-width: 0; gap: 2px; }
#mainnav > a { padding: 8px 11px; }
.nav-dropdown { position: relative; flex: none; }
.nav-dropdown-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--text-dim); background: transparent; border: 0; border-radius: 999px;
  padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}
.nav-dropdown-toggle:hover { background: var(--bg3); color: var(--text); }
.nav-dropdown-toggle.active {
  color: var(--gold2); font-weight: 600;
  background: linear-gradient(150deg, rgba(224,170,62,.26), rgba(224,170,62,.11));
  box-shadow: inset 0 0 0 1px rgba(224,170,62,.45);
}
.nav-dropdown-toggle[aria-expanded="true"] { color: var(--gold2); background: var(--bg3); }
.nav-caret { font-size: 10px; transition: transform .18s ease; }
.nav-dropdown-toggle[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }
.nav-dropdown-menu {
  display: none; position: absolute; top: calc(100% + 12px); right: 0; z-index: 75;
  width: 440px; grid-template-columns: 1fr 1fr; gap: 4px; padding: 10px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 55px rgba(0,0,0,.42);
}
.nav-dropdown.is-open .nav-dropdown-menu { display: grid; animation: popIn .16s ease both; }
#mainnav .nav-dropdown-menu a {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 9px;
  color: var(--text-dim); font-size: 13.5px; transform: none;
}
#mainnav .nav-dropdown-menu a > span { width: 20px; text-align: center; }
#mainnav .nav-dropdown-menu a:hover { color: var(--text); background: var(--bg3); }
#mainnav .nav-dropdown-menu a.active { color: var(--gold2); background: rgba(224,170,62,.13); box-shadow: none; }
#mainnav .nav-dropdown-menu a.active::after { display: none; }
#mainnav a:focus-visible, .nav-dropdown-toggle:focus-visible, #user-chip:focus-visible,
.mobile-bottom-nav a:focus-visible, .mobile-bottom-nav button:focus-visible,
.mobile-explore a:focus-visible, .mobile-explore button:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.userbox { flex: none; margin-left: auto; }
#user-chip { text-decoration: none; cursor: pointer; max-width: 270px; }
#user-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#user-chip.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(224,170,62,.16); }
.mobile-bottom-nav, .mobile-explore { display: none; }
.mobile-explore.hidden { display: none !important; }

/* ---- comunidad ---- */
.feed-welcome {
  position: relative; overflow: hidden; padding: 28px;
  background: linear-gradient(135deg, #242936, #181b24 72%);
  border: 1px solid var(--border-soft); border-radius: 18px; box-shadow: var(--shadow);
}
.feed-welcome::after {
  content: '♞'; position: absolute; right: -8px; top: -45px; font-size: 175px;
  line-height: 1; color: rgba(224,170,62,.065); pointer-events: none;
}
.feed-welcome-copy { position: relative; z-index: 1; }
.feed-kicker, .feed-eyebrow {
  display: block; margin: 0 0 7px; color: var(--gold2); font-size: 10.5px;
  font-weight: 800; letter-spacing: .13em; text-transform: uppercase;
}
.feed-welcome h1 { margin: 0 0 5px; font-size: 29px; }
.feed-welcome-copy > p:last-child { margin: 0; color: var(--text-dim); }
.feed-welcome-bottom {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-top: 22px; flex-wrap: wrap;
}
.feed-ctas { display: flex; gap: 8px; flex-wrap: wrap; }
.feed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; margin-top: 20px; align-items: start; }
.feed-main { min-width: 0; }
.feed-composer, .feed-post, .feed-side-card {
  background: var(--bg2); border: 1px solid var(--border-soft); border-radius: var(--radius);
}
.feed-composer { padding: 18px 20px; }
.feed-composer h2 { margin: 0 0 12px; font-size: 16px; }
.feed-composer textarea { width: 100%; min-height: 96px; line-height: 1.55; }
.feed-composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.feed-counter { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.feed-counter.near-limit { color: var(--gold2); font-weight: 700; }
.feed-composer .form-error { margin-bottom: -8px; }
.feed-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 17px 0 12px; }
.feed-filters { display: flex; gap: 5px; flex-wrap: wrap; }
.feed-filter, .feed-refresh {
  color: var(--text-dim); background: transparent; border: 1px solid transparent;
  border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.feed-filter:hover, .feed-refresh:hover { color: var(--text); background: var(--bg3); }
.feed-filter.active { color: var(--gold2); background: rgba(224,170,62,.13); border-color: rgba(224,170,62,.35); font-weight: 700; }
.feed-filter:focus-visible, .feed-refresh:focus-visible, .feed-action:focus-visible,
.feed-comment-delete:focus-visible, .feed-filter:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.feed-filter:disabled, .feed-refresh:disabled { opacity: .45; cursor: wait; }
.feed-refresh { width: 35px; height: 35px; padding: 0; font-size: 20px; flex: none; }
.feed-notice { margin: 0 0 10px; color: var(--text-dim); font-size: 13px; }
.feed-notice.error { color: #e88; }
.feed-notice:empty { display: none; }
.feed-timeline { display: flex; flex-direction: column; gap: 13px; }
.feed-loading, .feed-empty { margin: 0; text-align: center; color: var(--text-dim); }
.feed-loading { padding: 36px 20px; background: var(--bg2); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.feed-empty { padding: 42px 24px; border: 1px dashed var(--border); border-radius: var(--radius); background: rgba(35,40,54,.35); }
.feed-empty > span { display: block; color: var(--gold); font-size: 34px; margin-bottom: 8px; }
.feed-empty h2 { color: var(--text); font-size: 18px; margin: 0 0 6px; }
.feed-empty p { margin: 0; }
.feed-more { display: block; margin: 15px auto 0; min-width: 150px; }
.feed-more[hidden] { display: none !important; }
.feed-post { padding: 18px 20px 12px; animation: cardIn .24s ease both; }
.feed-post-game { border-top-color: rgba(224,170,62,.55); }
.feed-post-achievement { border-top-color: rgba(129,182,76,.55); }
.feed-post-learning { border-top-color: rgba(91,157,240,.55); }
.feed-post-head { display: flex; align-items: center; gap: 11px; }
.feed-avatar {
  width: 42px; height: 42px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; border-radius: 50%; color: #211804; background: linear-gradient(145deg, var(--gold2), var(--gold-deep));
  border: 1px solid rgba(224,170,62,.45); font-size: 13px; font-weight: 800;
}
.feed-avatar.small { width: 29px; height: 29px; font-size: 10px; }
.feed-avatar img { width: 100%; height: 100%; object-fit: cover; }
.feed-author { min-width: 0; }
.feed-author strong { overflow-wrap: anywhere; }
.feed-username { color: var(--text-dim); font-size: 12px; margin-left: 7px; }
.feed-byline { display: flex; gap: 5px; color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.feed-type { flex: none; border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 700; background: var(--bg3); color: var(--text-dim); }
.feed-type-game { color: var(--gold2); background: rgba(224,170,62,.12); }
.feed-type-achievement { color: var(--good); background: rgba(129,182,76,.12); }
.feed-type-learning { color: #8cbcf5; background: rgba(91,157,240,.12); }
.feed-post-text { margin: 15px 0 4px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.feed-game-card, .feed-achievement-card, .feed-learning-card {
  margin-top: 14px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--bg);
}
.feed-game-card { padding: 14px; }
.feed-game-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.feed-game-top .feed-eyebrow { margin-bottom: 1px; }
.feed-game-icon { font-size: 26px; color: var(--gold2); }
.feed-my-result { display: block; font-size: 14px; }
.feed-my-result.win { color: var(--good); }
.feed-my-result.loss { color: #e08080; }
.feed-my-result.draw { color: var(--gold2); }
.feed-versus { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 12px; margin-top: 14px; }
.feed-player { display: flex; align-items: center; gap: 8px; min-width: 0; }
.feed-player > span:last-child { min-width: 0; }
.feed-player strong, .feed-player small { display: block; overflow-wrap: anywhere; }
.feed-player small { color: var(--text-dim); margin-top: 2px; }
.feed-color { width: 11px; height: 11px; flex: none; border-radius: 3px; border: 1px solid var(--border); }
.feed-color.white { background: #f3f1e8; }
.feed-color.black { background: #262a33; }
.feed-vs { color: var(--text-dim); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.feed-game-meta { display: flex; gap: 7px 14px; flex-wrap: wrap; color: var(--text-dim); font-size: 12px; margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.feed-opening { color: var(--gold2); }
.feed-achievement-card { display: flex; align-items: center; gap: 14px; padding: 17px; background: linear-gradient(135deg, rgba(129,182,76,.10), var(--bg)); }
.feed-achievement-icon { width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; flex: none; border-radius: 14px; background: rgba(224,170,62,.14); font-size: 29px; }
.feed-achievement-card strong, .feed-learning-card strong { display: block; font-size: 15px; }
.feed-learning-card { display: flex; align-items: center; gap: 13px; padding: 16px; text-decoration: none; color: var(--text); background: linear-gradient(135deg, rgba(91,157,240,.10), var(--bg)); }
.feed-learning-card:hover { border-color: rgba(91,157,240,.55); }
.feed-learning-icon { font-size: 29px; }
.feed-learning-go { color: #8cbcf5; font-size: 20px; }
.feed-post-actions { display: flex; align-items: center; gap: 4px; margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border-soft); }
.feed-action {
  display: inline-flex; align-items: center; gap: 5px; min-height: 34px;
  color: var(--text-dim); background: transparent; border: 0; border-radius: 8px;
  padding: 5px 8px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.feed-action:hover { color: var(--text); background: var(--bg3); }
.feed-action.liked { color: #ef8585; }
.feed-action:disabled { opacity: .5; cursor: wait; }
.feed-delete:hover { color: #e08080; }
.feed-post-error { margin: 5px 0 0; }
.feed-comments { margin-top: 8px; padding: 11px 0 2px; border-top: 1px solid var(--border-soft); }
.feed-comment { display: flex; gap: 9px; margin: 9px 0; }
.feed-comment-body { flex: 1; min-width: 0; padding: 8px 11px; border-radius: 11px; background: var(--bg3); }
.feed-comment-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.feed-comment-head time { color: var(--text-dim); font-size: 11px; }
.feed-comment-head strong { overflow-wrap: anywhere; }
.feed-comment-body p { margin: 4px 0 0; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.feed-comment-delete { margin-left: auto; padding: 1px 5px; color: var(--text-dim); background: transparent; border: 0; border-radius: 5px; cursor: pointer; }
.feed-comment-delete:hover { color: #e08080; background: var(--bg); }
.feed-comment-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: end; margin-top: 12px; }
.feed-comment-form textarea { width: 100%; min-height: 42px; }
.feed-comment-error { margin: 4px 0 0; }
.feed-no-comments { font-size: 13px; }
.feed-sidebar { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 82px; }
.feed-side-card { padding: 20px; }
.feed-side-card h2 { margin: 0 0 7px; font-size: 19px; }
.feed-side-card > p { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.55; }
.feed-shortcuts { display: flex; flex-direction: column; gap: 5px; margin-top: 16px; }
.feed-shortcuts a { display: grid; grid-template-columns: 23px 1fr auto; align-items: center; gap: 8px; padding: 10px; margin: 0 -6px; border-radius: 9px; color: var(--text); text-decoration: none; font-size: 13.5px; }
.feed-shortcuts a:hover { background: var(--bg3); color: var(--gold2); }
.feed-shortcuts a > span:last-child { color: var(--text-dim); }
.feed-side-note { display: flex; align-items: flex-start; gap: 10px; background: transparent; border-style: dashed; }
.feed-side-note > span { font-size: 21px; }
.feed-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

body[data-mode="light"] .feed-welcome { background: linear-gradient(135deg, #fff, #f4f1e8); }
body[data-mode="light"] .feed-empty { background: rgba(255,255,255,.35); }
body[data-mode="light"] .nav-dropdown-menu { box-shadow: 0 20px 55px rgba(60,50,20,.20); }
body[data-mode="light"] .feed-color.black { border-color: #777; }

@media (max-width: 1100px) {
  #mainnav { display: none; }
  body.has-session .mobile-bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed;
    left: 0; right: 0; bottom: 0; z-index: 70;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: rgba(22,25,33,.96); border-top: 1px solid var(--border);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 -8px 30px rgba(0,0,0,.24);
  }
  .mobile-bottom-nav a, .mobile-bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-width: 0; min-height: 50px; padding: 4px 2px; border: 0; border-radius: 10px;
    color: var(--text-dim); background: transparent; font: inherit; font-size: 10.5px;
    text-decoration: none; cursor: pointer;
  }
  .mobile-bottom-nav a.active, .mobile-bottom-nav button.active { color: var(--gold2); background: rgba(224,170,62,.10); }
  .mobile-nav-icon { font-size: 21px; line-height: 1.05; }
  body.has-session #view { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.has-session #network-status { bottom: calc(78px + env(safe-area-inset-bottom)); }
  body[data-mode="light"] .mobile-bottom-nav { background: rgba(250,249,245,.97); }
  .mobile-explore { display: block; position: fixed; inset: 0; z-index: 85; }
  .mobile-explore-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(8,10,14,.68); backdrop-filter: blur(3px); }
  @keyframes exploreSheetIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
  .mobile-explore-sheet {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 82vh; max-height: 82dvh; overflow-y: auto;
    padding: 18px max(18px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    background: var(--bg2); border: 1px solid var(--border); border-bottom: 0; border-radius: 22px 22px 0 0;
    box-shadow: 0 -20px 60px rgba(0,0,0,.42); animation: exploreSheetIn .2s ease both;
  }
  .mobile-explore-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .mobile-explore-head h2 { margin: 0; font-size: 20px; }
  .mobile-explore-close { width: 36px; height: 36px; border-radius: 9px; color: var(--text); background: var(--bg3); border: 1px solid var(--border); cursor: pointer; }
  .mobile-explore-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .mobile-explore-grid a { display: flex; align-items: center; gap: 9px; min-height: 46px; padding: 10px 12px; border-radius: 10px; color: var(--text); background: var(--bg3); text-decoration: none; font-size: 13px; }
  .mobile-explore-grid a.active { color: var(--gold2); box-shadow: inset 0 0 0 1px rgba(224,170,62,.45); background: rgba(224,170,62,.12); }
  body.explore-open { overflow: hidden; }
}

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

@media (max-width: 720px) {
  #topbar { overflow: visible; gap: 8px; padding: 8px 10px; }
  .userbox { gap: 4px; }
  #user-chip { max-width: 155px; padding: 4px 8px 4px 4px; gap: 5px; }
  #user-chip .chip-name { max-width: 75px; }
  .userbox .btn { padding: 6px 7px; }
  .install-label { display: none; }
  .feed-welcome { padding: 22px; }
  .feed-welcome-bottom { align-items: flex-start; }
}

@media (max-width: 560px) {
  #view { padding: 18px 12px 70px; }
  .feed-welcome { padding: 20px 17px; border-radius: 15px; }
  .feed-welcome h1 { font-size: 25px; }
  .feed-welcome-copy > p:last-child { font-size: 13.5px; }
  .feed-welcome-bottom { margin-top: 17px; }
  .feed-ctas { width: 100%; }
  .feed-ctas .btn { flex: 1; padding-left: 10px; padding-right: 10px; white-space: nowrap; }
  .feed-composer, .feed-post { padding-left: 14px; padding-right: 14px; }
  .feed-filter { padding: 7px 9px; font-size: 12px; }
  .feed-toolbar { gap: 4px; }
  .feed-sidebar { grid-template-columns: 1fr; }
  .feed-side-note { display: none; }
  .feed-post-head { gap: 8px; }
  .feed-avatar { width: 38px; height: 38px; }
  .feed-username { display: block; margin-left: 0; }
  .feed-action { padding: 5px 7px; }
  .feed-comment-form { grid-template-columns: 1fr; }
  .feed-comment-form .btn { justify-self: end; }
  .feed-game-top .btn { margin-left: 35px; }
}

@media (max-width: 480px) {
  .userbox { flex: 1; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
  .userbox .locale-picker { min-width: 0; }
  .userbox .locale-picker select { min-width: 0; max-width: 120px; }
  #user-chip .chip-gem, #user-chip .chip-streak { display: none; }
  #user-chip { max-width: 132px; }
  #user-chip .chip-name { max-width: 57px; }
  #logout-btn { font-size: 12px; }
  .feed-versus { grid-template-columns: 1fr; gap: 9px; }
  .feed-vs { display: none; }
  .feed-action-label { font-size: 11.5px; }
  .mobile-explore-grid a { padding: 9px; font-size: 12.5px; }
}

@media (max-width: 370px) {
  .brand { display: none; }
  #user-chip { max-width: 145px; }
  #user-chip .chip-name { max-width: 72px; }
  .feed-action-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-dropdown.is-open .nav-dropdown-menu, .feed-post, .mobile-explore-sheet { animation: none; }
}
