:root {
    --bg-color: #191826;
    --text-color: #fdfef9;
    --accent-color: #ef6d17;
    --border-color: #b36652;
    --shadow-color: rgba(179, 102, 82, 0.25);
    --table-bg: rgba(179, 102, 82, 0.2);
    --table-header-bg: rgba(179, 102, 82, 0.15);
    --button-bg: #ef6d17;
    --button-hover-bg: #d78b5a;
    --button-text: #fdfef9;
    --link-color: #ef6d17;
    --header-bg: linear-gradient(to right, transparent 0%, #ef6d17 20%, #ef6d17 80%, transparent 100%);
    --header-text-color: #fdfef9;
    --cursor-color: rgba(239, 109, 23, 0.6);
    --inactive-color: #ab2325;
    --glow-color: #fcfc10;
    --footer-height: 50px;
}

.light {
    --bg-color: #fdfef9;
    --text-color: #191826;
    --accent-color: #d78b5a;
    --border-color: #b36652;
    --shadow-color: rgba(179, 102, 82, 0.25);
    --table-bg: rgba(179, 102, 82, 0.2);
    --table-header-bg: rgba(179, 102, 82, 0.15);
    --button-bg: #d78b5a;
    --button-hover-bg: #ef6d17;
    --button-text: #191826;
    --link-color: #d78b5a;
    --header-bg: linear-gradient(to right, transparent 0%, #d78b5a 20%, #d78b5a 80%, transparent 100%);
    --header-text-color: #191826;
    --cursor-color: rgba(215, 139, 90, 0.7);
    --inactive-color: #b41a1a;
    --glow-color: #b5b613;
}

.light .rank-1 {
    color: #B8860B;
}

.light .rank-2 {
    color: #787878;
}

.light .rank-3 {
    color: #8B4513;
}

.light .slide-reference small {
    color: var(--text-color);
}

.light .quiz-history-table .perfect {
    color: var(--glow-color);
}

.light .team-toggle-switch::before {
    background: var(--button-text);
}

* {
    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;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#terminal {
    position: relative;
    padding-bottom: var(--footer-height);
    width: 90%;
    max-width: 100%;
    background: var(--bg-color);
    border-radius: 0 0 8px 8px;
    padding: 30px;
    overflow-y: auto;
    margin: 0;
    min-height: calc(600px + var(--footer-height));
    -webkit-overflow-scrolling: touch;
}

.light #terminal {
    background: var(--bg-color);
}

#education-content,
#profile-content,
#leaderboard-content-container {
    min-height: 400px;
    position: relative;
}

#profile-content div {
    margin-bottom: .5em;
}

#profile-content p:last-child {
    margin-bottom: 20px;
}

.profile-fields {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1em;
}

.field-group {
    display: flex;
    flex-direction: column;
    width: 48%;
}

.field-group div {
    margin-bottom: 0.5em;
}

#quiz-history-content {
    margin-top: 20px;
}

.quiz-history-table {
    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: var(--inactive-color);
}

.quiz-history-table .perfect {
    color: var(--glow-color);
}

#header {
    font-size: 1.7em;
    font-weight: bold;
    margin-bottom: 25px;
    padding: 8px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#header-logo img {
    height: 69px;
    filter: drop-shadow(0 0 1px var(--shadow-color));
}

#header-logo:hover img {
    filter: drop-shadow(0 0 1px var(--shadow-color)) drop-shadow(0 0 6px rgba(239, 109, 23, 0.5));
}

.light #header-logo:hover img {
    filter: drop-shadow(0 0 1px var(--shadow-color)) drop-shadow(0 0 6px rgba(215, 139, 90, 0.5));
}

#header-title-container {
    text-align: right;
}

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

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

.light #nav {
    background: var(--bg-color);
}

#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(--button-text);
}

#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(--button-text);
}

.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);
    color: var(--header-text-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: none;
}

.rank-1 {
    color: #FFD700;
}

.rank-2 {
    color: #C0C0C0;
}

.rank-3 {
    color: #CD7F32;
}

.section {
    padding-bottom: 35px;
}

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

button {
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 10px 20px;
    margin: 10px 0;
    cursor: pointer;
    font-family: inherit;
    border-radius: 4px;
    box-shadow: 0 0 5px 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);
}

input:focus {
    position: relative;
    z-index: 1;
}

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

a:not(#nav a):hover {
    color: var(--button-hover-bg);
    text-decoration: none;
}

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 1px 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;
}

.slide-reference {
    margin-bottom: 25px;
    line-height: 1.8em;
    font-size: 1em;
    color: var(--text-color);
}

.slide-reference b {
    color: var(--text-color);
    font-weight: bold;
}

.slide-reference a {
    color: var(--link-color);
    text-decoration: none;
}

.slide-reference small {
    font-size: 0.869em;
    color: var(--text-color);
}

hr.slide-reference {
    border: none;
    border-top: 1px dashed var(--border-color);
    margin: 25px 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-button {
    background: var(--bg-color);
    color: var(--text-color);
    border: none;
    padding: 10px 20px;
    margin: 0;
    cursor: pointer;
    font-family: inherit;
    border-radius: 4px;
    box-shadow: 0 0 5px var(--shadow-color);
    transition: background 0.3s;
}

.nav-button:hover {
    background: var(--accent-color);
    color: var(--header-text-color);
}

.nav-button.active {
    background: var(--accent-color);
    color: var(--header-text-color);
}

.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 {
    line-height: 1;
    font-weight: bold;
    text-shadow: 0 0 1px var(--border-color);
}

.typed-cursor {
    display: inline;
    color: var(--cursor-color);
    animation: smooth-blink 0.7s ease-in-out infinite;
    font-family: monospace;
    vertical-align: middle;
    margin-left: -3px;
    position: relative;
    top: -3px;
    transition: opacity 0.5s ease, width 0.5s ease, margin-left 0.5s ease;
}

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

.typed-complete {
    animation: complete-glow 1s ease-in-out forwards;
}

@keyframes complete-glow {
    0% {
        text-shadow: 0 0 3px rgba(239, 109, 23, 0.5), 0 0 6px rgba(239, 109, 23, 0.5);
    }
    100% {
        text-shadow: 0 0 1px var(--border-color);
    }
}

.light .typed-complete {
    animation: complete-glow 1s ease-in-out forwards;
}

@keyframes complete-glow {
    0% {
        text-shadow: 0 0 3px rgba(215, 139, 90, 0.5), 0 0 6px rgba(215, 139, 90, 0.5);
    }
    100% {
        text-shadow: 0 0 1px var(--border-color);
    }
}

.headlines-refresh,
.refresh-time,
#content-refresh {
    color: var(--accent-color);
    display: inline !important;
}

.footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    margin-bottom: 0.9em;
    font-size: 0.9em;
    color: var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    height: var(--footer-height);
}

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

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

.pagination .nav-button:hover:not(:disabled) {
    background: var(--accent-color);
    color: var(--header-text-color);
}

.pagination .nav-button:disabled {
    background: var(--inactive-color);
    cursor: not-allowed;
}

.team-stats {
    margin-bottom: 10px;
    font-weight: bold;
    text-align: center;
}

.team-toggle-switch {
    appearance: none;
    width: 40px;
    height: 20px;
    background: var(--inactive-color);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: background 0.3s;
    vertical-align: middle;
}

.team-toggle-switch:checked {
    background: var(--bg-color);
}

.team-toggle-switch::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--button-text);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.team-toggle-switch:checked::before {
    transform: translateX(20px);
}

.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    max-width: 90%;
    align-items: center;
}

.toast {
    position: relative;
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 10px 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px var(--shadow-color);
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    z-index: 1;
    max-width: 400px;
    text-align: center;
    font-family: 'Courier New', monospace;
}

.toast.show {
    opacity: 1;
}

.toast-info {
    background-color: var(--accent-color);
    color: var(--header-text-color);
}

.toast-error {
    background-color: var(--inactive-color);
    color: #fff;
}

.light .toast-error {
    background-color: var(--bg-color);
    color: var(--inactive-color);
    border-left: 4px solid var(--inactive-color);
}

.toast-success {
    background-color: var(--success-bg, #e6ffe6);
    color: var(--success-text, #007700);
    border: 1px solid var(--success-border, #b3ffb3);
}

.light .toast-success {
    background-color: var(--success-bg-light, #e6ffe6);
    color: var(--success-text-light, #007700);
    border: 1px solid var(--success-border-light, #b3ffb3);
}

.inactive {
    color: var(--inactive-color);
}

.input-wrapper {
    position: relative;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.input-wrapper .input-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

.input-wrapper .input-container input {
    padding-right: 70px;
    width: 100%;
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    font-family: 'Courier New', monospace;
    border-radius: 4px;
    box-sizing: border-box;
    height: 40px;
    padding: 8px 10px;
}

.input-wrapper .input-container .char-count {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-color);
    font-size: 0.95em;
    font-family: 'Courier New', monospace;
    opacity: 0.9;
    z-index: 1;
    pointer-events: none;
    line-height: 1;
}

#username-error,
#bio-error {
    color: var(--inactive-color);
    font-size: 0.8em;
    margin-top: 5px;
    display: block;
    font-family: 'Courier New', monospace;
}

.welcome-message {
    background-color: rgba(202, 228, 219, 0.18);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    position: relative;
    font-size: 1em;
    line-height: 1.5;
}

.light .welcome-message {
    background-color: rgba(53, 27, 36, 0.18);
}

.dismiss-welcome {
    position: absolute;
    bottom: 5px;
    right: 10px;
    cursor: pointer;
    font-size: 1.2em;
    color: var(--text-color);
    line-height: 1;
    vertical-align: middle;
}

.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    flex-wrap: nowrap;
    width: 100%;
}

.nav-button-left {
    margin-right: auto;
    padding: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-button-right {
    margin-left: auto;
    padding: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-button-left i,
.nav-button-right i {
    font-size: 1.5em;
}

.master-phisher {
    color: var(--glow-color);
    font-weight: bold;
    margin-left: 10px;
    vertical-align: middle;
}

#phish-content p {
    margin-bottom: 1.23em;
}

#phish-content p:first-child {
    margin-top: 1em;
}

.phish-email {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    background: var(--table-bg);
    box-shadow: 0 2px 4px var(--shadow-color);
    margin-top: 15px;
}

.fas.fa-flag {
    display: inline-block;
    width: 1em;
    height: 1em;
    color: var(--inactive-color);
    margin-left: 5px;
    vertical-align: middle;
}

[data-redflag="true"].identified .fas.fa-flag {
    opacity: 1;
}

@media (max-width: 800px) {
    #terminal {
        width: 100%;
        max-width: 100%;
        padding: 5px;
        padding-bottom: 80px;
        border: none;
        box-shadow: none;
        margin: 0;
        min-height: 450px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    #education-content,
    #profile-content,
    #leaderboard-content-container {
        min-height: 400px;
    }
    .field-group {
        width: 100%;
    }
    #header {
        flex-direction: column;
        text-align: center;
    }
    #header-title-container {
        width: 100%;
        text-align: center;
    }
    body {
        padding: 5px;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .slide {
        padding: 15px;
    }
    #nav {
        width: 100%;
        max-width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        padding: 15px;
        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 {
        display: flex;
        justify-content: space-between;
        flex-wrap: nowrap;
        width: 100%;
        gap: 10px;
    }
    .nav-button-left {
        margin-right: auto;
        padding: 6px;
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    .nav-button-right {
        margin-left: auto;
        padding: 6px;
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    .nav-button-left i,
    .nav-button-right i {
        font-size: 1.3em;
    }
    .leaderboard-table .desktop-only {
        display: none;
    }
    .quiz-history-table th:nth-child(1),
    .quiz-history-table td:nth-child(1) {
        display: none;
    }
    #leaderboard-toggle {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    .team-stats {
        font-size: 0.9em;
    }
    .footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        margin-bottom: 0.9em;
        font-size: 0.9em;
        color: var(--accent-color);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
    }
}

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

@media (orientation: landscape) and (max-height: 600px) {
    #header {
        flex-direction: column;
        text-align: center;
    }
    #header-logo img {
        margin-bottom: 10px;
    }
    #header-title {
        font-size: 1.2em;
    }
    #header-title-container {
        width: 100%;
        text-align: center;
    }
}