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

body {
    font-family: 'Poppins', sans-serif;
    background: #0a0a1a;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
}

.bg-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(108, 92, 231, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 255, 242, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(253, 121, 168, 0.04) 0%, transparent 60%);
}

#bg-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* ===== NAV BAR ===== */

.nav-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 26, 0.9);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(108, 92, 231, 0.15);
    padding: 0 20px;
}

.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
}

.nav-back-home {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: #a29bfe;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 50px;
    border: 1px solid rgba(108, 92, 231, 0.25);
    background: rgba(108, 92, 231, 0.08);
    transition: all 0.25s;
}
.nav-back-home:hover {
    background: rgba(108, 92, 231, 0.2);
    border-color: rgba(108, 92, 231, 0.5);
    color: #fff;
}

.nav-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #a29bfe, #00fff2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-logo-glow {
    font-size: 1.3rem;
    filter: drop-shadow(0 0 6px rgba(0, 255, 242, 0.5));
    -webkit-text-fill-color: #00fff2;
}

.nav-right {
    width: 90px;
}

/* ===== SCREENS ===== */

.screen {
    display: none;
    position: relative;
    z-index: 1;
}
.screen.active {
    display: block;
}

/* ===== MENU SCREEN ===== */

.menu-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px 60px;
    text-align: center;
}

.menu-hero {
    margin-bottom: 36px;
}

.hero-icon {
    margin-bottom: 16px;
}

.hero-ring {
    animation: heroSpin 12s linear infinite;
    transform-origin: 40px 40px;
}
.hero-ring-inner {
    animation: heroSpin 8s linear infinite reverse;
    transform-origin: 40px 40px;
}
.hero-dot {
    animation: heroPulse 2s ease-in-out infinite;
}

@keyframes heroSpin {
    to { transform: rotate(360deg); }
}
@keyframes heroPulse {
    0%, 100% { r: 5; opacity: 1; }
    50% { r: 7; opacity: 0.7; }
}

.menu-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(135deg, #fff 20%, #a29bfe 50%, #00fff2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.menu-subtitle {
    font-size: 1rem;
    color: #8888a0;
    font-weight: 400;
}

/* Difficulty selector */

.diff-section {
    margin-bottom: 32px;
}

.diff-label {
    font-size: 0.8rem;
    color: #6c6c8a;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
    font-weight: 600;
}

.diff-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.diff-btn {
    padding: 8px 16px;
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: #808090;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}
.diff-btn:hover {
    color: #c0c0d0;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}
.diff-btn.active {
    color: #fff;
    background: rgba(0, 255, 242, 0.12);
    border-color: rgba(0, 255, 242, 0.4);
    box-shadow: 0 0 12px rgba(0, 255, 242, 0.15);
}
.diff-btn .diff-size {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-left: 4px;
}

/* Play button */

.btn-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 48px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #6c5ce7, #00cec9);
    border: none;
    border-radius: 60px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.3);
    margin-bottom: 36px;
}
.btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.5);
}
.btn-play:active {
    transform: translateY(0);
}

.btn-play-icon {
    font-size: 0.9rem;
}

/* Menu stats */

.menu-stats {
    margin-bottom: 32px;
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.menu-stat-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 12px 20px;
    text-align: center;
    min-width: 100px;
}
.menu-stat-card .ms-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #00fff2;
    display: block;
}
.menu-stat-card .ms-label {
    font-size: 0.7rem;
    color: #6c6c8a;
    margin-top: 2px;
}

/* Leaderboard */

.leaderboard-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 20px;
    text-align: left;
}

.lb-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: #a29bfe;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.lb-trophy {
    font-size: 1.1rem;
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s;
}
.lb-row:nth-child(1) { border-color: rgba(255, 215, 0, 0.2); }
.lb-row:nth-child(2) { border-color: rgba(192, 192, 192, 0.15); }
.lb-row:nth-child(3) { border-color: rgba(205, 127, 50, 0.15); }

.lb-rank {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}
.lb-row:nth-child(1) .lb-rank { background: rgba(255, 215, 0, 0.15); color: #ffd700; }
.lb-row:nth-child(2) .lb-rank { background: rgba(192, 192, 192, 0.15); color: #c0c0c0; }
.lb-row:nth-child(3) .lb-rank { background: rgba(205, 127, 50, 0.15); color: #cd7f32; }
.lb-row:nth-child(n+4) .lb-rank { color: #555570; }

.lb-name {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 500;
    color: #d0d0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: #00fff2;
}

.lb-diff {
    font-size: 0.6rem;
    color: #555570;
    background: rgba(255, 255, 255, 0.04);
    padding: 2px 8px;
    border-radius: 20px;
}

.lb-empty {
    text-align: center;
    color: #404050;
    font-size: 0.8rem;
    padding: 20px 0;
}

/* ===== GAME SCREEN ===== */

.game-layout {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 20px 40px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-stats-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 16px;
    width: 100%;
    max-width: 600px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 6px 14px;
    text-align: center;
    flex: 1;
    min-width: 70px;
}
.stat-label {
    font-size: 0.6rem;
    color: #555570;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
}
.stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #00fff2;
    display: block;
}

.canvas-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

#game-canvas {
    border-radius: 12px;
    cursor: pointer;
    touch-action: none;
}

.game-actions {
    display: flex;
    gap: 10px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    color: #a0a0b8;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.25s;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(108, 92, 231, 0.3);
    color: #fff;
}

/* Game sidebar */

.game-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 70px;
}

.game-sidebar .lb-title {
    font-size: 0.85rem;
}

.sidebar-tip {
    margin-top: 16px;
    font-size: 0.75rem;
    color: #404050;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 12px;
    line-height: 1.5;
    text-align: center;
}

/* ===== WIN OVERLAY ===== */

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(5, 5, 15, 0.85);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.overlay.active {
    display: flex;
}

.win-card {
    background: linear-gradient(160deg, rgba(20, 20, 45, 0.95), rgba(10, 10, 25, 0.98));
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: 24px;
    padding: 36px 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(108, 92, 231, 0.1);
    animation: winSlideIn 0.4s ease-out;
}

@keyframes winSlideIn {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.win-stars {
    font-size: 1.8rem;
    margin-bottom: 8px;
    animation: winStarPulse 1.5s ease-in-out infinite;
}
@keyframes winStarPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.win-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #00fff2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}

.win-score-display {
    margin-bottom: 16px;
}
.win-score-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #6c6c8a;
    margin-bottom: 4px;
}
.win-score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.4rem;
    font-weight: 900;
    color: #00fff2;
    text-shadow: 0 0 20px rgba(0, 255, 242, 0.4);
}

.win-details {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.win-detail {
    font-size: 0.78rem;
    color: #8888a0;
}
.win-detail span {
    color: #c0c0e0;
    font-weight: 600;
}

.win-name-section {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.win-name-input {
    flex: 1;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.25s;
}
.win-name-input:focus {
    border-color: rgba(0, 255, 242, 0.5);
}
.win-name-input::placeholder {
    color: #404050;
}

.btn-save-score {
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 242, 0.3);
    background: rgba(0, 255, 242, 0.1);
    color: #00fff2;
    font-family: 'Poppins', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}
.btn-save-score:hover {
    background: rgba(0, 255, 242, 0.2);
    border-color: rgba(0, 255, 242, 0.5);
}
.btn-save-score:disabled {
    opacity: 0.4;
    cursor: default;
}

.win-saved-msg {
    font-size: 0.75rem;
    color: #00b894;
    margin-bottom: 12px;
    min-height: 18px;
}

.win-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.btn-next {
    width: 100%;
    padding: 14px 32px;
    font-size: 1rem;
}

/* ===== ANIMATIONS ===== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== RESPONSIVE ===== */

@media (max-width: 800px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
        padding: 12px 12px 40px;
    }
    .game-sidebar {
        width: 100%;
        max-width: 500px;
        position: static;
    }
    .game-sidebar .lb-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }
    .sidebar-tip {
        display: none;
    }
    .stat-item {
        min-width: 60px;
        padding: 5px 8px;
    }
    .stat-value {
        font-size: 0.82rem;
    }
    .stat-diff {
        display: none;
    }
}

@media (max-width: 500px) {
    .menu-title {
        font-size: 2.2rem;
    }
    .nav-back-text {
        display: none;
    }
    .diff-btn {
        padding: 6px 12px;
        font-size: 0.72rem;
    }
    .btn-play {
        padding: 14px 36px;
        font-size: 0.95rem;
    }
    .win-card {
        padding: 24px 20px;
    }
    .win-score-value {
        font-size: 1.8rem;
    }
    .game-sidebar .lb-list {
        grid-template-columns: 1fr;
    }
}
