:root {
  --bg: #0e0b10;
  --bg2: #140f17;
  --card: #1a141e;
  --card2: #221a27;
  --line: #2f2536;
  --text: #f6eff7;
  --muted: #ad9fb6;
  --red: #e0262f;
  --red2: #ff4a52;
  --gold: #f5b301;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #38bdf8;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7f3f8; --bg2: #efe8f1; --card: #ffffff; --card2: #f6f0f7; --line: #e3d8e6;
    --text: #1d1420; --muted: #6e5f76; --shadow: 0 8px 24px rgba(40, 10, 50, .08); color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { min-height: 100vh; -webkit-text-size-adjust: 100%; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; overflow-wrap: anywhere; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ── botones y campos ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: .5rem .95rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card2); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--red2), var(--red)); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(224, 38, 47, .35); }
.btn.gold { background: var(--gold); color: #1b1200; border-color: transparent; }
.btn.danger { color: var(--bad); border-color: rgba(239, 68, 68, .45); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 32px; padding: .25rem .6rem; font-size: .88rem; }
.field { display: grid; gap: .3rem; margin-bottom: .8rem; }
.field label { font-size: .88rem; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: .55rem .75rem; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); outline: none; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 179, 1, .18); }
.code-input { font-size: 1.6rem; letter-spacing: .5em; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.check { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; }
.error { color: var(--bad); min-height: 1.2em; font-size: .9rem; }

/* ── ingreso ── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; background: radial-gradient(circle at 50% 0%, rgba(224, 38, 47, .22), transparent 55%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 1.6rem; box-shadow: var(--shadow); }
.auth-card .brand { display: flex; flex-direction: column; align-items: center; gap: .4rem; margin-bottom: 1rem; text-align: center; }
.auth-card .brand img { width: 108px; height: 108px; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: .5rem; margin: .6rem auto; width: fit-content; }
.qr svg { display: block; max-width: 240px; height: auto; }
.secret { text-align: center; font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; background: var(--bg2); border: 1px dashed var(--line); border-radius: 10px; padding: .5rem; margin: .4rem 0 .9rem; user-select: all; }
ol.steps { padding-left: 1.2rem; margin: .4rem 0 .8rem; color: var(--muted); }

/* ── estructura ── */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow: auto; background: var(--bg2); border-right: 1px solid var(--line); padding: 1rem .7rem; display: flex; flex-direction: column; gap: .2rem; }
.side .logo { display: flex; gap: .6rem; align-items: center; padding: .2rem .4rem .9rem; }
.side .logo img { width: 44px; height: 44px; }
.side .logo b { display: block; font-size: .98rem; }
.side .logo span { font-size: .78rem; color: var(--gold); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; border-radius: 10px; color: var(--text); font-weight: 600; }
.nav a:hover { background: var(--card); text-decoration: none; }
.nav a.on { background: var(--card2); box-shadow: inset 3px 0 0 var(--red); }
.nav .sep { margin: .7rem .7rem .3rem; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.nav .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.nav .badge { margin-left: auto; }
.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: .7rem; align-items: center; padding: .7rem 1.2rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .who { display: flex; flex-direction: column; line-height: 1.15; text-align: right; }
.top .who small { color: var(--muted); }
.content { padding: 1.2rem; max-width: 1280px; }
.menu-btn { display: none; }
.bottom-nav { display: none; }

/* ── tarjetas ── */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); min-width: 0; }
.card.click { cursor: pointer; transition: transform .12s, border-color .12s; }
.card.click:hover { transform: translateY(-2px); border-color: var(--muted); }
.game-card .head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.game-card .chip { width: 12px; height: 34px; border-radius: 6px; flex: none; }
.game-card .name { font-weight: 800; font-size: 1.05rem; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.kpi { background: var(--bg2); border-radius: 10px; padding: .5rem .6rem; min-width: 0; }
.kpi b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.kpi span { font-size: .76rem; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: .6rem; font-size: .84rem; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.badge.ok { background: rgba(34, 197, 94, .14); color: var(--ok); border-color: rgba(34, 197, 94, .35); }
.badge.warn { background: rgba(245, 158, 11, .14); color: var(--warn); border-color: rgba(245, 158, 11, .35); }
.badge.bad { background: rgba(239, 68, 68, .14); color: var(--bad); border-color: rgba(239, 68, 68, .35); }
.badge.info { background: rgba(56, 189, 248, .12); color: var(--info); border-color: rgba(56, 189, 248, .3); }
.badge.gold { background: rgba(245, 179, 1, .14); color: var(--gold); border-color: rgba(245, 179, 1, .35); }
.badge.n { background: var(--red); color: #fff; min-width: 1.4rem; justify-content: center; }
.banner { display: flex; gap: .7rem; align-items: center; padding: .75rem 1rem; border-radius: 12px; margin-bottom: 1rem; border: 1px solid; }
.banner.warn { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .4); }
.banner.bad { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .4); }
.banner.info { background: rgba(56, 189, 248, .08); border-color: rgba(56, 189, 248, .3); }
.section { margin: 1.4rem 0 .6rem; display: flex; align-items: center; gap: .6rem; }
.tabs { display: flex; gap: .3rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 1rem 0; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: .6rem .9rem; cursor: pointer; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--red); }

/* ── tablas ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; background: var(--bg2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--card2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); font-weight: 700; }
.neg { color: var(--bad); font-weight: 700; }
dl.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: .35rem .8rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ── jugador ── */
.player-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.avatar { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-weight: 900; font-size: 1.4rem; color: #fff; flex: none; }
.balance { font-size: 1.9rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.mod-item { display: grid; grid-template-columns: 140px 1fr; gap: 1rem; }
.mod-item .ph { width: 140px; height: 180px; border-radius: 12px; background: var(--bg2); object-fit: cover; display: grid; place-items: center; color: var(--muted); font-size: .8rem; text-align: center; }
.search { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search .input { flex: 1; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--card) 0%, var(--card2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; min-height: 120px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── diálogos y avisos ── */
dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--card); color: var(--text); width: min(520px, calc(100vw - 24px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5, 2, 8, .65); backdrop-filter: blur(3px); }
dialog .dlg-head { padding: 1rem 1.2rem .4rem; }
dialog .dlg-body { padding: .3rem 1.2rem 1rem; max-height: 70vh; overflow: auto; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.2rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.secret-box { display: flex; gap: .5rem; align-items: center; background: var(--bg2); border: 1px dashed var(--gold); border-radius: 10px; padding: .6rem .7rem; margin: .6rem 0; }
.secret-box code { flex: 1; overflow-wrap: anywhere; font-size: 1.02rem; }
#toasts { position: fixed; z-index: 50; right: 16px; bottom: 16px; display: grid; gap: .5rem; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--card2); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 12px; padding: .7rem .9rem; box-shadow: var(--shadow); animation: tin .2s ease-out; }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.perm-grid { display: grid; gap: .5rem; }
.perm-row { border: 1px solid var(--line); border-radius: 12px; padding: .6rem .7rem; display: grid; gap: .45rem; }
.perm-row .perms { display: flex; flex-wrap: wrap; gap: .5rem 1rem; padding-left: 1.6rem; }

/* ── celular ── */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 270px; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: .9rem .8rem 5.5rem; }
  .top { padding: .55rem .8rem; }
  .top .who { display: none; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi b { font-size: 1.05rem; }
  .bottom-nav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg2) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
  .bottom-nav a { display: grid; place-items: center; gap: .1rem; padding: .3rem; font-size: .72rem; color: var(--muted); font-weight: 700; border-radius: 10px; }
  .bottom-nav a .ic { font-size: 1.2rem; }
  .bottom-nav a.on { color: var(--text); background: var(--card); }
  .mod-item { grid-template-columns: 1fr; }
  .mod-item .ph { width: 100%; height: 260px; }
  dl.kv { grid-template-columns: 1fr; gap: .1rem; }
  dl.kv dd { margin-bottom: .45rem; }
  #toasts { right: 12px; left: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
