:root {
    --bg-color: #000;
    --text-color: #00ff00;
    --accent-color: #00cc00;
    --border-color: #00ff00;
    --shadow-color: rgba(0, 255, 0, 0.5);
    --table-bg: rgba(0, 255, 0, 0.169);
    --table-header-bg: rgba(0, 255, 0, 0.1);
    --button-bg: #00ff00;
    --button-hover-bg: #00cc00;
    --link-color: #00ff00;
    --header-bg: linear-gradient(to right, transparent 0%, #00ff00 20%, #00ff00 80%, transparent 100%);
    --header-text-color: #000;
    --cursor-color: #000;
}

.light {
    --bg-color: #ffffff;
    --text-color: #000000;
    --accent-color: #007bff;
    --border-color: #007bff;
    --shadow-color: rgba(0, 123, 255, 0.3);
    --table-bg: rgba(0, 123, 255, 0.05);
    --table-header-bg: rgba(0, 123, 255, 0.1);
    --button-bg: #007bff;
    --button-hover-bg: #0056b3;
    --link-color: #007bff;
    --header-bg: linear-gradient(to right, transparent 0%, #007bff 20%, #007bff 80%, transparent 100%);
    --header-text-color: #ffffff;
    --cursor-color: #000000;
}

.light .rank-1 {
    color: #B8860B; /* Darker gold for light mode */
}

.light .rank-2 {
    color: #787878; /* Darker silver for light mode */
}

.light .rank-3 {
    color: #8B4513; /* Darker bronze for light mode */
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

#terminal {
    width: 90%;
    max-width: 100%;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    padding: 30px;
    box-shadow: 0 0 20px var(--shadow-color);
    overflow-y: auto;
    margin: 0;
}

.light #terminal {
    background: rgba(255, 255, 255, 0.9);
}

#header {
    font-size: 1.8em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 40px;
    text-shadow: 0 0 5px var(--border-color);
    background: var(--header-bg);
    padding: 8px;
    border-radius: 4px;
}

.h-title {
    font-size: 1em;
    font-weight: bold;
}

#headlines-title {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

#headlines-title #headlines-caret {
    font-size: 1em;
    color: var(--text-color);
    transition: transform 0.3s ease !important;
    display: inline-block !important;
}

#headlines-title #headlines-caret.up {
    transform: rotate(0deg) !important;
}

#headlines-content {
    font-size: .969em;
    line-height: 1.5em;
    margin-bottom: -1em;
}

#nav {
    width: 90%;
    max-width: 100%;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-radius: 8px 8px 0 0;
    margin: 0;
}

.light #nav {
    background: rgba(255, 255, 255, 0.9);
}

#nav a {
    color: var(--link-color);
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    background: var(--bg-color);
    transition: background 0.3s;
}

#nav a:hover, #nav a.active {
    background: var(--accent-color);
    color: var(--header-text-color);
}

#mode-toggle {
    color: var(--link-color);
    padding: 8px 15px;
    border-radius: 4px;
    background: var(--bg-color);
    transition: background 0.3s;
    cursor: pointer;
}

#mode-toggle:hover {
    background: var(--accent-color);
    color: var(--header-text-color);
}

#nav-signin i {
    vertical-align: middle;
}

#mode-toggle i {
    vertical-align: middle;
}

#user-info {
    color: var(--accent-color);
    padding: 8px 15px;
}

#leaderboard-toggle {
    margin-bottom: 10px;
}

#leaderboard-toggle .nav-button {
    margin: 0 5px;
}

#leaderboard-toggle .active {
    background: var(--accent-color);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    background: var(--table-bg);
    font-family: 'Courier New', monospace;
    transition: opacity 0.3s;
}

.leaderboard-table th, .leaderboard-table td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: center;
}

.leaderboard-table th {
    background: var(--table-header-bg);
}

.leaderboard-table a {
    color: var(--link-color);
    text-decoration: underline;
}

.rank-1 {
    color: #FFD700;
}

.rank-2 {
    color: #C0C0C0;
}

.rank-3 {
    color: #CD7F32;
}

.section {
    margin-bottom: 50px;
}

.section-title {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow: 0 0 3px var(--border-color);
}

button {
    background: var(--button-bg);
    color: var(--header-text-color);
    border: none;
    padding: 10px 20px;
    margin: 10px 0;
    cursor: pointer;
    font-family: inherit;
    border-radius: 4px;
    box-shadow: 0 0 10px var(--shadow-color);
    transition: background 0.3s;
}

button:hover {
    background: var(--button-hover-bg);
}

input {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px;
    margin: 10px 0;
    font-family: inherit;
    border-radius: 4px;
    width: calc(100% - 22px);
}

a {
    color: var(--link-color);
    text-decoration: underline;
}

ul {
    list-style-type: none;
    padding: 0;
}

li {
    margin-bottom: 20px;
}

.progress {
    font-family: inherit;
    margin-top: 20px;
}

.slide {
    border: 1px solid var(--accent-color);
    padding: 20px;
    margin-bottom: 10px;
    border-radius: 5px;
    background: var(--table-bg);
    min-height: 300px;
}

.slide-title {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 30px;
    text-align: center;
    text-shadow: 0 0 3px var(--border-color);
}

.slide-section {
    margin-bottom: 25px;
    line-height: 2.0;
    white-space: pre-wrap;
    color: var(--text-color);
    font-size: 1.1em;
}

.slide-section b {
    color: var(--accent-color);
    font-weight: bold;
}

.slide-section:last-child {
    margin-bottom: 0;
}

.option-button {
    width: 100%;
    margin: 5px 0;
    text-align: left;
    padding: 10px;
    font-size: 1.1em;
    line-height: 2.0;
}

.restart-education {
    margin-left: 20px;
}

.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.nav-button {
    background: var(--button-bg);
    color: var(--header-text-color);
    border: none;
    padding: 10px 20px;
    margin: 0;
    cursor: pointer;
    font-family: inherit;
    border-radius: 4px;
    box-shadow: 0 0 10px var(--shadow-color);
    transition: background 0.3s;
}

.nav-button:hover {
    background: var(--button-hover-bg);
}

.fa-caret-left {
    vertical-align: middle !important;
    font-size: 1.3em !important;
}

.fa-caret-right {
    vertical-align: middle !important;
    font-size: 1.3em !important;
}

#header-title {
    font-weight: bold;
    text-align: center;
    text-shadow: 0 0 5px var(--border-color);
    color: var(--header-text-color);
}

.typed-cursor {
    display: inline;
    margin-left: 2px;
    color: var(--cursor-color);
    animation: blink 0.7s step-end infinite;
}

.headlines-refresh, .refresh-time {
    font-size: 0.8em;
    color: #666;
    display: block !important;
    margin-top: -11px;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

.footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9em;
    color: var(--accent-color);
}

.quiz-history-table {
    margin-top: 20px;
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    background: var(--table-bg);
    font-family: 'Courier New', monospace;
}

.quiz-history-table th, .quiz-history-table td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: center;
}

.quiz-history-table th {
    background: var(--table-header-bg);
}

.quiz-history-table .pass {
    color: var(--accent-color);
}

.quiz-history-table .fail {
    color: #ff0000; /* Red for fail, consistent in both modes */
}

.quiz-history-table .perfect {
    color: #FFD700; /* Gold for perfect, consistent in both modes */
}

.light .quiz-history-table .perfect {
    color: #B8860B; /* Darker gold for light mode */
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.pagination .nav-button {
    background: var(--button-bg);
    color: var(--header-text-color);
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    font-family: inherit;
    border-radius: 4px;
    box-shadow: 0 0 10px var(--shadow-color);
    transition: background 0.3s;
}

.pagination .nav-button:hover:not(:disabled) {
    background: var(--button-hover-bg);
}

.pagination .nav-button:disabled {
    background: #666;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    #terminal {
        width: 100%;
        max-width: 100%;
        padding: 5px;
        border: none;
        box-shadow: none;
        margin: 0;
    }
    .section {
        padding: 5px;
        margin-bottom: 30px;
    }
    body {
        padding: 5px;
        overflow-x: hidden;
    }
    .slide {
        padding: 15px;
    }
    #nav {
        width: 100%;
        max-width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        padding: 8px;
        margin: 0;
    }
    #nav a, #user-info, #mode-toggle {
        padding: 6px 10px;
        font-size: 0.9em;
    }
    .slide-title {
        font-size: 1.5em;
    }
    .restart-education {
        margin-left: 10px;
    }
    .nav-buttons {
        flex-direction: column;
        gap: 10px;
    }
    .leaderboard-table .desktop-only {
        display: none;
    }
    .quiz-history-table th:nth-child(1), .quiz-history-table td:nth-child(1) {
        display: none; /* Hide Quiz Date on mobile */
    }
}

@media (min-width: 601px) {
    .leaderboard-table .desktop-only {
        display: table-cell;
    }
}