/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

:root {
    /* Sci-Fi Dark Theme Colors */
    --bg-primary: #0a0e27;
    --bg-secondary: #121829;
    --bg-tertiary: #1a1f3a;

    --accent-cyan: #00f0ff;
    --accent-magenta: #ff00ff;
    --accent-yellow: #ffff00;
    --accent-green: #00ff88;
    --accent-red: #ff0055;
    --accent-blue: #4d4dff;
    --accent-orange: #ff9500;

    --text-primary: #e0e6ff;
    --text-secondary: #8892b0;
    --text-glow: #00f0ff;

    --border-color: rgba(0, 240, 255, 0.3);
    --shadow-glow: 0 0 20px rgba(0, 240, 255, 0.5);
}

body {
    font-family: 'Courier New', 'Consolas', monospace;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #050816 100%);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(0, 240, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(255, 0, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ===== Game Container ===== */
.game-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    padding: 0.5rem;
    overflow: hidden;
}

/* ===== Header ===== */
.game-header {
    text-align: center;
    flex-shrink: 0;
    padding: 0.25rem 0;
}

.game-title {
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 0.15em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    line-height: 1;
}

.glow {
    color: var(--text-glow);
    text-shadow:
        0 0 10px var(--accent-cyan),
        0 0 20px var(--accent-cyan);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 10px var(--accent-cyan), 0 0 20px var(--accent-cyan); }
    50% { text-shadow: 0 0 15px var(--accent-cyan), 0 0 30px var(--accent-cyan); }
}

.subtitle {
    font-size: 1rem;
    color: var(--accent-magenta);
    text-shadow: 0 0 10px var(--accent-magenta);
}

/* ===== Main Game Area ===== */
.game-main {
    flex: 1;
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

/* ===== Game Board ===== */
.board-wrapper {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gameCanvas {
    display: block;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: rgba(10, 14, 39, 0.8);
    box-shadow: var(--shadow-glow), inset 0 0 30px rgba(0, 0, 0, 0.5);
    max-height: 100%;
    max-width: 100%;
}

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

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

.overlay-content {
    text-align: center;
}

.overlay-title {
    font-size: 2rem;
    color: var(--accent-red);
    text-shadow: 0 0 10px var(--accent-red), 0 0 20px var(--accent-red);
    margin-bottom: 1rem;
    letter-spacing: 0.1em;
}

.overlay-score {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

/* ===== Side Panel ===== */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 180px;
    max-height: 100%;
    overflow-y: auto;
}

.info-section,
.next-section,
.controls-section,
.audio-section {
    background: rgba(18, 24, 41, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.section-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-glow);
    letter-spacing: 0.1em;
    margin-bottom: 0.4rem;
    text-shadow: 0 0 5px var(--accent-cyan);
}

/* Info Section */
.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(0, 240, 255, 0.1);
}

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

.info-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 1.1rem;
    color: var(--accent-cyan);
    font-weight: bold;
    text-shadow: 0 0 5px var(--accent-cyan);
}

/* Next Piece Section */
#nextCanvas {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    background: rgba(10, 14, 39, 0.6);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 4px;
}

/* Controls Section */
.controls-grid {
    display: grid;
    gap: 0.3rem;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.65rem;
}

kbd {
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.1rem 0.3rem;
    font-family: inherit;
    font-size: 0.6rem;
    color: var(--accent-cyan);
    min-width: 1.2rem;
    text-align: center;
}

/* ===== Buttons ===== */
.btn-restart,
.btn-start,
.btn-audio {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: bold;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    text-transform: uppercase;
}

.btn-restart:hover,
.btn-start:hover,
.btn-audio:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--accent-cyan);
}

.btn-audio {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem;
    font-size: 0.75rem;
}

.audio-icon {
    font-size: 1rem;
}

.btn-audio.muted {
    background: linear-gradient(135deg, #444, #666);
}

/* ===== Mobile Controls ===== */
.mobile-controls {
    display: none;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem;
    background: rgba(18, 24, 41, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    flex-shrink: 0;
}

.control-row {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.btn-control {
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--accent-cyan);
    touch-action: manipulation;
    user-select: none;
}

.btn-control:active {
    background: rgba(0, 240, 255, 0.3);
    transform: scale(0.95);
}

.btn-control svg {
    width: 60%;
    height: 60%;
}

.btn-control-large {
    width: 120px;
}

/* ===== Start Screen ===== */
.start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.start-screen.hidden {
    display: none;
}

.start-content {
    text-align: center;
}

.start-title {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.start-year {
    font-size: 2rem;
    color: var(--accent-magenta);
    text-shadow: 0 0 20px var(--accent-magenta);
}

.start-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    letter-spacing: 0.15em;
    animation: flicker 3s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== Responsive Design ===== */

/* 모바일 (세로) */
@media (max-width: 700px) {
    .game-container {
        padding: 0.3rem;
    }

    .game-header {
        padding: 0.15rem 0;
    }

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

    .subtitle {
        font-size: 0.8rem;
    }

    .game-main {
        flex-direction: column;
        gap: 0.4rem;
    }

    .board-wrapper {
        flex: 1;
        min-height: 0;
    }

    .side-panel {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        max-height: none;
        gap: 0.3rem;
    }

    .info-section,
    .next-section {
        flex: 1;
        min-width: 45%;
    }

    .controls-section {
        display: none;
    }

    .audio-section {
        width: 100%;
    }

    .mobile-controls {
        display: flex;
    }
}

/* 작은 화면 높이 */
@media (max-height: 600px) {
    .game-title {
        font-size: 1rem;
    }

    .subtitle {
        display: none;
    }

    .btn-control {
        width: 48px;
        height: 48px;
    }

    .btn-control-large {
        width: 100px;
    }
}

/* 매우 작은 높이 (가로 모드) */
@media (max-height: 450px) {
    .game-header {
        display: none;
    }

    .game-main {
        flex-direction: row;
    }

    .side-panel {
        flex-direction: column;
        width: 140px;
    }

    .mobile-controls {
        display: none;
    }

    .controls-section {
        display: block;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
