:root {
    /* Cyberpunk Theme (Default) */
    --neon-pink: #ff2a6d;
    --neon-cyan: #05d9e8;
    --neon-purple: #d300c5;
    --dark-blue: #0d0221;
    --dark-purple: #1a0b2e;
    --grid-line: rgba(133, 255, 245, 0.1);
    
    /* Ghibli Theme Colors */
    --ghibli-sky: #a8e0ff;
    --ghibli-grass: #8fd694;
    --ghibli-sun: #ffd166;
    --ghibli-wood: #8b5a2b;
    --ghibli-cloud: #f8f9fa;
    --ghibli-accent: #e85d75;
    
    /* Current Theme Variables */
    --primary: var(--neon-cyan);
    --secondary: var(--neon-pink);
    --accent: var(--neon-purple);
    --bg-dark: var(--dark-blue);
    --bg-light: var(--dark-purple);
    --text-color: var(--neon-cyan);
    --button-bg: linear-gradient(45deg, var(--neon-pink), var(--neon-purple));
    --button-hover: 0 0 20px var(--neon-pink), 0 0 30px var(--neon-pink);
    --box-shadow: 0 0 10px var(--neon-cyan), inset 0 0 10px var(--neon-cyan);
    --text-shadow: 0 0 5px var(--neon-cyan);
    --bg-pattern: linear-gradient(45deg, #0d0221 25%, #1a0b2e 25%, #1a0b2e 50%, #0d0221 50%, #0d0221 75%, #1a0b2e 75%, #1a0b2e 100%);
}

/* Ghibli Theme */
.ghibli-theme {
    --primary: #5c7f67;  /* Ghibli green */
    --secondary: #e6a4b4;  /* Ghibli pink */
    --accent: #f5e6ca;  /* Ghibli cream */
    --bg-dark: #f7f3e9;  /* Light cream */
    --bg-light: #e8e1d1;  /* Lighter cream */
    --text-color: #5c7f67;  /* Ghibli green */
    --button-bg: linear-gradient(45deg, #e6a4b4, #d4a5c0);
    --button-hover: 0 2px 8px rgba(0, 0, 0, 0.1);
    --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --text-shadow: none;
    --bg-pattern: linear-gradient(135deg, #f7f3e9 0%, #e8e1d1 100%);
}

/* Monochrome Theme */
.monochrome-theme {
    --primary: #333333;  /* Dark gray */
    --secondary: #666666;  /* Medium gray */
    --accent: #999999;  /* Light gray */
    --bg-dark: #111111;  /* Near black */
    --bg-light: #222222;  /* Very dark gray */
    --text-color: #CCCCCC;  /* Light gray for text */
    --button-bg: linear-gradient(45deg, #666666, #999999);
    --button-hover: 0 0 10px rgba(153, 153, 153, 0.5);
    --box-shadow: 0 0 5px rgba(153, 153, 153, 0.3);
    --text-shadow: none;
    --bg-pattern: linear-gradient(45deg, #111111 25%, #222222 25%, #222222 50%, #111111 50%, #111111 75%, #222222 75%, #222222 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=M+PLUS+Rounded+1c:wght@400;700&display=swap');
    font-family: 'Orbitron', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: var(--bg-pattern);
    background-size: 40px 40px;
    transition: all 0.5s ease;
}

.ghibli-theme, .monochrome-theme {
    font-family: 'M PLUS Rounded 1c', 'Orbitron', sans-serif;
}

.game-container {
    background-color: rgba(13, 2, 33, 0.9);
    border: 2px solid var(--primary);
    box-shadow: var(--box-shadow), 
                0 0 20px var(--secondary),
                inset 0 0 10px var(--primary);
    border-radius: 15px;
    padding: 20px;
    max-width: 800px;
    width: 95%;
    max-height: 90vh;
    height: 90vh;
    overflow: hidden;
    transition: all 0.5s ease;
}

.ghibli-theme .game-container {
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--primary);
    box-shadow: 0 0 20px rgba(92, 127, 103, 0.3);
}

.monochrome-theme .game-container {
    background-color: rgba(17, 17, 17, 0.9);
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px rgba(153, 153, 153, 0.3);
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    border-bottom: 1px solid var(--neon-pink);
}

h1 {
    color: var(--secondary);
    text-shadow: var(--text-shadow);
    margin-bottom: 15px;
    letter-spacing: 2px;
    font-size: 2.5em;
    transition: all 0.5s ease;
}

.ghibli-theme h1 {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    color: var(--primary);
    text-shadow: 2px 2px 0 var(--accent);
}

.monochrome-theme h1 {
    color: var(--secondary);
    text-shadow: 1px 1px 0 var(--accent);
}

/* Three-column layout for game UI */
.game-main {
    display: flex;
    flex-direction: row;
    gap: 20px;
    height: 75vh;
    min-height: 400px;
    align-items: flex-start;
    justify-content: center;
}

.game-board-col {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-middle-col {
    flex: 0 0 200px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
}

.game-right-col {
    flex: 0 0 180px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
    justify-content: flex-start;
}

.sidebar-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.game-main > div {
    transition: all 0.5s ease;
}

#game-board {
    background-color: rgba(5, 217, 232, 0.03);
    border: 2px solid var(--primary);
    box-shadow: var(--box-shadow);
    image-rendering: pixelated;
    height: 60vh !important;
    max-height: 500px;
    width: 250px;
    max-width: 45vw;
    transition: all 0.5s ease;
}

.ghibli-theme #game-board {
    background-color: rgba(255, 255, 255, 0.8);
    border: 2px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.monochrome-theme #game-board {
    background-color: rgba(33, 33, 33, 0.8);
    border: 2px solid var(--primary);
    box-shadow: 0 0 5px rgba(153, 153, 153, 0.3);
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 200px;
    height: auto;
    max-height: none;
    overflow-y: visible;
    justify-content: flex-start;
    align-items: stretch;
    position: relative;
}

.next-piece, .controls {
    background-color: rgba(5, 217, 232, 0.05);
    border: 1px solid var(--primary);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 0 5px var(--primary), 
                inset 0 0 5px var(--primary);
    transition: all 0.5s ease;
}

.ghibli-theme .next-piece,
.ghibli-theme .controls {
    background-color: rgba(255, 255, 255, 0.7);
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px rgba(92, 127, 103, 0.2);
}

.monochrome-theme .next-piece,
.monochrome-theme .controls {
    background-color: rgba(33, 33, 33, 0.7);
    border: 2px solid var(--primary);
    box-shadow: 0 0 5px rgba(153, 153, 153, 0.2);
}

.next-piece h3, .controls h3 {
    color: var(--secondary);
    margin-bottom: 10px;
    text-align: center;
    text-shadow: var(--text-shadow);
    transition: all 0.5s ease;
}

.ghibli-theme .next-piece h3,
.ghibli-theme .controls h3 {
    color: var(--primary);
    text-shadow: 1px 1px 0 var(--accent);
}

.monochrome-theme .next-piece h3,
.monochrome-theme .controls h3 {
    color: var(--secondary);
    text-shadow: 1px 1px 0 var(--accent);
}

#next-piece {
    width: 70%;
    height: 120px;
    background-color: rgba(5, 217, 232, 0.03);
    border: 1px solid var(--primary);
    margin: 10px 0;
    image-rendering: pixelated;
    transition: all 0.5s ease;
}

.ghibli-theme #next-piece {
    background-color: rgba(255, 255, 255, 0.7);
    border: 2px solid var(--primary);
}

.monochrome-theme #next-piece {
    background-color: rgba(33, 33, 33, 0.7);
    border: 2px solid var(--primary);
}

.controls p {
    margin: 8px 0;
    font-size: 0.9em;
    color: var(--text-color);
    text-shadow: var(--text-shadow);
    transition: all 0.5s ease;
}

.ghibli-theme .controls p {
    color: var(--primary);
    text-shadow: none;
}

.monochrome-theme .controls p {
    color: var(--text-color);
    text-shadow: none;
}

button {
    background: var(--button-bg);
    border: none;
    color: white;
    padding: 12px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 8px 2px;
    cursor: pointer;
    border-radius: 25px;
    font-family: inherit;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--button-hover);
}

.ghibli-theme button {
    background: linear-gradient(45deg, #e6a4b4, #d4a5c0);
    color: white;
    border: 2px solid var(--primary);
    font-family: 'M PLUS Rounded 1c', sans-serif;
}

.monochrome-theme button {
    background: var(--button-bg);
    color: var(--text-color);
    border: 2px solid var(--primary);
    font-family: 'M PLUS Rounded 1c', sans-serif;
}

.theme-toggle {
    background: linear-gradient(45deg, #5c7f67, #8fd694) !important;
    margin-top: 15px !important;
    width: 100%;
}

.ghibli-theme .theme-toggle {
    background: linear-gradient(45deg, #8b5a2b, #d4a76a) !important;
}

.monochrome-theme .theme-toggle {
    background: linear-gradient(45deg, #666666, #999999) !important;
}

button:active {
    transform: translateY(1px);
}

.score-display {
    display: flex;
    justify-content: space-around;
    margin-top: 10px;
    font-size: 1.2em;
    color: var(--text-color);
    text-shadow: var(--text-shadow);
    transition: all 0.5s ease;
}

.ghibli-theme .score-display {
    color: var(--primary);
    text-shadow: 1px 1px 0 var(--accent);
}

.monochrome-theme .score-display {
    color: var(--text-color);
    text-shadow: 1px 1px 0 var(--accent);
}

.game-over, .pause-screen {
    background-color: rgba(13, 2, 33, 0.95);
    border: 2px solid var(--secondary);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 0 20px var(--secondary);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    width: 80%;
    max-width: 400px;
    backdrop-filter: blur(5px);
    transition: all 0.5s ease;
}

.ghibli-theme .game-over,
.ghibli-theme .pause-screen {
    background-color: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--secondary);
    color: var(--primary);
}

.monochrome-theme .game-over,
.monochrome-theme .pause-screen {
    background-color: rgba(17, 17, 17, 0.95);
    border: 2px solid var(--secondary);
    color: var(--text-color);
}

.pause-screen {
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary);
}

.pause-screen h2 {
    color: var(--primary);
    text-shadow: var(--text-shadow);
    margin-bottom: 15px;
}

.game-over h2 {
    color: var(--secondary);
    margin-bottom: 15px;
    font-size: 2em;
    text-shadow: var(--text-shadow);
}

.ghibli-theme .pause-screen h2,
.ghibli-theme .game-over h2 {
    color: var(--secondary);
    text-shadow: 1px 1px 0 var(--accent);
}

.monochrome-theme .pause-screen h2,
.monochrome-theme .game-over h2 {
    color: var(--secondary);
    text-shadow: 1px 1px 0 var(--accent);
}

.hidden {
    display: none;
}

@media (max-width: 800px) {
    .game-container {
        max-height: 98vh;
        height: 98vh;
        padding: 8px;
    }
    .game-main {
        flex-direction: column;
        align-items: center;
        height: auto;
    }
    .game-board-col, .game-middle-col, .game-right-col {
        flex: 1 1 100%;
        width: 100%;
        max-width: 98vw;
        align-items: center;
    }
    .game-main > div {
        margin-bottom: 16px;
    }
    .sidebar-buttons {
        flex-direction: row;
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 900px) {
    .game-main {
        flex-direction: column;
        align-items: center;
        height: auto;
    }
    .game-board-col, .game-middle-col, .game-right-col {
        flex: 1 1 100%;
        width: 100%;
        max-width: 98vw;
        align-items: center;
    }
    .game-main > div {
        margin-bottom: 16px;
    }
    .sidebar-buttons {
        flex-direction: row;
        justify-content: center;
        width: 100%;
    }
}
