/* CSS 변수 정의 */
:root {
    --primary-color: #f59e0b;
    --primary-hover: #d97706;
    --secondary-color: #3b82f6;
    --secondary-hover: #2563eb;
    --accent-color: #10b981;
    --accent-hover: #059669;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border: #334155;
    --border-hover: #475569;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --radius: 12px;
    --radius-lg: 16px;
}

/* 기본 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
}

/* 네비게이션 바 */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-buttons {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.nav-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

/* 메인 컨테이너 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 6rem 2rem 2rem;
    height: 100vh;
    overflow-y: auto;
    position: relative;
}

/* 헤더 */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.header h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.025em;
}

.header p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* 게임 영역 */
.game-area {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: start;
    margin-bottom: 3rem;
}

/* 테스트 섹션 */
.test-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.test-container {
    text-align: center;
    width: 100%;
    max-width: 500px;
}

.test-message {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-weight: 500;
}

.start-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 2rem;
}

.start-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.test-area {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: all 0.3s ease;
}

.test-area.waiting {
    background: var(--surface);
    border-color: var(--border);
}

.test-area.ready {
    background: var(--accent-color);
    border-color: var(--accent-color);
    animation: pulse 1s infinite;
}

.test-area.click {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(0.98);
}

.click-zone {
    width: 100%;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.click-text {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

/* 사이드 패널 */
.side-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    min-width: 250px;
}

.current-section,
.best-section {
    margin-bottom: 2rem;
    text-align: center;
}

.current-section h3,
.best-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.current-time,
.best-time {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent-color);
}

.best-time {
    color: var(--primary-color);
}

.stats-section {
    margin-bottom: 2rem;
}

.stats-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

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

.stat-item span:first-child {
    color: var(--text-secondary);
}

.stat-item span:last-child {
    font-weight: 600;
    color: var(--text-primary);
}

/* 컨트롤 버튼 */
.controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.control-btn:hover {
    background: var(--secondary-hover);
    transform: translateY(-1px);
}

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

/* 기록 히스토리 */
.history-section {
    margin-top: 3rem;
}

.history-section h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.history-item {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--border);
    text-align: center;
    transition: all 0.2s ease;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.history-time {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.history-date {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    overflow: hidden;
}

.modal-header {
    background: var(--primary-color);
    color: white;
    padding: 1.5rem 2rem;
    text-align: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.modal-body {
    padding: 2rem;
    text-align: center;
}

.modal-body p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.result-time {
    margin-bottom: 2rem;
}

.result-time p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.time-display {
    font-size: 3rem;
    font-weight: 800;
    color: var(--accent-color);
}

.result-details {
    color: var(--text-secondary);
}

.result-details p {
    margin-bottom: 0.5rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    background: var(--background);
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal-btn {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

.modal-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.modal-btn.primary:hover {
    background: var(--primary-hover);
}

/* 모바일 알림 */
.mobile-notice {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    text-align: center;
    z-index: 1500;
    max-width: 400px;
    width: 90%;
}

.notice-content h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.notice-content p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.notice-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notice-btn:hover {
    background: var(--primary-hover);
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .container {
        padding: 5rem 1rem 1rem;
    }

    .header h1 {
        font-size: 2rem;
    }

    .game-area {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .side-panel {
        min-width: auto;
        padding: 1.5rem;
    }

    .click-zone {
        height: 200px;
    }

    .click-text {
        font-size: 1.5rem;
    }

    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .nav-bar {
        padding: 1rem;
    }

    .nav-buttons {
        gap: 0.5rem;
    }

    .nav-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.75rem;
    }

    .current-time,
    .best-time {
        font-size: 2rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-btn {
        width: 100%;
    }

    .click-zone {
        height: 150px;
    }

    .click-text {
        font-size: 1.25rem;
    }
}

/* 애니메이션 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.test-section {
    animation: fadeIn 0.6s ease-out;
}

.test-area.ready {
    animation: pulse 1s infinite;
}

.test-area.click {
    animation: flash 0.1s ease-out;
}

/* 접근성 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 포커스 스타일 */
button:focus,
.control-btn:focus,
.click-zone:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 다크 모드 대응 */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --surface: #1e293b;
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
    }
}