/* =====================================================
   Tetris Game - Modern Design System
   ===================================================== */

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

:root {
    /* Primary Colors */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --tetris-gradient: linear-gradient(135deg, #fc466b 0%, #3f5efb 100%);

    /* Tetromino Colors */
    --color-i: #00f5ff;
    --color-o: #ffd93d;
    --color-t: #c56cf0;
    --color-s: #6ab04c;
    --color-z: #eb4d4b;
    --color-j: #4834d4;
    --color-l: #f0932b;

    /* Background Colors */
    --bg-dark: #0a0a1a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.1);

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    /* Effects */
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glow-pink: 0 0 20px rgba(252, 70, 107, 0.4);

    /* Sizes */
    --border-radius: 20px;
    --border-radius-sm: 12px;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* =====================================================
   Background Animation
   ===================================================== */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(252, 70, 107, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(63, 94, 251, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 60%);
    animation: gradientShift 15s ease-in-out infinite;
}

@keyframes gradientShift {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

.floating-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.3;
}

.shape-1 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #fc466b, #3f5efb);
    top: -50px;
    left: -50px;
    animation: float1 20s ease-in-out infinite;
}

.shape-2 {
    width: 250px;
    height: 250px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    bottom: 10%;
    right: -50px;
    animation: float2 25s ease-in-out infinite;
}

.shape-3 {
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, #f0932b, #ffd93d);
    top: 50%;
    left: 20%;
    animation: float3 18s ease-in-out infinite;
}

@keyframes float1 {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(50px, 50px) rotate(120deg);
    }

    66% {
        transform: translate(30px, 80px) rotate(240deg);
    }
}

@keyframes float2 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(-60px, -40px);
    }
}

@keyframes float3 {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(40px, -30px) scale(1.1);
    }
}

/* =====================================================
   Container & Layout
   ===================================================== */
.container {
    position: relative;
    z-index: 1;
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =====================================================
   Header
   ===================================================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.back-btn {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.title-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-icon {
    font-size: 2rem;
    animation: blockBounce 1s ease-in-out infinite;
}

@keyframes blockBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.game-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--tetris-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =====================================================
   Game Container
   ===================================================== */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

/* =====================================================
   Side Panel
   ===================================================== */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 120px;
}

.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.panel-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

#next-canvas {
    display: block;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--tetris-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =====================================================
   Main Game Area
   ===================================================== */
.main-game {
    flex-shrink: 0;
}

.canvas-wrapper {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border: 2px solid var(--glass-border);
}

#game-canvas {
    display: block;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* =====================================================
   Game Overlay
   ===================================================== */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

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

#overlay-title {
    font-size: 1.8rem;
    margin-bottom: 15px;
    background: var(--tetris-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#overlay-message {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 0.9rem;
}

.start-btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: var(--tetris-gradient);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--glow-pink);
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(252, 70, 107, 0.6);
}

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

/* =====================================================
   Mobile Controls
   ===================================================== */
.mobile-controls {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
}

.controls-row {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.control-btn {
    width: 65px;
    height: 55px;
    font-size: 1.4rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

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

.rotate-btn {
    width: 75px;
    background: linear-gradient(135deg, rgba(118, 75, 162, 0.3), rgba(102, 126, 234, 0.3));
}

.soft-drop {
    flex: 1;
    max-width: 100px;
}

.hard-drop {
    flex: 1;
    max-width: 100px;
    background: linear-gradient(135deg, rgba(252, 70, 107, 0.3), rgba(63, 94, 251, 0.3));
}

/* =====================================================
   Control Hints
   ===================================================== */
.control-hints {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.hint-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hint-keys {
    font-family: monospace;
    background: var(--bg-card);
    padding: 4px 8px;
    border-radius: 5px;
    border: 1px solid var(--glass-border);
    font-size: 0.7rem;
}

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

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

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

    .side-panel {
        width: 100%;
        flex-direction: row;
        justify-content: center;
        gap: 10px;
    }

    .panel-card {
        flex: 1;
        max-width: 200px;
    }

    .stats {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-around;
    }

    .stat-item {
        min-width: 60px;
    }

    .mobile-controls {
        display: flex;
    }

    .control-hints {
        display: none;
    }
}

@media (max-width: 480px) {
    .header {
        justify-content: center;
    }

    .back-btn {
        position: absolute;
        left: 15px;
        top: 20px;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .title-area {
        margin-top: 40px;
    }

    .side-panel {
        flex-direction: column;
    }

    .panel-card {
        max-width: 100%;
    }

    .stats {
        flex-direction: row;
    }

    .stat-value {
        font-size: 0.95rem;
    }

    .control-btn {
        width: 55px;
        height: 50px;
        font-size: 1.2rem;
    }

    .rotate-btn {
        width: 65px;
    }

    #overlay-title {
        font-size: 1.4rem;
    }

    #overlay-message {
        font-size: 0.8rem;
    }

    .start-btn {
        padding: 12px 30px;
        font-size: 1rem;
    }
}

/* =====================================================
   Touch device optimization
   ===================================================== */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: flex;
    }

    .control-hints {
        display: none;
    }
}