/* Tetris - Classic Block Puzzle */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Nunito:wght@400;600;700&display=swap');

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

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(180deg, #0a0a0a 0%, #1a1a2e 100%);
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.back-btn {
    display: inline-block;
    color: #00d4ff;
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 5px;
    transition: color 0.3s;
}

.back-btn:hover {
    color: #fff;
}

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

.game-header h1 {
    font-family: 'Press Start 2P', cursive;
    font-size: 2rem;
    background: linear-gradient(180deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #8b00ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 4px;
}

/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
}

.screen.hidden {
    display: none;
}

/* Start Screen */
.tetris-art {
    margin-bottom: 15px;
}

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

.block {
    width: 40px;
    height: 40px;
    border-radius: 5px;
    animation: float 2s ease-in-out infinite;
}

.block.i { background: #00f0f0; animation-delay: 0s; }
.block.o { background: #f0f000; animation-delay: 0.2s; }
.block.t { background: #a000f0; animation-delay: 0.4s; }
.block.l { background: #f0a000; animation-delay: 0.6s; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

#startScreen h2 {
    font-size: 1.2rem;
    color: #00d4ff;
    margin-bottom: 10px;
}

.instructions {
    color: #aaa;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* High Scores Panel */
.high-scores-panel {
    background: rgba(0, 212, 255, 0.1);
    border: 2px solid #00d4ff;
    border-radius: 10px;
    padding: 15px 25px;
    margin-bottom: 20px;
    min-width: 280px;
}

.high-scores-panel h3 {
    font-family: 'Press Start 2P', cursive;
    color: #00d4ff;
    font-size: 0.7rem;
    margin-bottom: 10px;
}

.high-scores-panel ol {
    list-style: none;
    text-align: left;
}

.high-scores-panel li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
    font-size: 0.85rem;
}

.high-scores-panel li:last-child {
    border-bottom: none;
}

.high-scores-panel .score-name {
    color: #fff;
}

.high-scores-panel .score-value {
    color: #00ff00;
    font-weight: 700;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
}

/* Buttons */
.play-btn {
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    color: #000;
    border: none;
    padding: 15px 40px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s;
    font-family: 'Press Start 2P', cursive;
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
}

.play-btn:active {
    transform: scale(0.98);
}

.menu-btn {
    display: inline-block;
    background: transparent;
    color: #00d4ff;
    border: 2px solid #00d4ff;
    padding: 12px 25px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    margin-left: 15px;
}

.menu-btn:hover {
    background: #00d4ff;
    color: #000;
}

/* Game Screen */
#gameScreen {
    padding: 5px;
}

.game-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 15px;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 80px;
}

.info-box {
    background: rgba(0, 212, 255, 0.1);
    border: 2px solid #00d4ff;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.info-label {
    display: block;
    font-size: 0.6rem;
    color: #aaa;
    margin-bottom: 5px;
    font-family: 'Press Start 2P', cursive;
}

.info-value {
    display: block;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    color: #00ff00;
}

.next-box {
    padding: 10px;
}

#nextCanvas {
    display: block;
    margin: 5px auto 0;
}

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

#gameCanvas {
    border: 3px solid #00d4ff;
    border-radius: 5px;
    background: #000;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3);
    touch-action: none;
    max-width: 100%;
    height: auto;
}

/* Touch Controls */
.touch-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.touch-row {
    display: flex;
    gap: 15px;
}

.touch-btn {
    width: 70px;
    height: 60px;
    background: rgba(0, 212, 255, 0.2);
    border: 3px solid #00d4ff;
    border-radius: 15px;
    color: #00d4ff;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.touch-btn:active {
    background: #00d4ff;
    color: #000;
    transform: scale(0.95);
}

.touch-btn.rotate {
    background: rgba(160, 0, 240, 0.2);
    border-color: #a000f0;
    color: #a000f0;
}

.touch-btn.rotate:active {
    background: #a000f0;
    color: #fff;
}

.touch-btn.drop {
    width: 200px;
    height: 50px;
    font-size: 1rem;
    font-weight: 700;
    background: rgba(0, 255, 0, 0.1);
    border-color: #00ff00;
    color: #00ff00;
}

.touch-btn.drop:active {
    background: #00ff00;
    color: #000;
}

/* Game Over Screen */
#gameOverTitle {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.5rem;
    color: #ff0000;
    margin-bottom: 25px;
}

.final-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.final-stat {
    background: rgba(0, 212, 255, 0.1);
    border: 2px solid #00d4ff;
    border-radius: 10px;
    padding: 15px 20px;
    min-width: 100px;
}

.final-value {
    display: block;
    font-family: 'Press Start 2P', cursive;
    font-size: 1.2rem;
    color: #00ff00;
}

.final-label {
    display: block;
    font-size: 0.75rem;
    color: #aaa;
    margin-top: 5px;
}

/* New High Score */
.new-high-score {
    background: linear-gradient(135deg, rgba(0, 255, 0, 0.1) 0%, rgba(0, 212, 255, 0.1) 100%);
    border: 3px solid #00ff00;
    border-radius: 10px;
    padding: 20px 30px;
    margin-bottom: 25px;
    animation: rainbow-border 2s linear infinite;
}

@keyframes rainbow-border {
    0% { border-color: #ff0000; }
    17% { border-color: #ff7f00; }
    33% { border-color: #ffff00; }
    50% { border-color: #00ff00; }
    67% { border-color: #0000ff; }
    83% { border-color: #8b00ff; }
    100% { border-color: #ff0000; }
}

.new-high-score p {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.9rem;
    color: #00ff00;
    margin-bottom: 15px;
}

.new-high-score input {
    background: #000;
    border: 2px solid #00d4ff;
    border-radius: 5px;
    padding: 10px 15px;
    color: #00ff00;
    font-size: 1rem;
    width: 160px;
    text-align: center;
    margin-right: 10px;
    font-family: 'Press Start 2P', cursive;
}

.new-high-score input::placeholder {
    color: #555;
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
}

.save-btn {
    background: #00ff00;
    color: #000;
    border: none;
    padding: 12px 20px;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Press Start 2P', cursive;
    transition: all 0.3s;
}

.save-btn:hover {
    background: #00d4ff;
    transform: translateY(-2px);
}

.game-over-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

/* Responsive */
@media (max-width: 600px) {
    .game-header h1 {
        font-size: 1.5rem;
    }

    .game-info {
        min-width: 60px;
    }

    .info-box {
        padding: 8px;
    }

    .info-label {
        font-size: 0.5rem;
    }

    .info-value {
        font-size: 0.65rem;
    }

    .touch-btn {
        width: 60px;
        height: 55px;
        font-size: 1.3rem;
    }

    .touch-btn.drop {
        width: 180px;
        height: 45px;
        font-size: 0.9rem;
    }

    .game-over-buttons {
        flex-direction: column;
    }

    .menu-btn {
        margin-left: 0;
    }
}

/* Hide touch controls on desktop with keyboard hint */
@media (min-width: 769px) {
    .touch-controls {
        opacity: 0.5;
    }

    .touch-controls::after {
        content: 'Or use Arrow Keys + Space';
        display: block;
        margin-top: 10px;
        font-size: 0.8rem;
        color: #666;
    }
}
