:root {
  --bg: #17161b;           /* negro tenue (no full black) */
  --bg-panel: #1f1e24;
  --bg-panel-2: #2a2831;
  --border: #3a3630;
  --text: #ece6d8;
  --text-dim: #a89f8c;
  --accent: #c8b07a;       /* dorado metálico apagado */
  --accent-2: #a68a52;     /* dorado/bronce */
  --on-accent: #1c1810;    /* texto sobre dorado */
  --green: #22c55e;
  --yellow: #eab308;
  --orange: #f97316;
  --red: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, #241f15 0%, var(--bg) 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 230px;
  background: rgba(20, 19, 24, 0.7);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: block; font-size: 20px; font-weight: 700; margin-bottom: 28px; letter-spacing: .5px; }
.brand span { color: var(--accent); }
.nav a {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-size: 14px;
  transition: .15s;
}
.nav a:hover { background: var(--bg-panel-2); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%); color: var(--on-accent); font-weight: 600; }
.sidebar-footer { position: absolute; bottom: 18px; font-size: 12px; color: var(--text-dim); }

/* Content */
.content { flex: 1; padding: 26px 32px; max-width: 100%; overflow-x: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 700; margin: 0; }
.user-chip { font-size: 13px; color: var(--text-dim); }
.user-chip a { color: var(--accent); }
.logout-btn { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.logout-btn:hover { text-decoration: underline; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
}
.card .label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.card .value { font-size: 30px; font-weight: 700; margin-top: 6px; }
.card.accent { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); border: none; color: var(--on-accent); }
.card.accent .label { color: #54451f; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
}
.panel h2 { margin: 0 0 16px; font-size: 16px; color: var(--accent); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { display: flex; flex-direction: column; gap: 4px; }
.filters label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
.filters select {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  min-width: 140px;
}
.btn {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%); color: var(--on-accent); border: none;
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); font-weight: 400; }

/* Tables */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; }
thead th { color: var(--text-dim); font-weight: 600; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--bg-panel-2); }
.badge { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge.win { background: rgba(34,197,94,.18); color: #4ade80; }
.badge.loss { background: rgba(239,68,68,.18); color: #f87171; }
.badge.draw { background: rgba(200,176,122,.20); color: var(--accent); }

/* Winrate matrix */
.matrix-wrap { overflow-x: auto; }
table.matrix { border-collapse: separate; border-spacing: 3px; width: auto; }
table.matrix th, table.matrix td { text-align: center; padding: 0; vertical-align: bottom; }
table.matrix .corner { width: 96px; }
.matrix .lhead { width: 72px; padding: 2px; vertical-align: top; }
.matrix .lside { width: 96px; padding: 4px 6px; vertical-align: middle; }
.matrix .hdr { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.matrix .hdr img, .matrix .hdr .ph {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  background: var(--bg-panel-2); border: 1px solid var(--border); flex: none;
}
/* Altura reservada para 2 líneas: así las fotos quedan todas a la misma altura
   tengan nombre corto o largo. */
.matrix .lhead .lname { min-height: 25px; }
.matrix .lname { font-size: 10.5px; line-height: 1.12; color: var(--text-dim); font-weight: 600; }
.cell {
  width: 66px; height: 62px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; border-radius: 9px; gap: 1px;
  color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.cell .wr { font-weight: 700; font-size: 15px; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.cell .n { font-size: 9px; opacity: .92; white-space: nowrap; }
.cell .die { opacity: .82; }
.cell.diag { background: var(--bg-panel-2); color: var(--text-dim); }
.cell.none { background: #211f27; color: #6b6450; }
.cell.total-cell { border: 1px solid var(--accent); box-shadow: inset 0 0 0 1px rgba(200,176,122,.25); }
.matrix .total-head .lname { color: var(--accent); font-size: 12px; }
.cell.mirror { border: 1px dashed var(--accent); }
.mirror-tag { font-size: 7.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--on-accent); background: var(--accent); border-radius: 4px; padding: 0 4px; }
.cell.none.mirror-empty .wr { font-size: 9px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.cell.none.mirror-empty { border: 1px dashed var(--border); }

/* Selector de runas (colores) */
.rune-field { flex-basis: 100%; }
.runes { display: flex; gap: 7px; flex-wrap: wrap; }
.rune { cursor: pointer; border-radius: 9px; padding: 3px; border: 1px solid transparent; opacity: .38; filter: grayscale(.5); transition: .15s; }
.rune img { width: 30px; height: 30px; display: block; }
.rune:hover { opacity: .8; }
.rune.on { opacity: 1; filter: none; border-color: var(--rune); box-shadow: 0 0 10px -3px var(--rune); background: rgba(255,255,255,.05); }

/* Login */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 18px; padding: 34px; width: 340px; box-shadow: 0 0 50px rgba(200,176,122,.06); }
.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card p { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; }
.login-card input { width: 100%; background: var(--bg-panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 11px 12px; margin-bottom: 12px; font-size: 14px; }
.login-card .btn { width: 100%; padding: 11px; }
.errornote, .errorlist { color: #f87171; font-size: 13px; list-style: none; padding: 0; }

.muted { color: var(--text-dim); }
.pagination { display: flex; gap: 8px; margin-top: 16px; align-items: center; font-size: 13px; }

/* Calendario de eventos (estilo Google Calendar) */
.gcal-title { margin: 0 0 14px; color: var(--text); font-size: 18px; font-weight: 700; }
table.gcal { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.gcal thead th { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--border); }
.gcal-cell { border: 1px solid var(--border); height: 112px; vertical-align: top; padding: 3px; background: var(--bg-panel); overflow: hidden; }
.gcal-cell.out { background: transparent; }
.gcal-num { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 50%; font-size: 12px; color: var(--text-dim); float: right; margin: 1px 1px 2px; }
.gcal-cell.out .gcal-num { color: #4a443a; }
.gcal-num.today { background: var(--accent); color: var(--on-accent); font-weight: 700; }

/* Eventos (chips tipo Google Calendar) */
.evt { display: block; clear: both; border-radius: 5px; padding: 2px 6px; margin: 2px 1px 0; font-size: 11px; line-height: 1.18; }
.evt-top { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evt-store { display: block; font-size: 9.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evt:hover { filter: brightness(1.08); }
.evt-skirmish { background: linear-gradient(135deg, #e7c66b, #b8902f); color: #2a2008; }
.evt-nexus    { background: linear-gradient(135deg, #d5dae1, #9aa1ab); color: #1e2024; }
.evt-prerift  { background: linear-gradient(135deg, #cd8a57, #8a4f28); color: #2a1608; }

/* Leyenda de colores */
.evt-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.evt-key { display: inline-flex; align-items: center; gap: 6px; }
.evt-key .dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.dot.evt-skirmish { background: #d4af37; }
.dot.evt-nexus { background: #bfc5cd; }
.dot.evt-prerift { background: #b06a3a; }
@media (max-width: 820px) {
  .gcal-cell { height: 82px; }
  .evt-store { display: none; }
}

/* Recursos (blog) */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.res-card { display: flex; gap: 14px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px; padding: 18px; transition: .15s; }
.res-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.res-icon { font-size: 30px; line-height: 1; }
.res-card h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.res-card .res-meta { font-size: 11px; color: var(--text-dim); }
.res-card p { margin: 0 0 8px; font-size: 13px; }
.res-post-title { font-size: 26px; margin: 12px 0 4px; }
.res-post-summary { font-size: 14px; margin: 0 0 20px; }
.res-content { line-height: 1.65; color: var(--text); }
.res-content h2 { font-size: 19px; color: var(--accent); margin: 26px 0 10px; }
.res-content h3 { font-size: 16px; color: var(--text); margin: 20px 0 8px; }
.res-content p { margin: 0 0 12px; }
.res-content ul, .res-content ol { margin: 0 0 14px; padding-left: 22px; }
.res-content li { margin-bottom: 6px; }
.res-content a { color: var(--accent); text-decoration: underline; }
.res-content code { background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: 13px; }
.res-content pre { background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow-x: auto; }
.res-content pre code { border: none; padding: 0; background: none; }
.res-content blockquote { border-left: 3px solid var(--accent); margin: 0 0 14px; padding: 4px 14px; color: var(--text-dim); }
.video-embed { position: relative; width: 100%; padding-bottom: 56.25%; height: 0; margin: 4px 0 18px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.video-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

/* Acciones del historial */
td.actions { white-space: nowrap; }
.btn-mini {
  display: inline-block; padding: 4px 9px; border-radius: 6px; font-size: 12px;
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text-dim);
  cursor: pointer; font-family: inherit;
}
.btn-mini:hover { color: var(--text); border-color: var(--accent); }
.btn-mini.danger:hover { color: #f87171; border-color: #f87171; }

/* Historial en móvil: cada partida como tarjeta apilada (en vez de tabla ancha) */
@media (max-width: 820px) {
  .matches-table thead { display: none; }
  .matches-table, .matches-table tbody, .matches-table tr, .matches-table td { display: block; width: 100%; }
  .matches-table tr {
    background: var(--bg-panel-2); border: 1px solid var(--border);
    border-radius: 12px; padding: 6px 12px; margin-bottom: 12px;
  }
  .matches-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: none; padding: 6px 0; text-align: right;
  }
  .matches-table td + td { border-top: 1px solid var(--border); }
  .matches-table td::before {
    content: attr(data-label); color: var(--text-dim);
    font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
    text-align: left; flex: none; font-weight: 600;
  }
  .matches-table td.actions { justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
}

/* Botón registrar (sidebar) */
.btn-register {
  display: block; width: 100%; text-align: center; margin-bottom: 18px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--on-accent); border: none; padding: 11px; border-radius: 10px;
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.btn-register:hover { filter: brightness(1.07); }

/* Mensajes flash */
.messages { list-style: none; padding: 0; margin: 0 0 18px; }
.messages li { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 8px; }
.messages li.success { background: rgba(34,197,94,.15); color: #4ade80; border: 1px solid rgba(34,197,94,.3); }
.messages li.error { background: rgba(239,68,68,.15); color: #f87171; border: 1px solid rgba(239,68,68,.3); }

/* Campos de formulario */
.form-control {
  width: 100%; background: var(--bg-panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 9px 10px; font-size: 13px;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--accent); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50;
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px;
  width: min(720px, 100%); padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal h2 { margin: 0 0 18px; color: var(--accent); font-size: 18px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mfield { display: flex; flex-direction: column; gap: 5px; }
.mfield.full { grid-column: 1 / -1; }
.mfield label { font-size: 12px; color: var(--text-dim); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Responsive / móvil */
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: static; width: auto; height: auto; display: flex;
    align-items: center; gap: 10px; flex-wrap: wrap;
    border-right: none; border-bottom: 1px solid var(--border); padding: 14px 16px;
  }
  .sidebar .brand { margin: 0 8px 0 0; }
  .btn-register { width: auto; margin: 0; padding: 9px 14px; order: 3; }
  .nav { display: flex; gap: 4px; flex-wrap: wrap; }
  .nav a { margin: 0; padding: 8px 12px; }
  .sidebar-footer { display: none; }
  .content { padding: 18px 14px; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .filters select { min-width: 120px; }
  .modal { padding: 18px; }
}
@media (max-width: 560px) {
  .modal-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 20px; }
}
