@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Open+Sans:ital,wght@0,300..800;1,300..800&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');

:root[data-theme="dark"] {
    --bg-color: #333;
    --text-color: #fff;
    --link-color: #ddd;
    --nav-bg: #2b2b2b;
    --nav-btn-bg: #3a3a3a;
    --nav-btn-hover-bg: #474747;
    --nav-btn-border: #555;
    --nav-btn-hover-border: #666;
    --toggle-track: #4a4a4a;
    --toggle-knob: #f4f4f4;
    --toggle-icon-color: #f5f5f5;
    --nav-btn-primary-bg: #007acc;
    --nav-btn-primary-hover-bg: #006bb3;
    --nav-btn-danger-bg: #e74c3c;
    --nav-btn-danger-hover-bg: #c0392b;
}

:root[data-theme="light"] {
    --bg-color: #fff;
    --text-color: #333;
    --link-color: #007acc;
    --nav-bg: #f0f0f0;
    --nav-btn-bg: #e0e0e0;
    --nav-btn-hover-bg: #d0d0d0;
    --nav-btn-border: #ccc;
    --nav-btn-hover-border: #bbb;
    --toggle-track: #d3d3d3;
    --toggle-knob: #ffffff;
    --toggle-icon-color: #444;
    --nav-btn-primary-bg: #007acc;
    --nav-btn-primary-hover-bg: #006bb3;
    --nav-btn-danger-bg: #e74c3c;
    --nav-btn-danger-hover-bg: #c0392b;
}

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "Georgia", "Times New Roman", serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;

    /* Smooth Theme Transition */
    transition: background-color 0.25s ease, color 0.25s ease
}

html {
    background-color: var(--bg-color);
    color: var(--text-color);

    /* Smooth Theme Transition */
    transition: background-color 0.25s ease, color 0.25s ease
}

.page-header {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
}

header {
    position: sticky;
    top: 0;
    z-index: 1;
    width: 100%;
    padding: 0;
}

footer {
    text-align: center;
    padding: 20px 10px;
    background: var(--nav-bg);
    color: var(--text-color);
    font-size: 0.9rem;

    /* Smooth Theme Transition */
    transition: background-color 0.25s ease, color 0.25s ease;
}

main {
    flex: 1;
}

.page-footer {
    margin-top: auto;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 12px;
    margin-bottom: 8px;
    color: var(--text-color);

    /* Smooth Theme Transition */
    transition: color 0.25s ease;

    /* left side with padding */
    text-align: left;
    padding-left: 23px;
}

.page-paragraph {
    font-size: 1rem;
    line-height: 1.3;
    margin-bottom: 8px;
    color: var(--text-color);

    /* Smooth Theme Transition */
    transition: color 0.25s ease;

    /* left side with padding */
    text-align: left;
    padding-left: 23px;
}

.page-link {
    color: var(--link-color);
    text-decoration: underline;
    font-weight: 500;

    /* Smooth Theme Transition */
    transition: color 0.25s ease;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    margin: 0;
    padding: 10px 14px;
    /*border: 1px solid #444;
    border-radius: 10px;*/
    background: var(--nav-bg);

    /* Smooth Theme Transition */
    transition: background-color 0.25s ease, color 0.25s ease;
}

.page-title-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
}

.page-search-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 23px;
}

.page-paragraph-error {
    font-size: 0.9rem;
    line-height: 1.3;
    margin-bottom: 8px;
    color: #e74c3c;

    /* Smooth Theme Transition */
    transition: color 0.25s ease;
}

.page-paragraph-success {
    font-size: 0.9rem;
    line-height: 1.3;
    margin-bottom: 8px;
    color: #27ae60;

    /* Smooth Theme Transition */
    transition: color 0.25s ease;
}

.page-input {
    padding: 8px 10px;
    border: 1px solid var(--nav-btn-border);
    border-radius: 4px;
    background: var(--nav-btn-bg);
    color: var(--text-color);
    font-size: 0.92rem;
    font-family: inherit;

    /* Smooth Theme Transition */
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.page-login-form {
    margin-top: 10px;
    border: 1px solid var(--nav-btn-border);
    border-radius: 8px;
    background: var(--nav-btn-bg);
    color: var(--text-color);
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
    padding-top: 12px;
    width: max-content;
    margin-left: 23px;
}

.form-group input {
    padding: 8px 10px;
    border: 1px solid var(--nav-btn-border);
    border-radius: 4px;
    background: var(--nav-btn-bg);
    color: var(--text-color);
    font-size: 0.92rem;
    font-family: inherit;
    margin-top: 10px;
    width: 100%;

    /* Smooth Theme Transition */
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.page-login-form .form-group {
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    padding: 0 23px;
}

.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-title {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0px 4px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;

    /* Smooth Theme Transition */
    transition: color 0.25s ease;
}

.nav-right {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-btn, .page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--nav-btn-border);
    border-radius: 4px;
    background: var(--nav-btn-bg);
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.1;
    font-family: inherit;
    cursor: pointer;

    /* Smooth Theme Transition */
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.nav-btn:hover,
.nav-btn:focus-visible,
.page-btn:hover,
.page-btn:focus-visible {
    background: var(--nav-btn-hover-bg);
    border-color: var(--nav-btn-hover-border);
    outline: none;
}

.nav-btn-primary {
    background: var(--nav-btn-primary-bg);
    border-color: var(--nav-btn-primary-bg);
    color: #fff;
}

.nav-btn-primary:hover,
.nav-btn-primary:focus-visible {
    background: var(--nav-btn-primary-hover-bg);
    border-color: var(--nav-btn-primary-hover-bg);
    color: #fff;
    outline: none;
}

.nav-btn-danger {
    background: var(--nav-btn-danger-bg);
    border-color: var(--nav-btn-danger-bg);
    color: #fff;
}

.nav-btn-danger:hover,
.nav-btn-danger:focus-visible {
    background: var(--nav-btn-danger-hover-bg);
    border-color: var(--nav-btn-danger-hover-bg);
    color: #fff;
    outline: none;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    border: 1px solid var(--nav-btn-border);
    border-radius: 8px;
    background: var(--nav-btn-bg);
    color: var(--text-color);
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
    max-width: max(max-content, 400px);
    margin: 20px auto;
    margin-left: 23px;
    margin-right: 23px;
}

.fin-calculator-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.fin-calculator-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fin-calculator-form label {
    color: var(--text-color);
    font-size: 0.92rem;
    font-weight: 500;

    /* Smooth Theme Transition */
    transition: color 0.25s ease;
}

.fin-calculator-form .checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.fin-calculator-form .checkbox-group input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.fin-calculator-form .checkbox-group label {
    margin: 0;
    cursor: pointer;
}

.calculator-result {
    padding: 15px;
    border: 1px solid var(--nav-btn-border);
    border-radius: 4px;
    background: var(--nav-btn-bg);
    color: var(--text-color);

    /* Smooth Theme Transition */
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.calculator-result p {
    margin: 8px 0;
    font-size: 0.92rem;
    line-height: 1.4;
}

.page-unordered-list {
    list-style-type: disc;
    padding-left: 20px;
    color: var(--text-color);

    /* Smooth Theme Transition */
    transition: color 0.25s ease;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    visibility: hidden;
}

/* Prevent background scrolling while a modal is open */
body.modal-open {
    overflow: hidden;
    touch-action: none;
}

.close {
    position: fixed;
    top: 12px;
    right: 12px;
    font-size: 2rem;
    background-color: var(--nav-btn-bg);
    border: 1px solid var(--nav-btn-border);
    border-radius: 4px;
    padding: 0px 9px 3px 9px;
    margin-top: 4px;
    color: var(--text-color);
    cursor: pointer;
    transition: color 0.25s ease;
}

.close:hover {
    color: var(--nav-btn-primary-bg);
}

.page-btn-collection {
    display: flex;
    gap: 10px;
}

.modal-content {
    background: var(--nav-btn-bg);
    padding: 28px;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    position: relative;
    color: var(--text-color);
    transition: background-color 0.25s ease, color 0.25s ease;
    max-height: calc(100vh - 48px);
    overflow: auto;
}

/* Make images inside modals larger while constraining to viewport */
.image-modal-img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 80vh;
    margin: 0 auto;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.modal-buttons-left {
    justify-content: flex-start;
}

.game-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.game-intro {
    margin: 0;
    line-height: 1.5;
}

.game-meta {
    line-height: 1.4;
    margin: 0;
}

.game-definition-box {
    padding: 18px;
    border: 1px solid var(--nav-btn-border);
    border-radius: 8px;
    background: rgba(127, 127, 127, 0.08);
}

.game-section-label {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.8;
}

.game-definitions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-definition-line {
    padding-left: 16px;
    border-left: 3px solid var(--nav-btn-primary-bg);
    line-height: 1.5;
}

.game-input-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.game-guess-input {
    flex: 1 1 260px;
    min-width: 0;
}

.game-feedback {
    min-height: 1.4em;
    font-weight: 600;
}

.game-feedback.is-success {
    color: #27ae60;
}

.game-feedback.is-error {
    color: #e74c3c;
}

.game-feedback.is-neutral {
    color: var(--text-color);
}

.game-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.game-stats-grid p {
    padding: 12px 14px;
    border: 1px solid var(--nav-btn-border);
    border-radius: 8px;
    background: rgba(127, 127, 127, 0.08);
}

.game-stats-grid strong {
    display: block;
    margin-bottom: 4px;
}

.game-secret-answer {
    font-size: 0.95rem;
    opacity: 0.95;
}

.game-empty-state {
    font-style: italic;
    opacity: 0.8;
}

.modal-buttons .page-btn:hover {
    background: var(--nav-btn-hover-bg);
    border-color: var(--nav-btn-hover-border);
    color: var(--text-color);
    outline: none;
    cursor: pointer;
}

.modal-buttons .nav-btn-primary:hover {
    background: var(--nav-btn-primary-hover-bg);
    border-color: var(--nav-btn-primary-hover-bg);
    color: #fff;
    outline: none;
    cursor: pointer;
}

.modal-buttons .nav-btn-danger:hover {
    background: var(--nav-btn-danger-hover-bg);
    border-color: var(--nav-btn-danger-hover-bg);
    color: #fff;
    outline: none;
    cursor: pointer;
}

@media (max-width: 720px) {
    header {
        padding: 6px 8px;
    }

    nav {
        width: 100%;
        padding: 10px 12px;
        flex-direction: column;
        align-items: stretch;
    }

    .nav-left,
    .nav-right {
        justify-content: center;
    }

    .nav-right {
        gap: 10px;
    }
}

/* ── Theme toggle button ── */

.toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 4px 8px 4px 4px;
    border: 1px solid var(--nav-btn-border);
    border-radius: 20px;
    background: var(--nav-btn-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.toggle-btn:hover,
.toggle-btn:focus-visible {
    background: var(--nav-btn-hover-bg);
    border-color: var(--nav-btn-hover-border);
    outline: none;
}

.toggle-btn .track {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--toggle-track);
    position: relative;
    transition: background-color 0.25s ease;
    flex-shrink: 0;
}

.toggle-btn .knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--toggle-knob);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease;
}

[data-theme="dark"] .toggle-btn .knob {
    transform: translateX(20px);
}

.toggle-btn .toggle-icon {
    font-size: 0.95rem;
    line-height: 1;
    color: var(--toggle-icon-color);
    width: 1.1em;
    text-align: center;
    transition: color 0.25s ease;
}

/* Entry cards */
.entry-container, #entry-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    max-width: 100%;
    margin: 0 auto;
}

.entry-container-single, #entry-container-single {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    margin: 16px 4px;
    margin-top: -12px;
    max-width: 100%;
}

hr {
    border: none;
    border-top: 1px solid var(--nav-btn-border);
    margin: 20px 16px;
}

.entry-card {
    border: 1px solid var(--nav-btn-border);
    border-radius: 8px;
    padding: 16px;
    background: var(--nav-btn-bg);
    color: var(--text-color);
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;

    cursor: pointer;
}

.entry-card:hover {
    background: var(--nav-btn-hover-bg);
    border-color: var(--nav-btn-hover-border);
}

.entry-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.entry-definition {
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.entry-example {
    margin-top: 8px;
    font-size: 0.75rem;
    font-style: italic;
}

.page-collapse {
    border: 1px solid var(--nav-btn-border);
    border-radius: 8px;
    padding: 12px;
    padding-top: 18px;
    background: var(--nav-btn-bg);
    color: var(--text-color);
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
    margin: 0 23px;
    visibility: hidden;
}

.page-image-gallery {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    justify-content: center;
}

.page-gallery-image {
    width: 100%;
    max-width: 30%;
    border-radius: 4px;
    border: 1px solid var(--nav-btn-border);
    object-fit: cover;
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.page-gallery-image:hover {
    transform: scale(1.05);
    border-color: var(--nav-btn-hover-border);
}