* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --mint-gradient-start: #a5f3fc;
    --mint-gradient-end: #2dd4bf;
    --mint-primary: #2dd4bf;
    --mint-primary-dark: #0f766e;
    --mint-accent: #5eead4;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    color: #333;
    background: linear-gradient(135deg, var(--mint-gradient-start) 0%, var(--mint-gradient-end) 100%);
    overflow-x: hidden;
}

/* 메뉴 화면 */
#menu-screen {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

.logo-container {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

/* 로고 뒤 원형 그라데이션 (상단) */
.logo-container::before {
    content: '';
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1800px;
    height: 1800px;
    background: radial-gradient(circle, 
        rgba(255, 255, 255, 0.95) 0%,
        rgba(240, 253, 255, 0.85) 15%,
        rgba(224, 252, 255, 0.7) 30%,
        rgba(165, 243, 252, 0.4) 50%,
        transparent 70%
    );
    z-index: -1;
    pointer-events: none;
}

.menu-logo {
    max-width: 300px;
    width: 80%;
    height: auto;
}

.beta-label {
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--mint-primary-dark);
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
}

.menu-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
}

.menu-section h2 {
    color: var(--mint-primary-dark);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.menu-section h3 {
    color: var(--mint-primary);
    margin: 15px 0 10px 0;
    font-size: 1.1em;
}

.practice-mode-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.practice-mode-group > .section-block {
    padding: 20px 0;
}

.practice-mode-group > .section-block:first-of-type {
    padding-top: 0;
    border-bottom: 4px solid var(--mint-primary);
    margin-bottom: 15px;
}

.practice-mode-group > #single-chord-options,
.practice-mode-group > #progression-options {
    padding: 20px 0;
}

.practice-mode-group #single-chord-options .section-block,
.practice-mode-group #progression-options .section-block {
    padding: 20px 0;
    border-top: 2px dashed #d1d5db;
}

.practice-mode-group #single-chord-options .section-block:first-of-type,
.practice-mode-group #progression-options .section-block:first-of-type {
    border-top: none;
    padding-top: 0;
}

.practice-mode-group .section-block h3 {
    color: var(--mint-primary-dark);
    margin-bottom: 12px;
    font-size: 1.15em;
}

.practice-mode-group .section-block h4 {
    color: var(--mint-primary);
    margin: 10px 0 8px;
    font-size: 1em;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.key-group {
    max-width: 100%;
}

button {
    padding: 12px 20px;
    border: 2px solid var(--mint-primary-dark);
    background: white;
    color: var(--mint-primary-dark);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
}

button:hover {
    background: var(--mint-primary-dark);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

button.active {
    background: var(--mint-primary-dark);
    color: white;
}

.key-btn, .key-btn-progression, .chord-btn, .progression-btn, .key-change-btn, .practice-mode-btn, .key-loop-btn {
    min-width: 60px;
}

/* 키보드 설정 */
.keyboard-status {
    padding: 15px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 600;
}

.secondary-btn {
    background: white;
    color: var(--mint-primary-dark);
    border: 2px solid var(--mint-primary-dark);
}

.secondary-btn:hover {
    background: var(--mint-primary-dark);
    color: white;
}

/* 캘리브레이션 오버레이 */
#calibration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--mint-gradient-start) 0%, var(--mint-gradient-end) 100%);
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.calibration-modal {
    background: white;
    border-radius: 15px;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.calibration-modal h2 {
    color: var(--mint-primary-dark);
    margin-bottom: 30px;
    text-align: center;
}

.calibration-steps {
    margin: 30px 0;
}

.step {
    display: flex;
    align-items: center;
    padding: 20px;
    margin: 15px 0;
    background: #f5f5f5;
    border-radius: 10px;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.step.active {
    background: #e8f5e9;
    border-color: #4CAF50;
    animation: pulse 2s infinite;
}

.step.completed {
    background: #c8e6c9;
    border-color: #4CAF50;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.step-number {
    width: 40px;
    height: 40px;
    background: var(--mint-primary-dark);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2em;
    margin-right: 15px;
    flex-shrink: 0;
}

.step.completed .step-number {
    background: #4CAF50;
}

.step.completed .step-number::after {
    content: '✓';
}

.step-content {
    flex: 1;
    font-size: 1.1em;
}

.calibration-status {
    text-align: center;
    padding: 20px;
    background: #f0f0f0;
    border-radius: 10px;
    margin: 20px 0;
    font-weight: 600;
    color: #666;
}

.calibration-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.time-btn {
    flex: 1;
}

#bpm-slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

#bpm-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--mint-primary-dark);
    cursor: pointer;
}

#bpm-slider::-moz-range-thumb {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--mint-primary-dark);
    cursor: pointer;
    border: none;
}

#bpm-value {
    color: var(--mint-primary);
    font-weight: bold;
    font-size: 1.2em;
}

.start-btn-wrapper {
    position: relative;
}

/* Start 버튼 뒤 원형 그라데이션 (하단) */
.start-btn-wrapper::before {
    content: '';
    position: fixed;
    bottom: 10%;
    right: 50%;
    transform: translate(50%, 50%);
    width: 1800px;
    height: 1800px;
    background: radial-gradient(circle, 
        rgba(255, 255, 255, 0.95) 0%,
        rgba(240, 253, 255, 0.85) 15%,
        rgba(224, 252, 255, 0.7) 30%,
        rgba(165, 243, 252, 0.4) 50%,
        transparent 70%
    );
    z-index: -1;
    pointer-events: none;
}

#start-btn {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 30px auto 0;
    padding: 20px;
    font-size: 1.3em;
    background: linear-gradient(135deg, var(--mint-primary) 0%, var(--mint-primary-dark) 100%);
    border: none;
    color: white;
    position: relative;
    z-index: 1;
}

#start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* 게임 화면 */
#game-screen {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: black;
}

/* 타이머 */
#timer-container {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 80px;
    height: 80px;
    z-index: 100;
}

#timer-container svg {
    transform: rotate(-90deg);
}

#timer-bg {
    fill: none;
    stroke: rgba(255,255,255,0.3);
    stroke-width: 8;
}

#timer-fill {
    fill: none;
    stroke: #ff4757;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 220;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

#timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: black;
    font-weight: bold;
    font-size: 0.9em;
}

/* Sheet Music 컨테이너 */
#sheet-music-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 200px;
    overflow: hidden;
    background: white;
}

#sheet-music-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 450px; /* 고정 높이 */
    background: rgba(255,255,255,0.95);
    overflow: hidden;
    min-width: 1200px;
}

#staff-canvas {
    width: 100%;
    height: 100%;
}

#judgment-line {
    position: absolute;
    left: 100px;
    top: 140px;
    height: 160px;
    width: 4px;
    background: var(--mint-primary);
    z-index: 10;
}

#judgment-line.beat-pulse {
    box-shadow: none;
    background: rgb(94, 234, 213);
    transition: none;
}

#judgment-line.beat-pulse::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 60px;
    height: 100%;
    background: linear-gradient(to left, rgb(94, 234, 213), transparent);
    pointer-events: none;
}

/* Falling Notes 컨테이너 */
#falling-notes-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 200px;
    overflow: hidden;
}

#falling-notes-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: black;
    overflow-y: hidden;
}

#falling-canvas {
    width: 100%;
    height: 100%;
}

#falling-judgment-line {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #ff4757;
    z-index: 10;
    transition: all 0.1s ease;
}

#falling-judgment-line.beat-pulse {
    box-shadow: 0 0 40px #ff4757, 0 0 80px #ff4757, 0 0 120px rgba(255, 71, 87, 0.7);
    background: #ff6b81;
}

/* 판정 표시 */
#judgment-display {
    position: absolute;
    bottom: 220px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3em;
    font-weight: bold;
    text-align: center;
    z-index: 50;
    pointer-events: none;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.2s ease;
}

#judgment-display.show {
    opacity: 1;
}

#judgment-display.perfect {
    color: #FFD700;
}

#judgment-display.good {
    color: #4CAF50;
}

#judgment-display.miss {
    color: #f44336;
}

/* 피아노 컨테이너 */
#piano-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: black;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#piano-keyboard {
    position: relative;
    width: 100%;
    height: 100%;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

/* 피아노 키 */
.piano-key {
    position: absolute;
    cursor: pointer;
    transition: all 0.05s ease;
    user-select: none;
}

.white-key {
    height: 100%;
    background: linear-gradient(to bottom, #ffffff 0%, #f5f5f5 100%);
    border: 1px solid #999;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1;
}

.white-key:hover {
    background: linear-gradient(to bottom, #f0f0f0 0%, #e8e8e8 100%);
}

.white-key:active,
.white-key.active {
    background: linear-gradient(to bottom, var(--mint-primary) 0%, var(--mint-primary-dark) 100%);
    transform: translateY(2px);
    box-shadow: 0 2px 3px rgba(0,0,0,0.2);
}

.black-key {
    height: 60%;
    background: linear-gradient(to bottom, #000000 0%, #333333 100%);
    border: 1px solid #000;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    z-index: 2;
}

.black-key:hover {
    background: linear-gradient(to bottom, #1a1a1a 0%, #404040 100%);
}

.black-key:active,
.black-key.active {
    background: linear-gradient(to bottom, var(--mint-primary) 0%, var(--mint-primary-dark) 100%);
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.key-label {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8em;
    color: #666;
    font-weight: bold;
}

.black-key .key-label {
    color: #ccc;
    bottom: 5px;
    font-size: 0.7em;
}

.octave-label {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9em;
    color: #333;
    font-weight: bold;
    pointer-events: none;
}

/* 게임 정보 */
#game-info {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
}

#game-info div {
    margin: 5px 0;
    font-weight: 600;
    color: var(--mint-primary-dark);
    font-size: 1.1em;
}

/* Falling Notes 모드에서는 흰색 */
body.falling-mode #game-info div {
    color: white;
}

/* 게임 컨트롤 버튼 */
.game-controls {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 100;
}

#pause-btn,
#back-btn {
    background: rgba(255,255,255,0.9);
    color: var(--mint-primary-dark);
    border: 2px solid var(--mint-primary-dark);
    padding: 10px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

#pause-btn:hover,
#back-btn:hover {
    background: var(--mint-primary-dark);
    color: white;
}

#pause-btn.paused {
    background: #ff4757;
    border-color: #ff4757;
    color: white;
}

#pause-btn.paused:hover {
    background: #ff6b81;
    border-color: #ff6b81;
}

/* 반응형 */
@media (max-width: 768px) {
    #menu-screen h1 {
        font-size: 2em;
    }
    
    .button-group {
        gap: 5px;
    }
    
    button {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    
    .white-key {
        width: 35px;
        height: 150px;
    }
    
    .black-key {
        width: 22px;
        height: 90px;
        margin-left: -11px;
    }
    
    #judgment-display {
        font-size: 2em;
    }
}

/* ==================== 인증 UI ==================== */

.auth-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
}

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 15px;
}

.auth-message {
    color: #666;
    font-size: 1em;
    margin: 0;
}

.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: #333;
    border: 2px solid #ddd;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.auth-btn:hover {
    background: #f8f9fa;
    border-color: #4285F4;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 로그인 후 UI */
#auth-logged-in {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--mint-primary);
}

.user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-name {
    font-weight: 600;
    color: #333;
    font-size: 1em;
}

.user-tier {
    font-size: 0.85em;
    color: #888;
    font-weight: 500;
}

.auth-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.premium-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.3);
    transition: all 0.3s ease;
}

.premium-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}

.small-btn {
    padding: 8px 16px;
    font-size: 0.9em;
}

/* Premium 잠금 표시 */
.locked {
    position: relative;
    opacity: 0.5;
    pointer-events: none;
}

.locked::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5em;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* 반응형 - 인증 UI */
@media (max-width: 768px) {
    #auth-logged-in {
        flex-direction: column;
        gap: 15px;
    }
    
    .auth-actions {
        width: 100%;
        justify-content: center;
    }
    
    .user-info {
        width: 100%;
        justify-content: center;
    }
}

/* 체크박스 스타일 */
.checkbox-group {
    display: flex;
    gap: 15px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 1em;
    color: #333;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--mint-primary);
}

/* ==================== Floating Notes Background Animation ==================== */
.floating-notes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* 게임 화면에서는 숨김 */
#game-screen.active ~ .floating-notes,
body.game-active .floating-notes {
    opacity: 0;
}

.floating-note {
    position: absolute;
    pointer-events: none;
    user-select: none;
    font-weight: bold;
}

@keyframes float-note {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    80% {
        transform: translateY(-85vh) rotate(450deg);
        opacity: 0.3;
    }
    100% {
        transform: translateY(-85vh) rotate(450deg);
        opacity: 0;
    }
}

/* ==================== Footer ==================== */
#app-footer {
    display: block;
    text-align: center;
    padding: 30px 20px;
    color: #666;
    background: transparent;
    margin-top: -20px;
    margin-bottom: 0px;
    position: relative;
    z-index: 100;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    border-top: none;
}

/* 게임 화면에서 footer 숨김 */
#game-screen.active ~ #app-footer,
body.game-active #app-footer {
    display: none;
}

.footer-content {
    max-width: 900px;
    margin: 0 auto;
}

.footer-content p {
    margin-bottom: 15px;
}

.footer-content p:last-child {
    margin-bottom: 0;
}

.footer-content a {
    color: #999;
    text-decoration: none;
    margin: 0 15px;
    font-weight: 400;
}

.footer-content a:hover {
    text-decoration: underline;
}

.footer-content span {
    color: #ccc;
}

.footer-content .copyright {
    font-size: 0.9em;
    color: #999;
}

/* ==================== Falling Notes 2 ==================== */
#falling-notes2-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 200px;
    overflow: hidden;
}

#falling-notes2-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: black;
    overflow-y: hidden;
}

#falling-canvas2 {
    width: 100%;
    height: 100%;
    display: block;
}

#falling-judgment-line2 {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 100, 100, 0.8);
    z-index: 10;
    pointer-events: none;
}