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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000;
    color: white;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 상단 헤더 */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-left, .header-center, .header-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.header-center {
    justify-content: center;
}

.header-right {
    justify-content: flex-end;
}

.logo-text {
    font-size: 1.3rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff, #888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 모드 선택 버튼 */
.mode-selector {
    display: flex;
    gap: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 3px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.mode-btn svg {
    width: 18px;
    height: 18px;
}

.mode-btn span {
    font-weight: 500;
}

.mode-btn:hover {
    color: white;
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* 도형 선택 드롭다운 */
.shape-selector {
    position: relative;
}

.shape-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 120px;
}

.shape-dropdown-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.shape-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(20, 20, 20, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 150px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.shape-dropdown.show {
    display: block;
}

.shape-option {
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.shape-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.shape-option.active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffeb3b;
}

/* 도전 정보 */
.challenge-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.9rem;
}

.challenge-info .divider {
    color: rgba(255, 255, 255, 0.3);
}

/* 메인 콘텐츠 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 20px;
}

/* 게임 통계 */
.game-stats {
    display: flex;
    gap: 30px;
    align-items: center;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

#targetAccuracyContainer .stat-value {
    color: #ffd700;
}

/* 게임 영역 */
.game-area {
    position: relative;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#gameCanvas {
    display: block;
    background: #0a0a0a;
    border-radius: 12px;
    cursor: crosshair;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* 점수 표시 */
.score-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: bold;
    pointer-events: none;
    color: #ffffff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.score-display.show {
    opacity: 1;
    animation: scorePopIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes scorePopIn {
    from {
        transform: translate(-50%, -50%) scale(0);
    }
    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 타이머 바 */
.timer-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #ffff00, #ff0000);
    transition: width 0.1s linear;
    width: 100%;
}

/* 피드백 텍스트 */
.feedback-text {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
}

.feedback-text.show {
    animation: feedbackPop 1.5s ease-out;
}

@keyframes feedbackPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    40% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -80%) scale(1);
    }
}

/* 스테이지 진행 표시 */
.stage-progress {  
    position: absolute;
    bottom: -45px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 10px 0;
}

.progress-dots {
    display: flex;
    gap: 6px;
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.progress-dot.completed {
    background: #00ff00;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.5);
}

.progress-dot.failed {
    background: #ff4444;
    box-shadow: 0 0 8px rgba(255, 68, 68, 0.5);
}

.progress-dot.current {
    background: #ffd700;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* 버튼 */
.btn {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 30px;
    font-size: 0.95rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* 도전 모드일 때 버튼 위치 조정 */
.challenge-active #resetBtn {
    margin-top: 60px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

/* 파티클 효과 */
.particle {
    position: absolute;
    pointer-events: none;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
    animation: float 1s ease-out forwards;
}

@keyframes float {
    to {
        transform: translateY(-30px) scale(0);
        opacity: 0;
    }
}

/* 색상 클래스 */
.perfect { color: #00ff00; }
.excellent { color: #ffd700; }
.good { color: #87ceeb; }
.nice { color: #ffffff; }
.fail { color: #ff4444; }

/* 토스트 메시지 */
.toast-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-message.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.toast-success {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.95), rgba(56, 142, 60, 0.95));
    border: 1px solid rgba(129, 199, 132, 0.3);
}

.toast-success .toast-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.toast-error {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.95), rgba(198, 40, 40, 0.95));
    border: 1px solid rgba(239, 83, 80, 0.3);
}

.toast-error .toast-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .toast-message {
        font-size: 14px;
        padding: 12px 20px;
        width: 90%;
        max-width: 320px;
    }
}

/* 티어 표시 */
.tier-display {
    font-size: 3rem;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
    letter-spacing: 2px;
    animation: tierGlow 2s ease-in-out infinite;
}

@keyframes tierGlow {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

/* 티어별 텍스트 색상 */
.tier-sss { color: #ff00ff; text-shadow: 0 0 30px #ff00ff; }
.tier-ss { color: #ff6b6b; text-shadow: 0 0 25px #ff6b6b; }
.tier-s { color: #ffd700; text-shadow: 0 0 20px #ffd700; }
.tier-a { color: #00ff00; text-shadow: 0 0 20px #00ff00; }
.tier-b { color: #4169e1; text-shadow: 0 0 20px #4169e1; }
.tier-c { color: #9370db; text-shadow: 0 0 20px #9370db; }
.tier-d { color: #ff8c00; text-shadow: 0 0 20px #ff8c00; }
.tier-e { color: #cd853f; text-shadow: 0 0 20px #cd853f; }
.tier-f { color: #808080; text-shadow: 0 0 10px #808080; }

/* 모달 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a1a 0%, #0f0f0f 100%);
    border-radius: 16px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-title {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 25px;
    background: linear-gradient(135deg, #fff, #888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.result-summary {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin-bottom: 25px;
}

.result-item {
    text-align: center;
}

.result-label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.7;
    margin-bottom: 8px;
}

.result-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #ffd700;
}

.stage-details {
    margin-bottom: 25px;
}

.stage-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.stage-detail-item.passed {
    border-left-color: #00ff00;
}

.stage-detail-item.failed {
    border-left-color: #ff4444;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-buttons button {
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

#shareBtn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

#shareBtn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

#shareBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

#shareBtn:hover:before {
    left: 100%;
}

#shareBtn:active {
    transform: translateY(0);
}

#closeModalBtn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#closeModalBtn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.share-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

/* 모바일 반응형 */
@media (max-width: 768px) {
    .top-header {
        padding: 10px 15px;
    }
    
    .logo-text {
        font-size: 1.1rem;
    }
    
    .mode-btn {
        padding: 6px 10px;
    }
    
    .mode-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .mode-btn span {
        font-size: 0.8rem;
    }
    
    .shape-dropdown-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        min-width: 100px;
    }
    
    .challenge-info {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .game-stats {
        gap: 20px;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .main-content {
        padding: 15px;
        gap: 15px;
    }
    
    .game-area {
        padding: 15px;
        width: 100%;
        max-width: 90vw;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
        max-width: 400px;
        touch-action: none;
    }
    
    .score-display {
        font-size: 3rem;
    }
    
    .feedback-text {
        font-size: 1.2rem;
    }
    
    .btn {
        padding: 8px 24px;
        font-size: 0.9rem;
    }
}

/* 아주 작은 화면 */
@media (max-width: 480px) {
    .header-left {
        flex: 0.5;
    }
    
    .logo-text {
        font-size: 0.9rem;
    }
    
    .mode-btn span {
        display: none;
    }
    
    .mode-btn {
        padding: 8px;
    }
    
    .stat-label {
        display: none;
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    #gameCanvas {
        max-width: 320px;
    }
    
    .score-display {
        font-size: 2.5rem;
    }
}

/* 터치 기기 최적화 */
@media (hover: none) and (pointer: coarse) {
    .mode-btn:active {
        transform: scale(0.95);
    }
    
    .shape-dropdown-btn:active {
        transform: scale(0.95);
    }
    
    .btn:active {
        transform: scale(0.95);
    }
}
