:root {
    --bg-color: #0f111a;
    --text-color: #f8f8f2;
    --python-blue: #3776ab;
    --python-yellow: #ffd43b;
    --danger-red: #ff5555;
    --success-green: #50fa7b;
    --hud-bg: rgba(15, 17, 26, 0.8);
    --btn-hover: #ffb86c;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #0a0c10;
    color: var(--text-color);
    font-family: 'Roboto', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    padding: 30px;
    position: relative;
    min-width: 400px;
    min-height: 600px;
    border: 4px solid var(--python-blue);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(55, 118, 171, 0.5);
    background-color: var(--bg-color);
    overflow-y: scroll; /* or overflow-y: auto; */
}

canvas {
    display: block;
}

/* UI Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 12, 16, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.hidden {
    display: none !important;
}

h1 {
    font-family: 'Press Start 2P', cursive;
    color: var(--python-yellow);
    text-shadow: 2px 2px 0 var(--python-blue), 4px 4px 0 #000;
    margin-bottom: 20px;
    text-align: center;
    font-size: 2.5rem;
}

.instructions {
    max-width: 600px;
    text-align: center;
    margin-bottom: 30px;
    line-height: 1.6;
    font-size: 1.1rem;
}

.highlight {
    font-weight: bold;
}
.python-color {
    color: var(--success-green);
}
.non-python-color {
    color: var(--danger-red);
}

input[type="text"] {
    padding: 12px 20px;
    font-size: 1rem;
    border: 2px solid var(--python-blue);
    border-radius: 4px;
    background-color: #1a1e29;
    color: #fff;
    margin-bottom: 20px;
    width: 250px;
    text-align: center;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--python-yellow);
}

.btn {
    padding: 15px 30px;
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    background-color: var(--python-blue);
    color: white;
    border: none;
    border-bottom: 4px solid #1c4b73;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
    text-transform: uppercase;
}

.btn:hover {
    background-color: #4a90e2;
}

.btn:active {
    transform: translateY(4px);
    border-bottom: 0;
    margin-top: 4px;
}

.small-btn {
    padding: 10px 15px;
    font-size: 0.6rem;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    z-index: 50;
    background: linear-gradient(to bottom, var(--hud-bg), transparent);
}

.hud-item {
    text-shadow: 2px 2px 0 #000;
}

#score { color: var(--success-green); }
#round { color: var(--python-yellow); }
#lives { color: var(--danger-red); }

/* Leaderboard */
#leaderboard-section {
    margin-top: 40px;
    text-align: center;
}

#leaderboard-section h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    color: #bd93f9;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    max-height: 150px;
    overflow-y: auto;
}

#leaderboard-list li {
    background-color: rgba(255,255,255,0.05);
    padding: 8px;
    border-radius: 4px;
}

/* Share Page specific */
.share-page {
    background-color: var(--bg-color);
}
.share-container {
    text-align: center;
    padding: 40px;
    border: 2px solid var(--python-blue);
    border-radius: 8px;
    background-color: #1a1e29;
    box-shadow: 0 0 30px rgba(55, 118, 171, 0.4);
}
.score-card {
    margin: 30px 0;
    font-family: 'Press Start 2P', cursive;
}
.highlight-score {
    color: var(--success-green);
    font-size: 2rem;
}
.timestamp {
    font-family: 'Roboto', sans-serif;
    color: #6272a4;
    margin-top: 15px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #1a1e29; 
}
::-webkit-scrollbar-thumb {
    background: var(--python-blue); 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--python-yellow); 
}

/* Dictionary Page */
.dict-page {
    overflow-y: auto;
    padding: 40px;
    align-items: flex-start;
}
.dict-container {
    max-width: 1000px;
    margin: 0 auto;
    background-color: #1a1e29;
    border: 3px solid #bd93f9;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 0 20px rgba(189, 147, 249, 0.3);
}
.dict-subtitle {
    text-align: center;
    color: #6272a4;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    margin-bottom: 40px;
}
.dict-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}
.dict-card {
    background-color: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    padding: 20px;
    transition: transform 0.2s, background-color 0.2s;
}
.dict-card:hover {
    background-color: rgba(255,255,255,0.1);
    transform: translateY(-5px);
}
.dict-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}
.dict-term {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.9rem;
    color: var(--python-yellow);
}
.dict-pill {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.python-pill {
    background-color: var(--success-green);
    color: #000;
}
.other-pill {
    background-color: var(--danger-red);
    color: #fff;
}
.dict-desc {
    font-size: 1rem;
    line-height: 1.5;
    color: #f8f8f2;
    margin-bottom: 10px;
}
.dict-round {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.6rem;
    color: #6272a4;
    text-align: right;
}
.dict-footer {
    text-align: center;
    margin-top: 20px;
}

/* Mobile Controls & Responsiveness */
canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#mobile-controls {
    display: none; /* hidden by default on desktop */
}

@media (max-width: 768px) {
    body, html {
        height: 100%;
        overflow: hidden;
    }
    
    #game-container {
        width: 100vw;
        height: 100vh;
        min-width: unset;
        min-height: unset;
        padding: 0;
        border: none;
        border-radius: 0;
    }

    /* Force canvas to fit the screen */
    canvas {
        object-fit: cover;
    }

    #mobile-controls {
        display: flex; /* overridden by .hidden if game is not active */
        position: absolute;
        bottom: 20px;
        left: 0;
        width: 100%;
        justify-content: space-between;
        align-items: flex-end;
        padding: 0 20px;
        box-sizing: border-box;
        z-index: 100;
        pointer-events: auto; /* ensure we can click them */
    }
    
    /* Ensure the container of mobile controls disappears when hidden class is given via JS */
    #mobile-controls.hidden {
        display: none !important;
    }

    #dpad {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        opacity: 0.6;
    }
    .dpad-row {
        display: flex;
        gap: 5px;
    }

    .ctrl-btn {
        width: 50px;
        height: 50px;
        background-color: var(--python-blue);
        color: white;
        border: 2px solid #fff;
        border-radius: 50%;
        font-size: 1.2rem;
        user-select: none;
        -webkit-user-select: none;
    }
    .ctrl-btn:active {
        background-color: var(--python-yellow);
        color: #000;
    }

    .action-btn {
        width: 70px;
        height: 70px;
        border-radius: 50%;
        background-color: var(--danger-red);
        font-family: 'Press Start 2P', cursive;
        font-size: 0.7rem;
        opacity: 0.7;
    }
    
    .action-btn:active {
        background-color: var(--python-yellow);
        transform: scale(0.9);
    }

    /* Make text readable on small screens */
    h1 {
        font-size: 1.5rem;
    }
    .instructions {
        font-size: 0.8rem;
    }
    input[type="text"] {
        width: 200px;
    }
    .hud-item {
        font-size: 0.7rem;
    }
}

