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

:root {
    --bg-0: #081226;
    --bg-1: #0d1f3f;
    --bg-2: #17335e;
    --cyan: #00f5ff;
    --magenta: #ff006e;
    --gold: #ffe600;
    --mint: #00ff88;
    --text: #f4fbff;
    --muted: rgba(231, 246, 255, 0.74);
    --panel: rgba(10, 18, 36, 0.82);
    --panel-border: rgba(255, 255, 255, 0.18);
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at 16% 10%, #214f96 0%, transparent 44%),
        radial-gradient(circle at 84% 86%, #3a1a59 0%, transparent 36%),
        linear-gradient(170deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
    color: var(--text);
    font-family: 'Space Grotesk', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

.back-link {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1200;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.86rem;
    letter-spacing: 0.06em;
    background: rgba(0, 0, 0, 0.32);
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    transition: 0.2s ease;
}

.back-link:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.34);
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
}

.panel {
    width: min(450px, 100%);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    padding: 30px 24px;
    text-align: center;
    backdrop-filter: blur(16px);
    box-shadow: 0 24px 90px rgba(0, 0, 0, 0.44),
        inset 0 0 20px rgba(255, 255, 255, 0.05);
}

.title {
    font-family: 'Changa', sans-serif;
    font-size: clamp(1.8rem, 10vw, 3.1rem);
    line-height: 1;
    letter-spacing: 0.05em;
    text-shadow: 0 0 24px rgba(0, 245, 255, 0.55), 0 0 54px rgba(255, 0, 110, 0.26);
}

.subtitle {
    margin-top: 9px;
    margin-bottom: 24px;
    color: var(--muted);
    letter-spacing: 0.14em;
    font-size: 0.79rem;
}

.best-row {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 20px;
    color: #dbedff;
}

.best-row span {
    font-size: 0.74rem;
    letter-spacing: 0.1em;
    opacity: 0.86;
}

.best-row strong {
    font-size: 2rem;
    color: var(--gold);
    text-shadow: 0 0 18px rgba(255, 230, 0, 0.4);
}

.btn {
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 14px 16px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    letter-spacing: 0.07em;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.14s ease, filter 0.14s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(120deg, #00f5ff, #00b6ff 35%, #ff4fa6);
    color: #071224;
}

.btn-primary:hover {
    filter: brightness(1.06);
}

.btn-secondary {
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.26);
    color: #fff;
}

.hint {
    margin-top: 13px;
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
}

.over-title {
    font-family: 'Changa', sans-serif;
    letter-spacing: 0.05em;
    font-size: 1.6rem;
    margin-bottom: 4px;
}

.over-game-name {
    font-size: 0.74rem;
    letter-spacing: 0.2em;
    color: var(--muted);
    margin-bottom: 12px;
}

.score-label {
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    color: var(--muted);
}

.score-value {
    font-size: 2.9rem;
    font-weight: 700;
    color: var(--gold);
    margin-top: 4px;
    text-shadow: 0 0 18px rgba(255, 230, 0, 0.44);
}

.stats {
    margin: 16px 0 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.stat-value {
    font-size: 1.26rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.64rem;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.share-feedback {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--mint);
}

.share-feedback.hidden {
    visibility: hidden;
}

.hud {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    display: flex;
    gap: 8px;
}

.hud.hidden {
    display: none;
}

.hud-chip {
    background: rgba(5, 14, 32, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    padding: 8px 12px;
    min-width: 92px;
    text-align: center;
}

.hud-chip span {
    display: block;
    font-size: 0.58rem;
    letter-spacing: 0.15em;
    color: var(--muted);
}

.hud-chip strong {
    display: block;
    margin-top: 2px;
    font-size: 1rem;
}

@media (max-width: 560px) {
    .back-link {
        top: 10px;
        left: 10px;
        font-size: 0.75rem;
        padding: 7px 10px;
    }

    .panel {
        padding: 24px 16px;
    }

    .button-row {
        grid-template-columns: 1fr;
    }

    .hud {
        top: 10px;
        gap: 6px;
    }

    .hud-chip {
        min-width: 80px;
        padding: 7px 9px;
    }
}
