:root {
    --primary-color: #00f2ff;
    --secondary-color: #00ff9d;
    --accent-color: #ff6b35;
    --bg-dark: #0a0e27;
    --bg-darker: #050714;
    --text-light: #ffffff;
    --text-dim: #a0a0a0;
    --glow-primary: 0 0 20px rgba(0, 242, 255, 0.6);
    --glow-secondary: 0 0 20px rgba(0, 255, 157, 0.6);
}

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

body {
    font-family: 'Arial', 'Microsoft JhengHei', sans-serif;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    color: var(--text-light);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameContainer {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    background: #1a1a2e;
    box-shadow: 0 0 50px rgba(0, 242, 255, 0.3);
}

/* Screens */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Menu Content */
.menu-content {
    background: rgba(10, 14, 39, 0.95);
    padding: 30px;
    border-radius: 20px;
    border: 2px solid var(--primary-color);
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--glow-primary);
}

/* Compact layout for game over screen */
#gameOverScreen .menu-content {
    padding: 25px;
    max-height: 80vh;
}

#gameOverScreen h2 {
    margin-bottom: 15px;
    font-size: 1.8em;
}

/* Main Menu Logo (Top) */
.menu-logo {
    max-width: 180px;
    height: auto;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px rgba(0, 242, 255, 0.3));
}

/* Language Selector */
.language-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.lang-option {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--primary-color);
    color: var(--text-light);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s ease;
    outline: none;
}

.lang-option:hover {
    background: rgba(0, 242, 255, 0.2);
    transform: translateY(-2px);
}

.lang-option.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--bg-dark);
    font-weight: bold;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.5);
}

/* Logo in Bottom Left Corner (Main Menu & Game Over) */
.menu-logo-corner,
.gameover-logo-corner {
    position: fixed;
    bottom: 30px;
    left: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 101;
}

.menu-logo-corner img,
.gameover-logo-corner img {
    max-width: 120px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(0, 242, 255, 0.4));
    transition: transform 0.3s ease;
    cursor: pointer;
}

.menu-logo-corner:hover img,
.gameover-logo-corner:hover img {
    transform: scale(1.05);
}

.more-games-text {
    font-size: 1.1em;
    color: var(--primary-color);
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 242, 255, 0.6);
    white-space: nowrap;
    cursor: pointer;
}

/* Title */
.game-title {
    margin-bottom: 25px;
    text-align: center;
}

.title-main {
    display: block;
    font-size: 3em;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(0, 242, 255, 0.5);
    margin-bottom: 10px;
}

.title-sub {
    display: block;
    font-size: 1.5em;
    color: var(--secondary-color);
    text-shadow: var(--glow-secondary);
}

/* Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    padding: 12px 30px;
    font-size: 1em;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--bg-dark);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 30px rgba(0, 242, 255, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: rgba(0, 242, 255, 0.2);
    transform: translateY(-3px);
}

/* Instructions */
.instructions-content {
    text-align: left;
    margin: 20px 0;
    max-height: 60vh;
    overflow-y: auto;
}

.instruction-section {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 242, 255, 0.05);
    border-left: 3px solid var(--primary-color);
    border-radius: 5px;
}

.instruction-section h3 {
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.instruction-section p {
    margin: 5px 0;
    line-height: 1.6;
}

/* HUD */
.hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    z-index: 50;
    pointer-events: none;
    display: none;
}

.hud.active {
    display: block;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.hud-item {
    background: rgba(10, 14, 39, 0.8);
    padding: 10px 20px;
    border-radius: 10px;
    border: 2px solid var(--primary-color);
    box-shadow: var(--glow-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-size: 0.8em;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.hud-value {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
}

.combo-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3em;
    font-weight: bold;
    color: var(--accent-color);
    text-shadow: 0 0 20px rgba(255, 107, 53, 0.8);
    opacity: 0;
    pointer-events: none;
    animation: comboPopup 1s ease;
}

@keyframes comboPopup {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

.powerup-indicators {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

.powerup-indicator {
    background: rgba(10, 14, 39, 0.9);
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
    box-shadow: var(--glow-secondary);
    font-size: 0.9em;
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Keyboard Hints */
.keyboard-hints {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hud.active .keyboard-hints {
    opacity: 1;
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(10, 14, 39, 0.8);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
}

.hint-item kbd {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--bg-dark);
    padding: 4px 10px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.9em;
    min-width: 50px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hint-item span {
    color: var(--text-light);
    font-size: 0.9em;
}

/* Game Over Stats */
.game-over-stats,
.pause-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 15px 0;
    padding: 15px;
    background: rgba(0, 242, 255, 0.05);
    border-radius: 10px;
    border: 1px solid var(--primary-color);
}

.stat-item {
    text-align: center;
    padding: 8px;
}

.stat-label {
    display: block;
    font-size: 0.85em;
    color: var(--secondary-color);
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 1.3em;
    font-weight: bold;
    color: var(--primary-color);
}

.pause-stats {
    grid-template-columns: 1fr;
    gap: 8px;
}

.pause-stats p {
    margin: 6px 0;
    font-size: 1em;
}

/* High Score Input */
.high-score-input {
    margin: 15px 0;
    padding: 15px;
    background: rgba(0, 255, 157, 0.1);
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
}

.congrats-text {
    color: var(--secondary-color);
    font-size: 1em;
    margin-bottom: 12px;
}

#playerNameInput {
    width: 100%;
    max-width: 300px;
    padding: 10px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    color: var(--text-light);
    font-size: 1em;
    text-align: center;
}

#playerNameInput:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 10px rgba(0, 255, 157, 0.3);
}

/* Menu Buttons */
.leaderboard-list {
    margin: 20px 0;
    max-height: 60vh;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin: 10px 0;
    background: rgba(0, 242, 255, 0.05);
    border-radius: 10px;
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s ease;
}

.leaderboard-item:hover {
    background: rgba(0, 242, 255, 0.1);
    transform: translateX(5px);
}

.leaderboard-item.rank-1 {
    border-left-color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
}

.leaderboard-item.rank-2 {
    border-left-color: #c0c0c0;
    background: rgba(192, 192, 192, 0.1);
}

.leaderboard-item.rank-3 {
    border-left-color: #cd7f32;
    background: rgba(205, 127, 50, 0.1);
}

.leaderboard-rank {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
    min-width: 50px;
}

.leaderboard-name {
    flex: 1;
    font-size: 1.2em;
    margin: 0 20px;
}

.leaderboard-score {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--secondary-color);
}

.leaderboard-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
    font-size: 1.1em;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .title-main {
        font-size: 2em;
    }

    .title-sub {
        font-size: 1.2em;
    }

    .menu-content {
        padding: 20px;
        max-width: 90%;
    }

    .btn {
        padding: 12px 30px;
        font-size: 1em;
    }

    .hud-top {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .hud-item {
        padding: 8px 15px;
        flex: 1;
        min-width: 80px;
    }

    .hud-label {
        font-size: 0.7em;
    }

    .hud-value {
        font-size: 1.2em;
    }

    .combo-display {
        font-size: 2em;
    }

    .instruction-section {
        padding: 10px;
    }

    .instruction-section h3 {
        font-size: 1em;
    }

    .instruction-section p {
        font-size: 0.9em;
    }

    /* Mobile: Adjust corner logo */
    .menu-logo-corner,
    .gameover-logo-corner {
        bottom: 15px;
        left: 15px;
        gap: 10px;
    }

    .menu-logo-corner img,
    .gameover-logo-corner img {
        max-width: 80px;
    }

    .more-games-text {
        font-size: 0.9em;
    }

    /* Mobile: Stack game over logo on top */
    .gameover-container {
        flex-direction: column;
        gap: 20px;
    }

    .gameover-logo {
        max-width: 150px;
        min-width: 150px;
    }

    /* Mobile: Stack logo on top */
    .menu-with-logo {
        flex-direction: column;
        gap: 20px;
    }

    .menu-logo-side {
        max-width: 150px;
        min-width: 150px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}