/* TETRIS PAGE STYLES */

/* Tetromino Colors */
:root {
    --color-I: #12421e;
    --color-O: #FFC857;
    --color-T: #ff0000;
    --color-S: #51291e;
    --color-Z: #8332ac;
    --color-J: #51bbfe;
    --color-L: #2e2aa8;
}

/* Page Container */
.tetris-page {
    max-width: 100vw;
    margin: 0 auto;
    padding: 0.5rem;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    overflow: hidden;
}

/* Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.game-header .logo-link {
    display: block;
    width: 80px;
    transition: opacity 0.2s ease;
}

.game-header .logo-link:hover {
    opacity: 0.6;
    animation: none;
}

.game-header .logo-link svg {
    width: 100%;
    height: auto;
}

.game-header h1 {
    font-family: "GT Alpina", Times, serif;
    font-size: 1.25rem;
    font-weight: 300;
    visibility: visible;
    width: auto;
    height: auto;
    text-indent: 0;
    text-overflow: clip;
    padding: 0;
}

/* Game Wrapper */
.game-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-height: 0;
}

/* Side Panels */
.side-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 60px;
}

.side-panel small {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.031rem;
    opacity: 0.5;
}

/* Mini Grid for Hold/Next */
.mini-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    width: 48px;
    height: 48px;
    border: 1px solid var(--color-content-primary);
    opacity: 0.3;
}

.mini-grid.has-piece {
    opacity: 1;
}

.mini-grid .cell {
    width: 100%;
    height: 100%;
}

/* Board Container */
.board-container {
    position: relative;
    height: 100%;
    max-height: calc(100vh - 180px);
    aspect-ratio: 1 / 2;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(20, 1fr);
    width: 100%;
    height: 100%;
    border: 2px solid var(--color-content-primary);
    background: var(--color-surface-primary);
}

.game-board .cell {
    border: 1px solid rgba(170, 0, 0, 0.08);
    transition: background-color 0.05s ease;
}

html.darkmode .game-board .cell {
    border-color: rgba(255, 255, 255, 0.08);
}

/* Cell Colors */
.cell.I { background-color: var(--color-I); }
.cell.O { background-color: var(--color-O); }
.cell.T { background-color: var(--color-T); }
.cell.S { background-color: var(--color-S); }
.cell.Z { background-color: var(--color-Z); }
.cell.J { background-color: var(--color-J); }
.cell.L { background-color: var(--color-L); }

/* Ghost Piece */
.cell.ghost-I { background-color: rgba(18, 66, 30, 0.6); }
.cell.ghost-O { background-color: rgba(255, 200, 87, 0.6); }
.cell.ghost-T { background-color: rgba(255, 0, 0, 0.6); }
.cell.ghost-S { background-color: rgba(81, 41, 30, 0.6); }
.cell.ghost-Z { background-color: rgba(131, 50, 172, 0.6); }
.cell.ghost-J { background-color: rgba(81, 187, 254, 0.6); }
.cell.ghost-L { background-color: rgba(46, 42, 168, 0.6); }

/* Game Overlay */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    color: #fff;
}

.overlay-content h2 {
    font-family: "GT Alpina", Times, serif;
    font-size: 1.5rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    padding: 0;
}

.overlay-content p {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.031rem;
    margin-bottom: 1rem;
    opacity: 0.7;
    padding: 0;
}

/* Game Button */
.game-btn {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.031rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid #fff;
    background: transparent;
    color: #fff;
    cursor: crosshair;
    transition: all 0.15s ease;
}

.game-btn:hover {
    background: #fff;
    color: #000;
}

/* Stats Panel */
.stats-panel {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--color-content-primary);
    border-bottom: 1px solid var(--color-content-primary);
    opacity: 0.15;
    flex-shrink: 0;
}

.stats-panel .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stats-panel small {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.031rem;
    opacity: 0.5;
}

.stats-panel span {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 1rem;
}

/* Controls Info */
.controls-info {
    margin-top: 0.5rem;
    text-align: center;
    flex-shrink: 0;
}

.controls-info small {
    opacity: 0.4;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.mobile-only {
    display: none;
}

/* Music Toggle */
.music-toggle-wrapper {
    display: inline-flex;
    align-items: center;
}

.music-toggle {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--color-content-primary);
    background: transparent;
    color: var(--color-content-primary);
    cursor: crosshair;
    transition: all 0.15s ease;
    opacity: 0.3;
    line-height: 1;
}

.music-toggle:hover {
    opacity: 0.6;
}

.music-toggle.active {
    opacity: 1;
    background: var(--color-content-primary);
    color: var(--color-surface-primary);
}

/* Line Clear Animation */
@keyframes line-clear {
    0% { background-color: var(--color-content-primary); }
    50% { background-color: transparent; }
    100% { background-color: var(--color-content-primary); }
}

.cell.clearing {
    animation: line-clear 0.15s ease-in-out 2;
}

/* Game Over Animation */
@keyframes game-over-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.game-board.game-over .cell:not(:empty) {
    animation: game-over-flash 0.3s ease-in-out 3;
}

/* Mobile Responsive */
@media screen and (max-width: 600px) {
    .tetris-page {
        padding: 0.5rem;
    }

    .game-header {
        margin-bottom: 0.5rem;
    }

    .game-header .logo-link {
        width: 50px;
    }

    .game-header h1 {
        font-size: 0.9rem;
    }

    .game-wrapper {
        gap: 0.35rem;
    }

    .side-panel {
        min-width: 40px;
    }

    .side-panel small {
        font-size: 0.5rem;
    }

    .mini-grid {
        width: 36px;
        height: 36px;
    }

    .board-container {
        max-height: calc(100dvh - 140px);
    }

    .stats-panel {
        gap: 0.75rem;
        margin-top: 0.5rem;
        padding: 0.5rem 0;
    }

    .stats-panel small {
        font-size: 0.5rem;
    }

    .stats-panel span {
        font-size: 0.8rem;
    }

    .controls-info {
        margin-top: 0.5rem;
    }

    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: inline;
    }
}

/* Very small screens */
@media screen and (max-width: 360px) {
    .mini-grid {
        width: 28px;
        height: 28px;
    }

    .side-panel {
        min-width: 32px;
    }

    .board-container {
        max-height: calc(100dvh - 120px);
    }
}
