/* ============================================================
   Medida — base: tokens, reset, layout, HUD
   ============================================================ */

:root {
  /* Fieltro de mesa */
  --felt-900: #060d0a;
  --felt-800: #0a1712;
  --felt-700: #0f2019;
  --felt-600: #143024;
  --felt-500: #1b4332;
  --felt-400: #2d6a4f;

  --bg:        #070f0c;
  --surface:   #0e1a15;
  --surface-2: #142520;
  --surface-3: #1b322a;
  --line:      #1f3a30;
  --line-soft: #172b24;

  /* Oro y neón */
  --gold:      #f2c14e;
  --gold-soft: #ffd97a;
  --gold-deep: #9a7420;
  --mint:      #3ee0a5;
  --mint-deep: #12a578;
  --red:       #ff4d6d;
  --red-deep:  #8c1f33;
  --violet:    #8b6cff;
  --blue:      #4cc9f0;

  --text:      #e9f2ec;
  --text-2:    #a9c2b6;
  --text-3:    #6f8d80;

  --radius:    14px;
  --radius-sm: 9px;
  --radius-lg: 22px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
  --shadow-2: 0 10px 40px rgba(0,0,0,.55);
  --glow-gold: 0 0 24px rgba(242,193,78,.35);
  --glow-mint: 0 0 24px rgba(62,224,165,.3);

  --sidebar-w: 286px;
  --hud-h: 58px;

  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --font-display: "Playfair Display", "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  --ease: cubic-bezier(.2,.7,.3,1);
}

* { box-sizing: border-box; }

/* El `display: none` que el navegador da a [hidden] viene de su hoja de estilos,
   así que CUALQUIER regla nuestra que fije `display` lo gana: `.btn` es
   inline-flex y `.mini-lista` es grid, y entonces `elemento.hidden = true` deja
   de ocultar nada. Como toda la app esconde cosas con el atributo `hidden`,
   hace falta esta regla para que siga significando lo que parece. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(1200px 700px at 78% -8%, rgba(27,67,50,.55), transparent 60%),
    radial-gradient(900px 600px at 8% 100%, rgba(139,108,255,.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Textura sutil de fieltro */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.012) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.05) 0 1px, transparent 1px 5px);
}

a { color: var(--mint); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #2a4a3e; background-clip: padding-box; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------- BOOT */

#boot {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg);
  transition: opacity .45s var(--ease), visibility .45s;
}
#boot.gone { opacity: 0; visibility: hidden; }
.boot-chip {
  font-size: 64px;
  animation: bootspin 1.4s var(--ease) infinite;
}
.boot-text { color: var(--text-3); font-size: 14px; letter-spacing: .04em; }
@keyframes bootspin {
  0%,100% { transform: rotate(-8deg) scale(1); }
  50%     { transform: rotate(8deg) scale(1.12); }
}

/* ---------------------------------------------------------- HUD */

#hud {
  position: fixed; top: 0; left: 0; right: 0; height: var(--hud-h);
  z-index: 60;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(10,23,18,.82);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid var(--line);
}

.hud-spacer { flex: 1; }

.hud-icon {
  width: 36px; height: 36px;
  display: grid; place-content: center;
  border-radius: 10px;
  font-size: 16px;
  color: var(--text-2);
  transition: background .15s, color .15s, transform .15s;
}
.hud-icon:hover { background: var(--surface-2); color: var(--text); transform: translateY(-1px); }

#navToggle { display: none; }

.hud-brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none;
  font-weight: 600; letter-spacing: -.01em;
}
.hud-brand:hover { text-decoration: none; }
.hud-brand-mark { font-size: 22px; filter: drop-shadow(0 0 10px rgba(242,193,78,.5)); }
.hud-brand-text { font-size: 15px; }
.hud-brand-text em {
  font-style: normal;
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 700;
}

.hud-stat {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 14px;
}
.hud-stat-icon { font-size: 15px; line-height: 1; }
.hud-stat-etq { font-size: 12px; font-weight: 550; color: var(--text-3); }

/* El único número del HUD. No es el logro de nadie: es cuántas cartas acaba
   de meter en el bombo quien está mirando, así que cambia al vuelo. */
.hud-bombo {
  color: var(--gold-soft);
  border-color: rgba(242,193,78,.28);
  text-decoration: none;
  transition: transform .16s var(--ease), box-shadow .2s var(--ease), border-color .2s;
}
.hud-bombo:hover {
  text-decoration: none;
  border-color: rgba(242,193,78,.5);
  box-shadow: var(--glow-gold);
  transform: translateY(-1px);
}
.hud-bombo.bump { animation: chipbump .45s var(--ease); }
@keyframes chipbump {
  0% { transform: scale(1); }
  35% { transform: scale(1.16); box-shadow: var(--glow-gold); }
  100% { transform: scale(1); }
}

/* ---------------------------------------------------------- LAYOUT */

#app {
  position: fixed; inset: var(--hud-h) 0 0 0;
  display: flex;
  z-index: 1;
}

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 10px 60px;
  border-right: 1px solid var(--line);
  background: rgba(7,15,12,.5);
}

#scrim { display: none; }

#view {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
  outline: none;
}

/* ---------------------------------------------------------- SIDEBAR */

.side-group + .side-group { margin-top: 18px; }
.side-label {
  font-size: 10.5px; font-weight: 800;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--text-3);
  padding: 0 12px 7px;
}

.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
  transition: background .13s, color .13s;
  position: relative;
}
.side-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-link.active {
  background: linear-gradient(90deg, rgba(62,224,165,.14), rgba(62,224,165,.03));
  color: var(--text);
  font-weight: 600;
}
.side-link.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--mint);
}
.side-ico { width: 20px; text-align: center; font-size: 15px; flex: 0 0 20px; }
.side-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side-badge {
  font-size: 10.5px; font-weight: 800;
  padding: 1px 6px; border-radius: 99px;
  background: var(--red); color: #fff;
  font-variant-numeric: tabular-nums;
}
.side-badge.zero { display: none; }
.side-badge.soft { background: var(--surface-3); color: var(--text-3); }

/* Anillo de progreso por sección */
.ring { width: 18px; height: 18px; flex: 0 0 18px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .bg { stroke: var(--surface-3); }
.ring .fg { stroke: var(--mint); stroke-linecap: round; transition: stroke-dasharray .6s var(--ease); }
.ring.done .fg { stroke: var(--gold); }

.side-foot {
  margin-top: 22px; padding: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--text-3); line-height: 1.5;
}
.side-foot .side-link.mini { font-size: 12.5px; padding: 6px 10px; margin-bottom: 8px; }
.side-foot-txt { padding: 0 2px; }
.side-cuenta {
  float: right; font-weight: 700; letter-spacing: 0;
  color: var(--text-3); font-variant-numeric: tabular-nums;
}
.side-foot b { color: var(--text-2); font-weight: 600; }
.side-foot kbd {
  font-family: var(--font-mono); font-size: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 4px;
}

/* ---------------------------------------------------------- TOASTS */

#toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 120;
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  border-radius: 99px;
  background: rgba(20,37,32,.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  font-size: 14px; font-weight: 550;
  backdrop-filter: blur(10px);
  animation: toastin .4s var(--ease);
}
.toast.gold { border-color: rgba(242,193,78,.5); box-shadow: var(--shadow-2), var(--glow-gold); }
.toast.out { animation: toastout .35s var(--ease) forwards; }
.toast-ico { font-size: 18px; }
@keyframes toastin  { from { opacity: 0; transform: translateY(16px) scale(.94); } }
@keyframes toastout { to   { opacity: 0; transform: translateY(-8px) scale(.97); } }

/* ---------------------------------------------------------- FX LAYER */

#fxlayer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
}

/* ---------------------------------------------------------- UTILS */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  transition: transform .12s var(--ease), background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-3); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.985); }
.btn.gold {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #241a02; border-color: var(--gold-deep);
  box-shadow: 0 4px 16px rgba(242,193,78,.25);
}
.btn.gold:hover { box-shadow: 0 6px 22px rgba(242,193,78,.4); }
.btn.mint {
  background: linear-gradient(180deg, #4defb4, var(--mint));
  color: #04281c; border-color: #1a8f68;
  box-shadow: 0 4px 16px rgba(62,224,165,.22);
}
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 26px; font-size: 15.5px; border-radius: var(--radius); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* ---------------------------------------------------------- RESPONSIVE */

@media (max-width: 900px) {
  #navToggle { display: grid; }
  #sidebar {
    position: fixed; top: var(--hud-h); bottom: 0; left: 0;
    z-index: 55;
    transform: translateX(-102%);
    transition: transform .28s var(--ease);
    background: var(--surface);
    box-shadow: var(--shadow-2);
  }
  body.nav-open #sidebar { transform: none; }
  body.nav-open #scrim {
    display: block;
    position: fixed; inset: var(--hud-h) 0 0 0;
    background: rgba(0,0,0,.5);
    z-index: 54;
  }
  .hud-stat-etq { display: none; }
  .hud-brand-text { display: none; }
}

@media (max-width: 560px) {
  .hud-stat { padding: 5px 9px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
