/* ============================================
   Mini Tetris Spin - Main Styles
   ============================================ */

/* CSS Variables */
:root {
    --bg-dark: #001201;
    --bg-board: #001201;
    --bg-surface: #00420c;
    --cell-empty: #003a0a;
    --cell-border: #005510;
    --accent: #fad900;
    --accent-light: #fff8dc;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --gold: #fad900;
    --gold-dark: #b8860b;

    /* Tetromino colors */
    --cyan: #00f0f0;
    --yellow: #f0f000;
    --purple: #a000f0;
    --green: #00f000;
    --red: #f00000;
    --blue: #0000f0;
    --orange: #f0a000;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: transparent;
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    min-height: calc(100dvh - 3.5rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Screen states */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    z-index: 100;
}

.screen.hidden {
    display: none;
}

/* Loading Screen */
#loading-screen {
    background: #001201;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-surface);
    border-top-color: #fad900;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-screen p {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Login Screen */
#login-screen {
    background: #001201;
}

.login-content {
    text-align: center;
    padding: 40px;
}

.login-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.login-content h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.login-content p {
    color: var(--text-secondary);
}

/* Game Container */
#game-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    padding: 10px;
    padding-bottom: 20px;
}

#game-container.hidden {
    display: none;
}

/* Header */
#game-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-surface);
    border-radius: 12px;
    margin-bottom: 10px;
}

.balance-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.balance-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#balance-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold);
}

.balance-currency {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Game Info Panel */
#game-info {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.info-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background: var(--bg-surface);
    border-radius: 10px;
}

.info-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.next-piece {
    flex: 0 0 auto;
    width: 90px;
}

#next-piece-display {
    background: var(--cell-empty);
    border-radius: 8px;
    padding: 5px;
}

#next-canvas {
    display: block;
}

#score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
}

#timer-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

#timer-value.urgent {
    color: #ef4444;
    animation: timerPulse 0.5s ease infinite;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Tetris Section */
#tetris-section {
    position: relative;
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
}

#tetris-canvas {
    display: block;
    background: var(--bg-board);
    border-radius: 4px;
}

/* Countdown Overlay */
#countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 12px;
    z-index: 10;
}

#countdown-overlay.hidden {
    display: none;
}

#countdown-number {
    font-size: 6rem;
    font-weight: 700;
    color: var(--accent);
    animation: countdownPop 0.5s ease;
}

@keyframes countdownPop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* Game Over Overlay */
#gameover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 12px;
    z-index: 10;
}

#gameover-overlay.hidden {
    display: none;
}

.gameover-content {
    text-align: center;
    padding: 20px;
}

.gameover-title {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 20px;
}

.gameover-score,
.gameover-multiplier,
.gameover-win {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.gameover-win {
    border-bottom: none;
    margin-top: 10px;
}

.gameover-content .label {
    color: var(--text-secondary);
    font-size: 1rem;
}

#final-score {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

#final-multiplier {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
}

#final-win {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
}

/* Controls */
#controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.control-btn {
    width: 70px;
    height: 55px;
    background: var(--bg-surface);
    border: 2px solid var(--cell-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: var(--cell-empty);
    border-color: var(--accent);
}

.control-btn:active {
    transform: scale(0.95);
    background: var(--accent);
}

.control-btn:disabled {
    /* Dimming with opacity let the storefront's light page bleed through the
       button, so the glyphs measured 1.5:1 before the round starts. Mute the
       colours instead and the contrast no longer depends on what is behind. */
    opacity: 1;
    background: var(--cell-empty);
    border-color: var(--cell-border);
    color: rgba(255, 255, 255, 0.72);
    cursor: not-allowed;
}

.control-btn.rotate {
    font-size: 1.8rem;
}

.control-btn.drop {
    width: 150px;
    flex-direction: column;
    gap: 2px;
}

.drop-text {
    font-size: 0.7rem;
    letter-spacing: 2px;
}

/* Bet Controls */
#bet-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-surface);
    border-radius: 12px;
    margin-bottom: 10px;
}

.bet-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.bet-buttons {
    display: flex;
    gap: 8px;
}

.amount-btn {
    padding: 10px 16px;
    background: var(--cell-empty);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.amount-btn:hover {
    background: var(--cell-border);
}

.amount-btn.active {
    background: var(--accent);
    border-color: var(--accent-light);
}

.amount-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Start Button */
#start-button {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #fad900 0%, #fff8dc 100%);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

#start-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(250, 217, 0, 0.4);
}

#start-button:disabled {
    background: var(--cell-empty);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Game Title */
.game-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    opacity: 0.6;
}

.title-icon {
    font-size: 1.5rem;
}

.title-text {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Win Display */
#win-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    padding: 25px 50px;
    border-radius: 20px;
    text-align: center;
    z-index: 50;
    opacity: 0;
    transition: all 0.3s ease;
}

#win-display.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#win-display.hidden {
    display: none;
}

.win-label {
    display: block;
    font-size: 1.2rem;
    color: var(--bg-dark);
    margin-bottom: 5px;
}

#win-amount {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--bg-dark);
}

/* Message Display */
#message-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 20px 40px;
    border-radius: 12px;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#message-display.visible {
    opacity: 1;
}

#message-display.hidden {
    display: none;
}

#message-text {
    color: var(--text-primary);
    font-size: 1.1rem;
}

/* Particles */
#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 60;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: particleFall 1.5s ease-out forwards;
}

@keyframes particleFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(200px) rotate(720deg);
    }
}

/* Line Clear Effect */
.line-clear-flash {
    animation: lineFlash 0.3s ease;
}

@keyframes lineFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; background: white; }
}

/* Board Shake */
.board-shake {
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Responsive */
@media (max-width: 380px) {
    .control-btn {
        width: 60px;
        height: 50px;
    }

    .control-btn.drop {
        width: 130px;
    }

    .amount-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* Hidden utility */
.hidden {
    display: none !important;
}

.game-instructions { color: oklch(0.3 0.04 150); font-size: 14px; line-height: 1.5; margin: 12px 16px; text-align: center; }
#start-button, .amount-btn.active { color: oklch(0.24 0.04 150); }
.control-btn:not(:disabled) { color: oklch(0.98 0.01 90); }
