:root {
    --bg: #06070d;
    --bg2: #0b0e1a;
    --panel: rgba(255, 255, 255, .04);
    --panel-line: rgba(255, 255, 255, .08);
    --text: #eef1f8;
    --text2: #8b93ad;
    --accent: #7c5cff;
    --accent2: #00e6c3;
    --danger: #ff5470;
    --r: 16px;
    --font-display: 'Sora', system-ui, sans-serif;
    --font-body: 'Outfit', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(60% 50% at 15% -5%, rgba(124, 92, 255, .22), transparent 60%),
        radial-gradient(55% 45% at 95% 5%, rgba(0, 230, 195, .14), transparent 60%),
        linear-gradient(180deg, var(--bg2), var(--bg));
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: .035;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 22px;
    backdrop-filter: blur(14px);
    background: rgba(6, 7, 13, .6);
    border-bottom: 1px solid var(--panel-line);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 19px;
    letter-spacing: -.02em;
    color: var(--text);
    text-decoration: none;
}
.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 0 16px var(--accent);
}

/* ---------- SPA chrome ---------- */
#spa-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0;
    z-index: 100;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    box-shadow: 0 0 10px var(--accent);
    opacity: 0;
}
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    place-items: center;
    background: rgba(6, 7, 13, .55);
    backdrop-filter: blur(6px);
}
.page-loader.is-active { display: grid; }
.loader-spinner, .play-spinner {
    width: 46px; height: 46px;
    border-radius: 50%;
    border: 3px solid var(--panel-line);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Games page ---------- */
.games-shell {
    max-width: 1240px;
    margin: 0 auto;
    padding: 34px 22px 80px;
}
.games-hero {
    position: relative;
    padding: 34px 0 18px;
    overflow: hidden;
}
.games-hero__glow {
    position: absolute;
    top: -120px; left: 50%;
    transform: translateX(-50%);
    width: 520px; height: 280px;
    background: radial-gradient(50% 50% at 50% 50%, rgba(124, 92, 255, .35), transparent 70%);
    filter: blur(20px);
    pointer-events: none;
}
.games-hero__title {
    position: relative;
    font-family: var(--font-display);
    font-size: clamp(30px, 5vw, 50px);
    font-weight: 800;
    letter-spacing: -.03em;
    margin: 0;
    background: linear-gradient(120deg, #fff 30%, var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.games-hero__sub {
    position: relative;
    color: var(--text2);
    margin: 8px 0 0;
    font-size: 15px;
}
.games-search {
    position: relative;
    margin-top: 22px;
    max-width: 460px;
}
.games-search svg {
    position: absolute;
    left: 16px; top: 50%;
    transform: translateY(-50%);
    width: 18px; height: 18px;
    color: var(--text2);
}
.games-search input {
    width: 100%;
    height: 50px;
    padding: 0 16px 0 44px;
    border-radius: 999px;
    border: 1px solid var(--panel-line);
    background: var(--panel);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.games-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(124, 92, 255, .15);
}

.api-tabs {
    display: flex;
    gap: 8px;
    margin-top: 26px;
    flex-wrap: wrap;
}
.api-tab {
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid var(--panel-line);
    background: transparent;
    color: var(--text2);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: .2s;
}
.api-tab:hover { color: var(--text); border-color: var(--accent); }
.api-tab.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #5b3dff);
    border-color: transparent;
    box-shadow: 0 8px 24px -8px var(--accent);
}

.prov-bar {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
}
.prov-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    padding: 7px 14px;
    border-radius: 12px;
    border: 1px solid var(--panel-line);
    background: var(--panel);
    color: var(--text2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: .18s;
}
.prov-chip i {
    font-style: normal;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 7px;
    background: rgba(255, 255, 255, .06);
    color: var(--text2);
}
.prov-chip:hover { color: var(--text); border-color: rgba(124, 92, 255, .5); }
.prov-chip.is-active {
    color: #fff;
    border-color: var(--accent2);
    background: rgba(0, 230, 195, .08);
}
.prov-chip.is-active i { background: var(--accent2); color: #04231d; }

.games-grid {
    margin-top: 28px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 18px;
}

.game-card {
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: rise .4s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.game-card__art {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: var(--r);
    overflow: hidden;
    border: 1px solid var(--panel-line);
    background: var(--bg2);
    transition: transform .25s, box-shadow .25s, border-color .25s;
}
.game-card__art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game-card__ph {
    width: 100%; height: 100%;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: 46px;
    font-weight: 800;
    color: var(--accent);
    background: radial-gradient(circle at 50% 35%, rgba(124, 92, 255, .25), transparent 70%);
}
.game-card__badge {
    position: absolute;
    top: 8px; left: 8px;
    padding: 3px 8px;
    border-radius: 7px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: rgba(6, 7, 13, .7);
    backdrop-filter: blur(6px);
    color: var(--accent2);
}
.game-card__play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    opacity: 0;
    background: linear-gradient(180deg, rgba(6,7,13,.1), rgba(6,7,13,.7));
    transition: opacity .25s;
}
.game-card__play svg {
    width: 46px; height: 46px;
    padding: 12px;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 10px 30px -6px var(--accent);
}
.game-card:hover .game-card__art {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 18px 40px -16px rgba(124, 92, 255, .7);
}
.game-card:hover .game-card__play { opacity: 1; }
.game-card__meta { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.game-card__name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.game-card__prov { font-size: 12px; color: var(--text2); }

.games-status {
    margin-top: 50px;
    text-align: center;
    color: var(--text2);
    font-size: 15px;
}
.games-more { margin-top: 32px; text-align: center; }
.games-more button {
    padding: 12px 32px;
    border-radius: 999px;
    border: 1px solid var(--panel-line);
    background: var(--panel);
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 600;
    cursor: pointer;
    transition: .2s;
}
.games-more button:hover { border-color: var(--accent); }
.games-more button:disabled { opacity: .5; cursor: default; }

/* ---------- Play page ---------- */
.play-shell { display: flex; flex-direction: column; height: calc(100vh - 64px); }
.play-top {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--panel-line);
}
.play-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text2);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: color .2s;
}
.play-back:hover { color: var(--text); }
.play-back svg { width: 18px; height: 18px; }
.play-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    margin-right: auto;
}
.play-full {
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--panel-line);
    background: var(--panel);
    color: var(--text2);
    cursor: pointer;
    transition: .2s;
}
.play-full:hover { color: var(--text); border-color: var(--accent); }
.play-full svg { width: 18px; height: 18px; }

.play-stage { position: relative; flex: 1; background: #000; }
.play-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.play-loader, .play-error {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text2);
    text-align: center;
    padding: 24px;
}
.play-error h2 { font-family: var(--font-display); color: var(--text); }
.play-error button {
    padding: 10px 24px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.play-shell[data-state="loading"] .play-loader { display: flex; }
.play-shell[data-state="error"] .play-error { display: flex; }
.play-shell[data-state="loaded"] .play-frame { z-index: 2; }

/* ---------- 404 ---------- */
.nf-shell {
    position: relative;
    min-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
    padding: 24px;
}
.nf-glow {
    position: absolute;
    width: 460px; height: 460px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(124, 92, 255, .25), transparent 65%);
    filter: blur(30px);
}
.nf-code {
    position: relative;
    font-family: var(--font-display);
    font-size: clamp(80px, 16vw, 150px);
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(120deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.nf-title { position: relative; font-family: var(--font-display); margin: 0; }
.nf-sub { position: relative; color: var(--text2); margin: 0; }
.nf-btn {
    position: relative;
    margin-top: 8px;
    padding: 12px 28px;
    border-radius: 999px;
    text-decoration: none;
    color: #fff;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), #5b3dff);
    box-shadow: 0 12px 30px -10px var(--accent);
}

/* ---------- Admin import ---------- */
.admin-shell {
    max-width: 880px;
    margin: 0 auto;
    padding: 40px 22px 80px;
}
.admin-head h1 {
    font-family: var(--font-display);
    font-size: clamp(26px, 4vw, 38px);
    font-weight: 800;
    letter-spacing: -.03em;
    margin: 0;
    background: linear-gradient(120deg, #fff 30%, var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.admin-head p { color: var(--text2); margin: 8px 0 0; }

.admin-controls {
    margin-top: 26px;
    display: flex;
    align-items: flex-end;
    gap: 22px;
    flex-wrap: wrap;
}
.admin-token { flex: 1; min-width: 240px; }
.admin-token label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text2);
    margin-bottom: 8px;
}
.admin-token input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid var(--panel-line);
    background: var(--panel);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.admin-token input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(124, 92, 255, .15);
}

.admin-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    height: 48px;
}
.admin-switch input { display: none; }
.admin-switch__track {
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    position: relative;
    transition: background .2s;
}
.admin-switch__thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform .2s;
}
.admin-switch input:checked + .admin-switch__track {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.admin-switch input:checked + .admin-switch__track .admin-switch__thumb {
    transform: translateX(20px);
}
.admin-switch__label { font-size: 14px; font-weight: 600; color: var(--text); }

.admin-apis {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.admin-api {
    border-radius: var(--r);
    border: 1px solid var(--panel-line);
    background: var(--panel);
    overflow: hidden;
}
.admin-api--all {
    background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(0,230,195,.1));
    border-color: rgba(124, 92, 255, .4);
}
.admin-api__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    flex-wrap: wrap;
}
.admin-api__name { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.admin-api__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.admin-btn {
    padding: 9px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, var(--accent), #5b3dff);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: .18s;
}
.admin-btn:hover { box-shadow: 0 10px 24px -10px var(--accent); transform: translateY(-1px); }
.admin-btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }
.admin-btn--ghost {
    background: transparent;
    border-color: var(--panel-line);
    color: var(--text2);
}
.admin-btn--ghost:hover { color: var(--text); border-color: var(--accent); box-shadow: none; }
.admin-btn--accent { background: linear-gradient(135deg, var(--accent2), #00b89c); color: #04231d; }
.admin-btn--sm { padding: 6px 14px; font-size: 12px; }

.admin-api__providers {
    border-top: 1px solid var(--panel-line);
    padding: 8px 20px 16px;
    max-height: 380px;
    overflow-y: auto;
}
.admin-loading { color: var(--text2); font-size: 14px; padding: 12px 0; }
.prov-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.prov-row:last-child { border-bottom: none; }
.prov-row__name { font-size: 14px; font-weight: 500; }

.admin-out {
    margin-top: 22px;
    padding: 18px;
    border-radius: var(--r);
    border: 1px solid var(--panel-line);
    background: rgba(0, 0, 0, .35);
    color: var(--text);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}