/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    will-change: transform, opacity;
}

.screen.hidden {
    display: none !important;
    opacity: 0;
}

.screen.active {
    opacity: 1;
    animation: fadeIn 0.3s ease-out;
}

/* Difficulty Screen */
#difficulty-screen {
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

/* Ensure content doesn't get clipped at the top when scrolling */
@media (max-height: 600px) {
    #difficulty-screen {
        justify-content: flex-start;
        padding-top: 40px;
    }
}

#difficulty-screen h2 {
    margin-bottom: 1.5rem;
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 2px 0 rgba(0,0,0,0.3);
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.secondary-group {
    display: flex;
    gap: 12px;
    width: 100%;
}

.secondary-group button {
    flex: 1;
    padding: 12px 8px;
    font-size: 1rem;
    white-space: nowrap;
}

/* High Scores */
#high-scores-screen { align-items: center; width: 100%; }
#high-scores-screen h2 { margin-bottom: 1.5rem; font-size: 2rem; font-weight: 800; color: var(--text-primary); text-transform: uppercase; }

.high-scores-container {
    width: 100%;
    max-width: 400px;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    border: 2px solid var(--surface-border);
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
    overflow: hidden;
    margin-bottom: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.score-tabs { 
    display: flex; 
    background: var(--surface-border); 
    padding: 4px;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
    opacity: 1;
    transition: all 0.2s;
}

.tab-btn:hover { background: rgba(255, 255, 255, 0.05); }

.tab-btn.active {
    background: var(--surface-color);
    color: var(--accent-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.scores-list { padding: 0; overflow-y: auto; flex: 1; }

.score-entry {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--surface-border);
    font-size: 1.1rem;
    font-weight: 600;
}
.score-entry:last-child { border-bottom: none; }
.score-entry .rank { color: var(--text-secondary); width: 30px; font-weight: 800; }
.score-entry .score-val { font-weight: 800; color: var(--accent-color); }
.score-entry .date { font-size: 0.8rem; color: var(--text-secondary); margin-left: auto; padding-left: 10px; display: flex; align-items: center; }

.screen-actions { width: 100%; max-width: 320px; }
.screen-actions button { width: 100%; }
.empty-scores { padding: 40px; text-align: center; color: var(--text-secondary); font-style: italic; }

/* Lexicon Screen */
#lexicon-screen {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#lexicon-screen h2 {
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
}

.lexicon-header {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.lexicon-container {
    width: 100%;
    max-width: 600px;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    border: 2px solid var(--surface-border);
    overflow: hidden;
    margin-bottom: 1rem;
}

.lexicon-tabs {
    display: flex;
    overflow-x: auto;
    background: var(--surface-border);
    padding: 4px;
    gap: 4px;
    scrollbar-width: none;
}
.lexicon-tabs.hidden {
    display: none !important;
}

.lexicon-current-letter {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    padding: 8px 16px;
}

.lexicon-tab-btn {
    min-width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
}

.lexicon-tab-btn.active {
    background: var(--surface-color);
    color: var(--accent-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.lexicon-grid {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    align-content: flex-start;
}

.lexicon-word {
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    padding: 8px 4px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: default;
    user-select: none;
}

.lexicon-word.found {
    background: var(--accent-light);
    color: var(--accent-dark);
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.lexicon-word.missing {
    opacity: 0.3;
    letter-spacing: 2px;
    font-size: 0.6rem;
}

.lexicon-word.found:hover {
    transform: translateY(-1px);
}

/* New Lexicon Grid View Styles */
.lexicon-grid.alphabet-view {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 16px;
}

.lexicon-letter-card {
    background: var(--surface-color);
    border: 2px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    aspect-ratio: 1;
    user-select: none;
}

.lexicon-letter-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.lexicon-letter-card .letter-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.lexicon-letter-card .letter-large {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.lexicon-letter-card .letter-pct {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-color);
    opacity: 0.8;
}

.lexicon-letter-card .letter-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    line-height: 1.2;
}

.stat-val {
    color: var(--text-primary);
    font-weight: 700;
}

.progress-bar {
    height: 4px;
    background: rgba(0,0,0,0.2);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

.lexicon-letter-card.disabled {
    opacity: 0.5;
    cursor: default;
    background: var(--surface-border);
    border-color: transparent;
}

.lexicon-letter-card.disabled .progress-bar {
    display: none;
}

.lexicon-letter-card.disabled .stat-val {
    opacity: 0.5;
}

/* Retro Theme Redaction Style */
[data-theme="retro"] .lexicon-letter-card.disabled {
    opacity: 1;
    background: transparent;
    border: 1px dashed var(--surface-border);
    position: relative;
}

[data-theme="retro"] .lexicon-letter-card.disabled .letter-large {
    opacity: 0.3;
}

[data-theme="retro"] .lexicon-letter-card.disabled .letter-info,
[data-theme="retro"] .lexicon-letter-card.disabled .letter-pct {
    opacity: 0.1;
}

[data-theme="retro"] .lexicon-letter-card.disabled::after {
    content: "REDACTED";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--bg-color);
    background: var(--accent-color);
    padding: 4px 8px;
    letter-spacing: 2px;
    pointer-events: none;
    box-shadow: 0 0 8px var(--accent-color);
    border: 1px solid var(--bg-color);
}

.lexicon-letter-card.disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: transparent;
}

.lexicon-back-btn {
    margin-top: 12px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--accent-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.lexicon-back-btn:hover {
    background: var(--accent-dark);
}

.loading, .empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Theme Selector */
.theme-selector {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
    margin: 8px 0;
}

.theme-btn {
    /* Reset flex:1 so they behave like fixed tiles */
    flex: none;
    /* Override tile font size if needed, but 1.8rem is fine for emoji */
    opacity: 0.7;
    transition: all 0.2s;
}

.theme-btn:hover {
    transform: translateY(-2px);
    opacity: 1;
}

.theme-btn.active {
    opacity: 1;
    transform: translateY(2px);
    /* Add a glow or border to indicate selection without destroying the theme look */
    box-shadow: 0 0 0 2px var(--accent-color), 0 0 15px var(--accent-color);
    z-index: 1;
}

/* Specific tweaks for active state if needed */
.theme-btn[data-set-theme="retro"].active {
    box-shadow: 0 0 0 2px #33ff33, 0 0 15px #33ff33;
}

