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

body {
    background: #000;
    color: #fff;
    font-family: 'Segoe UI', sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

.screen {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
}

.screen.active {
    display: flex;
}

/* 타이틀 화면 */
#title-screen {
    background: #000;
    flex-direction: column;
}

#title-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, #1a0a0a 0%, #000 70%);
    animation: bgPulse 4s ease-in-out infinite;
}

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

#title-overlay {
    position: relative;
    z-index: 1;
    text-align: center;
}

#title-overlay h1 {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 0.3em;
    text-shadow: 0 0 40px rgba(255, 0, 0, 0.5);
    animation: flicker 3s infinite;
}

#title-overlay p {
    font-size: 1.2rem;
    letter-spacing: 0.5em;
    opacity: 0.6;
    margin-top: 0.5rem;
}

/* 인트로 영상 */
#intro-screen {
    background: #000;
    flex-direction: column;
}

#intro-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#skip-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 5;
    padding: 0.6rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    transition: all 0.3s;
    backdrop-filter: blur(4px);
}

#skip-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#start-btn {
    margin-top: 3rem;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    cursor: pointer;
    letter-spacing: 0.3em;
    transition: all 0.3s;
}

#start-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
    53% { opacity: 0.4; }
    55% { opacity: 0.9; }
    57% { opacity: 0.5; }
    60% { opacity: 1; }
}

/* 메뉴 */
#menu-screen {
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 100%);
}

.menu-container {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.menu-container h1 {
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 30px rgba(255, 0, 0, 0.4);
}

.subtitle {
    opacity: 0.6;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.camera-permission {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.camera-permission.ready {
    border-color: rgba(0, 255, 0, 0.3);
    background: rgba(0, 255, 0, 0.05);
}

.difficulty-select h3 {
    font-size: 1rem;
    opacity: 0.7;
    margin-bottom: 1rem;
}

.diff-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.diff-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateX(4px);
}

.diff-name {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
}

.diff-desc {
    display: block;
    font-size: 0.8rem;
    opacity: 0.5;
    margin-top: 0.2rem;
}

/* 게임 */
#game-screen {
    background: #000;
}

#game-canvas {
    width: 100%;
    height: 100%;
}

#camera-feed {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 160px;
    height: 120px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    overflow: hidden;
    z-index: 10;
}

#camera-feed video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

#camera-feed canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#hud {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    text-align: center;
}

#distance-bar {
    width: 300px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

#distance-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ffaa00, #44ff44);
    border-radius: 4px;
    transition: width 0.3s;
    width: 100%;
}

#distance-text {
    font-size: 0.9rem;
    opacity: 0.8;
}

#blink-warning {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 900;
    color: #ff4444;
    text-shadow: 0 0 30px rgba(255, 0, 0, 0.8);
    z-index: 20;
    animation: pulse 0.5s ease-in-out infinite;
    pointer-events: none;
}

#blink-warning.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* 게임오버 & 클리어 */
#gameover-screen {
    background: rgba(0, 0, 0, 0.95);
}

.gameover-container, .clear-container {
    text-align: center;
}

.gameover-container h1 {
    font-size: 4rem;
    color: #ff2222;
    text-shadow: 0 0 40px rgba(255, 0, 0, 0.6);
    margin-bottom: 1rem;
}

.clear-container h1 {
    font-size: 3rem;
    color: #44ff44;
    text-shadow: 0 0 40px rgba(0, 255, 0, 0.6);
    margin-bottom: 1rem;
}

#survival-time, #clear-time {
    font-size: 1.2rem;
    opacity: 0.7;
    margin-bottom: 2rem;
}

.gameover-container button, .clear-container button {
    padding: 1rem 3rem;
    font-size: 1.1rem;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
}

.gameover-container button:hover, .clear-container button:hover {
    background: rgba(255, 255, 255, 0.1);
}

#clear-screen {
    background: rgba(0, 0, 0, 0.9);
}

/* 크랙 오버레이 */
.crack-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 30;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.1s;
}

/* 모바일 */
@media (max-width: 768px) {
    #intro-overlay h1 { font-size: 2.5rem; }
    .menu-container h1 { font-size: 2rem; }
    #camera-feed { width: 120px; height: 90px; bottom: 8px; right: 8px; }
    #distance-bar { width: 200px; }
    #blink-warning { font-size: 2rem; }
}
