/* --- Reset & Base --- */
:root {
    --primary-color: #4f46e5; /* Indigo */
    --primary-light: #6366f1;
    --primary-dark: #4338ca;
    --secondary-color: #f3f4f6; /* Light Gray */
    --background-color: #ffffff;
    --card-background: #ffffff;
    --text-color: #1f2937; /* Dark Gray */
    --text-light: #6b7280; /* Medium Gray */
    --text-lighter: #9ca3af; /* Light Gray */
    --border-color: #e5e7eb;
    --success-color: #10b981; /* Emerald */
    --warning-color: #f59e0b; /* Amber */
    --danger-color: #ef4444; /* Red */
    --info-color: #3b82f6; /* Blue */
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --border-radius: 8px;
    --spacing-unit: 1rem; /* 16px */
    --font-family: 'Inter', sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 100%; /* 16px */
}

body {
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: var(--secondary-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 1200px; /* Increased max-width */
    margin: 0 auto;
    padding: calc(var(--spacing-unit) * 1.5); /* 24px */
    flex-grow: 1; /* Allows footer to stick to bottom */
}

main {
    display: grid;
    gap: calc(var(--spacing-unit) * 1.5);
}

img, video {
    max-width: 100%;
    height: auto;
    display: block;
}

/* --- Header & Footer --- */
header {
    text-align: center;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

header h1 {
    font-size: 2.25rem; /* 36px */
    font-weight: 700;
    color: var(--primary-dark);
}

footer {
    text-align: center;
    margin-top: calc(var(--spacing-unit) * 3);
    padding-top: var(--spacing-unit);
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem; /* 14px */
    color: var(--text-light);
}
.footer-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}
.footer-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}


/* --- Cards --- */
.card {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: calc(var(--spacing-unit) * 1.5); /* 24px */
    border: 1px solid var(--border-color);
    overflow: hidden; /* Contain elements */
}

/* Section Title for Details Summary */
.section-title {
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
    color: var(--primary-dark);
    cursor: pointer;
    padding: calc(var(--spacing-unit) * 0.5) 0;
    list-style: none; /* Remove default marker */
    transition: color 0.2s ease;
}
.section-title:hover {
    color: var(--primary-color);
}
.section-title i {
    margin-right: calc(var(--spacing-unit) * 0.5);
    color: var(--primary-light);
}
details > summary {
    list-style: none;
}
details > summary::-webkit-details-marker {
    display: none;
}
details[open] > summary {
    margin-bottom: var(--spacing-unit);
}


/* --- File Upload --- */
#fileUploadSection {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-unit);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    padding-bottom: calc(var(--spacing-unit) * 1.5);
    border-bottom: 1px dashed var(--border-color);
    justify-content: center; /* Center buttons */
}

input[type="file"] {
    display: none; /* Hide default input */
}

.fileLabel {
    display: inline-flex; /* Use flex for icon alignment */
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5); /* Space between icon and text */
    background-color: var(--primary-color);
    color: white;
    padding: calc(var(--spacing-unit) * 0.6) calc(var(--spacing-unit) * 1.2); /* 10px 18px */
    border-radius: calc(var(--border-radius) / 2); /* Slightly smaller radius */
    font-size: 0.9rem; /* 14.4px */
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
    white-space: nowrap; /* Prevent wrapping */
}

.fileLabel:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.fileLabel:active {
    transform: translateY(0);
}

.fileLabel i {
    font-size: 1rem; /* Adjust icon size */
}

/* --- Video Player --- */
#videoSection video {
    width: 100%;
    border-radius: var(--border-radius);
    background-color: #000; /* Black background for video area */
    margin-bottom: calc(var(--spacing-unit) * 0.5);
}

#currentTime {
    text-align: right;
    font-size: 0.875rem; /* 14px */
    color: var(--text-light);
    padding-right: var(--spacing-unit);
}

/* --- Subtitle Section --- */
#subtitle-control-section {
    position: sticky; /* Make subtitle controls sticky */
    top: var(--spacing-unit); /* Add some space from the top */
    z-index: 10; /* Ensure it's above other content when scrolling */
    background-color: rgba(255, 255, 255, 0.95); /* Slightly transparent background */
    backdrop-filter: blur(5px); /* Optional: Blur effect */
}

#subtitleWrapper {
    min-height: 100px; /* Ensure some space even when empty */
    margin-bottom: var(--spacing-unit);
    padding: var(--spacing-unit);
    background-color: var(--secondary-color); /* Subtle background */
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column; /* Stack elements vertically */
    gap: calc(var(--spacing-unit) * 0.5);
    border: 1px solid var(--border-color);
}

#secondarySubtitleArea {
    font-size: 1.1rem; /* 17.6px */
    color: var(--text-light);
    text-align: center;
    order: 1; /* Show secondary sub first (e.g., translation) */
    padding: calc(var(--spacing-unit) * 0.25) 0;
    min-height: 1.5em; /* Reserve space */
}

#subtitleArea {
    font-size: 1.5rem; /* 24px */
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    padding: calc(var(--spacing-unit) * 0.5) 0;
    min-height: 1.5em; /* Reserve space */
    order: 2; /* Show primary sub second (target language) */
    /* Animation (optional) */
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

#userInput {
    width: 100%;
    padding: calc(var(--spacing-unit) * 0.75); /* 12px */
    font-size: 1.1rem; /* Match secondary subtitle */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
    color: var(--text-color);
    text-align: center;
    transition: border-color 0.2s ease;
    order: 3; /* Show input last */
    display: none; /* Hidden by default, JS toggles */
    margin-top: calc(var(--spacing-unit) * 0.5);
}

#userInput:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); /* Focus ring */
}

.subtitle-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: calc(var(--spacing-unit) * 0.75);
    margin-top: var(--spacing-unit);
}

/* --- Buttons --- */
button {
    display: inline-flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.4);
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 1); /* 8px 16px */
    border-radius: calc(var(--border-radius) / 1.5);
    cursor: pointer;
    font-size: 0.875rem; /* 14px */
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    white-space: nowrap;
}

button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:active {
    transform: translateY(0);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

button:disabled {
    background-color: var(--text-lighter);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Specific button styles */
button#minimizeButton { background-color: var(--info-color); }
button#minimizeButton:hover { background-color: #2563eb; }

button#toggleSubtitleButton,
button#toggleSecondarySubtitleButton,
button#hideSubtitleButton {
    background-color: var(--text-light);
}
button#toggleSubtitleButton:hover,
button#toggleSecondarySubtitleButton:hover,
button#hideSubtitleButton:hover {
    background-color: var(--text-color);
}

.icon-button { /* For buttons with only icons like play, repeat, save in table */
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.1rem;
    padding: calc(var(--spacing-unit) * 0.25);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.1s ease;
    box-shadow: none;
}
.icon-button:hover {
    color: var(--primary-dark);
    transform: scale(1.1);
    background: none; /* Override general button hover */
}
.icon-button:active {
    transform: scale(1);
    box-shadow: none;
}

/* --- Tables --- */
.table-wrapper { /* Added wrapper for potential horizontal scroll on small screens */
    overflow-x: auto;
    margin-top: var(--spacing-unit);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem; /* 14.4px */
    color: var(--text-color);
}

th, td {
    padding: calc(var(--spacing-unit) * 0.75); /* 12px */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

th {
    background-color: var(--secondary-color);
    font-weight: 600;
    color: var(--text-color); /* Darker text for headers */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem; /* 12px */
}

tbody tr:nth-child(even) {
    background-color: var(--secondary-color);
}

tbody tr:hover {
    background-color: #e0e7ff; /* Light Indigo on hover */
}

/* Specific Table Styling */

/* History Table */
#historySection {
    max-height: 400px; /* Increased height */
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-top: var(--spacing-unit); /* Add space within details */
    padding: calc(var(--spacing-unit) * 0.5); /* Padding inside scroll area */
}
#historyTable td:nth-child(1), /* STT */
#historyTable td:nth-child(5), /* Time */
#historyTable td:nth-child(6), /* Play */
#historyTable td:nth-child(7), /* Repeat */
#historyTable td:nth-child(8) { /* Save */
    text-align: center;
    white-space: nowrap;
}
#historyTable td:nth-child(4) { /* Result */
    font-weight: 500;
}
#historyTable td:nth-child(4)[style*="color: green"] { color: var(--success-color); }
#historyTable td:nth-child(4)[style*="color: red"] { color: var(--danger-color); }
#historyTable td:nth-child(2) span { /* User input in history */
    display: block;
    font-size: 0.85em;
    color: var(--text-light);
    font-style: italic;
    margin-top: 4px;
}

/* Current Movie Saved Subtitles */
#subtitleTable td:first-child { /* Time */
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
}
#subtitleTable td:first-child:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}
#subtitleTable td:last-child div:first-child { /* Primary subtitle */
    font-weight: 500;
}
#subtitleTable td:last-child div:last-child { /* Secondary subtitle */
    font-size: 0.9em;
    color: var(--text-light);
}

/* Learning Stats Table */
#statsTable th, #statsTable td { text-align: center; }
#statsTable tbody tr:last-child { /* Summary Row if added by JS */
    font-weight: bold;
    background-color: #e0e7ff;
}

/* All Subtitles Table */
#allSubtitlesTable .file-name-row td { /* Group header */
    background-color: var(--secondary-color);
    font-weight: 600;
    font-size: 1rem;
    color: var(--primary-dark);
    text-align: center;
    border-bottom: 2px solid var(--primary-light);
    padding: var(--spacing-unit);
}
#allSubtitlesTable td:nth-child(1) { text-align: center; } /* STT */
#allSubtitlesTable .subtitle-container {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5);
    margin-bottom: calc(var(--spacing-unit) * 0.25);
}
#allSubtitlesTable .subtitle-container span { flex-grow: 1; }
#allSubtitlesTable .subtitle-container .primary-subtitle { font-weight: 500; }
#allSubtitlesTable .subtitle-container .secondary-subtitle { color: var(--text-light); }
#allSubtitlesTable .edit-button,
#allSubtitlesTable .save-button,
#allSubtitlesTable .play-audio-button,
#allSubtitlesTable .delete-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0 2px;
    font-size: 1rem;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.2s;
}
#allSubtitlesTable .play-audio-button { color: var(--info-color); }
#allSubtitlesTable .edit-button { color: var(--warning-color); }
#allSubtitlesTable .save-button { color: var(--success-color); }
#allSubtitlesTable .delete-button { color: var(--danger-color); }

#allSubtitlesTable .edit-button:hover,
#allSubtitlesTable .save-button:hover,
#allSubtitlesTable .play-audio-button:hover,
#allSubtitlesTable .delete-button:hover {
    filter: brightness(0.8);
}
#allSubtitlesTable .category-select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8rem;
    margin-right: 5px;
}
#allSubtitlesTable .add-category-button {
    background: none; border: none; padding: 0; margin-left: 5px;
    color: var(--success-color); font-size: 1.1rem; cursor: pointer;
}
#allSubtitlesTable td:nth-child(3) { /* Category & Actions Column */
    display: flex;
    flex-direction: column; /* Stack select/add and delete */
    align-items: flex-start;
    gap: var(--spacing-unit) * 0.5;
}

/* Subtitle Stats Table (by film) */
#subtitleStatsTable th, #subtitleStatsTable td { text-align: center; }
#subtitleStatsTable tbody tr:last-child { /* Summary Row */
    font-weight: bold;
    background-color: #e0e7ff;
}

/* --- Charts --- */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: calc(var(--spacing-unit) * 1.5);
    margin-top: var(--spacing-unit);
}
.chart-wrapper {
    padding: var(--spacing-unit);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--secondary-color);
}
.chart-wrapper h4 {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--spacing-unit);
    color: var(--text-light);
}
#spiderChartSection, #weeklyStats {
    position: relative; /* Needed for Chart.js responsiveness */
    min-height: 250px; /* Ensure charts have space */
}
canvas {
    display: block;
    width: 100%;
    height: auto;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center; /* Center tabs */
    gap: calc(var(--spacing-unit) * 0.5);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    padding-bottom: var(--spacing-unit);
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    background-color: var(--secondary-color); /* Lighter background for inactive */
    color: var(--text-light);
    border: 1px solid var(--border-color);
    box-shadow: none;
    font-weight: 600;
    padding: calc(var(--spacing-unit) * 0.6) calc(var(--spacing-unit) * 1.2);
}
.tab-button:hover {
    background-color: #e5e7eb; /* Slightly darker gray on hover */
    color: var(--primary-dark);
    transform: none;
    box-shadow: none;
}
.tab-button.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--card-shadow);
}
.tab-button.active:hover {
    background-color: var(--primary-dark);
}

.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-title {
    font-size: 1.25rem; /* 20px */
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: var(--spacing-unit);
    text-align: center;
}

/* --- Search & Categories (All Subtitles Tab) --- */
.saved-subtitles-controls {
    display: flex;
    flex-direction: column; /* Stack search and categories */
    gap: var(--spacing-unit);
    margin-bottom: var(--spacing-unit);
    align-items: center; /* Center controls */
}
#subtitleSearch {
    width: 100%;
    max-width: 500px;
    padding: calc(var(--spacing-unit) * 0.6);
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}
#subtitleSearch:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}
#searchResults {
    list-style: none;
    padding: 0;
    margin: var(--spacing-unit) auto; /* Center results */
    max-width: 600px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
}
#searchResults li {
    padding: calc(var(--spacing-unit) * 0.6);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-unit);
    transition: background-color 0.2s ease;
}
#searchResults li:last-child { border-bottom: none; }
#searchResults li:hover { background-color: #e0e7ff; }
#searchResults .search-primary { font-weight: 500; }
#searchResults .search-secondary { font-size: 0.9em; color: var(--text-light); }
#searchResults .search-speaker-button {
    background: none; border: none; color: var(--info-color); font-size: 1.1rem; cursor: pointer; padding: 0 5px;
}
#searchResults .search-speaker-button:hover { color: var(--primary-dark); }

#categoryLinks h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: calc(var(--spacing-unit) * 0.5);
    text-align: center;
}
#categoryList {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: calc(var(--spacing-unit) * 0.5);
}
#categoryList li {
    background-color: var(--secondary-color);
    color: var(--text-light);
    padding: 4px 12px;
    border-radius: 15px; /* Pill shape */
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
#categoryList li:hover {
    background-color: #e0e7ff;
    color: var(--primary-dark);
    border-color: var(--primary-light);
}
#categoryList li.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 600;
}

/* --- Voice Settings --- */
.voice-settings {
    margin-top: calc(var(--spacing-unit) * 2);
    padding-top: var(--spacing-unit);
    border-top: 1px dashed var(--border-color);
    text-align: center;
}
.voice-settings h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-unit);
    color: var(--text-light);
}
#voiceSelect {
    display: block; /* Make it block for centering */
    margin: 0 auto var(--spacing-unit) auto; /* Center */
    max-width: 400px;
    padding: calc(var(--spacing-unit) * 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
}
#testVoice {
    background-color: var(--info-color);
}
#testVoice:hover {
    background-color: #2563eb;
}

/* --- Game Area --- */
#gameArea {
    text-align: center;
}
#secondarySubtitleDisplay {
    font-size: 1rem; /* 16px */
    color: var(--text-light);
    margin-bottom: var(--spacing-unit);
    font-style: italic;
}
#secondarySubtitleDisplay strong { color: var(--text-color); }
#userInput1 {
    display: block; /* Make it block for centering */
    width: 100%;
    max-width: 500px;
    margin: 0 auto var(--spacing-unit) auto; /* Center */
    padding: calc(var(--spacing-unit) * 0.75);
    font-size: 1.1rem;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}
#userInput1:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}
p#resultMessage {
    font-size: 1.2rem; /* Larger result message */
    font-weight: 600;
    min-height: 1.5em; /* Reserve space */
    margin: var(--spacing-unit) 0;
}
p#resultMessage[style*="color: green"] { color: var(--success-color); }
p#resultMessage[style*="color: red"] { color: var(--danger-color); }
p#resultMessage[style*="color: blue"] { color: var(--info-color); }
p#resultMessage[style*="color: orange"] { color: var(--warning-color); }
/* Default (learning mode) */
p#resultMessage:not([style*="color:"]) {
    color: var(--text-color); /* Black or dark gray for the prompt */
}


.game-controls {
    margin: var(--spacing-unit) 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-unit);
}
#checkButton { background-color: var(--success-color); }
#checkButton:hover { background-color: #059669; }
#skipButton { background-color: var(--warning-color); }
#skipButton:hover { background-color: #d97706; }
#playGameButton { background-color: var(--info-color); }
#playGameButton:hover { background-color: #2563eb; }

#gameStats {
    margin-top: var(--spacing-unit);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
}
#gameHistoryTable th, #gameHistoryTable td { text-align: center; }

/* --- Minimized Mode --- */
body.minimized-mode {
    background: #111; /* Dark background */
    padding: 0;
    overflow: hidden; /* Hide scrollbars */
}
body.minimized-mode .container {
    max-width: none;
    padding: 0;
    height: 100vh;
    display: flex; /* Use flex to center content */
    flex-direction: column;
    justify-content: center; /* Center vertically */
    align-items: center; /* Center horizontally */
}
body.minimized-mode header,
body.minimized-mode footer,
body.minimized-mode #player-section #fileUploadSection,
body.minimized-mode #history-saved-section,
body.minimized-mode #stats-tabs-section,
body.minimized-mode .backup-restore,
body.minimized-mode .help-section, 
body.minimized-mode #currentTime /* Optionally hide time */
{
    display: none;
}
body.minimized-mode #player-section {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
   
}
body.minimized-mode #videoSection video {
    border-radius: 0; /* Remove border radius for full focus */
    box-shadow: none;
    margin-bottom: 0;
}
body.minimized-mode #subtitle-control-section {
    position: static; /* No longer sticky */
    background: none;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
    padding: 0;
   

    margin-top: calc(var(--spacing-unit) * 0.5); /* Small gap */
}
body.minimized-mode #subtitleWrapper {
    background: rgba(0, 0, 0, 0.7); /* Dark transparent background */
    border: none;
}
body.minimized-mode #subtitleArea,
body.minimized-mode #secondarySubtitleArea {
    color: #fff; /* White text */
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8); /* Text shadow for readability */
}
body.minimized-mode #userInput {
     background-color: rgba(255, 255, 255, 0.9); /* Slightly transparent white input */
     border-color: rgba(255, 255, 255, 0.5);
}
body.minimized-mode .subtitle-controls {
    margin-top: var(--spacing-unit);
    justify-content: center;
}
body.minimized-mode #minimizeButton {
     /* Style the exit button */
     background-color: var(--danger-color);
}
body.minimized-mode #minimizeButton:hover {
    background-color: #dc2626;
}


/* --- Hide Subtitle Input Mode --- */
body.hide-subtitle #userInput {
    display: none !important; /* Force hide input via JS class */
}

/* --- Responsive --- */
@media (max-width: 768px) {
    html { font-size: 93.75%; } /* 15px base */
    .container { padding: var(--spacing-unit); }
    header h1 { font-size: 1.75rem; } /* Smaller heading */
    .card { padding: var(--spacing-unit); }
    #fileUploadSection { justify-content: space-around; } /* Better spacing on small screens */
    .fileLabel { padding: calc(var(--spacing-unit) * 0.5) var(--spacing-unit); font-size: 0.8rem; }
    #subtitleArea { font-size: 1.25rem; }
    #secondarySubtitleArea { font-size: 1rem; }
    .subtitle-controls { gap: calc(var(--spacing-unit) * 0.5); }
    button { font-size: 0.8rem; padding: calc(var(--spacing-unit) * 0.4) calc(var(--spacing-unit) * 0.8); }
    .tabs { justify-content: flex-start; overflow-x: auto; padding-bottom: 5px; } /* Allow horizontal scroll for tabs */
    th, td { padding: calc(var(--spacing-unit) * 0.5); font-size: 0.8rem; }
    .charts-container { grid-template-columns: 1fr; } /* Stack charts */
}

@media (max-width: 480px) {
    html { font-size: 87.5%; } /* 14px base */
    header h1 { font-size: 1.5rem; }
    .section-title { font-size: 1rem; }
    #subtitleArea { font-size: 1.1rem; }
    #secondarySubtitleArea { font-size: 0.9rem; }
    .fileLabel { width: 100%; text-align: center; justify-content: center;} /* Full width upload buttons */
    #categoryList li { font-size: 0.75rem; padding: 3px 10px; }
    p#resultMessage { font-size: 1rem; }
    .game-controls button { width: calc(50% - var(--spacing-unit) * 0.5); } /* Two buttons per row */
}
/* --- Help Section --- */
.help-section {
    background-color: #eef2ff; /* Light Indigo background */
    border-left: 5px solid var(--primary-color); /* Accent border */
    margin-bottom: calc(var(--spacing-unit) * 1.5); /* Space below help */
}

.help-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
    cursor: pointer;
    padding: calc(var(--spacing-unit) * 0.75) 0;
    list-style: none; /* Remove default marker */
    transition: color 0.2s ease;
    display: flex; /* Align icon and text */
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5);
}

.help-title:hover {
    color: var(--primary-color);
}

.help-title i {
    color: var(--primary-light);
    font-size: 1.2em; /* Slightly larger icon */
}

.help-section[open] > .help-title {
    margin-bottom: var(--spacing-unit);
}

.help-content {
    padding: 0 var(--spacing-unit) var(--spacing-unit) var(--spacing-unit); /* Padding inside */
    color: var(--text-color);
    font-size: 0.95rem; /* Slightly larger than table text */
    border-top: 1px dashed var(--border-color); /* Separator line */
    margin-top: calc(var(--spacing-unit) * 0.5);
    padding-top: var(--spacing-unit);
}

.help-content h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-top: var(--spacing-unit);
    margin-bottom: calc(var(--spacing-unit) * 0.5);
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5);
}
.help-content h4:first-child {
    margin-top: 0;
}
.help-content h4 i {
    color: var(--primary-light);
}


.help-content ul {
    list-style: none; /* Remove default bullets */
    padding-left: calc(var(--spacing-unit) * 1.5); /* Indent list */
    margin-bottom: var(--spacing-unit);
}

.help-content ul li {
    margin-bottom: calc(var(--spacing-unit) * 0.4);
    position: relative; /* For custom bullet */
}

.help-content ul li::before {
    content: '•'; /* Custom bullet */
    color: var(--primary-color);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1.1em; /* Position bullet */
    position: absolute;
    top: 1px;
}

.help-content ul ul { /* Nested list styling */
    margin-top: calc(var(--spacing-unit) * 0.5);
    margin-bottom: calc(var(--spacing-unit) * 0.5);
}

.help-content ul ul li::before {
     content: '◦'; /* Custom bullet for nested list */
     color: var(--primary-light);
}


.help-content strong {
    font-weight: 600;
    color: var(--primary-dark);
}

.help-content i { /* Style icons within help text */
   color: var(--primary-color);
   font-size: 0.9em; /* Slightly smaller icons in text */
   margin: 0 2px;
}

/* Responsive Help Section */
@media (max-width: 768px) {
    .help-title { font-size: 1rem; }
    .help-content { font-size: 0.9rem; }
    .help-content h4 { font-size: 1rem; }
}
/* --- Backup & Restore Section --- */
.backup-restore {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #dee2e6;
	    padding: 30px;
}

.backup-restore h3 {
    margin-bottom: 1rem;
}

.backup-restore button,
.restore-label {
    display: inline-block; /* Align next to each other */
    margin-right: 1rem;
    margin-bottom: 0.5rem; /* Spacing for wrapping */
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid #007bff;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    background-color: #fff;
    color: #007bff;
    text-align: center;
}

.backup-restore button:hover,
.restore-label:hover {
    background-color: #e7f3ff;
}

.backup-restore .restore-label {
    background-color: #28a745; /* Green for restore */
    border-color: #28a745;
    color: white;
}
.backup-restore .restore-label:hover {
     background-color: #218838;
     border-color: #1e7e34;
}

.backup-restore .note {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 0.5rem;
}