/* Word Quest — presentation only.
 *
 * Lifted verbatim out of index.html when the game was split into the house
 * layout (index.html + style.css + data.js + app.js). Not one declaration was
 * changed: the split is a refactor, and a refactor that also tidies is a
 * refactor nobody can review.
 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    color: #333;
}

/* The card is a column the height of the window: header and footer
   stay put, and .content is the only thing that scrolls. Without this
   the footer sat below the fold on a short screen. */
.container {
    max-width: 900px;
    width: 100%;
    /* height, not max-height: .modal is absolute against .content, and
       a card sized by its contents can leave that region too short to
       hold one. See yahtzee. */
    height: 100%;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 10px;
    text-align: center;
}

.header h1 {
    font-size: 1.6em;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
/* Three 44px buttons plus padding is 152px of a 320px phone, so the
   TITLE is what shrinks — never a control. */
.hdr-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.hdr-btn {
    flex: 0 0 auto; width: 44px; height: 44px; border: 0; border-radius: 12px;
    background: rgba(255,255,255,.18); color: #fff; font-size: 19px; cursor: pointer;
}
.hdr-btn:active { background: rgba(255,255,255,.32); }

.header .tagline {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    flex-wrap: wrap;
    gap: 10px;
}

.stat {
    text-align: center;
    flex: 1;
    min-width: 80px;
}

.stat-label {
    font-size: 0.8em;
    color: #6c757d;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

/* Main Content */
/* R-C2: the modals are absolute against THIS, so nothing covers the
   header and the 🏠 in it. */
.content {
    padding: 30px 20px;
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Menu Screen */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center; min-height: 44px;}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white; min-height: 44px;}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white; min-height: 44px;}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-success {
    background: #28a745;
    color: white; min-height: 44px;}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

/* Setup Screen */
.setup-grid {
    display: grid;
    gap: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.setup-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    max-height: 500px;
    overflow-y: auto;
}

.setup-section h3 {
    margin-bottom: 15px;
    color: #667eea;
    position: sticky;
    top: 0;
    background: #f8f9fa;
    padding-bottom: 10px;
    z-index: 1;
}

.theme-selector, .difficulty-selector, .category-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.option-btn {
    padding: 15px;
    border: 3px solid #dee2e6;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    text-align: center;
}

.option-btn:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.option-btn.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

/* Game Screen */
.theme-visualization {
    min-height: 200px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    text-align: center;
    position: relative;
}

.theme-character {
    font-size: 4em;
    margin-bottom: 10px;
}

.theme-progress {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 120px;
    margin-top: 20px;
}

.progress-step {
    width: 40px;
    background: #dee2e6;
    border-radius: 5px 5px 0 0;
    transition: all 0.5s;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 5px;
    font-size: 1.5em;
}

.progress-step.completed {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.progress-step.current {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Word Display */
.word-display {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 30px 0;
    min-height: 80px;
}

.letter-slot {
    width: 50px;
    height: 60px;
    border: 3px solid #667eea;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    font-weight: bold;
    background: white;
    transition: all 0.3s;
}

.letter-slot.revealed {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    transform: rotateY(360deg);
}

.letter-slot.space {
    border: none;
    width: 20px;
}

/* Hint Display */
.hint-display {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #000;
    padding: 15px;
    border-radius: 10px;
    margin: 20px auto;
    text-align: center;
    font-weight: bold;
    font-size: 1.1em;
    max-width: 600px;
    box-shadow: 0 3px 10px rgba(255, 193, 7, 0.3);
    animation: slideIn 0.3s ease-out;
}

.hint-display .hint-icon {
    font-size: 1.5em;
    margin-right: 10px;
}

.hint-display .hint-text {
    display: inline-block;
}

/* Keyboard */
.keyboard {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    max-width: 700px;
    margin: 20px auto;
}

.key {
    aspect-ratio: 1;           /* min-height below is the pre-existing fallback */
    border: 2px solid #dee2e6;
    background: white;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}

.key:hover:not(.disabled) {
    background: #f8f9fa;
    transform: scale(1.05);
}

.key.correct {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.key.incorrect {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.key.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.hint-btn {
    background: #ffc107;
    color: #000;
}

.hint-btn:hover {
    background: #e0a800;
}

.hint-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* ---- the hint control (docs/offline-pwa.md R-C16) -------------------------
ONE bulb, and the count as an OVERLAID badge. Absolutely positioned inside
`.bulb`, so 10 -> 9 -> 8 can never change the button's width and shove
whatever sits beside it — which is exactly what the inline count did on a
phone. The number is always how many are LEFT, it is shown at 1 and at 0,
and at 0 the button is disabled with the badge still on it, because a
control that vanishes teaches a child nothing about why.
The badge is dark with a pale ring at every game, on purpose: the games run
from near-black to amber to a light theme, and a dark pill with a light halo
is the one combination that reads on all of them. */
.hintBtn { position: relative; overflow: visible; }
.hintBtn .bulb { position: relative; display: inline-block; line-height: 1; }
.hintBtn .hintN {
position: absolute; right: -9px; bottom: -6px;
min-width: 16px; height: 16px; padding: 0 3px; border-radius: 999px;
background: #0f172a; color: #f8fafc; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .6);
font: 800 10px/16px inherit; letter-spacing: 0; pointer-events: none;
}
.hintBtn:disabled .hintN, .hintBtn[disabled] .hintN { background: #64748b; }
/* `wide` = the bulb is followed by a WORD. The badge hangs 9px past the
bulb, so without this it sits on the first letter of the label. */
.hintBtn.wide .bulb { margin-right: 11px; }

/* Results Screen */
.results {
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.results h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #667eea;
}

.results .word-reveal {
    font-size: 2em;
    font-weight: bold;
    margin: 20px 0;
    color: #28a745;
}

.results .definition {
    font-size: 1.1em;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    text-align: left;
}

.results .stars {
    font-size: 3em;
    margin: 20px 0;
}

.results .performance {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.performance-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.performance-label {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 5px;
}

.performance-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #667eea;
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.achievement {
    padding: 15px;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    text-align: center;
    transition: all 0.3s;
}

.achievement.unlocked {
    border-color: #28a745;
    background: #d4edda;
}

.achievement.locked {
    opacity: 0.5;
}

.achievement-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.achievement-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.achievement-desc {
    font-size: 0.9em;
    color: #6c757d;
}

.achievement-progress {
    margin-top: 10px;
    height: 10px;
    background: #dee2e6;
    border-radius: 5px;
    overflow: hidden;
}

.achievement-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

/* Settings */
.settings-grid {
    display: grid;
    gap: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.setting-label {
    font-weight: bold;
}

.toggle {
    position: relative;
    width: 60px;
    height: 30px;
    background: #dee2e6;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.toggle.active {
    background: #28a745;
}

.toggle-slider {
    position: absolute;
    width: 26px;
    height: 26px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
}

.toggle.active .toggle-slider {
    left: 32px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 300px;
}

.slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #dee2e6;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

/* Tutorial */
.tutorial-content {
    max-width: 600px;
    margin: 0 auto;
}

.tutorial-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.tutorial-section h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.tutorial-section ul {
    margin-left: 20px;
}

.tutorial-section li {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Modal */
.modal {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    max-height: 80dvh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #6c757d;
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }

    .theme-selector, .difficulty-selector, .category-selector {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .keyboard {
        grid-template-columns: repeat(7, 1fr);
        gap: 3px;
    }

    .key {
        font-size: 1em;
        /* #279: NOT 40px. A media query that shrinks a tap target on a small
           screen has it exactly backwards — the 44px floor matters most on the
           smallest phone, which is the whole reason the floor exists. */
        min-height: 44px;
    }

    .letter-slot {
        width: 40px;
        height: 50px;
        font-size: 1.5em;
    }

    .theme-character {
        font-size: 3em;
    }

    .btn {
        padding: 12px 20px;
        font-size: 1em; min-height: 44px;}
}

@media (max-width: 480px) {
    .stats-bar {
        padding: 10px;
    }

    .stat {
        min-width: 60px;
    }

    .stat-value {
        font-size: 1.2em;
    }

    .theme-selector, .difficulty-selector, .category-selector {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .option-btn {
        padding: 10px;
        font-size: 0.9em;
    }

    .keyboard {
        gap: 2px;
    }

    .key {
        font-size: 0.9em;
    }

    .letter-slot {
        width: 35px;
        height: 45px;
        font-size: 1.3em;
    }
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen.active {
    animation: slideIn 0.3s ease-out;
}

/* Accessibility */

*:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* ---------- toasts ----------
   alert() is a modal system dialog: it blocks the loop, steals focus,
   and on an installed PWA it renders as an OS panel. An achievement is
   a reward — it must not arrive through the same channel as an error. */
.toast-host {
    position: fixed; left: 50%; transform: translateX(-50%);
    top: calc(10px + env(safe-area-inset-top));
    z-index: 9000; display: flex; flex-direction: column; gap: 8px;
    align-items: center; pointer-events: none;
    width: max-content; max-width: calc(100vw - 24px);
}
.toast {
    pointer-events: auto; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: 14px;
    background: #2b2b3a; color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    font-size: 15px; line-height: 1.35; font-weight: 600;
    max-width: calc(100vw - 24px); box-sizing: border-box;
    opacity: 0; transform: translateY(-12px);
    transition: opacity .22s ease, transform .22s ease;
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast .toast-icon { font-size: 26px; line-height: 1; flex: 0 0 auto; }
.toast .toast-body { min-width: 0; }
.toast .toast-title { font-size: 16px; font-weight: 800; }
.toast .toast-sub { font-weight: 500; opacity: .85; font-size: 13px; }
/* a reward should look like one */
.toast.achievement {
    background: linear-gradient(135deg, #f6b93b 0%, #e58e26 100%);
    color: #3a2400;
}
.toast.achievement .toast-sub { opacity: .8; }
@media (prefers-reduced-motion: reduce) {
    .toast { transition: none; opacity: 1; transform: none; }
}

/* docs/offline-pwa.md R-C15 — the PAGE must never scroll.
The product is a fixed frame: header, a named scroll region, footer. If the
document scrolls too, the header scrolls away, the version chip drifts, and
a drag that reaches the end of the inner region chains out to the page and
drags the whole board under the player's thumb. That is the "double scroll".
`overflow: hidden` stops the second scrollbar; `overscroll-behavior: none`
stops the chaining, which is the half that is invisible on a desktop mouse
and obvious on a phone. */
html, body {
overflow: hidden;
overscroll-behavior: none;
}
