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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ECE9E6;  /* fallback for old browsers */
    background: -webkit-linear-gradient(to top, #FFFFFF, #ECE9E6);  /* Chrome 10-25, Safari 5.1-6 */
    background: linear-gradient(to top, #FFFFFF, #ECE9E6); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* School header */
.school-header {
    text-align: center;
    margin-bottom: 20px;
}

.school-logo {
    max-width: 400px;
    width: 100%;
    height: auto;
    margin: 0 auto;
    display: block;
}

.school-subtitle {
    color: #666;
    font-size: 0.95em;
    margin-top: 10px;
}

/* Main title box with music graphic */
.main-title-box {
    background: #f5f3ed;
    border-radius: 15px;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
    cursor: pointer;
}

.main-title-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.title-content {
    flex: 1;
}

.main-title-box h1 {
    color: #64247e;
    margin-bottom: 10px;
    font-size: 2.2em;
    text-align: left;
}

.main-title-box .subtitle {
    color: #666;
    font-size: 1em;
    text-align: left;
    margin-bottom: 0;
}

.music-graphic {
    width: 120px;
    height: auto;
    flex-shrink: 0;
}

/* Start quiz button */
.start-quiz-button {
    display: block;
    background: #64247e;
    color: white;
    text-decoration: none;
    border-radius: 12px;
    padding: 20px 30px;
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.start-quiz-button:hover {
    background: #4a1a5e;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

h1 {
    color: #64247e;
    text-align: center;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.back-button {
    display: inline-block;
    color: #64247e;
    text-decoration: none;
    margin-bottom: 20px;
    font-size: 1.1em;
    padding: 10px 15px;
    background: rgba(100, 36, 126, 0.1);
    border-radius: 8px;
    transition: background 0.3s;
}

.back-button:hover {
    background: rgba(100, 36, 126, 0.2);
}

/* Home page mode selection */
.mode-selection {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.mode-button {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s, box-shadow 0.3s;
    text-align: center;
}

.mode-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.mode-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.mode-button h2 {
    color: #64247e;
    margin-bottom: 10px;
}

.mode-button p {
    color: #666;
    font-size: 0.95em;
}

/* Listening mode */
.songs-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.song-item {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.song-number {
    background: #64247e;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
    flex-shrink: 0;
}

.song-info {
    flex: 1;
}

.song-period {
    color: #64247e;
    font-weight: bold;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.song-name {
    color: #333;
    font-size: 1em;
}

audio {
    width: 100%;
    height: 40px;
}

/* Quiz setup */
.quiz-setup {
    background: white;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.quiz-setup p {
    font-size: 1.3em;
    margin-bottom: 20px;
    color: #333;
}

.number-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.number-buttons button {
    background: #64247e;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 20px 40px;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 80px;
}

.number-buttons button:hover {
    background: #4a1a5e;
    transform: scale(1.1);
}

/* Quiz area */
.quiz-area {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.progress {
    text-align: center;
    font-size: 1.2em;
    color: #64247e;
    font-weight: bold;
    margin-bottom: 10px;
}

.score {
    text-align: center;
    font-size: 1em;
    color: #666;
    margin-bottom: 20px;
}

.audio-player {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.audio-player audio {
    width: 100%;
}

/* ABCD Options */
.options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.option-button {
    background: white;
    border: 3px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1em;
    text-align: left;
}

.option-button:hover:not(:disabled) {
    border-color: #64247e;
    background: #f3f0f7;
    transform: translateX(5px);
}

.option-button:disabled {
    cursor: not-allowed;
}

.option-label {
    background: #64247e;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.3em;
    flex-shrink: 0;
}

.option-text {
    flex: 1;
}

.option-period {
    color: #64247e;
    font-weight: bold;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.option-name {
    color: #333;
    font-size: 0.95em;
}

.option-button.correct {
    border-color: #4caf50;
    background: #e8f5e9;
}

.option-button.correct .option-label {
    background: #4caf50;
}

.option-button.incorrect {
    border-color: #f44336;
    background: #ffebee;
}

.option-button.incorrect .option-label {
    background: #f44336;
}

/* Full list options */
.search-box {
    margin: 20px 0;
}

.search-box input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #64247e;
}

.options-full {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
    padding-right: 10px;
}

.options-full::-webkit-scrollbar {
    width: 8px;
}

.options-full::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.options-full::-webkit-scrollbar-thumb {
    background: #64247e;
    border-radius: 10px;
}

.option-button-full {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.95em;
    text-align: left;
}

.option-button-full:hover:not(:disabled) {
    border-color: #64247e;
    background: #f3f0f7;
}

.option-button-full:disabled {
    cursor: not-allowed;
}

.option-number {
    background: #64247e;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.option-button-full.correct {
    border-color: #4caf50;
    background: #e8f5e9;
}

.option-button-full.correct .option-number {
    background: #4caf50;
}

.option-button-full.incorrect {
    border-color: #f44336;
    background: #ffebee;
}

.option-button-full.incorrect .option-number {
    background: #f44336;
}

/* Feedback */
.feedback {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    text-align: center;
}

.feedback-correct {
    color: #4caf50;
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 10px;
}

.feedback-incorrect {
    color: #f44336;
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 10px;
}

.feedback-correct-answer {
    color: #333;
    font-size: 1.1em;
    margin: 15px 0;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #4caf50;
}

.next-button {
    background: #64247e;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 15px 40px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    transition: background 0.3s;
}

.next-button:hover {
    background: #4a1a5e;
}

/* Results */
.results {
    background: white;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.results h2 {
    color: #64247e;
    margin-bottom: 30px;
    font-size: 2em;
}

.final-score {
    margin: 30px 0;
}

.score-item {
    font-size: 1.3em;
    margin: 15px 0;
    padding: 15px;
    border-radius: 10px;
}

.score-item.correct {
    background: #e8f5e9;
    color: #4caf50;
    font-weight: bold;
}

.score-item.incorrect {
    background: #ffebee;
    color: #f44336;
    font-weight: bold;
}

.score-percentage {
    font-size: 2em;
    font-weight: bold;
    color: #64247e;
    margin: 25px 0;
    padding: 25px;
    background: #f3f0f7;
    border-radius: 15px;
}

.restart-button,
.home-button {
    display: inline-block;
    background: #64247e;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 15px 40px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    margin: 10px;
    text-decoration: none;
    transition: background 0.3s;
}

.restart-button:hover,
.home-button:hover {
    background: #4a1a5e;
}

/* AB Quiz - larger buttons for only 2 options */
.option-button-ab {
    padding: 30px;
    margin: 10px 0;
}

.option-button-ab .option-label {
    width: 60px;
    height: 60px;
    font-size: 1.8em;
}

.option-button-ab .option-text {
    font-size: 1.1em;
}

.option-button-ab .option-period {
    font-size: 1em;
}

.option-button-ab .option-name {
    font-size: 1.05em;
}

/* Period cards */
.period-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.period-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    text-align: center;
}

.period-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.period-card-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.period-card h3 {
    color: #64247e;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.period-card-count {
    color: #999;
    font-size: 0.9em;
}

/* Period practice page */
.practice-modes {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.practice-mode-btn {
    flex: 1;
    min-width: 150px;
    background: white;
    border: 2px solid #64247e;
    border-radius: 10px;
    padding: 15px 25px;
    font-size: 1em;
    font-weight: bold;
    color: #64247e;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
}

.practice-mode-btn:hover {
    background: #64247e;
    color: white;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .school-logo {
        max-width: 280px;
    }

    .main-title-box {
        flex-direction: column-reverse;
        padding: 25px;
        text-align: center;
    }

    .main-title-box h1 {
        font-size: 1.8em;
        text-align: center;
    }

    .main-title-box .subtitle {
        text-align: center;
        font-size: 0.95em;
    }

    .music-graphic {
        width: 100px;
        margin-bottom: 15px;
    }

    h1 {
        font-size: 2em;
    }

    .mode-button {
        padding: 25px;
    }

    .mode-icon {
        font-size: 2.5em;
    }

    .quiz-area,
    .quiz-setup,
    .results {
        padding: 20px;
    }

    .option-button {
        padding: 15px;
    }

    .option-label {
        width: 40px;
        height: 40px;
        font-size: 1.1em;
    }

    .option-button-ab {
        padding: 20px;
    }

    .option-button-ab .option-label {
        width: 50px;
        height: 50px;
        font-size: 1.5em;
    }

    .number-buttons button {
        padding: 15px 30px;
        font-size: 1.3em;
    }

    .period-grid {
        grid-template-columns: 1fr;
    }

    .practice-modes {
        flex-direction: column;
    }

    .practice-mode-btn {
        min-width: 100%;
    }
}
