/* Tetris Game Styles - Using Portfolio Colors */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-bg: #181a20;
    --accent-color: #ffb347;
    --text-secondary: #b2becd;
    --border-color: #353866;
}

body {
    font-family: 'Montserrat', 'Roboto', Arial, sans-serif;
    background: #181a20;
    color: #f5f6fa;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    margin: 0;
}

.container {
    width: 100vw;
    min-height: 100vh;
    background: linear-gradient(120deg, #23263a 60%, #353866 100%);
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.game-header {
    text-align: center;
    margin-bottom: 15px;
}

.game-header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: #ffb347;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.game-header p {
    color: #b2becd;
    font-size: 1rem;
}

.game-area {
    display: grid;
    grid-template-columns: minmax(200px, 250px) auto minmax(200px, 250px);
    gap: 30px;
    margin-bottom: 15px;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto 15px auto;
    justify-content: center;
}

.game-board {
    position: relative;
    background: #181a20;
    border: 3px solid #ffb347;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: fit-content;
}

#gameCanvas {
    background: #0f1015;
    border: 2px solid #353866;
    border-radius: 5px;
    display: block;
    max-width: 100%;
    height: auto;
    width: 300px;
    height: 600px;
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(24, 26, 32, 0.95);
    border: 3px solid #ffb347;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    z-index: 100;
}

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

.game-over h2 {
    color: #ffb347;
    margin-bottom: 15px;
    font-size: 2rem;
}

.restart-btn {
    background: linear-gradient(45deg, #ffb347, #ff9500);
    color: #181a20;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 15px;
}

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

.game-info-left {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 180px;
    max-width: 250px;
}

.game-info-right {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 180px;
    max-width: 250px;
}

.info-panel {
    background: #181a20;
    border: 2px solid #353866;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
}

.info-panel h3 {
    color: #ffb347;
    font-size: 1.1rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.score-value, .level-value, .lines-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #f5f6fa;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.next-piece {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#nextCanvas {
    background: #0f1015;
    border: 2px solid #353866;
    border-radius: 5px;
    margin-top: 10px;
}

.controls-info {
    background: #181a20;
    border: 2px solid #353866;
    border-radius: 10px;
    padding: 15px;
}

.controls-info h3 {
    color: #ffb347;
    font-size: 1.1rem;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}

.control-item {
    color: #b2becd;
    font-size: 0.9rem;
    margin-bottom: 8px;
    text-align: left;
    padding: 5px 10px;
    background: rgba(53, 56, 102, 0.3);
    border-radius: 5px;
}

.game-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.control-btn {
    background: linear-gradient(45deg, #353866, #23263a);
    color: #f5f6fa;
    border: 2px solid #ffb347;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.control-btn:hover:not(:disabled) {
    background: linear-gradient(45deg, #ffb347, #ff9500);
    color: #181a20;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 179, 71, 0.4);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.control-btn:active:not(:disabled) {
    transform: translateY(0);
}

.return-section {
    display: grid;
    margin-top: 40px;
    text-align: center;
    animation: fadeInUp 0.8s ease 0.3s both;
}
.btn-return {
    background: var(--primary-bg);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    padding: 12px 25px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Montserrat', Arial, sans-serif;
}
    
.btn-return:hover {
    background: var(--border-color);
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(53, 56, 102, 0.4);
}

/* Ensure scrollbars work properly */
::-webkit-scrollbar {
    width: 10px;
}
    
::-webkit-scrollbar-track {
    background: var(--primary-bg);
}
    
::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}
    
::-webkit-scrollbar-thumb:hover {
    background: #ff8c42;
}

/* Desktop/Laptop optimization */
@media (min-width: 1025px) {
    .container {
        padding: 15px 40px;
    }
    
    .game-area {
        max-width: 1400px;
        gap: 40px;
    }
    
    #gameCanvas {
        width: 350px;
        height: 700px;
    }
}

/* Responsive Design - Tablet */
@media (max-width: 1024px) {
    .container {
        padding: 10px;
        justify-content: flex-start;
    }
    
    .game-area {
        grid-template-columns: 1fr;
        gap: 15px;
        max-width: 100%;
    }
    
    .game-info-left,
    .game-info-right {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
        max-width: 100%;
    }
    
    .game-info-left {
        order: 2; /* Move below game board */
    }
    
    .game-board {
        order: 1; /* Game board first */
        justify-self: center;
    }
    
    .game-info-right {
        order: 3; /* Bottom */
    }
    
    .next-piece,
    .controls-info {
        grid-column: 1 / -1;
    }
    
    #gameCanvas {
        width: min(300px, 90vw);
        height: min(600px, 70vh);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 8px;
        justify-content: flex-start;
    }
    
    .game-header {
        margin-bottom: 10px;
    }
    
    .game-header h1 {
        font-size: clamp(1.2rem, 5vw, 1.8rem);
    }
    
    .game-header p {
        font-size: clamp(0.8rem, 3vw, 0.95rem);
    }
    
    #gameCanvas {
        width: min(280px, 85vw);
        height: min(560px, 65vh);
    }
    
    .game-info-left,
    .game-info-right {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .info-panel {
        padding: 10px;
    }
    
    .info-panel h3 {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }
    
    .score-value, .level-value, .lines-value {
        font-size: 1.4rem;
    }
    
    .next-piece,
    .controls-info {
        grid-column: 1 / -1;
    }
    
    #nextCanvas {
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .game-header h1 {
        font-size: clamp(1rem, 6vw, 1.4rem);
        margin-bottom: 5px;
    }
    
    .game-header p {
        font-size: clamp(0.7rem, 3.5vw, 0.85rem);
        line-height: 1.3;
    }
    
    #gameCanvas {
        width: min(250px, 80vw);
        height: min(500px, 60vh);
    }
    
    .game-info-left,
    .game-info-right {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
    }
    
    .info-panel {
        padding: 8px;
    }
    
    .info-panel h3 {
        font-size: 0.8rem;
        margin-bottom: 6px;
    }
    
    .score-value, .level-value, .lines-value {
        font-size: 1.2rem;
    }
    
    .next-piece,
    .controls-info {
        grid-column: 1 / -1;
    }
    
    .controls-info h3 {
        margin-bottom: 8px;
    }
    
    .control-item {
        font-size: 0.75rem;
        margin-bottom: 4px;
        padding: 4px 8px;
    }
    
    #nextCanvas {
        width: 80px;
        height: 80px;
    }
    
    .game-footer {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
    
    .control-btn {
        width: 100%;
        max-width: 180px;
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .game-over {
        padding: 20px;
        border-radius: 10px;
        width: 90%;
    }
    
    .game-over h2 {
        font-size: 1.4rem;
        margin-bottom: 10px;
    }
    
    .restart-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* Landscape orientation for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .container {
        max-height: 90vh;
    }
    
    .game-area {
        grid-template-columns: minmax(200px, 1fr) minmax(150px, 250px);
        gap: 10px;
    }
    
    #gameCanvas {
        width: min(200px, 35vw);
        height: min(400px, 75vh);
    }
    
    .game-info {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .info-panel {
        padding: 6px;
    }
    
    .info-panel h3 {
        font-size: 0.75rem;
        margin-bottom: 4px;
    }
    
    .score-value, .level-value, .lines-value {
        font-size: 1rem;
    }
    
    #nextCanvas {
        width: 60px;
        height: 60px;
    }
    
    .controls-info {
        display: none; /* Hide controls in landscape to save space */
    }
}

/* Mobile Touch Controls */
.mobile-controls {
    display: none;
    margin: 10px 0 0 0;
    width: 100%;
}

.touch-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

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

.touch-btn {
    background: linear-gradient(45deg, #353866, #23263a);
    color: #f5f6fa;
    border: 2px solid #ffb347;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.touch-btn:hover {
    background: linear-gradient(45deg, #ffb347, #ff9500);
    color: #181a20;
    transform: scale(1.1);
}

.touch-btn:active {
    transform: scale(0.95);
    background: linear-gradient(45deg, #ff9500, #ffb347);
}

/* Show mobile controls on touch devices */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: block;
    }
    
    .controls-info {
        display: none;
    }
}

/* Adjust controls for smaller mobile screens */
@media (max-width: 480px) and (hover: none) and (pointer: coarse) {
    .mobile-controls {
        margin: 8px 0 0 0;
    }
    
    .touch-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .control-row {
        gap: 10px;
    }
    
    .touch-controls {
        gap: 6px;
    }
}

/* Animation for piece drop */
@keyframes dropEffect {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.piece-drop {
    animation: dropEffect 0.2s ease-out;
}

/* Pulse effect for score updates */
@keyframes pulseScore {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.score-update {
    animation: pulseScore 0.3s ease-out;
}