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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    margin: 0;
    padding: 10px;
}

/* Game container */
.game-container {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    padding: 20px;
    max-width: 600px;
    width: 100%;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.game-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.5px;
}

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

.info-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    gap: 30px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 60px;
}

.info-item label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 2px;
}

.info-item span {
    font-size: 1.2rem;
    font-weight: 700;
    color: #222;
}

:root {
    --board-width: 280px;
    --board-height: 560px;
}
/* Main game area */
.game-main {
    display: grid;
    grid-template-columns: auto auto;
    gap: 20px;
    align-items: start; /* top-align both columns */
    justify-content: center;
}

/* Game board container */
.game-board-container {
    position: relative;
    display: flex;
    justify-content: center;
    max-width: var(--board-width);
    width: var(--board-width);
    margin: 0 auto;
}

#game-board {
    border: 3px solid #333;
    border-radius: 12px;
    background: #000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    display: block;
    width: var(--board-width);
    height: var(--board-height);
}

/* Game overlay for pause/game over */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.game-overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    color: white;
    padding: 20px;
    max-width: 300px;
    margin: 0 auto;
}

.overlay-content h2 {
    font-size: 2.2rem;
    margin-bottom: 12px;
    color: #fff;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

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

/* Button styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
    font-size: 1.1rem;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: none;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Sidebar styles */
.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 200px;
    height: var(--board-height); /* match board height */
    justify-content: space-between; /* push Controls to bottom */
}

.next-piece-container,
.hold-piece-container {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.next-piece-container h3,
.hold-piece-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

#next-piece,
#hold-piece {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #000;
    display: block;
    margin: 0 auto;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    width: 100px;
    height: 100px;
}

/* Controls info */
.controls-info {
    background: rgba(255, 255, 255, 0.9);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    max-height: calc(var(--board-height) - 300px); /* limit height to fit in sidebar */
    overflow-y: auto; /* allow scrolling if needed */
}

.controls-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    text-align: center;
}

.control-list {
    display: flex;
    flex-direction: column;
    gap: 4px; /* reduce gap to fit more content */
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0; /* reduce padding */
    border-bottom: 1px solid #eee;
    font-size: 0.85rem; /* slightly smaller font */
}

.control-item:last-child {
    border-bottom: none;
}

.key {
    background: #333;
    color: white;
    padding: 3px 6px; /* reduce padding */
    border-radius: 6px;
    font-size: 0.7rem; /* smaller font */
    font-weight: 600;
    min-width: 35px; /* smaller min-width */
    text-align: center;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Responsive design */
@media (max-width: 768px) {
    :root {
        --board-width: 300px;
        --board-height: 600px;
    }
    body {
        padding: 10px;
    }
    
    .game-container {
        padding: 20px;
        margin: 5px;
        max-width: 100%;
    }

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

    .game-main {
        grid-template-columns: 1fr;
        gap: 15px;
        justify-content: stretch;
    }

    .game-board-container {
        max-width: 100%;
        width: 100%;
    }

    .game-sidebar {
        flex-direction: row;
        justify-content: space-around;
        width: auto;
        gap: 15px;
        height: auto; /* let it grow naturally on mobile */
    }

    .next-piece-container,
    .hold-piece-container,
    .controls-info {
        flex: 1;
        padding: 12px;
    }

    #game-board {
        width: 100%;
        height: auto;
    }

    #next-piece,
    #hold-piece {
        width: 70px;
        height: 70px;
    }

    .info-panel {
        flex-direction: column;
        gap: 12px;
        padding: 15px 20px;
    }
    
    .info-item span {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .game-sidebar {
        flex-direction: column;
    }

    .controls-info {
        display: none;
    }
}

/* Animation for line clear flash */
@keyframes lineClear {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.line-clear {
    animation: lineClear 0.3s ease-in-out;
}

/* Smooth transitions for UI elements */
.game-container {
    transition: all 0.3s ease;
}

.info-panel,
.next-piece-container,
.hold-piece-container,
.controls-info {
    transition: all 0.2s ease;
}

/* Hover effects */
.info-panel:hover,
.next-piece-container:hover,
.hold-piece-container:hover,
.controls-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

/* Ghost piece styling */
.ghost-piece {
    opacity: 0.3;
}

/* Hold piece disabled state */
.hold-disabled {
    opacity: 0.5;
    filter: grayscale(100%);
}
