:root {
    --primary-color: #2c3e50;
    --accent-blue: #3498db;
    --accent-red: #e74c3c;
    --accent-green: #27ae60;
    --bg-light: #f4f7f6;
    --white: #ffffff;
    --correct: #27ae60;
    --wrong: #c0392b;
    --yellow-light: #fff5e6;
    --yellow-bg: #fef3c7;
    --border-gray: #ddd;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-light);
    color: var(--primary-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: var(--primary-color);
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1.1em;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

h2 {
    border-bottom: 2px solid var(--bg-light);
    padding-bottom: 10px;
    margin-top: 0;
}

/* Section Titles */
.section-title {
    color: var(--primary-color);
    font-size: 1.8em;
    margin-top: 20px;
    margin-bottom: 15px;
    border-bottom: 3px solid var(--accent-blue);
    padding-bottom: 10px;
}

/* Text Utilities */
.text-base-lg {
    font-size: 1.1em;
    line-height: 1.8;
}

.text-xl {
    font-size: 1.25em;
}

.text-sm {
    font-size: 0.875em;
}

.text-error-strong {
    color: var(--accent-red);
    font-weight: bold;
}

.text-green-700 {
    color: #15803d;
}

.text-gray-700 {
    color: #374151;
}

/* Margin and Padding Utilities */
.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.mt-8 {
    margin-top: 2rem;
}

.p-3 {
    padding: 0.75rem;
}

/* Font Utilities */
.font-mono {
    font-family: 'Courier New', monospace;
}

.font-bold {
    font-weight: bold;
}

.fw-bold {
    font-weight: bold;
}

/* Background Utilities */
.bg-yellow-100 {
    background-color: var(--yellow-bg);
}

/* Border Utilities */
.rounded-lg {
    border-radius: 0.5rem;
}

/* Text Decoration */
.underline {
    text-decoration: underline;
}

/* Lists */
.list-disc {
    list-style-type: disc;
    padding-left: 2rem;
}

.list-decimal {
    list-style-type: decimal;
    padding-left: 2rem;
}

.list-spaced li {
    margin-bottom: 0.75rem;
}

.list-nested {
    margin-top: 0.5rem;
    margin-left: 1rem;
}

/* Grammar Highlights */
.subject {
    color: var(--accent-blue);
    font-weight: bold;
}

.verb {
    color: var(--accent-red);
    font-weight: bold;
}

.text-highlight {
    background-color: #fef3c7;
    color: var(--accent-red);
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
}

.text-highlight-past {
    background-color: #e0f2fe;
    color: #0369a1;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Callout Boxes */
.callout-important {
    background: #fee2e2;
    border-left: 5px solid var(--accent-red);
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: 5px;
}

.callout-deep-dive {
    background: #f0f9ff;
    border: 2px solid var(--accent-blue);
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
}

.deep-dive-title {
    color: var(--accent-blue);
    font-size: 1.5em;
    margin-top: 0;
    margin-bottom: 10px;
}

.deep-dive-subtitle {
    color: #0369a1;
    font-size: 1.2em;
    margin-top: 15px;
    margin-bottom: 10px;
}

/* Formula Box */
.formula-box {
    background: #eef2f3;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.2em;
    margin: 15px 0;
}

.warning-box {
    background: var(--yellow-light);
    border-left: 5px solid #ffa502;
    padding: 15px;
    margin-top: 15px;
    font-size: 0.95em;
}

/* Example Boxes */
.example-box {
    background: #f0fdf4;
    border-left: 4px solid var(--accent-green);
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: 5px;
}

.example-box p {
    margin: 8px 0;
    font-size: 1.05em;
}

.example-box-past {
    background: #f0f9ff;
    border-left: 4px solid #0369a1;
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: 5px;
}

.example-box-past p {
    margin: 8px 0;
    font-size: 1.05em;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin: 20px 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.table-header {
    background-color: var(--accent-blue);
    color: white;
}

.table-body tr:nth-child(even) {
    background-color: #f8f9fa;
}

.table-cell {
    border: 1px solid var(--border-gray);
    padding: 12px;
    text-align: left;
}

.grammar-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.grammar-table th, .grammar-table td {
    border: 1px solid var(--border-gray);
    padding: 12px;
    text-align: left;
}

.grammar-table th {
    background-color: #f8f9fa;
}

/* Collapsible Details */
details {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    cursor: pointer;
}

summary {
    font-weight: bold;
    outline: none;
    padding: 10px;
}

summary:hover {
    background: #f0f0f0;
}

.details-content {
    padding: 15px 0 0 15px;
    border-top: 1px solid #eee;
    margin-top: 10px;
}

.example-list {
    list-style: none;
    padding: 0;
}

.example-list li {
    background: #f8f9fa;
    border-left: 4px solid var(--accent-blue);
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 0 5px 5px 0;
}

.example-list small {
    color: #6c757d;
    font-size: 0.9em;
}

/* Quiz Section */
.quiz-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.quiz-section h2 {
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

/* Quiz UI */
.audio-player-ui {
    background: #2d3436;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.control-btn {
    background: #636e72;
    color: white;
    border: none;
    padding: 8px 15px;
    margin: 0 5px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Noto Sans JP', sans-serif;
}

.control-btn:hover {
    background: #b2bec3;
}

.progress {
    text-align: center;
    font-size: 1.1em;
    margin-bottom: 15px;
    font-weight: bold;
}

.question-box {
    font-size: 1.3em;
    text-align: center;
    margin: 20px 0;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 8px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.option-btn {
    padding: 15px;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--border-gray);
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Noto Sans JP', sans-serif;
}

.option-btn:hover {
    background: #f0f0f0;
    border-color: #bbb;
    transform: translateY(-2px);
}

.option-btn.correct {
    background: var(--correct);
    color: white;
    border-color: var(--correct);
}

.option-btn.wrong {
    background: var(--wrong);
    color: white;
    border-color: var(--wrong);
}

.hidden {
    display: none;
}

#feedback {
    margin-top: 20px;
    text-align: center;
    font-weight: bold;
    padding: 15px;
    border-radius: 5px;
}

#feedback.success {
    background: #d4edda;
    color: #155724;
}

#feedback.error {
    background: #f8d7da;
    color: #721c24;
}

#next-btn, .restart-btn {
    display: block;
    width: 100%;
    padding: 15px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    margin-top: 20px;
    font-family: 'Noto Sans JP', sans-serif;
}

/* Timeline Slider */
#seek-bar {
    width: 100%;
    margin-bottom: 15px;
    cursor: pointer;
    accent-color: var(--accent-blue); /* Modern browser support for slider color */
}

/* Loading Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* When the button has the .loading class */
.control-btn.loading {
    position: relative;
    color: transparent; /* Hide text while loading */
    pointer-events: none; /* Prevent clicking while loading */
}

.control-btn.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#next-btn:hover, .restart-btn:hover {
    background: #2980b9;
}

#score-screen {
    text-align: center;
    padding: 20px;
}

#score-screen h3 {
    font-size: 2em;
    margin-bottom: 20px;
}

#final-score {
    font-size: 2.5em;
    color: var(--accent-green);
    font-weight: bold;
}
/* Update the quiz container to be a reference point for absolute positioning */
#quiz-container {
    position: relative; /* CRITICAL for splash screen containment */
    min-height: 400px; /* Ensure there is space for the splash screen */
    padding-top: 20px;
}

/* Splash Screen Styles */
#quiz-splash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10; /* Ensure it is on top of other content */
    background: rgba(255, 255, 255, 0.95); /* Light background */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-radius: 12px;
    padding: 20px;
    font-size: 1.2em;
    font-weight: bold;
}

.start-btn {
    padding: 15px 30px;
    background: #2ecc71; /* Green color for start */
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s;
}

.start-btn:hover {
    background: #27ae60;
}


/* Strong/Bold emphasis replacement for ** */
strong {
    font-weight: bold;
    color: var(--primary-color);
}

em {
    font-style: italic;
    color: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .container {
        max-width: 100%;
    }
    
    h1 {
        font-size: 1.8em;
        margin-bottom: 5px;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .section-title {
        font-size: 1.3em;
        padding-bottom: 5px;
    }
    
    .card {
        padding: 10px;
        margin-bottom: 10px;
        border-radius: 8px;
    }
    
    .callout-important,
    .callout-deep-dive,
    .example-box,
    .example-box-past,
    .warning-box {
        padding: 10px;
        margin: 10px 0;
        border-left-width: 3px;
    }
    
    .deep-dive-title {
        font-size: 1.2em;
    }
    
    .deep-dive-subtitle {
        font-size: 1em;
    }
    
    .table-cell {
        padding: 8px;
        font-size: 0.9em;
    }
    
    .example-box p,
    .example-box-past p {
        font-size: 0.95em;
        margin: 5px 0;
    }
    
    .text-base-lg {
        font-size: 1em;
    }
    
    .question-box {
        font-size: 1.1em;
        padding: 15px 10px;
    }
    
    .audio-player-ui {
        padding: 10px;
    }
    
    .control-btn {
        padding: 6px 10px;
        font-size: 0.9em;
        margin: 2px;
    }
    
    .option-btn {
        padding: 12px;
        font-size: 0.95em;
    }
    
    .options-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    details {
        padding: 8px;
    }
    
    summary {
        padding: 8px;
        font-size: 0.95em;
    }
    
    .details-content {
        padding: 10px 0 0 10px;
    }
    
    .example-list li {
        padding: 8px 12px;
    }
    
    ul.list-disc,
    ol.list-decimal {
        padding-left: 1.2rem;
    }
}