/* ============================
   CSS VARIABLES
   ============================ */
:root {
    --gold: #FFD700;
    --blue: #4A9EFF;
    --dark-bg: rgba(0, 0, 0, 0.9);
    --dark-bg-lighter: rgba(0, 0, 0, 0.7);
    --gold-glow: rgba(255, 215, 0, 0.3);
    --blue-glow: rgba(74, 158, 255, 0.2);
}

/* ============================
   GLOBAL STYLES
   ============================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #000;
    margin: 0;
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* ============================
   INTRO SCROLL SCREEN
   ============================ */
#intro-scroll-screen {
    background-color: transparent;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: hidden;
    z-index: 10;
}

#scroll-text {
    color: white;
    font-size: 4em;
    font-weight: bold;
    text-align: center;
    position: absolute;
    bottom: -100%;
    width: 80%;
    transform: perspective(300px) rotateX(25deg);
    transform-origin: center bottom;
    animation: scrollUp 20s linear forwards;
}

@keyframes scrollUp {
    0% {
        bottom: -100%;
        opacity: 1;
    }
    10% {
        bottom: 0%;
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        bottom: 100%;
        opacity: 0;
    }
}

/* ============================
   START SCREEN
   ============================ */
#start-screen {
    text-align: center;
    background: var(--dark-bg);
    padding: 3rem;
    border-radius: 15px;
    border: 2px solid var(--gold);
    box-shadow: 0 0 30px var(--gold-glow), inset 0 0 30px rgba(255, 215, 0, 0.1);
    display: none;
    max-width: 500px;
    transition: opacity 0.5s ease-out;
    z-index: 10;
    position: relative;
}

#start-screen.fade-out {
    opacity: 0;
}

#start-screen h1 {
    color: var(--gold);
    font-size: 3.5rem;
    margin: 0 0 1.5rem 0;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    letter-spacing: 0.1em;
    font-weight: bold;
}

#logo {
    width: 100%;
    max-width: 600px;
    height: auto;
    margin: 0 auto 2rem;
    display: block;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.6));
}

#name-input {
    display: block;
    margin: 2rem auto;
    padding: 1rem;
    width: 85%;
    background: var(--dark-bg-lighter);
    border: 2px solid var(--blue);
    border-radius: 8px;
    color: var(--gold);
    font-size: 1.1rem;
    text-align: center;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

#name-input::placeholder {
    color: rgba(255, 215, 0, 0.5);
}

#name-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

#difficulty-selection {
    margin: 2rem 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.difficulty-btn {
    padding: 1rem 1.5rem;
    margin: 0.5rem;
    border: 2px solid var(--blue);
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(145deg, var(--blue-glow), rgba(74, 158, 255, 0.05));
    color: var(--blue);
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--blue-glow);
}

.difficulty-btn:hover {
    background: linear-gradient(145deg, rgba(74, 158, 255, 0.4), rgba(74, 158, 255, 0.15));
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
    transform: translateY(-2px);
}

.difficulty-btn:active {
    transform: translateY(0);
}

#start-game-btn {
    padding: 1.2rem 3rem;
    margin: 2rem auto 0;
    border: 3px solid var(--gold);
    border-radius: 10px;
    cursor: pointer;
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
    color: var(--gold);
    font-size: 1.5rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.3s ease;
    box-shadow: 0 6px 25px var(--gold-glow);
    display: block;
}

#start-game-btn:hover:not(:disabled) {
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.5), rgba(255, 215, 0, 0.2));
    box-shadow: 0 8px 30px rgba(255, 215, 0, 0.5);
    transform: translateY(-3px);
}

#start-game-btn:active:not(:disabled) {
    transform: translateY(0);
}

#start-game-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================
   GAME CANVAS & INPUT
   ============================ */
#game-canvas {
    background-color: transparent;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 5;
    display: none;
}

#answer-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

/* ============================
   GAME HUD
   ============================ */
#score, #kills, #difficulty-indicator {
    position: absolute;
    color: white;
    font-size: 24px;
    z-index: 10;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-weight: bold;
    display: none;
}

#score {
    top: 10px;
    left: 10px;
}

#kills {
    top: 10px;
    right: 10px;
}

#difficulty-indicator {
    top: 50px;
    left: 10px;
    font-size: 18px;
    color: var(--gold);
}

#answer-display {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--gold);
    font-size: 48px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 2px 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 10;
    min-width: 100px;
    text-align: center;
    display: none;
}

#sound-toggle {
    position: absolute;
    top: 50px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--gold);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: none;
}

#sound-toggle:hover {
    background: rgba(0, 0, 0, 0.9);
    box-shadow: 0 0 15px var(--gold-glow);
    transform: scale(1.1);
}

#keyboard-toggle {
    position: absolute;
    top: 110px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--gold);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: none; /* Hidden by default */
}

#keyboard-toggle:hover {
    background: rgba(0, 0, 0, 0.9);
    box-shadow: 0 0 15px var(--gold-glow);
    transform: scale(1.1);
}

#keyboard-toggle.hidden-keyboard {
    opacity: 0.5;
    border-color: var(--blue);
}

/* ============================
   PAUSE OVERLAY
   ============================ */
#pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

#pause-overlay.show {
    display: flex;
}

#pause-container {
    text-align: center;
    background: var(--dark-bg);
    padding: 3rem;
    border-radius: 15px;
    border: 2px solid var(--gold);
    box-shadow: 0 0 30px var(--gold-glow);
}

#pause-container h1 {
    color: var(--gold);
    font-size: 4rem;
    margin: 0 0 1rem 0;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

#pause-container p {
    color: var(--blue);
    font-size: 1.5rem;
}

/* ============================
   LEADERBOARD
   ============================ */
#leaderboard-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    flex-direction: column;
}

#leaderboard-screen.show {
    display: flex;
}

#leaderboard-container {
    background: var(--dark-bg);
    padding: 3rem;
    border-radius: 15px;
    border: 2px solid var(--gold);
    box-shadow: 0 0 30px var(--gold-glow);
    max-width: 600px;
    width: 90%;
}

#leaderboard-container h1 {
    color: var(--gold);
    font-size: 3rem;
    margin: 0 0 1rem 0;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    text-align: center;
}

#leaderboard-container h2 {
    color: var(--blue);
    font-size: 1.5rem;
    margin: 1rem 0;
    text-align: center;
}

#leaderboard-container h3 {
    color: var(--gold);
    text-align: center;
    margin: 1rem 0;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 2rem 0;
}

#leaderboard-list li {
    color: var(--gold);
    font-size: 1.3rem;
    padding: 0.8rem;
    margin: 0.5rem 0;
    background: var(--blue-glow);
    border-left: 4px solid var(--blue);
    display: flex;
    justify-content: space-between;
}

#leaderboard-list li.current-player {
    border-left-color: var(--gold);
    background: rgba(255, 215, 0, 0.1);
}

#play-again-btn {
    padding: 1rem 2rem;
    margin: 1rem auto;
    border: 2px solid var(--blue);
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(145deg, var(--blue-glow), rgba(74, 158, 255, 0.05));
    color: var(--blue);
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
    transition: all 0.3s ease;
    display: block;
}

#play-again-btn:hover {
    background: linear-gradient(145deg, rgba(74, 158, 255, 0.4), rgba(74, 158, 255, 0.15));
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

/* ============================
   VIRTUAL KEYBOARD (Mobile Only)
   ============================ */
#virtual-keyboard {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 400px;
    background: rgba(0, 0, 0, 0.95);
    padding: 15px;
    border-top: 3px solid var(--gold);
    z-index: 20;
    display: none; /* Hidden by default */
}

#virtual-keyboard.show {
    display: block; /* Only show when .show class is added */
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.key-btn {
    flex: 1;
    max-width: 80px;
    height: 60px;
    background: linear-gradient(145deg, rgba(74, 158, 255, 0.3), rgba(74, 158, 255, 0.1));
    border: 2px solid var(--blue);
    border-radius: 8px;
    color: var(--gold);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.key-btn:active {
    background: linear-gradient(145deg, rgba(74, 158, 255, 0.5), rgba(74, 158, 255, 0.2));
    transform: scale(0.95);
    border-color: var(--gold);
}

.key-enter {
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
    border-color: var(--gold);
}

.key-enter:active {
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.5), rgba(255, 215, 0, 0.2));
}

.key-backspace {
    background: linear-gradient(145deg, rgba(255, 69, 0, 0.3), rgba(255, 69, 0, 0.1));
    border-color: #FF4500;
}

.key-backspace:active {
    background: linear-gradient(145deg, rgba(255, 69, 0, 0.5), rgba(255, 69, 0, 0.2));
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 768px) {
    #scroll-text {
        font-size: 2em;
    }

    #start-screen h1 {
        font-size: 2.5rem;
    }

    #logo {
        width: 95%;
        max-width: 400px;
    }

    #start-screen {
        padding: 2rem;
    }

    .difficulty-btn {
        padding: 0.8rem 1.2rem;
        font-size: 0.9rem;
    }

    #answer-display {
        font-size: 36px;
        bottom: 200px; /* Move up to make room for keyboard */
    }

    /* Show keyboard toggle button on mobile */
    #keyboard-toggle.show {
        display: block;
    }

    #leaderboard-container {
        padding: 2rem;
    }

    #leaderboard-container h1 {
        font-size: 2rem;
    }
}
