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

body {
    font-family: 'Orbitron', monospace;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3a 50%, #2d2d5f 100%);
    color: #ffffff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Game Container */
.game-container {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.3);
    border: 2px solid rgba(0, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

/* Header */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-title {
    font-size: 3rem;
    font-weight: 900;
    color: #00ffff;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
    margin-bottom: 10px;
    letter-spacing: 0.2em;
}

.game-controls-info {
    margin-top: 10px;
}

.control-hint {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.key {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-weight: bold;
}

/* Game Layout */
.game-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Panels */
.left-panel, .right-panel {
    width: 150px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.main-game {
    flex: 1;
    display: flex;
    justify-content: center;
}

/* Game Board */
.game-board-container {
    position: relative;
    border: 3px solid #00ffff;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.9);
    box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.3);
}

#gameCanvas {
    display: block;
    background: transparent;
}

/* Hold and Next Containers */
.hold-container, .next-container {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
}

.hold-container h3, .next-container h3 {
    color: #00ffff;
    font-size: 1rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.next-pieces {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

#holdCanvas, #nextCanvas1, #nextCanvas2, #nextCanvas3 {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.5);
}

/* Stats */
.stats-container {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 10px;
    padding: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-label {
    font-size: 0.8rem;
    color: #cccccc;
    font-weight: 400;
}

.stat-value {
    font-size: 1.2rem;
    color: #00ffff;
    font-weight: 700;
}

/* Game Overlay */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    border-radius: 7px;
}

.game-overlay.active {
    display: flex;
}

.overlay-content {
    text-align: center;
    padding: 30px;
}

.overlay-content h2 {
    color: #00ffff;
    font-size: 2rem;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
}

.overlay-content p {
    color: #cccccc;
    margin-bottom: 20px;
    font-size: 1rem;
}

.game-btn {
    background: linear-gradient(45deg, #00ffff, #0080ff);
    color: #000;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 255, 255, 0.4);
}

/* Footer */
.game-footer {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.high-score {
    display: flex;
    gap: 10px;
    align-items: center;
}

.game-info {
    font-size: 0.8rem;
    color: #888;
}

/* Mobile Touch Controls */
.mobile-controls {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: rgba(0, 0, 0, 0.8);
    border-top: 2px solid rgba(0, 255, 255, 0.3);
    padding: 10px;
    gap: 10px;
    justify-content: space-around;
    align-items: center;
}

.touch-area {
    background: rgba(0, 255, 255, 0.2);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 10px;
    color: #00ffff;
    font-weight: bold;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    min-width: 50px;
    height: 50px;
}

.touch-area:active {
    background: rgba(0, 255, 255, 0.4);
    transform: scale(0.95);
}

.touch-area.touch-hold {
    font-size: 0.8rem;
    min-width: 60px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
        margin: 10px;
    }

    .game-layout {
        flex-direction: column;
        align-items: center;
    }

    .left-panel, .right-panel {
        width: 100%;
        max-width: 300px;
        flex-direction: row;
        justify-content: space-around;
    }

    .game-title {
        font-size: 2rem;
    }

    .control-hint {
        font-size: 0.7rem;
        gap: 8px;
    }

    .game-board-container {
        position: relative;
        margin-bottom: 130px; /* Make room for mobile controls */
    }

    .mobile-controls {
        display: flex;
    }

    .game-footer {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* Animation Classes */
@keyframes lineFlash {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(255, 255, 255, 0.8); }
}

.line-flash {
    animation: lineFlash 0.5s ease-in-out 3;
}

@keyframes pieceGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5) drop-shadow(0 0 10px currentColor); }
}

.piece-glow {
    animation: pieceGlow 0.3s ease-in-out;
}

@keyframes titlePulse {
    0%, 100% { text-shadow: 0 0 20px rgba(0, 255, 255, 0.8); }
    50% { text-shadow: 0 0 30px rgba(0, 255, 255, 1), 0 0 40px rgba(0, 255, 255, 0.5); }
}

.game-title {
    animation: titlePulse 3s ease-in-out infinite;
}

@keyframes borderGlow {
    0%, 100% { box-shadow: 0 0 50px rgba(0, 255, 255, 0.3); }
    50% { box-shadow: 0 0 70px rgba(0, 255, 255, 0.5), inset 0 0 20px rgba(0, 255, 255, 0.1); }
}

.game-container {
    animation: borderGlow 4s ease-in-out infinite;
}

@keyframes statUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); color: #ffffff; }
    100% { transform: scale(1); }
}

.stat-value.updated {
    animation: statUpdate 0.3s ease-out;
}

@keyframes buttonHover {
    0% { transform: translateY(0); }
    100% { transform: translateY(-2px); }
}

.game-btn:hover {
    animation: buttonHover 0.2s ease-out forwards;
}

/* Particle effects for line clears */
@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0.5);
    }
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #00ffff;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 1s ease-out forwards;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3a 50%, #2d2d5f 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-content .game-title {
    margin-bottom: 30px;
}

.loading-content p {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #cccccc;
}

/* Loading animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    border: 3px solid rgba(0, 255, 255, 0.3);
    border-top: 3px solid #00ffff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
