/* --- Tetris Game Styles --- */
/* Inherits variables from style.css */

.content-wrapper {
    background-color: var(--bg-dark);
}

.game-container {
    background-color: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
    text-align: center;
    position: relative;
    box-sizing: border-box;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

#score {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 5px var(--accent-glow);
}

/* Control Toggle Switch Styles */
.controls-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}
.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
}
input:checked + .slider {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}
input:checked + .slider:before {
    transform: translateX(26px);
    background-color: white;
}
.slider.round {
    border-radius: 34px;
}
.slider.round:before {
    border-radius: 50%;
}

.canvas-container {
    position: relative;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background-color: #000; /* Tetris background should stay black for contrast */
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
    margin: 0 auto;
    width: 300px; /* Base canvas width */
    height: 600px; /* Base canvas height */
    overflow: hidden;
    /* Responsive scaling */
    max-width: 100%;
    aspect-ratio: 1 / 2;
}

#tetrisCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Overlays */
.start-overlay-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 20px var(--accent-glow);
    transition: all 0.2s;
    z-index: 10;
}

.start-overlay-btn:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 0 30px var(--accent-glow);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid var(--accent-color);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 0 40px var(--accent-glow);
    position: relative;
    color: var(--text-primary);
}

.modal-content h2 {
    color: var(--accent-color);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.modal-content p {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Form Elements inside Modal */
.submit-score-section {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#playerInitials {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    padding: 0.8rem;
    font-size: 1.2rem;
    text-align: center;
    border-radius: 4px;
    text-transform: uppercase;
    font-family: monospace;
    letter-spacing: 3px;
}

#playerInitials:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* High Scores List */
.high-scores-section {
    text-align: left;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding: 0.5rem;
    background-color: var(--bg-dark);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.high-scores-section h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-align: center;
}

ol {
    padding-left: 1.5rem;
    margin: 0;
}

li {
    margin-bottom: 0.5rem;
    font-family: monospace;
    font-size: 1.1rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.2rem;
}

li:last-child {
    border-bottom: none;
}

/* Scrollbar for high scores */
.high-scores-section::-webkit-scrollbar {
    width: 8px;
}
.high-scores-section::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
.high-scores-section::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
.high-scores-section::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Buttons */
button {
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}

#highScoresButton {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

#submitScoreBtn, #closeModalBtn, #closeHighScoresBtn {
    width: 100%;
    padding: 0.8rem;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-weight: 600;
    margin-top: 0.5rem;
}

#submitScoreBtn {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

#submitScoreBtn:hover {
    box-shadow: 0 0 15px var(--accent-glow);
}

#closeModalBtn:hover, #closeHighScoresBtn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* =========================================
   Responsive Breakpoints for Tetris
   ========================================= */

@media (max-width: 768px) {
    .game-container {
        padding: 1rem;
        border-radius: 8px;
    }

    .game-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
    }

    #score {
        font-size: 1.2rem;
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    .controls-toggle {
        font-size: 0.85rem;
    }

    #highScoresButton {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

@media (max-width: 400px) {
    .game-container {
        padding: 0.75rem;
        margin: 0 0.5rem;
    }

    .canvas-container {
        width: 100%;
        height: auto;
    }

    #score {
        font-size: 1rem;
    }

    .controls-toggle label {
        font-size: 0.75rem;
    }

    .switch {
        width: 40px;
        height: 20px;
    }

    .slider:before {
        height: 14px;
        width: 14px;
        left: 3px;
        bottom: 2px;
    }

    input:checked + .slider:before {
        transform: translateX(20px);
    }

    .modal-content {
        margin: 5% auto;
        padding: 1.5rem;
        width: 95%;
    }

    .modal-content h2 {
        font-size: 1.3rem;
    }

    #playerInitials {
        font-size: 1rem;
        padding: 0.6rem;
    }
}
