:root {
  --bg: #161512;
  --bg2: #1f1e1b;
  --panel: #262421;
  --panel2: #2f2c28;
  --line: #3a3733;
  --text: #ebe7e1;
  --muted: #9a958d;
  --accent: #81b64c;
  --accent2: #6a9a3c;
  --danger: #e2524a;
  --gold: #f2c14e;
  --light: #ebecd0;
  --dark: #779556;
  --hl-last: rgba(255, 255, 51, .42);
  --hl-sel: rgba(255, 255, 51, .55);
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --header: 56px;
  --player: 50px;
  --evalw: 24px;
  --panelw: 380px;
  --bs: min(calc(100vh - var(--header) - 2 * var(--player) - 44px), calc(100vw - var(--panelw) - var(--evalw) - 72px), 860px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 30% -10%, #23211d 0%, var(--bg) 60%);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Barra superior ---------- */
.topbar {
  height: var(--header);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(20, 19, 17, .85);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.brand img { width: 32px; height: 32px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.top-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background .15s, transform .05s, border-color .15s;
}
.btn:hover { background: #3a3632; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent2); }
.btn.primary:hover { background: #8fc45a; }
.btn.icon { width: 40px; padding: 0; font-size: 17px; }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); }
.btn.wide { width: 100%; height: 44px; font-size: 15px; }
.btn .ico { font-size: 16px; }

/* ---------- Disposición ---------- */
.layout {
  display: flex; justify-content: center; align-items: flex-start; gap: 24px;
  padding: 16px;
}
.play-area { display: flex; flex-direction: column; gap: 6px; }
.board-row { display: flex; gap: 10px; }

.player {
  height: var(--player);
  display: flex; align-items: center; gap: 10px;
  margin-left: calc(var(--evalw) + 10px);
}
.avatar {
  width: 40px; height: 40px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 22px;
  background: var(--panel2); border: 1px solid var(--line);
}
.pinfo { flex: 1; min-width: 0; }
.pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pname .rating { color: var(--muted); font-weight: 500; margin-left: 4px; }
.pname .thinking { display: inline-block; margin-left: 8px; color: var(--accent); font-weight: 500; font-size: 12px; }
.pname .thinking::after { content: '…'; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }
.captured { display: flex; align-items: center; height: 18px; }
.captured img { width: 18px; height: 18px; margin-right: -6px; }
.captured .gap { width: 10px; }
.captured .adv { margin-left: 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
.clock {
  min-width: 110px; padding: 6px 12px; border-radius: 6px;
  font: 700 24px/1.1 ui-monospace, "SF Mono", Menlo, monospace; text-align: right;
  background: #1b1a17; color: #8a867f; border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.clock:empty { display: none; }
.clock.active { background: #ffffff; color: #111; border-color: #fff; }
.clock.low.active { background: #e2524a; color: #fff; border-color: #e2524a; animation: pulse 1s infinite; }
@keyframes pulse { 50% { filter: brightness(1.2); } }

/* ---------- Barra de evaluación ---------- */
.evalbar {
  width: var(--evalw); height: var(--bs); border-radius: 4px; overflow: hidden;
  background: #403d39; position: relative; flex: none;
  transition: opacity .3s;
}
.evalbar.off { opacity: 0; pointer-events: none; }
.evalfill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 50%;
  background: #f4f3ef; transition: height .6s cubic-bezier(.2,.8,.2,1);
}
.evaltext {
  position: absolute; left: 0; right: 0; text-align: center;
  font-size: 10px; font-weight: 800; bottom: 4px; color: #333;
}
.evaltext.top { top: 4px; bottom: auto; color: #eee; }
.flipped-eval .evalfill { bottom: auto; top: 0; }

/* ---------- Tablero ---------- */
.board-wrap { width: var(--bs); height: var(--bs); flex: none; }
.board {
  position: relative; width: 100%; height: 100%;
  border-radius: 4px; overflow: hidden; box-shadow: var(--shadow);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; background: var(--light); }
.sq.d { background: var(--dark); }
.sq::before { content: ''; position: absolute; inset: 0; pointer-events: none; }
.sq.last::before { background: var(--hl-last); }
.sq.sel::before { background: var(--hl-sel); }
.sq.pre::before { background: rgba(220, 70, 60, .5); }
.sq.mark-r::before { background: rgba(235, 97, 80, .8); }
.sq.mark-g::before { background: rgba(172, 206, 89, .8); }
.sq.mark-b::before { background: rgba(82, 176, 220, .8); }
.sq.mark-y::before { background: rgba(255, 170, 0, .8); }
.sq.check::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(255,0,0,.9) 0%, rgba(231,0,0,.55) 30%, rgba(169,0,0,0) 72%);
}
.sq.dot::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 32%; height: 32%;
  transform: translate(-50%, -50%); border-radius: 50%; background: rgba(0,0,0,.16);
}
.sq.ring::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: inset 0 0 0 calc(var(--bs) / 8 * .09) rgba(0,0,0,.16);
}
.sq.hover { box-shadow: inset 0 0 0 calc(var(--bs) / 8 * .05) rgba(255,255,255,.65); }
.coord {
  position: absolute; font-size: calc(var(--bs) / 8 * .19); font-weight: 700; pointer-events: none;
  color: var(--dark); line-height: 1;
}
.sq.d .coord { color: var(--light); }
.coord.rank { top: 4%; left: 5%; }
.coord.file { bottom: 4%; right: 6%; }
.no-coords .coord { display: none; }

.pieces { position: absolute; inset: 0; pointer-events: none; }
.piece {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%;
  background-size: 100% 100%; background-repeat: no-repeat;
  will-change: transform;
}
.piece.anim { transition: transform var(--anim, .18s) cubic-bezier(.25,.8,.35,1); }
.piece.dragging { z-index: 10; transition: none; filter: drop-shadow(0 8px 10px rgba(0,0,0,.4)); }
.piece.ghost { opacity: .35; }
.piece.fade { transition: opacity .18s; opacity: 0; }
.badge {
  position: absolute; width: 4.6%; height: 4.6%; z-index: 6; pointer-events: none;
  border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: calc(var(--bs) * .019); color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.4); transform: translate(-60%, -40%);
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: translate(-60%, -40%) scale(.3); } }

.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

.promo {
  position: absolute; z-index: 30; width: 12.5%;
  background: #fff; border-radius: 4px; box-shadow: var(--shadow); overflow: hidden;
}
.promo button {
  display: block; width: 100%; aspect-ratio: 1; border: 0; cursor: pointer;
  background: #fff center / 88% no-repeat;
}
.promo button:hover { background-color: #e7e3d8; }
.promo-shade { position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 29; }

/* ---------- Panel lateral ---------- */
.panel {
  width: var(--panelw);
  height: calc(var(--bs) + 2 * var(--player) + 12px);
  min-height: 460px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow);
}
.panel-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.opening { font-weight: 700; font-size: 15px; min-height: 20px; }
.opening .eco { color: var(--muted); font-weight: 500; }
.status { color: var(--muted); font-size: 13px; min-height: 18px; margin-top: 2px; }
.status.win { color: var(--accent); font-weight: 700; }
.status.loss { color: var(--danger); font-weight: 700; }

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: 10px 0; background: none; border: 0; cursor: pointer;
  color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { display: none; flex: 1; min-height: 0; overflow: auto; }
.tabpane.active { display: flex; flex-direction: column; }

.movelist {
  list-style: none; margin: 0; padding: 6px 0; flex: 1;
  display: grid; grid-template-columns: 44px 1fr 1fr; align-content: start;
  overflow: auto;
}
.movelist li { display: contents; }
.movelist .num { color: var(--muted); padding: 4px 0 4px 14px; font-size: 13px; }
.movelist li:nth-child(odd) > * { background: rgba(255,255,255,.025); }
.mv {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; cursor: pointer; border-radius: 4px; font-weight: 600;
  margin: 1px 4px;
}
.mv:hover { background: var(--panel2) !important; }
.mv.cur { background: #4b4844 !important; box-shadow: inset 0 -2px 0 var(--accent); }
.mv .cls { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 900; color: #fff; flex: none; }
.movelist .result { grid-column: 1 / -1; text-align: center; padding: 10px; font-weight: 800; color: var(--muted); }
.movelist .empty { grid-column: 1 / -1; padding: 24px 16px; color: var(--muted); text-align: center; }

.coach {
  margin: 8px; padding: 10px 12px; border-radius: 8px;
  background: var(--panel2); border-left: 4px solid var(--accent);
  display: flex; gap: 10px; align-items: flex-start; font-size: 13px;
}
.coach .cls { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 11px; color: #fff; flex: none; }
.coach b { font-weight: 800; }

.engine-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.engine-meta { color: var(--muted); font-size: 12px; }
.engine-lines { padding: 12px 16px; }
.engine-line { display: flex; gap: 10px; align-items: flex-start; }
.engine-line .score {
  flex: none; min-width: 56px; text-align: center; padding: 3px 6px; border-radius: 4px;
  font-weight: 800; background: #f4f3ef; color: #222;
}
.engine-line .score.neg { background: #403d39; color: #eee; }
.engine-line .pv { line-height: 1.7; word-break: break-word; }
.engine-line .pv span { cursor: pointer; padding: 1px 3px; border-radius: 3px; }
.engine-line .pv span:hover { background: var(--panel2); }

.review-empty { padding: 20px 16px; color: var(--muted); }
.review-empty p { margin: 0 0 16px; }
.review-progress { padding: 20px 16px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.review-progress .bar { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.review-progress .bar div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.accuracy { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px 6px; }
.acc-card { border-radius: 8px; padding: 10px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.acc-card.white { background: #f4f3ef; color: #222; }
.acc-card.black { background: #3d3a36; color: #eee; }
.acc-card .acc-name { font-size: 12px; font-weight: 600; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-card .acc-val { font-size: 26px; font-weight: 900; }
.acc-card small { opacity: .7; }
.graph { width: calc(100% - 32px); height: 80px; margin: 8px 16px; border-radius: 6px; background: #3d3a36; cursor: pointer; flex: none; }
.classes { width: calc(100% - 32px); margin: 4px 16px 16px; border-collapse: collapse; font-size: 13px; }
.classes td { padding: 5px 4px; }
.classes td.n { text-align: center; font-weight: 800; width: 48px; }
.classes td.n.w { color: #f4f3ef; }
.classes .cls { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 900; color: #fff; vertical-align: middle; margin-right: 8px; }
.classes tr { cursor: pointer; }
.classes tr:hover td { background: var(--panel2); }

.controls { border-top: 1px solid var(--line); padding: 10px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.controls .nav, .controls .actions { display: flex; gap: 6px; }

/* ---------- Diálogos ---------- */
.dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow);
  width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
.dialog.narrow { width: min(360px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.dialog[open] { animation: dlgIn .2s ease-out; }
@keyframes dlgIn { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.dlg-body { padding: 20px 22px; }
.dlg-body.center { text-align: center; }
.dlg-body h2 { margin: 0 0 14px; font-size: 22px; }
.dlg-body h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.dlg-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 22px; }
.dlg-foot > div { display: flex; gap: 8px; }
.dlg-foot.column { flex-direction: column; }
.seg { display: flex; background: var(--bg2); border-radius: 10px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; border: 0; background: none; padding: 10px; border-radius: 7px; cursor: pointer; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted);
}
.seg button img { width: 22px; height: 22px; }
.seg button.active { background: var(--panel2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 2px 6px rgba(0,0,0,.3); }
.seg.small button { padding: 7px; }

.bots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.bot {
  border: 2px solid transparent; background: var(--bg2); border-radius: 10px; padding: 8px 4px;
  cursor: pointer; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bot:hover { border-color: var(--line); }
.bot.active { border-color: var(--accent); background: #2b3324; }
.bot .face { font-size: 26px; }
.bot .bname { font-weight: 700; font-size: 12px; }
.bot .belo { font-size: 11px; color: var(--muted); }
.bot-desc { margin-top: 8px; font-size: 13px; color: var(--muted); min-height: 18px; }

.times { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.times button {
  background: var(--bg2); border: 2px solid transparent; border-radius: 8px; padding: 8px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
}
.times button b { font-size: 15px; }
.times button small { color: var(--muted); font-size: 11px; }
.times button.active { border-color: var(--accent); background: #2b3324; }
.stats { color: var(--muted); font-size: 12px; }

.themes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.theme {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: pointer; border: 3px solid transparent;
  display: grid; grid-template-columns: 1fr 1fr; padding: 0;
}
.theme i { display: block; }
.theme.active { border-color: var(--accent); }
.piecesets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pset {
  background: var(--bg2); border: 3px solid transparent; border-radius: 8px; padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; font-size: 12px;
}
.pset div { display: flex; }
.pset img { width: 34px; height: 34px; }
.pset.active { border-color: var(--accent); }
.prefs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; }
.switch input { display: none; }
.switch span {
  width: 36px; height: 20px; border-radius: 10px; background: #4a4642; position: relative; flex: none; transition: background .2s;
}
.switch span::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }

textarea, input:not([type]) {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font: 12px/1.5 ui-monospace, Menlo, monospace; resize: vertical;
}
.row { margin-top: 8px; }
.row.gap { display: flex; gap: 8px; flex-wrap: wrap; }
.error { color: var(--danger); font-size: 13px; }

.over-icon { font-size: 54px; margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #f4f3ef; color: #222; padding: 10px 18px; border-radius: 999px; font-weight: 700;
  box-shadow: var(--shadow); z-index: 100; animation: dlgIn .2s;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  :root { --panelw: 100%; --evalw: 14px; --player: 46px;
    --bs: min(calc(100vw - 32px - var(--evalw) - 10px), calc(100vh - var(--header) - 2 * var(--player) - 40px), 640px); }
  .layout { flex-direction: column; align-items: center; padding: 12px 16px; gap: 14px; }
  .panel { width: calc(var(--bs) + var(--evalw) + 10px); height: auto; min-height: 0; max-width: 100%; }
  .tabpane { max-height: 320px; min-height: 140px; }
  .top-actions .lbl { display: none; }
  .top-actions .btn:not(.icon) { width: 40px; padding: 0; }
  .clock { font-size: 20px; min-width: 90px; }
  .bots { grid-template-columns: repeat(5, 1fr); }
  .prefs { grid-template-columns: 1fr; }
  .themes { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 520px) {
  :root { --bs: min(calc(100vw - 32px - var(--evalw) - 6px), 640px); }
  .board-row { gap: 6px; }
  .player { margin-left: calc(var(--evalw) + 6px); }
  .bots { grid-template-columns: repeat(3, 1fr); }
  .times { grid-template-columns: repeat(3, 1fr); }
  .brand span { display: none; }
  .controls .btn.icon { width: 36px; }
}
.evaltext { white-space: nowrap; }
@media (max-width: 960px) { .evaltext { font-size: 7px; } }

/* ---------- Cuentas y juego en línea ---------- */
.btn.account { max-width: 220px; }
.btn.account .lbl { overflow: hidden; text-overflow: ellipsis; }
.btn.account b { color: var(--gold); margin-left: 4px; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.pname .you { margin-left: 6px; font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; }

.offer {
  margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #3a3a22; border: 1px solid #6b6b2e;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 600;
}
.offer span { flex: 1; }

.field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.field input, .row input:not([type]) {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: 14px system-ui, sans-serif;
}
.field input:focus, .row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font-size: 13px; text-decoration: underline; }
.linkbtn:hover { color: var(--text); }
.ok { color: var(--accent); font-size: 13px; }
.switch.rated { margin-top: 12px; }

.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.profile-head h2 { margin: 0; }
.avatar.big { width: 64px; height: 64px; font-size: 36px; border-radius: 14px; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rating-card { background: var(--bg2); border-radius: 10px; padding: 10px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.rating-card small { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
.rating-card strong { font-size: 24px; color: var(--gold); }
.rating-card span { font-size: 11px; color: var(--muted); }
.history { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow: auto; }
.hist {
  display: grid; grid-template-columns: 28px 1fr auto auto; gap: 10px; align-items: center; text-align: left;
  background: var(--bg2); border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.hist:hover { background: var(--panel2); }
.hist .res { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-weight: 900; font-size: 12px; color: #fff; }
.hist.win .res { background: var(--accent); }
.hist.loss .res { background: var(--danger); }
.hist.draw .res { background: #777; }
.hist .opp small { display: block; color: var(--muted); font-size: 11px; }
.hist .diff { font-weight: 800; }
.hist.win .diff { color: var(--accent); }
.hist.loss .diff { color: var(--danger); }
.hist .date { color: var(--muted); font-size: 12px; }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.avatars button { width: 40px; height: 40px; font-size: 20px; border-radius: 8px; border: 2px solid transparent; background: var(--bg2); cursor: pointer; }
.avatars button.active { border-color: var(--accent); }

.ranking { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.ranking th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.ranking td { padding: 8px; border-bottom: 1px solid rgba(255,255,255,.04); }
.ranking tr.me td { background: #2b3324; }

.spinner {
  width: 44px; height: 44px; margin: 6px auto 14px; border-radius: 50%;
  border: 4px solid var(--panel2); border-top-color: var(--accent); animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#inviteBox { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
#inviteBox input { height: 40px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: 12px ui-monospace, monospace; }
.over-rating { font-size: 18px; font-weight: 800; color: var(--gold); margin: 6px 0 0; }

@media (max-width: 960px) {
  .btn.account .lbl { display: none; }
  .ratings { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Pantalla de cuenta (inicio de sesión / registro) ---------- */
.dialog.auth { width: min(880px, calc(100vw - 32px)); padding: 0; overflow: hidden; border-radius: 18px; }
.auth-wrap { display: grid; grid-template-columns: 0.95fr 1.05fr; min-height: 540px; }
.auth-side {
  position: relative; overflow: hidden; padding: 32px 30px;
  background:
    radial-gradient(500px 300px at 0% 0%, rgba(129,182,76,.35), transparent 60%),
    linear-gradient(160deg, #2b3a22 0%, #1d2617 55%, #161d12 100%);
  display: flex; flex-direction: column; gap: 22px;
}
.auth-side::after {
  content: ''; position: absolute; inset: auto -40px -40px auto; width: 260px; height: 260px; opacity: .08;
  background: conic-gradient(#fff 25%, transparent 0 50%, #fff 0 75%, transparent 0) 0 0 / 65px 65px;
  transform: rotate(12deg); border-radius: 16px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; }
.auth-brand img { width: 40px; height: 40px; filter: drop-shadow(0 3px 6px rgba(0,0,0,.4)); }
.auth-side h2 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.3px; }
.auth-perks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-perks li { display: flex; gap: 12px; align-items: flex-start; }
.auth-perks .pk { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.08); display: grid; place-items: center; font-size: 18px; flex: none; }
.auth-perks b { display: block; font-size: 14px; }
.auth-perks small { color: #b9c4ad; font-size: 12.5px; }
.auth-pieces { margin-top: auto; display: flex; gap: 6px; position: relative; z-index: 1; }
.auth-pieces img { width: 44px; height: 44px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)); animation: bob 3s ease-in-out infinite; }
.auth-pieces img:nth-child(2) { animation-delay: .3s; } .auth-pieces img:nth-child(3) { animation-delay: .6s; } .auth-pieces img:nth-child(4) { animation-delay: .9s; }
@keyframes bob { 50% { transform: translateY(-5px); } }

.auth-main { position: relative; padding: 34px 34px 28px; display: flex; flex-direction: column; justify-content: center; }
.auth-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--panel2); color: var(--muted); cursor: pointer; font-size: 14px; }
.auth-close:hover { color: var(--text); background: #3a3632; }
.auth-main h2 { margin: 0; font-size: 24px; }
.auth-sub { margin: 6px 0 18px; color: var(--muted); font-size: 14px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg2); border-radius: 12px; padding: 4px; margin-bottom: 6px; }
.auth-tabs button { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.auth-tabs button.active { background: var(--panel2); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3); }

.afield { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.alabel { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: #cfcac2; }
.ainput {
  display: flex; align-items: center; height: 46px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--bg2); transition: border-color .15s, box-shadow .15s;
}
.ainput:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(129,182,76,.15); }
.ainput.bad { border-color: var(--danger); }
.ainput.good { border-color: var(--accent); }
.ainput i { font-style: normal; width: 40px; text-align: center; font-size: 15px; opacity: .8; flex: none; }
.ainput input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); font: 15px system-ui, sans-serif; padding-right: 10px; }
.ainput input::placeholder { color: #6f6a63; }
.astatus { font-style: normal; font-size: 12px; font-weight: 700; padding-right: 12px; white-space: nowrap; }
.astatus.good { color: var(--accent); } .astatus.bad { color: #f08080; } .astatus.wait { color: var(--muted); }
.aeye { border: 0; background: none; cursor: pointer; width: 42px; height: 100%; font-size: 16px; opacity: .6; }
.aeye:hover, .aeye.on { opacity: 1; }
.ahint { color: var(--muted); font-size: 12px; }
.alink { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer; }
.alink:hover { text-decoration: underline; }
.alink.center { align-self: center; margin-top: 4px; }
.strength { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 4px; align-items: center; }
.strength span { height: 4px; border-radius: 2px; background: var(--panel2); transition: background .2s; }
.strength small { font-size: 11px; color: var(--muted); margin-left: 6px; min-width: 70px; text-align: right; }
.amsg { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.4; }
.amsg.error { background: rgba(226,82,74,.12); border: 1px solid rgba(226,82,74,.35); color: #f3a39e; }
.amsg.ok { background: rgba(129,182,76,.12); border: 1px solid rgba(129,182,76,.35); color: #b6dd8f; }
.asubmit { margin-top: 20px; height: 48px; font-size: 16px; }
.asubmit .spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite; }
.aswitch { text-align: center; color: var(--muted); font-size: 13.5px; margin: 16px 0 0; }

.auth-sent { display: flex; flex-direction: column; gap: 12px; text-align: center; }
.auth-sent .sent-ico { font-size: 56px; animation: pop .4s ease-out; }
.auth-sent p { margin: 0; color: #cfcac2; line-height: 1.5; }
.auth-sent p b { color: var(--text); }
.sent-tips { display: flex; flex-direction: column; gap: 6px; background: var(--bg2); border-radius: 10px; padding: 12px; font-size: 13px; color: var(--muted); text-align: left; margin: 4px 0 6px; }

@media (max-width: 760px) {
  .auth-wrap { grid-template-columns: 1fr; min-height: 0; }
  .auth-side { padding: 18px 20px; gap: 0; }
  .auth-side h2, .auth-perks, .auth-pieces { display: none; }
  .auth-main { padding: 22px 20px 22px; }
}
a.btn { text-decoration: none; }
