* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Back Button */
.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    z-index: 100;
    text-decoration: none;
    color: #333;
}

.back-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background-color: #f8f9fa;
}

.back-button:active {
    transform: scale(0.95);
}

.back-button svg {
    width: 28px;
    height: 28px;
    transition: color 0.2s;
}

.back-button:hover svg {
    color: #4ECDC4;
}

/* Mode Indicator */
.mode-indicator {
    position: fixed;
    top: 20px;
    left: 90px;
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: white;
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 100;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.mode-indicator svg {
    width: 24px;
    height: 24px;
    color: #4ECDC4;
}

.mode-indicator span {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.mode-indicator.competition {
    background-color: #FF6B6B;
}

.mode-indicator.competition svg {
    color: white;
}

.mode-indicator.competition span {
    color: white;
}

/* Competition Button */
.competition-button {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 30px;
    background-color: #4ECDC4;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

.competition-button:hover {
    background-color: #45B7D1;
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.competition-button:active {
    transform: translateX(-50%) scale(0.95);
}

.competition-button.stop {
    background-color: #FF6B6B;
}

.competition-button.stop:hover {
    background-color: #E55A5A;
}

/* Settings Button */
.settings-button {
    position: fixed;
    top: 20px;
    right: 80px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    z-index: 100;
    color: #333;
    font-size: 24px;
}

.settings-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background-color: #f8f9fa;
}

.settings-button:active {
    transform: scale(0.95);
}

/* Help Button */
.help-button {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    z-index: 100;
    color: #333;
    font-size: 24px;
}

.help-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background-color: #f8f9fa;
}

.help-button:active {
    transform: scale(0.95);
}

/* Popup Overlay */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.popup-overlay.active {
    display: flex;
}

/* Popup Content */
.popup-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Popup Header */
.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa;
}

.popup-header h2 {
    font-size: 24px;
    color: #333;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.close-btn:hover {
    background-color: #e0e0e0;
    color: #333;
}

/* Popup Body */
.popup-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.setting-item {
    margin-bottom: 20px;
    width: 700px;
}

.setting-item label {
    display: flex;
    align-items: center;
    font-size: 16px;
    color: #333;
    cursor: pointer;
    margin-bottom: 10px;
}

/* Toggle Selector */
.toggle-selector {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.toggle-button {
    padding: 10px 30px;
    border: 3px solid #4ECDC4;
    background-color: white;
    color: #4ECDC4;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.toggle-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

.toggle-button:active {
    transform: scale(0.95);
}

.toggle-button.selected {
    background-color: #4ECDC4;
    color: white;
    border-color: #4ECDC4;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

.setting-item h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 10px;
}

.intervals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.interval-tile {
    padding: 12px 20px;
    border: 3px solid #4ECDC4;
    background-color: white;
    color: #4ECDC4;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    text-align: center;
}

.interval-tile:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

.interval-tile:active {
    transform: scale(0.95);
}

.interval-tile.selected {
    background-color: #4ECDC4;
    color: white;
    border-color: #4ECDC4;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

.setting-item input[type="number"] {
    width: 100px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    margin-left: 10px;
}

/* Number Selector */
.number-selector {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.number-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 4px solid #4ECDC4;
    background-color: white;
    color: #4ECDC4;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.number-circle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

.number-circle.selected {
    background-color: #4ECDC4;
    color: white;
    border-color: #4ECDC4;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

.number-circle:active {
    transform: scale(0.95);
}

.save-btn {
    width: 100%;
    padding: 12px;
    background-color: #4ECDC4;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.save-btn:hover {
    background-color: #45B7D1;
}

.save-btn:active {
    transform: scale(0.98);
}

/* Main Container */
.main-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 80px 20px 20px;
}

/* Piano Section */
.piano-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

/* Notation Display */
.notation-display {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 74/50;
    background-image: url('images/open_book.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    margin-bottom: 20px;
    position: relative;
}

/* KOTTA containers */
.kotta {
    position: absolute;
    width: 110px;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.kotta.visible {
    opacity: 1;
}

.kotta-left {
    left: 50px;
    top: 25px;
}

.kotta-right {
    left: 240px;
    top: 25px;
}

.empty-score {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
}

.note-image-container {
    position: absolute;
    width: 110px;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

.note-image-container img {
    max-width: 110px;
    max-height: 150px;
    object-fit: contain;
}

/* Note Name Display (shown outside task on right side) */
.note-name-display {
    position: absolute;
    left: 220px;
    top: 90px;
    transform: translateY(-50%);
    font-size: 48px;
    font-weight: bold;
    color: #333;
    opacity: 0;
    width: 140px;
    text-align: center;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}

.note-name-display.visible {
    opacity: 1;
}

/* Piano Keyboard */
.piano-keyboard {
    display: flex;
    position: relative;
    width: 100%;
    max-width: 1200px;
    height: 200px;
    background-color: #333;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.piano-key {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.1s;
}

.piano-key:hover {
    transform: translateY(2px);
}

.piano-key:active {
    transform: translateY(4px);
}

.white-key {
    flex: 1;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 0 0 4px 4px;
    height: 100%;
    margin: 0 1px;
}

.black-key {
    position: absolute;
    width: 30px;
    height: 60%;
    background-color: #333;
    border-radius: 0 0 4px 4px;
    z-index: 10;
    top: 0;
}


/* Result Section */
.result-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
}

/* Competition Mode */
.competition-mode {
    display: none;
    width: 100%;
    max-width: 800px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.competition-mode.active {
    display: flex;
}

.team {
    display: flex;
    align-items: center;
    gap: 20px;
}

.team-button {
    width: 80px;
    height: 80px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.team-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.team-button:active {
    transform: scale(0.95);
}

.team-button svg {
    width: 40px;
    height: 40px;
}

.red-button {
    background-color: #FF6B6B;
    color: white;
}

.blue-button {
    background-color: #45B7D1;
    color: white;
}

.team-score {
    font-size: 48px;
    font-weight: bold;
    color: #333;
    min-width: 60px;
    text-align: center;
}

@keyframes flashWinner {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.5;
    }
}

/* Start Button */
.start-button {
    padding: 15px 40px;
    background-color: #4ECDC4;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

.start-button:hover {
    background-color: #45B7D1;
    transform: scale(1.05);
}

.start-button:active {
    transform: scale(0.95);
}

.start-button.hidden {
    display: none;
}

/* Answer Display */
.answer-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffffc0;
    padding: 30px 50px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    font-size: 32px;
    font-weight: bold;
    color: #333;
    z-index: 500;
    display: none;
    text-align: center;
}

.answer-display.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Countdown Timer */
.countdown-timer {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 600;
}

.countdown-timer.active {
    display: flex;
}

.timer-svg {
    width: 150px;
    height: 150px;
}

.timer-circle-bg {
    fill: none;
    stroke: #f0f0f0;
    stroke-width: 8;
}

.timer-circle-progress {
    fill: none;
    stroke: #4ECDC4;
    stroke-width: 8;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.1s linear;
}

.timer-text {
    position: absolute;
    font-size: 48px;
    font-weight: bold;
    color: #333;
}

/* Question Mark Button (Practice Mode) */
.question-mark-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 80px;
    height: 80px;
    border: 3px solid #4ECDC4;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 48px;
    font-weight: bold;
    color: #4ECDC4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: blink 1s ease-in-out infinite;
    z-index: 600;
}

.question-mark-button.active {
    display: flex;
}

.question-mark-button:hover {
    background-color: #4ECDC4;
    color: white;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Teacher Approval Buttons (Competition Mode) */
.teacher-approval-buttons {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: none;
    gap: 15px;
    z-index: 600;
}

.teacher-approval-buttons.active {
    display: flex;
}

.approval-button {
    width: 80px;
    height: 80px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.approval-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.approval-button:active {
    transform: scale(0.95);
}

.approval-button svg {
    width: 48px;
    height: 48px;
}

.check-button {
    background-color: #4CAF50;
    color: white;
}

.check-button:hover {
    background-color: #45a049;
}

.x-button {
    background-color: #f44336;
    color: white;
}

.x-button:hover {
    background-color: #da190b;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-container {
        padding: 70px 10px 10px;
    }
    
    .piano-keyboard {
        height: 150px;
    }
    
    .black-key {
        width: 20px;
    }
    
    .notation-display {
        max-width: 100%;
        padding: 15px;
    }
    
    .kotta {
        width: 60px;
        height: 80px;
    }
    
    .kotta-left {
        left: 20%;
    }
    
    .kotta-right {
        right: 20%;
    }
    
    .note-name-display {
        font-size: 36px;
        right: 20%;
    }
    
    .team-button {
        width: 60px;
        height: 60px;
    }
    
    .team-button svg {
        width: 30px;
        height: 30px;
    }
    
    .team-score {
        font-size: 36px;
        min-width: 45px;
    }
    
    .start-button {
        padding: 12px 30px;
        font-size: 18px;
    }
    
    .answer-display {
        padding: 20px 30px;
        font-size: 24px;
    }
    
    .intervals-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .teacher-approval-buttons {
        bottom: 20px;
        right: 20px;
        gap: 10px;
    }
    
    .approval-button {
        width: 60px;
        height: 60px;
    }
    
    .approval-button svg {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .piano-keyboard {
        height: 120px;
    }
    
    .black-key {
        width: 15px;
    }
    
    .notation-display {
        padding: 10px;
    }
    
    .kotta {
        width: 50px;
        height: 60px;
    }
    
    .kotta-left {
        left: 15%;
    }
    
    .kotta-right {
        right: 15%;
    }
    
    .note-name-display {
        font-size: 28px;
        right: 15%;
    }
    
    .team-button {
        width: 50px;
        height: 50px;
    }
    
    .team-button svg {
        width: 25px;
        height: 25px;
    }
    
    .team-score {
        font-size: 28px;
        min-width: 35px;
    }
    
    .start-button {
        padding: 10px 25px;
        font-size: 16px;
    }
    
    .answer-display {
        padding: 15px 25px;
        font-size: 20px;
    }
    
    .intervals-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .teacher-approval-buttons {
        bottom: 15px;
        right: 15px;
        gap: 8px;
    }
    
    .approval-button {
        width: 50px;
        height: 50px;
    }
    
    .approval-button svg {
        width: 30px;
        height: 30px;
    }
}

/* Help Popup */
.help-popup {
    z-index: 1100;
}

.help-content {
    max-width: 600px;
}

.help-body {
    max-height: 60vh;
    overflow-y: auto;
}

.help-body h3 {
    color: #4ECDC4;
    margin-bottom: 10px;
    margin-top: 20px;
}

.help-body h3:first-child {
    margin-top: 0;
}

.help-body p {
    line-height: 1.6;
    margin-bottom: 15px;
    color: #555;
}

