/* ==========================================================
   ARCADE ANISCET — Sistema visual
   Estética: neo-arcade retrofuturista, oscuro, neón quirúrgico
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=JetBrains+Mono:wght@400;600&family=Manrope:wght@400;500;700&display=swap');

:root {
    /* Paleta */
    --bg:           #07080b;
    --bg-2:         #0d0f15;
    --surface:      #11141c;
    --surface-2:    #181c27;
    --line:         #1f2433;
    --line-2:       #2a3144;
    --text:         #eef0f7;
    --muted:        #8a90a3;
    --dim:          #5a6075;

    /* Acentos */
    --accent:       #d4ff3a;   /* lima eléctrico */
    --accent-glow:  #d4ff3a55;
    --hot:          #ff3d8a;   /* magenta hot */
    --cyan:         #5cf7ff;
    --amber:        #ffb33a;

    /* Tipografía */
    --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
    --font-body:    'Manrope', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', monospace;

    /* Geometría */
    --radius:    14px;
    --radius-sm: 8px;
    --radius-lg: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Fondo con grid sintético + ruido sutil */
body {
    background:
        radial-gradient(ellipse at 20% -10%, #1a2440 0%, transparent 55%),
        radial-gradient(ellipse at 100% 110%, #2a0d1f 0%, transparent 60%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 60px 60px;
    opacity: .12;
    pointer-events: none;
    z-index: 0;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; }

/* ==========================================================
   TOPBAR
   ========================================================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(14px);
    background: rgba(7,8,11,.7);
    border-bottom: 1px solid var(--line);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 28px; height: 28px;
    background: var(--accent);
    border-radius: 6px;
    display: grid; place-items: center;
    color: #0a0a0a;
    font-weight: 800;
    font-size: 14px;
    box-shadow: 0 0 24px var(--accent-glow);
}

.brand-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .15em;
    margin-left: 4px;
}

.topbar nav {
    display: flex; gap: 6px; align-items: center;
}
.topbar nav a {
    font-size: 13px;
    color: var(--muted);
    padding: 8px 14px;
    border-radius: 999px;
    transition: all .2s;
    font-weight: 500;
}
.topbar nav a:hover { color: var(--text); background: var(--surface); }
.topbar nav a.active { color: var(--accent); background: var(--surface); }

.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px 6px 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 13px;
}
.user-chip .avatar {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--hot), var(--accent));
    border-radius: 50%;
    display: grid; place-items: center;
    color: #0a0a0a;
    font-weight: 700;
    font-size: 12px;
}

/* ==========================================================
   LAYOUT
   ========================================================== */
.shell {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 40px 28px 80px;
}

.page-head {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 36px; gap: 24px;
    flex-wrap: wrap;
}
.page-title {
    font-family: var(--font-display);
    font-size: clamp(34px, 5vw, 56px);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.035em;
}
.page-title em {
    font-style: normal;
    background: linear-gradient(90deg, var(--accent), var(--cyan));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.page-sub {
    color: var(--muted);
    font-size: 15px;
    margin-top: 8px;
    max-width: 520px;
}

/* ==========================================================
   CARDS / SUPERFICIES
   ========================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--line-2); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 36px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: .6;
}
.stat-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .2em;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 800;
    margin-top: 8px;
    letter-spacing: -.03em;
}
.stat-foot { font-size: 12px; color: var(--dim); margin-top: 4px; }

/* ==========================================================
   GAME GRID
   ========================================================== */
.section-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .25em;
    color: var(--muted);
    margin: 32px 0 16px;
    display: flex; align-items: center; gap: 12px;
}
.section-title::after {
    content: '';
    flex: 1; height: 1px; background: var(--line);
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.game-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: all .25s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}
.game-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 0% 0%, var(--accent-glow), transparent 60%);
    opacity: 0;
    transition: opacity .35s;
    pointer-events: none;
}
.game-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}
.game-card:hover::before { opacity: 1; }

.game-icon {
    width: 56px; height: 56px;
    border-radius: 12px;
    display: grid; place-items: center;
    margin-bottom: 16px;
    font-size: 28px;
    font-weight: 700;
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.game-card[data-cat="arcade"]    .game-icon { color: var(--hot); }
.game-card[data-cat="memoria"]   .game-icon { color: var(--cyan); }
.game-card[data-cat="iq"]        .game-icon { color: var(--accent); }
.game-card[data-cat="cognitivo"] .game-icon { color: var(--amber); }

.game-name {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.02em;
    margin-bottom: 6px;
}
.game-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
    flex: 1;
}
.game-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}
.game-meta .best { color: var(--accent); font-weight: 600; }

.cat-pill {
    position: absolute;
    top: 18px; right: 18px;
    font-family: var(--font-mono);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .15em;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--line);
    color: var(--muted);
}

/* ==========================================================
   BOTONES
   ========================================================== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .01em;
    transition: all .2s;
    border: 1px solid transparent;
}
.btn-primary {
    background: var(--accent);
    color: #0a0a0a;
    box-shadow: 0 4px 24px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 32px var(--accent-glow); }
.btn-ghost {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
}
.btn-ghost:hover { border-color: var(--line-2); background: var(--surface-2); }
.btn-danger {
    background: var(--hot); color: #0a0a0a;
}
.btn-block { width: 100%; justify-content: center; }

/* ==========================================================
   FORMS
   ========================================================== */
.field {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 16px;
}
.field label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .2em;
}
.field input, .field select, .field textarea {
    background: var(--bg-2);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 12px 14px;
    transition: border-color .2s;
    font-family: var(--font-body);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error { background: rgba(255,61,138,.08); border: 1px solid rgba(255,61,138,.3); color: #ffaecf; }
.alert-success { background: rgba(212,255,58,.08); border: 1px solid rgba(212,255,58,.3); color: var(--accent); }

/* ==========================================================
   LEADERBOARD
   ========================================================== */
.lb {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.lb-row {
    display: grid;
    grid-template-columns: 56px 1fr 120px 120px;
    align-items: center;
    padding: 14px 22px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    transition: background .15s;
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: var(--surface-2); }
.lb-row.head {
    background: var(--bg-2);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .2em;
}
.lb-rank {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: var(--dim);
}
.lb-row:nth-child(2) .lb-rank { color: var(--accent); }
.lb-row:nth-child(3) .lb-rank { color: var(--cyan); }
.lb-row:nth-child(4) .lb-rank { color: var(--hot); }
.lb-user { font-weight: 600; }
.lb-score { font-family: var(--font-mono); font-weight: 600; color: var(--accent); text-align: right; }
.lb-level { font-family: var(--font-mono); color: var(--muted); text-align: right; font-size: 12px; }

/* ==========================================================
   GAME UI (canvas wrapper)
   ========================================================== */
.game-shell {
    max-width: 720px;
    margin: 40px auto;
    padding: 0 20px;
}
.game-hud {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 16px;
}
.hud-stat {
    display: flex; flex-direction: column; gap: 2px;
}
.hud-stat label {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .2em;
}
.hud-stat .v {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
}
.hud-stat .v.accent { color: var(--accent); }

.canvas-wrap {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    display: grid; place-items: center;
    position: relative;
    overflow: hidden;
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 720px) {
    .topbar { padding: 12px 16px; flex-wrap: wrap; }
    .topbar nav { order: 3; width: 100%; justify-content: center; }
    .shell { padding: 24px 16px 60px; }
    .lb-row { grid-template-columns: 40px 1fr 90px; padding: 12px 14px; font-size: 13px; }
    .lb-level { display: none; }
}

/* ==========================================================
   UTILS
   ========================================================== */
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mt-32 { margin-top: 32px; }
.text-center { text-align: center; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.tiny { font-size: 11px; }
