:root {
    --bg: #ffffff;
    --fg: #000000;
    --timer-width: 24px;
    --timer-margin: 40px;
    --current-font: 'Overpass Mono', monospace;
}

[data-theme="dark"] {
    --bg: #000000;
    --fg: #ffffff;
}

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

body {
    background: var(--bg);
    color: var(--fg);
    height: 100vh;
    font-family: var(--current-font);
    position: relative;
    transition: background 0.4s ease, color 0.4s ease, font-family 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

button, input {
    font-family: inherit;
}

.top-left {
    position: fixed;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    height: 48px;
    z-index: 100;
}

.title-symbol {
    font-size: 32px;
    color: var(--fg);
    margin-right: 8px;
    line-height: 48px;
    transition: color 0.4s ease;
}

.title-main {
    font-size: 36px;
    color: var(--fg);
    line-height: 48px;
    transition: color 0.4s ease;
    letter-spacing: 0.3px;
}

.theme-toggle-box {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--bg);
    color: var(--fg);
    border: 2px solid var(--fg);
    cursor: pointer;
    user-select: none;
    border-radius: 0;
    transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease;
    z-index: 100;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 50;
    transition: opacity 0.5s ease, background 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 1;
}

.menu-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.menu-slider {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease;
}

.menu-slider.no-transition {
    transition: none;
}

.menu-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.menu-main {
    position: relative;
    justify-content: center;
    gap: 20px;
}

.menu-main-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 28px;
    user-select: none;
}

.font-bottom {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.font-caption {
    font-size: 16px;
    letter-spacing: 1px;
    margin-bottom: 0;
}

.font-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    user-select: none;
    margin-bottom: 0;
}

.font-label {
    min-width: 150px;
    text-align: center;
    font-weight: 500;
}

.arrow-btn {
    font-size: 36px;
    background: transparent;
    border: none;
    color: var(--fg);
    cursor: pointer;
    padding: 8px 12px;
    transition: color 0.3s ease;
}

.arrow-btn:hover {
    color: #a0a0a0;
}
[data-theme="dark"] .arrow-btn:hover {
    color: #444444;
}

.arrow-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.difficulty-label {
    min-width: 200px;
    text-align: center;
    letter-spacing: 2px;
    font-weight: 500;
}

.play-btn {
    padding: 16px 60px;
    font-size: 24px;
    background: transparent;
    border: 2px solid var(--fg);
    color: var(--fg);
    cursor: pointer;
    border-radius: 0;
    letter-spacing: 3px;
    transition: background 0.3s ease, color 0.3s ease;
    outline: none;
}

.play-btn:hover {
    background: var(--fg);
    color: var(--bg);
}

/* Word list page: stacked full-width boxes */
.menu-wordlists {
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch; /* full width */
    gap: 10px;
    padding: 80px 20px 20px 20px;
    height: 100%;
    overflow-y: auto; /* page scroll if needed */
}

.wordlist-columns {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.credits-column {
    width: 100%;
    max-width: none;
    background: var(--bg);
    border: 2px solid var(--fg);
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    max-height: 30vh; /* internal scroll */
}

.credits-column-header {
    padding: 10px 16px;
    font-size: 18px;
    text-align: center;
    border-bottom: 2px solid var(--fg);
    letter-spacing: 1px;
    flex-shrink: 0;
}

.credits-word-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    overflow-x: auto;
    flex: 1;
    min-height: 0;
    width: 100%;
}

.credits-word-list li {
    padding: 6px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
}

.total-word-count {
    font-size: 18px;
    text-align: center;
    padding: 10px;
    flex-shrink: 0;
}

.menu-credits {
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    gap: 0;
    height: 100%;
    padding-top: 60px;
    padding-bottom: 40px;
}

.credits-half {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

.credits-divider {
    width: 2px;
    background: var(--fg);
    margin: 0 20px;
    opacity: 0.5;
}

.credits-title {
    font-size: 40px;
    font-weight: 400;
    text-decoration: underline;
    margin-bottom: 15px;
}

.credits-subtitle {
    font-size: 24px;
    margin-top: 12px;
    font-weight: 400;
}

.credits-name {
    font-size: 18px;
    margin: 4px 0;
    font-weight: 400;
}

.updates-title {
    font-size: 40px;
    font-weight: 400;
    text-decoration: underline;
    margin-bottom: 15px;
}

.updates-scroll {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    text-align: left;
    padding: 10px;
}

.updates-scroll p {
    font-size: 14px;
    margin: 6px 0;
}

.menu-page-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 48px;
    background: transparent;
    border: none;
    color: var(--fg);
    cursor: pointer;
    padding: 20px;
    z-index: 55;
    transition: color 0.3s, opacity 0.3s;
}

.menu-page-arrow:hover {
    color: #a0a0a0;
}
[data-theme="dark"] .menu-page-arrow:hover {
    color: #444444;
}

.menu-page-arrow:disabled {
    opacity: 0.2;
    pointer-events: none;
}

#menuPrevPage {
    left: 10px;
}
#menuNextPage {
    right: 10px;
}

/* Game UI Layout */
.timer-bar-container {
    position: fixed;
    right: 16px;
    top: 80px;
    bottom: 40px;
    width: var(--timer-width);
    background: var(--bg);
    border: 2px solid var(--fg);
    border-radius: 0;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s ease, opacity 0.5s ease;
    left: auto;
}
.timer-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--fg);
    transition: height 0.1s linear;
}
.timer-text {
    position: fixed;
    right: 16px;
    bottom: 12px;
    font-size: 20px;
    color: var(--fg);
    z-index: 10;
    transition: color 0.4s ease, opacity 0.3s ease, opacity 0.5s ease;
    opacity: 0;
    left: auto;
}
.timer-bar-container.active,
.timer-text.active {
    opacity: 1;
}

.right-panel {
    position: fixed;
    left: 0;
    bottom: 0;
    right: calc(var(--timer-width) + var(--timer-margin));
    width: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    z-index: 10;
    transition: opacity 0.5s ease;
}

.right-box {
    width: 100%;
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    color: var(--fg);
    padding: 6px 16px;
    font-size: 14px;
    transition: background 0.4s ease, color 0.4s ease;
}

.star-box {
    padding: 10px 16px;
    border-bottom: none;
}

.best-box {
    padding: 6px 16px;
    font-size: 14px;
}

.best-icon {
    font-size: 14px;
    margin-right: 8px;
}
.best-text {
    text-align: left;
}
.star-symbol {
    font-size: 22px;
    line-height: 1;
    margin-right: 8px;
}
.star-count {
    font-size: 24px;
    line-height: 1;
    display: inline-block;
    white-space: nowrap;
}

.game-container {
    text-align: center;
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}
.hidden-game {
    opacity: 0;
    pointer-events: none;
}
.info-row {
    font-size: 18px;
    color: var(--fg);
    margin-bottom: 6px;
    opacity: 0.9;
    transition: color 0.4s ease;
}
.spell-prompt {
    font-size: 24px;
    color: var(--fg);
    margin-bottom: 20px;
    transition: color 0.4s ease;
}
.input-row {
    display: inline-block;
    position: relative;
}
.countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: var(--fg);
    pointer-events: none;
    transition: opacity 0.2s ease;
    opacity: 0;
    z-index: 7;
}
.countdown-overlay.active {
    opacity: 1;
}
.spelling-input {
    width: 100%;
    max-width: 400px;
    font-size: 36px;
    color: var(--fg);
    background: transparent;
    border: 2px solid transparent;
    outline: none;
    text-align: center;
    padding: 8px 4px;
    letter-spacing: 2px;
    transition: color 0.4s ease, border-color 0.2s, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    box-sizing: border-box;
}
.spelling-input.active {
    opacity: 1;
    pointer-events: auto;
    border-color: var(--fg);
}
.spelling-input.correct {
    border-color: #10b981;
    background: rgba(16,185,129,0.1);
}
.spelling-input.incorrect {
    border-color: #ef4444;
    background: rgba(239,68,68,0.1);
}
.spelling-input:disabled {
    pointer-events: none;
}
.repeat-btn {
    position: absolute;
    left: 100%;
    margin-left: 12px;
    top: 0;
    bottom: 0;
    width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    background: var(--bg);
    color: var(--fg);
    border: 2px solid var(--fg);
    cursor: pointer;
    user-select: none;
    border-radius: 0;
    transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    padding: 0;
    box-sizing: border-box;
}
.repeat-btn.active {
    opacity: 1;
    pointer-events: auto;
}
.repeat-btn:hover {
    background: var(--fg);
    color: var(--bg);
}
.submit-btn {
    position: absolute;
    right: 100%;
    margin-right: 12px;
    top: 0;
    bottom: 0;
    width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    background: var(--bg);
    color: var(--fg);
    border: 2px solid var(--fg);
    cursor: pointer;
    user-select: none;
    border-radius: 0;
    transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    padding: 0;
    box-sizing: border-box;
}
.submit-btn.active {
    opacity: 1;
    pointer-events: auto;
}
.submit-btn:hover {
    background: var(--fg);
    color: var(--bg);
}
.wpm-display {
    font-size: 18px;
    color: var(--fg);
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.3s ease, color 0.4s ease;
    height: 24px;
}
.wpm-display.active {
    opacity: 1;
}

/* Mobile friendly adjustments */
@media (max-width: 768px) {
    :root { --timer-margin: 30px; }
    .title-main { font-size: 28px; line-height: 40px; }
    .title-symbol { font-size: 24px; line-height: 40px; }
    .theme-toggle-box { width: 40px; height: 40px; font-size: 20px; top: 12px; right: 12px; }
    .top-left { top: 12px; left: 12px; height: 40px; }
    .menu-slide { padding: 10px; }
    .difficulty-selector { gap: 10px; font-size: 20px; }
    .difficulty-label { min-width: 140px; }
    .arrow-btn { font-size: 28px; padding: 6px 8px; }
    .play-btn { padding: 12px 30px; font-size: 20px; letter-spacing: 2px; }
    .font-bottom { bottom: 5px; }
    .font-selector { gap: 5px; font-size: 14px; }
    .font-label { min-width: 100px; }
    .menu-wordlists { padding-top: 60px; gap: 10px; }
    .wordlist-columns { gap: 10px; }
    .credits-column { max-width: none; max-height: 25vh; }
    .credits-column-header { font-size: 14px; padding: 8px; }
    .credits-word-list li { font-size: 12px; padding: 4px 8px; }
    .menu-credits { padding-top: 60px; padding-bottom: 20px; flex-direction: column; gap: 0; }
    .credits-half { padding: 10px; }
    .credits-title, .updates-title { font-size: 32px; }
    .credits-subtitle { font-size: 20px; }
    .credits-name { font-size: 16px; }
    .credits-divider { width: 100%; height: 2px; margin: 10px 0; }
    .star-count { font-size: 20px; }
    .timer-bar-container { width: 18px; right: 8px; top: 60px; bottom: 30px; }
    .timer-text { right: 8px; bottom: 8px; font-size: 16px; }
    .right-panel { right: 36px; }
    .spelling-input { max-width: 280px; font-size: 28px; padding: 6px 2px; }
    .submit-btn, .repeat-btn { width: 40px; font-size: 28px; }
    .info-row { font-size: 16px; }
    .spell-prompt { font-size: 20px; margin-bottom: 15px; }
    .wpm-display { font-size: 16px; }
    .menu-page-arrow { font-size: 36px; padding: 10px; }
}
@media (max-width: 480px) {
    .difficulty-selector { gap: 5px; font-size: 16px; }
    .difficulty-label { min-width: 100px; }
    .arrow-btn { font-size: 24px; }
    .play-btn { padding: 10px 20px; font-size: 18px; }
    .font-bottom { bottom: 2px; }
    .spelling-input { max-width: 200px; font-size: 24px; }
    .submit-btn, .repeat-btn { width: 36px; font-size: 24px; }
}