:root {
    --bg: #05060f;
    --panel: rgba(11, 14, 30, 0.78);
    --line: rgba(0, 240, 255, 0.22);
    --text: #eafcff;
    --dim: #7f92b8;
    --cyan: #00f0ff;
    --magenta: #ff2d95;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: Orbitron, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
    position: relative;
    padding: 28px 20px 48px;
    overflow-x: hidden;
}

body.no-scroll { overflow: hidden; }

#bgCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: block;
}

.wrap {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
}

/* ---- hero ---- */
.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 26px;
    flex-wrap: wrap;
}

.kicker {
    display: inline-block;
    font-size: 12px;
    letter-spacing: 6px;
    color: var(--magenta);
    text-shadow: 0 0 12px rgba(255, 45, 149, 0.7);
    margin-bottom: 6px;
}

.hero h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 48px);
    font-weight: 900;
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 0 0 18px rgba(0, 240, 255, 0.75), 0 0 46px rgba(0, 240, 255, 0.35);
}

.hero .sub { margin: 8px 0 0; color: var(--dim); font-size: 14px; letter-spacing: 0.5px; }

.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--cyan);
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.45);
    border-radius: 999px;
    padding: 9px 16px;
    cursor: pointer;
    transition: background 0.18s, box-shadow 0.18s, transform 0.12s;
}
.pill:hover { background: rgba(0, 240, 255, 0.2); box-shadow: 0 0 16px rgba(0, 240, 255, 0.35); }
.pill:active { transform: scale(0.96); }
.pill.off { opacity: 0.5; }

/* ---- toolbar ---- */
.toolbar {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(3, 6, 16, 0.85);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 12px;
    padding: 0 14px;
    flex: 1 1 260px;
    max-width: 420px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search:focus-within { border-color: var(--cyan); box-shadow: 0 0 18px rgba(0, 240, 255, 0.35); }
.search-icon { color: var(--cyan); font-size: 20px; }
.search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    padding: 12px 0;
}
.search input::placeholder { color: #4a5b7a; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    font-family: inherit;
    font-size: 13px;
    color: var(--dim);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 7px 15px;
    cursor: pointer;
    transition: all 0.18s;
}
.chip:hover { color: #fff; border-color: rgba(0, 240, 255, 0.5); }
.chip.active {
    color: #04141a;
    background: linear-gradient(135deg, #00f0ff, #39ff14);
    border-color: transparent;
    box-shadow: 0 0 16px rgba(0, 240, 255, 0.5);
}

/* ---- recent ---- */
.recent { margin-bottom: 22px; }
.recent h2 { font-size: 13px; letter-spacing: 3px; color: var(--dim); font-weight: 700; margin: 0 0 10px; }
.recent-list { display: flex; gap: 10px; flex-wrap: wrap; }
.recent-item {
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.18s;
}
.recent-item:hover { transform: translateY(-2px); box-shadow: 0 0 16px var(--accent, rgba(0, 240, 255, 0.4)); }

/* ---- grid ---- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.card {
    --accent: #00f0ff;
    font-family: inherit;
    text-align: left;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: transform 0.18s ease, box-shadow 0.22s ease, border-color 0.22s;
    outline: none;
}
.card:hover, .card:focus-visible {
    transform: translateY(-6px);
    border-color: var(--accent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 26px var(--accent);
}
.card:focus-visible { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 26px var(--accent); }

.thumb {
    position: relative;
    height: 132px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--accent) 42%, transparent), transparent 60%),
        radial-gradient(circle at 78% 80%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 55%),
        #060a18;
    overflow: hidden;
}
.thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
    opacity: 0.55;
    pointer-events: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .icon {
    font-size: 58px;
    filter: drop-shadow(0 0 16px var(--accent));
    transform: translateZ(0);
    transition: transform 0.25s ease;
}
.card:hover .thumb .icon { transform: scale(1.12) rotate(-3deg); }
.thumb .cat {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 11px;
    letter-spacing: 1px;
    color: #04141a;
    background: var(--accent);
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 700;
    box-shadow: 0 0 12px var(--accent);
}

.body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.body h3 { margin: 0; font-size: 19px; letter-spacing: 0.5px; }
.body p { margin: 0; color: var(--dim); font-size: 13px; line-height: 1.55; }

.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tags span { font-size: 11px; color: color-mix(in srgb, var(--accent) 75%, #ffffff); opacity: 0.9; }

.meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.meta .controls { font-size: 10.5px; color: #5f7093; line-height: 1.4; }
.meta .best {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
    white-space: nowrap;
}

.empty { text-align: center; color: var(--dim); padding: 60px 0; font-size: 15px; }

.foot { margin-top: 34px; text-align: center; color: #54648a; font-size: 12px; letter-spacing: 0.5px; }
.foot kbd {
    font-family: inherit;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 5px;
    padding: 1px 6px;
    margin: 0 2px;
    color: #cfe6ff;
}

.hidden { display: none !important; }

/* ---- overlay ---- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: #02030a;
    animation: fade 0.22s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.overlay-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(8, 11, 24, 0.95);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}
.overlay-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.overlay-title span#overlayIcon { font-size: 20px; }
.overlay-actions { display: flex; gap: 8px; }

.overlay-body { position: relative; flex: 1; }
#gameFrame { position: absolute; inset: 0; width: 100%; height: 100%; border: none; background: #02030a; z-index: 2; }

.loader {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--dim);
    font-size: 14px;
}
.spinner {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid rgba(0, 240, 255, 0.2);
    border-top-color: var(--cyan);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
    body { padding: 18px 14px 36px; }
    .thumb { height: 112px; }
    .meta { flex-direction: column; align-items: flex-start; }
}
