:root {
    --bg: #05070d;
    --bg-2: #0b1220;
    --cyan: #00f0ff;
    --magenta: #ff2bd6;
    --gold: #ffd166;
    --lime: #7dff6a;
    --text: #e8f4ff;
    --muted: #8aa0b8;
    --card: rgba(10, 18, 36, 0.72);
    --stroke: rgba(0, 240, 255, 0.28);
    --radius: 18px;
    --font-display: "Orbitron", sans-serif;
    --font-body: "Rajdhani", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(0, 240, 255, 0.16), transparent 50%),
        radial-gradient(900px 500px at 110% 10%, rgba(255, 43, 214, 0.14), transparent 45%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 18px;
    overflow-x: hidden;
}

.scanlines {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 8;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.03) 0,
        rgba(255, 255, 255, 0.03) 1px,
        transparent 1px,
        transparent 4px
    );
    mix-blend-mode: overlay;
}
.bg-stars {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.app { position: relative; z-index: 1; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--stroke);
    backdrop-filter: blur(12px);
}
.brand { text-decoration: none; color: var(--cyan); display: flex; flex-direction: column; line-height: 1; }
.brand-mark { font-family: var(--font-display); font-weight: 800; letter-spacing: 0.18em; font-size: 20px; }
.brand-sub { font-size: 11px; letter-spacing: 0.42em; color: var(--magenta); }
.player-chip {
    margin-left: auto;
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--stroke);
    border-radius: 999px;
    background: rgba(0, 240, 255, 0.06);
}
.player-chip .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--lime); box-shadow: 0 0 10px var(--lime);
}
.player-chip small { color: var(--muted); }
.topnav { display: flex; gap: 12px; }
.topnav a, .linkish {
    background: none; border: 0; color: var(--cyan); cursor: pointer;
    font-family: var(--font-body); font-size: 16px; text-decoration: none;
}
.stage { flex: 1; padding: 28px 22px 48px; max-width: 1100px; width: 100%; margin: 0 auto; }

h1, h2, h3 { font-family: var(--font-display); margin: 0 0 10px; }
h1 { font-size: clamp(32px, 6vw, 64px); letter-spacing: 0.04em; }
h1 span { color: var(--cyan); text-shadow: 0 0 18px rgba(0, 240, 255, 0.6); }
.kicker {
    color: var(--magenta); letter-spacing: 0.28em; text-transform: uppercase;
    font-size: 12px; margin: 0 0 8px;
}
.lede { color: var(--muted); max-width: 52ch; }
.hint { color: var(--gold); margin: 8px 0 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; cursor: pointer; text-decoration: none;
    font-family: var(--font-display); font-size: 13px; letter-spacing: 0.12em;
    text-transform: uppercase; padding: 14px 22px; border-radius: 999px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
    color: #031016; background: linear-gradient(90deg, var(--cyan), #7dfff3);
    box-shadow: 0 0 24px rgba(0, 240, 255, 0.35);
}
.btn-ghost {
    color: var(--text); background: transparent; border: 1px solid var(--stroke);
}
.btn-gold {
    color: #2a1b00; background: linear-gradient(90deg, var(--gold), #fff1b8);
    box-shadow: 0 0 24px rgba(255, 209, 102, 0.4);
}

.hero { text-align: center; padding-top: 24px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 24px 0 36px; }
.hero .lede { margin: 0 auto; }
.game-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.preview-card, .panel, .game-tile, .board-card, .combo-meter {
    background: var(--card);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}
.preview-card.c1 { border-color: rgba(255, 43, 214, 0.4); }
.preview-card.c2 { border-color: rgba(125, 255, 106, 0.35); }
.preview-card.c3 { border-color: rgba(255, 209, 102, 0.4); }

.form { display: grid; gap: 14px; max-width: 420px; }
.form label { display: grid; gap: 6px; color: var(--muted); font-size: 15px; }
.form input, .prize-row input[type="text"], .prize-row input[type="number"] {
    background: #070d18; border: 1px solid var(--stroke); color: var(--text);
    border-radius: 12px; padding: 12px 14px; font-size: 18px; font-family: var(--font-body);
}
.error { color: #ff6b8a; }
.panel { max-width: 560px; margin: 0 auto; }

.hub-hero { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 20px; margin-bottom: 22px; }
.combo-meter .combo-label { display: flex; justify-content: space-between; margin-bottom: 8px; }
.bar { height: 12px; background: #10182a; border-radius: 999px; overflow: hidden; }
.bar i {
    display: block; height: 100%;
    background: linear-gradient(90deg, var(--magenta), var(--cyan), var(--gold));
    box-shadow: 0 0 16px var(--cyan);
}
.game-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.game-tile { text-decoration: none; color: inherit; min-height: 220px; position: relative; overflow: hidden; }
.game-tile:hover { transform: translateY(-4px); transition: 0.2s ease; }
.game-tile .tag { color: var(--cyan); letter-spacing: 0.2em; font-size: 12px; }
.game-tile.gun { background: linear-gradient(160deg, rgba(255, 43, 214, 0.16), var(--card)); }
.game-tile.snake { background: linear-gradient(160deg, rgba(125, 255, 106, 0.14), var(--card)); }
.game-tile.word { background: linear-gradient(160deg, rgba(255, 209, 102, 0.14), var(--card)); }

.game-shell { display: flex; flex-direction: column; gap: 12px; }
.hud {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.hud-back {
    color: var(--cyan); text-decoration: none; border: 1px solid var(--stroke);
    padding: 8px 12px; border-radius: 999px;
}
.hud-stat {
    background: var(--card); border: 1px solid var(--stroke); border-radius: 14px;
    padding: 8px 14px; min-width: 90px;
}
.hud-stat span { display: block; color: var(--muted); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.hud-stat strong { font-family: var(--font-display); font-size: 20px; }
.hud-stat.hearts { color: #ff4d6d; letter-spacing: 4px; font-size: 22px; }

.canvas-wrap, .word-wrap {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--stroke);
    background: #070b14;
    min-height: min(70dvh, 640px);
}
.canvas-wrap canvas { display: block; width: 100%; height: min(70dvh, 640px); touch-action: none; cursor: crosshair; }
.canvas-wrap.snake canvas { cursor: default; }
.overlay {
    position: absolute; inset: 0; display: grid; place-items: center;
    background: rgba(5, 8, 16, 0.72); backdrop-filter: blur(6px);
}
.overlay.hidden { display: none; }
.overlay-card { text-align: center; padding: 24px; max-width: 420px; }
.overlay-card .btn { margin: 10px 6px 0; }

.word-stage { padding: 22px; display: grid; gap: 16px; min-height: min(70dvh, 640px); }
.timer-bar { height: 8px; background: #152033; border-radius: 99px; overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: var(--cyan); transform-origin: left; }
.letters, .built {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
}
.tile {
    width: 58px; height: 64px; display: grid; place-items: center;
    font-family: var(--font-display); font-size: 24px;
    border-radius: 12px; border: 1px solid var(--stroke);
    background: #10192b; cursor: pointer; user-select: none;
}
.tile.used { opacity: 0.3; pointer-events: none; }
.tile.pop { animation: pop 0.25s ease; }
.built .tile { border-color: var(--gold); color: var(--gold); }
.word-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.word-msg { text-align: center; min-height: 1.4em; color: var(--gold); }

.board-head { margin-bottom: 18px; }
.board-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-list li {
    display: grid; grid-template-columns: 42px 1fr auto; gap: 8px; align-items: center;
    padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.rank-list .empty { grid-template-columns: 1fr; color: var(--muted); }
.rank { color: var(--cyan); font-family: var(--font-display); }
.who small { color: var(--muted); margin-left: 6px; }
.pts { font-family: var(--font-display); color: var(--gold); }
.board-card.featured { margin-bottom: 8px; }

.prize-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.qrbox {
    width: 260px; height: 260px; margin: 16px auto; padding: 12px;
    background: #dffaff; border-radius: 16px;
    display: grid; place-items: center;
}
.slot {
    height: 160px; display: grid; place-items: center;
    border: 1px solid var(--gold); border-radius: 20px;
    background: radial-gradient(circle at 50% 0%, rgba(255, 209, 102, 0.18), #0a0f1a 70%);
    overflow: hidden;
}
.slot-window { height: 72px; overflow: hidden; }
.slot-reel {
    font-family: var(--font-display); font-size: 28px; text-align: center;
    color: var(--gold); text-shadow: 0 0 18px rgba(255, 209, 102, 0.8);
}
.slot-reel.spin { animation: slotspin 0.12s linear infinite; }
.prize-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.inline { display: flex; gap: 6px; align-items: center; color: var(--muted); }

@keyframes pop { from { transform: scale(0.7); } to { transform: scale(1); } }
@keyframes slotspin {
    from { transform: translateY(-12px); filter: blur(2px); }
    to { transform: translateY(12px); filter: blur(2px); }
}

@media (max-width: 860px) {
    .game-preview, .game-grid, .board-grid, .hub-hero, .prize-layout {
        grid-template-columns: 1fr;
    }
    .topbar { flex-wrap: wrap; }
    .player-chip { margin-left: 0; }
    .tile { width: 46px; height: 52px; font-size: 18px; }
}
