@import url(
    'https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&family=Press+Start+2P&display=swap'
);


/* ================================================================
   VARIABLES
   ================================================================ */

:root {

    --bg: #03040a;

    --panel: #080b16;

    --cyan: #00f6ff;

    --purple: #b000ff;

    --pink: #ff008c;

    --green: #00ff66;

    --yellow: #ffe600;

    --white: #f5f7ff;

    --muted: #69718c;

    --border: rgba(
        0,
        246,
        255,
        0.22
    );

    --glow-cyan:
        0 0 5px #00f6ff,
        0 0 15px rgba(
            0,
            246,
            255,
            0.65
        );

    --glow-green:
        0 0 5px #00ff66,
        0 0 20px rgba(
            0,
            255,
            102,
            0.7
        );
}


/* ================================================================
   RESET
   ================================================================ */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
}

body {

    background:
        radial-gradient(
            ellipse at center,
            #10152d 0%,
            #050713 45%,
            #010207 100%
        );

    color: var(--white);

    font-family: 'Orbitron', monospace;

    overflow-x: hidden;
}


/* ================================================================
   CRT EFFECT
   ================================================================ */

body::before {

    content: "";

    position: fixed;

    inset: 0;

    pointer-events: none;

    background:
        radial-gradient(
            ellipse at center,
            transparent 40%,
            rgba(0,0,0,.55) 100%
        );

    z-index: 50;
}

.scanlines {

    position: fixed;

    inset: 0;

    pointer-events: none;

    z-index: 100;

    opacity: .08;

    background:
        repeating-linear-gradient(
            to bottom,
            transparent 0px,
            transparent 3px,
            #fff 4px
        );
}


/* ================================================================
   MAIN ARCADE FRAME
   ================================================================ */

.arcade {

    width: min(
        1500px,
        96vw
    );

    min-height: 100vh;

    margin: auto;

    padding: 28px 20px;

    position: relative;
}


/* ================================================================
   HEADER
   ================================================================ */

.header {

    display: flex;

    align-items: center;

    justify-content: space-between;

    border-bottom: 2px solid var(--border);

    padding-bottom: 20px;

    margin-bottom: 20px;
}

.header-actions {

    display: flex;

    align-items: center;

    gap: 12px;
}

.brand-small {

    font-size: 10px;

    letter-spacing: 5px;

    color: var(--cyan);

    text-shadow: var(--glow-cyan);

    margin-bottom: 8px;
}

h1 {

    margin: 0;

    font-family: 'Press Start 2P', monospace;

    font-size: clamp(
        20px,
        4vw,
        48px
    );

    line-height: 1.3;

    color: white;

    text-shadow:
        3px 3px 0 var(--purple),
        0 0 15px var(--cyan);
}

h1 span {

    color: var(--pink);

    text-shadow:
        0 0 5px var(--pink),
        0 0 20px var(--pink);
}


/* ================================================================
   CONNECTION
   ================================================================ */

.connection {

    display: flex;

    align-items: center;

    gap: 9px;

    font-size: 11px;

    letter-spacing: 2px;

    padding: 9px 14px;

    border: 1px solid;

    border-radius: 4px;
}

.connection-dot {

    width: 9px;
    height: 9px;

    border-radius: 50%;

    display: block;
}

.connection.online {

    color: var(--green);

    border-color: var(--green);

    box-shadow: var(--glow-green);
}

.connection.online .connection-dot {

    background: var(--green);

    box-shadow: var(--glow-green);
}

.connection.offline {

    color: var(--muted);

    border-color: #30364d;
}

.connection.offline .connection-dot {

    background: var(--muted);
}


/* ================================================================
   NAV LINK

   A small pill-shaped link to another page (e.g. the live view
   <-> high scores). Deliberately understated by default -- muted
   border, no glow -- so it doesn't compete with the connection
   status badge, but lights up on hover/focus so it reads clearly
   as clickable.
   ================================================================ */

.nav-link {

    display: flex;

    align-items: center;

    gap: 8px;

    font-size: 11px;

    letter-spacing: 2px;

    padding: 9px 14px;

    border: 1px solid var(--border);

    border-radius: 4px;

    color: var(--cyan);

    text-decoration: none;

    transition:
        border-color .2s,
        box-shadow .2s,
        background .2s;
}

.nav-link:hover,
.nav-link:focus-visible {

    border-color: var(--cyan);

    box-shadow: var(--glow-cyan);

    background: rgba(0, 246, 255, .06);
}


/* ================================================================
   STATUS
   ================================================================ */

.status {

    display: grid;

    grid-template-columns:
        1fr auto 1fr;

    align-items: center;

    margin-bottom: 28px;

    min-height: 100px;
}

.game-state {

    color: var(--cyan);

    font-size: 12px;

    letter-spacing: 4px;
}

.timer {

    font-family: 'Press Start 2P', monospace;

    font-size: clamp(
        28px,
        7vw,
        70px
    );

    color: white;

    text-align: center;

    min-width: 220px;

    text-shadow:
        0 0 5px white,
        0 0 20px var(--cyan),
        0 0 40px var(--cyan);

    transition:
        color .2s,
        text-shadow .2s;
}

.timer.warning {

    color: var(--yellow);

    text-shadow:
        0 0 5px var(--yellow),
        0 0 25px var(--yellow);

    animation:
        timer-pulse .5s infinite alternate;
}

@keyframes timer-pulse {

    from {
        opacity: .65;
    }

    to {
        opacity: 1;
    }
}

.last-update {

    text-align: right;

    font-size: 9px;

    letter-spacing: 2px;

    color: var(--muted);
}


/* ================================================================
   PLAYER GRID
   ================================================================ */

.players {

    display: grid;

    grid-template-columns:
        repeat(
            var(--player-count, 2),
            minmax(0, 1fr)
        );

    gap: 18px;

    min-height: 450px;
}


/* ================================================================
   PLAYER CARD
   ================================================================ */

.player {

    --player-color: var(--cyan);

    position: relative;

    background:
        linear-gradient(
            145deg,
            rgba(255,255,255,.04),
            rgba(255,255,255,.01)
        );

    border: 2px solid
        color-mix(
            in srgb,
            var(--player-color) 35%,
            transparent
        );

    min-height: 450px;

    padding: 24px;

    overflow: hidden;

    transition:
        border-color .25s,
        box-shadow .25s,
        transform .25s;

    contain: layout paint;
}


/* decorative corner */

.player::before {

    content: "";

    position: absolute;

    top: 0;
    left: 0;

    width: 80px;
    height: 3px;

    background: var(--player-color);

    box-shadow:
        0 0 15px var(--player-color);
}

.player::after {

    content: "";

    position: absolute;

    inset: 0;

    pointer-events: none;

    background:
        linear-gradient(
            135deg,
            color-mix(
                in srgb,
                var(--player-color) 6%,
                transparent
            ),
            transparent 35%
        );
}

.player.leader {

    border-color: var(--green);

    box-shadow:
        inset 0 0 40px
            rgba(0,255,102,.08),
        0 0 20px
            rgba(0,255,102,.25);

    transform: scale(1.015);
}

.player.leader::before {

    background: var(--green);

    box-shadow:
        0 0 15px var(--green),
        0 0 30px var(--green);

    width: 100%;
}


/* ================================================================
   PLAYER HEADER
   ================================================================ */

.player-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    position: relative;

    z-index: 1;
}

.player-number {

    font-size: 10px;

    letter-spacing: 3px;

    color: var(--player-color);
}

.player-position {

    font-size: 10px;

    letter-spacing: 2px;

    color: var(--muted);
}

.player.leader .player-position {

    color: var(--green);

    text-shadow: var(--glow-green);
}


/* ================================================================
   PLAYER NAME
   ================================================================ */

.player-name {

    margin-top: 15px;

    font-size: clamp(
        18px,
        3vw,
        28px
    );

    font-weight: 800;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;

    color: white;

    text-shadow:
        0 0 8px
        color-mix(
            in srgb,
            var(--player-color) 50%,
            transparent
        );

    position: relative;

    z-index: 1;
}


/* ================================================================
   SCORE
   ================================================================ */

.score-label {

    margin-top: 28px;

    color: var(--muted);

    font-size: 9px;

    letter-spacing: 4px;

    position: relative;

    z-index: 1;
}

.score {

    font-family: 'Press Start 2P', monospace;

    font-size: clamp(
        32px,
        7vw,
        72px
    );

    line-height: 1;

    margin-top: 10px;

    color: white;

    position: relative;

    z-index: 1;

    transition:
        color .12s,
        text-shadow .12s;
}

.score.bump {

    animation:
        score-bump .25s ease-out;
}

@keyframes score-bump {

    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.16);

        color: var(--green);

        text-shadow:
            0 0 5px var(--green),
            0 0 20px var(--green),
            0 0 40px var(--green);
    }

    65% {
        transform: scale(1.06);
    }

    100% {
        transform: scale(1);

        color: white;
    }
}


/* ================================================================
   STATS
   ================================================================ */

.stats {

    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 10px;

    margin-top: 35px;

    position: relative;

    z-index: 1;
}

.stat {

    background: rgba(
        0,
        0,
        0,
        .35
    );

    border: 1px solid rgba(
        255,
        255,
        255,
        .07
    );

    padding: 12px;
}

.stat-label {

    font-size: 8px;

    color: var(--muted);

    letter-spacing: 2px;
}

.stat-value {

    margin-top: 6px;

    font-size: 20px;

    font-weight: 700;

    color: var(--player-color);
}


/* ================================================================
   KEY HISTORY
   ================================================================ */

.history-label {

    margin-top: 22px;

    font-size: 8px;

    letter-spacing: 2px;

    color: var(--muted);

    position: relative;

    z-index: 1;
}

.history {

    display: flex;

    gap: 4px;

    margin-top: 8px;

    height: 36px;

    position: relative;

    z-index: 1;
}

.key {

    flex: 1;

    min-width: 0;

    display: flex;

    align-items: center;

    justify-content: center;

    border: 1px solid rgba(
        255,
        255,
        255,
        .12
    );

    background: rgba(
        255,
        255,
        255,
        .03
    );

    font-size: 12px;

    color: #aaa;
}

.key.combo {

    color: var(--green);

    border-color: var(--green);

    background: rgba(
        0,
        255,
        102,
        .14
    );

    box-shadow:
        0 0 8px
        rgba(0,255,102,.45);

    animation:
        combo-key .45s
        ease-in-out infinite alternate;
}

@keyframes combo-key {

    from {
        opacity: .65;
    }

    to {
        opacity: 1;
    }
}


/* ================================================================
   COMBO
   ================================================================ */

.combo {

    margin-top: 20px;

    min-height: 40px;

    display: flex;

    align-items: center;

    justify-content: center;

    position: relative;

    z-index: 1;
}

.combo span {

    color: var(--yellow);

    font-family: 'Press Start 2P', monospace;

    font-size: 11px;

    text-shadow:
        0 0 8px var(--yellow);

    animation:
        combo-text .45s
        ease-in-out infinite alternate;
}

@keyframes combo-text {

    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.05);
    }
}


/* ================================================================
   COMBO BANNER
   ================================================================ */

.combo-banner {

    position: fixed;

    left: 50%;

    bottom: 45px;

    transform:
        translateX(-50%);

    z-index: 200;

    padding: 18px 40px;

    text-align: center;

    background:
        rgba(3,4,10,.94);

    border: 2px solid var(--green);

    box-shadow:
        0 0 10px var(--green),
        0 0 35px
            rgba(0,255,102,.5);

    min-width: min(
        500px,
        85vw
    );

    animation:
        combo-banner-in .2s
        ease-out;
}

.combo-banner.hidden {
    display: none;
}

.combo-small {

    font-size: 9px;

    letter-spacing: 5px;

    color: var(--green);
}

.combo-text {

    margin-top: 10px;

    font-family:
        'Press Start 2P',
        monospace;

    font-size: 16px;

    color: white;

    text-shadow:
        0 0 8px var(--green);
}

@keyframes combo-banner-in {

    from {
        opacity: 0;
        transform:
            translateX(-50%)
            translateY(20px)
            scale(.9);
    }

    to {
        opacity: 1;
        transform:
            translateX(-50%)
            translateY(0)
            scale(1);
    }
}


/* ================================================================
   FOOTER
   ================================================================ */

footer {

    display: flex;

    justify-content: space-between;

    margin-top: 25px;

    padding-top: 15px;

    border-top: 1px solid
        rgba(255,255,255,.08);

    color: var(--muted);

    font-size: 8px;

    letter-spacing: 3px;
}

.green-dot {

    display: inline-block;

    width: 6px;
    height: 6px;

    background: var(--green);

    border-radius: 50%;

    box-shadow: var(--glow-green);

    margin-right: 5px;
}


/* ================================================================
   EMPTY / WAITING
   ================================================================ */

.waiting {

    grid-column:
        1 / -1;

    display: flex;

    align-items: center;

    justify-content: center;

    min-height: 400px;

    color: var(--muted);

    font-family:
        'Press Start 2P',
        monospace;

    font-size: 14px;

    letter-spacing: 3px;

    text-align: center;

    animation:
        waiting-pulse 1.5s
        infinite alternate;
}

@keyframes waiting-pulse {

    from {
        opacity: .35;
    }

    to {
        opacity: 1;
    }
}


/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 900px) {

    .players {

        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .player {
        min-height: 380px;
    }
}

@media (max-width: 600px) {

    .arcade {
        width: 100%;
        padding: 15px 10px;
    }

    .header {
        align-items: flex-start;
    }

    .connection,
    .nav-link {
        font-size: 8px;
        padding: 6px 8px;
    }

    .header-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .status {

        grid-template-columns:
            1fr;

        gap: 10px;

        text-align: center;
    }

    .game-state,
    .last-update {
        text-align: center;
    }

    .timer {
        min-width: 0;
    }

    .players {

        grid-template-columns:
            1fr;

        min-height: 0;
    }

    .player {

        min-height: 350px;

        transform: none !important;
    }

    .combo-banner {
        bottom: 20px;
    }
}

/* ============================================================
   HIGH SCORES
   ============================================================ */

.highscores-heading {

    text-align: center;

    font-family: 'Press Start 2P', monospace;

    font-size: clamp(
        16px,
        3vw,
        26px
    );

    letter-spacing: 4px;

    color: var(--cyan);

    text-shadow: var(--glow-cyan);

    margin: 4px 0 28px;
}

.highscores-panel {

    position: relative;

    background:
        linear-gradient(
            145deg,
            rgba(255,255,255,.04),
            rgba(255,255,255,.01)
        );

    border: 2px solid var(--border);

    box-shadow:
        inset 0 0 40px
            rgba(0,246,255,.05);

    padding: 6px 24px 10px;

    overflow: hidden;
}

.highscores-panel::before {

    content: "";

    position: absolute;

    top: 0;
    left: 0;

    width: 100%;
    height: 3px;

    background: var(--cyan);

    box-shadow: 0 0 15px var(--cyan);
}

.highscores {
    width: 100%;
    overflow-x: auto;
}

.highscores-table {
    width: 100%;
    border-collapse: collapse;
}

.highscores-table th,
.highscores-table td {
    padding: 16px 18px;
    text-align: center;
}

.highscores-table th {

    font-size: 9px;

    letter-spacing: 3px;

    color: var(--muted);

    border-bottom: 2px solid var(--border);
}

.highscores-table td {

    font-size: 1.05rem;

    border-bottom: 1px solid
        rgba(255,255,255,.06);
}

.highscores-table tbody tr:hover {
    background: rgba(255,255,255,.03);
}

.highscores-table .rank {

    width: 60px;

    font-family: 'Press Start 2P', monospace;

    font-size: 12px;

    color: var(--cyan);
}

.highscores-table .player {

    text-align: left;

    font-weight: 700;

    color: white;

    text-shadow:
        0 0 8px rgba(0,246,255,.35);
}

.highscores-table .score {

    font-family: 'Press Start 2P', monospace;

    font-size: 14px;

    color: white;

    text-shadow: 0 0 8px var(--cyan);
}

.highscores-table .combos {
    color: var(--yellow);
}

.highscores-table .speed {
    color: var(--green);
}

.highscores-table .empty {

    padding: 60px 20px;

    color: var(--muted);

    font-family: 'Press Start 2P', monospace;

    font-size: 12px;

    letter-spacing: 3px;

    animation:
        waiting-pulse 1.5s
        infinite alternate;
}

/* Top three */

.highscores-table tbody tr:nth-child(1) .rank {
    color: #ffd700;
    text-shadow: 0 0 10px #ffd700;
}

.highscores-table tbody tr:nth-child(2) .rank {
    color: #c0c0c0;
    text-shadow: 0 0 10px #c0c0c0;
}

.highscores-table tbody tr:nth-child(3) .rank {
    color: #cd7f32;
    text-shadow: 0 0 10px #cd7f32;
}

/* Mobile */

@media (max-width: 700px) {

    .highscores-panel {
        padding: 4px 10px 6px;
    }

    .highscores-table th,
    .highscores-table td {
        padding: 10px 8px;
    }

    .highscores-table td {
        font-size: 0.95rem;
    }

    .highscores-table th {
        font-size: 8px;
    }

}