:root {
    --bg-color: #F8F9FA;
    --text-color: #212529;
    --primary-color-adult: #007BFF;
    --primary-color-kids: #FF6B6B;
    --card-bg-color: #FFFFFF;
    --border-color: #DEE2E6;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --grey-color: #202020;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #EAEAEA;
    --primary-color-adult: #58A6FF;
    --primary-color-kids: #FFA07A;
    --card-bg-color: #1E1E1E;
    --border-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --grey-color: #acacac;
}

*, ::before, ::after {
    box-sizing: border-box;
    margin: 0px;
    padding: 0px;
}

body {
    font-family: Poppins, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    height: 4em;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--card-bg-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    transition: background-color 0.3s, border-bottom 0.3s;
}

main {
    flex-grow: 1;
    padding: 2rem;
    max-width: 900px;
    width: 100%;
    margin: 0px auto;
}

footer {
    text-align: center;
    padding: 1rem 2rem;
    font-size: 0.9rem;
    color: rgb(108, 117, 125);
    border-top: 1px solid var(--border-color);
    background-color: var(--card-bg-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-color);
}

nav a {
    margin: 0px 1rem;
    text-decoration: none;
    font-weight: 600;
    color: var(--text-color);
    position: relative;
    transition: color 0.2s;
}

nav a:hover {
    color: var(--primary-color-adult);
}

body[data-mode="kids"] nav a:hover {
    color: var(--primary-color-kids);
}

.controls {
    display: flex;
    gap: 1rem;
}

.control-button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-color);
    border-radius: 20px;
    font-family: Poppins, sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.control-button:hover {
    border-color: var(--primary-color-adult);
    color: var(--primary-color-adult);
}

body[data-mode="kids"] .control-button:hover {
    border-color: var(--primary-color-kids);
    color: var(--primary-color-kids);
}

body[data-mode="kids"] .adult-feature {
    display: none;
}

.page-header {
    text-align: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.converter-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.input-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-area label {
    font-weight: 600;
    font-size: 1.1rem;
}

#numberInput {
    padding: 1rem;
    font-size: 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background-color: var(--card-bg-color);
    color: var(--text-color);
    font-family: Poppins, sans-serif;
    text-align: center;
    transition: 0.2s;
}

#numberInput:focus {
    outline: currentcolor;
    border-color: var(--primary-color-adult);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color-adult) 25%, transparent);
}

body[data-mode="kids"] #numberInput:focus {
    border-color: var(--primary-color-kids);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color-kids) 25%, transparent);
}

.output-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.output-card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 8px var(--shadow-color);
    transition: 0.3s;
}

.output-card h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.output-card .formatted-number {
    font-size: clamp(1.2rem, 5vw, 2.2rem);
    font-weight: 700;
    overflow-wrap: break-word;
    margin-bottom: 0.5rem;
    min-height: 48px;
}

.output-card .words {
    font-size: 1rem;
    color: rgb(108, 117, 125);
    min-height: 48px;
}

.hamburger-btn {
    display: none;
    background: none;
    border: medium;
    cursor: pointer;
    z-index: 1001;
}

.hamburger-btn svg rect {
    fill: var(--text-color);
}

.mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    header {
        padding: 1rem;
    }

    .desktop-nav, .controls {
        display: none;
    }

    .hamburger-btn {
        display: block;
    }

    .mobile-nav {
        position: fixed;
        top: 0px;
        right: 0px;
        width: 100%;
        height: 100%;
        background-color: var(--card-bg-color);
        z-index: 1000;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2rem;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
    }

    .mobile-nav.active {
        transform: translateX(0px);
    }

    .mobile-nav a {
        font-size: 2rem;
        text-decoration: none;
        color: var(--text-color);
    }

    .output-grid {
        grid-template-columns: 1fr;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }
}

.sub-nav {
    background-color: var(--card-bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0px 1rem;
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.sub-nav::-webkit-scrollbar {
    display: none;
}

.sub-nav a {
    padding: 0.8rem 0.5rem;
    text-decoration: none;
    color: rgb(108, 117, 125);
    font-weight: 600;
    white-space: nowrap;
    border-bottom-width: 3px;
    border-bottom-style: solid;
    border-bottom-color: transparent;
    transition: 0.2s;
}

.sub-nav a:hover {
    color: var(--text-color);
}

.sub-nav a.active {
    color: var(--primary-color-adult);
    border-bottom-color: var(--primary-color-adult);
}

body[data-mode="kids"] .sub-nav a.active {
    color: var(--primary-color-kids);
    border-bottom-color: var(--primary-color-kids);
}

.words-container .secondary {
    display: none;
    font-size: 0.9rem;
    color: rgb(136, 136, 136);
    margin-top: 0.5rem;
}

.words-container.show-secondary .secondary {
    display: block;
}

.input-info {
    text-align: center;
    color: rgb(108, 117, 125);
    font-size: 0.9rem;
    min-height: 1.2rem;
    margin-top: 0.5rem;
}

.sub-nav-container {
    position: absolute;
    width: 100%;
    z-index: 999;
    background-color: var(--card-bg-color);
    border-bottom: 1px solid var(--border-color);
    max-height: 0px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    margin-top: 4em;
}

.sub-nav-container.active {
    max-height: 100px;
}

.sub-nav {
    display: none;
    padding: 0px 1rem;
    gap: 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.sub-nav.active {
    display: flex;
}

.sub-nav a {
    padding: 0.6rem 0.5rem;
    font-size: 0.95rem;
    text-decoration: none;
    color: rgb(108, 117, 125);
    font-weight: 600;
    white-space: nowrap;
    border-bottom-width: 3px;
    border-bottom-style: solid;
    border-bottom-color: transparent;
    transition: 0.2s;
}

.sub-nav a:hover {
    color: var(--text-color);
}

.sub-nav a.active {
    color: var(--primary-color-adult);
    border-bottom-color: var(--primary-color-adult);
}

body[data-mode="kids"] .sub-nav a.active {
    color: var(--primary-color-kids);
    border-bottom-color: var(--primary-color-kids);
}

.desktop-nav a.menu-active {
    color: var(--primary-color-adult);
}

body[data-mode="kids"] .desktop-nav a.menu-active {
    color: var(--primary-color-kids);
}

body[data-mode="kids"] .kids-feature {
    display: block !important;
}

.modal-overlay {
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background-color: var(--card-bg-color);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: rgba(0, 0, 0, 0.3) 0px 5px 15px;
    width: 90%;
    max-width: 600px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: medium;
    font-size: 2rem;
    color: var(--text-color);
    cursor: pointer;
    line-height: 1;
}

.modal-content ul {
    list-style-position: inside;
    margin-top: 1rem;
    padding-left: 0.5rem;
}

.modal-content li {
    margin-bottom: 0.5rem;
}

.modal-content code {
    background-color: var(--border-color);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

.page-footer-link {
    text-align: center;
    margin-top: 2rem;
}

#instructions-link {
    color: var(--text-color);
    font-weight: 500;
}

a {
    text-decoration: none;
}

.challenge-screen h1 {
    margin-bottom: 1em;
}

.challenge-screen .challenge-btn {
    margin: 2.5em 0px 1em;
}

.challenge-screen p {
    padding: 0px 2.5em;
}

.timer {
    font-size: 1.8rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    background-color: var(--border-color);
    border-radius: 12px;
    min-width: 90px;
    text-align: center;
    position: absolute;
    top: 1rem;
    right: 1rem;
    transition: color 0.3s, background-color 0.3s;
}

.timer.danger {
    color: rgb(255, 255, 255);
    background-color: rgb(220, 53, 69);
    animation: 1s infinite pulse;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: rgba(220, 53, 69, 0.7) 0px 0px 0px 0px;
    }

    70% {
        transform: scale(1.05);
        box-shadow: rgba(220, 53, 69, 0) 0px 0px 10px 10px;
    }

    100% {
        transform: scale(1);
        box-shadow: rgba(220, 53, 69, 0) 0px 0px 0px 0px;
    }
}

#game-screen {
    display: none;
    position: relative;
}

.skill-legend {
    margin-top: 3rem;
    color: var(--grey-color);
    background-color: var(--card-bg-color);
    border-radius: 16px;
    padding: 1.5em;
}

.skill-legend ul {
    list-style: lower-roman;
    padding: 0 2em;
    margin: auto;
}

.skill-legend .skill-card {
    margin-top: 1em;
}

/* 9. KIDS MODE ENHANCEMENTS */

.kids-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

body[data-mode="kids"] .kids-bg {
    opacity: 1; /* Fade in only in kids mode */
}

/* This is the style for each shape we generate with JS */
.bg-shape {
    position: absolute;
    animation: float 20s infinite linear;
}

.bg-shape svg {
    width: 100%;
    height: 100%;
    stroke: var(--border-color); /* Use theme color for the outline */
    transition: stroke 0.3s ease;
}

@keyframes float {
    0%   { transform: translateY(0) rotate(var(--r-start)); }
    50%  { transform: translateY(-20px) rotate(var(--r-end)); }
    100% { transform: translateY(0) rotate(var(--r-start)); }
}

/* Other Kids UI tweaks (these can remain) */
body[data-mode="kids"] .challenge-btn {
    transform: scale(1.05);
    font-size: 1.2rem;
    transition: transform 0.2s ease-out;
}
body[data-mode="kids"] .challenge-btn:hover {
    transform: scale(1.1);
}
body[data-mode="kids"] .feedback {
    font-size: 1.2rem;
    font-weight: 700;
}
.skill-legend h2 svg {
    width: 60px;
    float: left;
    margin-right: .5em;
}
.adult-instructions {
    display: none;
}

/* When in kids mode, hide the adult instructions and show the kids one */
body[data-mode="kids"] .adult-instructions {
    display: none;
}
body[data-mode="kids"] .kids-instructions {
    display: block;
}

/* When in adult mode, hide the kids instructions and show the adult one */
body[data-mode="adult"] .kids-instructions {
    display: none;
}
body[data-mode="adult"] .adult-instructions {
    display: block;
}