/* ============================================================
   GEOGRAPHY QUIZ — "The Bound Atlas"
   Cover (start screen): petrol cloth, brass-stamped type, graticule.
   Plates (quiz screens): paper landmasses on chart-sea, ink rules.
   Type: Besley (display) · Archivo (UI) · system mono (data).
   ============================================================ */

/* ----- Tokens ------------------------------------------------
   Map palette — single source of truth for country/state colors.
   The SVG maps ship their own embedded .land stylesheet; the rules
   in the MAP COUNTRIES section override it by specificity. */
:root {
    /* palette */
    --ink: #253c46;
    --ink-soft: #5d7078;
    --ink-faint: rgba(37, 60, 70, 0.16);
    --cover: #1c3138;
    --cover-deep: #13242a;
    --sea: #d2e0e3;
    --paper: #efe6d0;
    --paper-bright: #f9f4e7;
    --brass: #c09a55;
    --brass-bright: #d6b471;
    --brass-soft: rgba(192, 154, 85, 0.55);
    --leaf: #4d8a62;
    --leaf-deep: #2f6644;
    --leaf-tint: #e5edd9;
    --carmine: #be4b33;
    --carmine-deep: #8f3b28;
    --carmine-tint: #f5e0d7;
    --amber: #e2a63d;

    /* type */
    --font-display: 'Besley', 'Iowan Old Style', Georgia, serif;
    --font-ui: 'Archivo', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    /* layout */
    --topbar-h: 64px;

    /* map contract (names used by the design brief / JS-adjacent rules) */
    --country-fill: #ece2c8;
    --country-stroke: #6d7f82;
    --country-stroke-width: 0.5;
    --country-hover-fill: #f0d69b;
    --state-correct: #4d8a62;
    --state-incorrect: #be4b33;
    --state-hint: #e2a63d;
    --micro-hit-fill: rgba(192, 154, 85, 0.18);
    --micro-hit-stroke: #a8823f;
}

/* ----- Base --------------------------------------------------- */

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

/* The design is a fixed light "atlas" palette; opt out of Chrome's
   forced dark mode, which otherwise inverts the paper surfaces. */
:root {
    color-scheme: only light;
}

/* Sea, not cover: the quiz screens are fixed panels and any gap between
   them (e.g. below the top bar) should read as more sea, not a dark seam. */
body {
    font-family: var(--font-ui);
    background-color: var(--sea);
    color: var(--ink);
    line-height: 1.5;
}

.container {
    width: 100%;
}

button {
    font-family: inherit;
}

input,
select {
    font-family: inherit;
}

.hidden {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

/* ============================================================
   COVER — start screen
   ============================================================ */

header {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    position: relative;
    background-color: var(--cover);
    background-image:
        radial-gradient(ellipse 120% 90% at 50% -10%, rgba(214, 180, 113, 0.07), transparent 60%),
        linear-gradient(rgba(249, 244, 231, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(249, 244, 231, 0.045) 1px, transparent 1px),
        linear-gradient(var(--cover-deep), var(--cover) 30%, var(--cover) 70%, var(--cover-deep));
    background-size: auto, 96px 96px, 96px 96px, auto;
}

/* stamped double-rule frame */
header::before {
    content: '';
    position: absolute;
    inset: 18px;
    border: 1px solid var(--brass-soft);
    outline: 1px solid rgba(192, 154, 85, 0.22);
    outline-offset: 5px;
    pointer-events: none;
}

.cover-eyebrow {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--brass);
    text-align: center;
    margin-bottom: 22px;
    animation: coverRise 0.55s ease-out both;
}

h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(44px, 7vw, 76px);
    line-height: 1.05;
    letter-spacing: 0.01em;
    color: var(--brass-bright);
    text-align: center;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    animation: coverRise 0.55s ease-out 0.06s both;
}

.cover-rule {
    display: flex;
    align-items: center;
    gap: 14px;
    width: min(360px, 60vw);
    margin: 26px 0 18px;
    color: var(--brass);
    font-size: 9px;
    animation: coverRise 0.55s ease-out 0.12s both;
}

.cover-rule::before,
.cover-rule::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--brass-soft);
}

.header-subtitle {
    color: rgba(249, 244, 231, 0.72);
    text-align: center;
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 44px;
    animation: coverRise 0.55s ease-out 0.18s both;
}

/* tipped-in plate card holding the controls */
.header-content {
    width: min(660px, 100%);
    animation: coverRise 0.55s ease-out 0.24s both;
}

.start-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 18px;
    background: var(--paper-bright);
    border: 1px solid rgba(19, 36, 42, 0.6);
    box-shadow:
        inset 0 0 0 1px rgba(37, 60, 70, 0.12),
        inset 0 0 0 5px var(--paper-bright),
        inset 0 0 0 6px rgba(37, 60, 70, 0.25),
        0 18px 40px rgba(0, 0, 0, 0.35);
    padding: 30px 32px 28px;
    border-radius: 3px;
}

.select-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.select-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--ink-soft);
}

.region-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    padding: 11px 36px 11px 12px;
    border: 1px solid rgba(37, 60, 70, 0.4);
    border-radius: 3px;
    font-size: 15px;
    font-weight: 500;
    background-color: var(--paper-bright);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23253c46' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.region-select:hover {
    border-color: var(--ink);
}

.region-select:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgba(192, 154, 85, 0.28);
}

.btn.start-btn {
    grid-column: 1 / -1;
    margin-top: 6px;
    padding: 15px 20px;
    border: 1px solid rgba(19, 36, 42, 0.55);
    border-radius: 3px;
    background: linear-gradient(var(--brass-bright), var(--brass));
    color: var(--cover-deep);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 2px 0 rgba(19, 36, 42, 0.35);
    transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn.start-btn:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 3px 0 rgba(19, 36, 42, 0.35);
}

.btn.start-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 rgba(19, 36, 42, 0.35);
}

@keyframes coverRise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   TOP BAR — quiz chrome
   ============================================================ */

.compact-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--paper-bright);
    border-bottom: 1px solid rgba(37, 60, 70, 0.35);
    box-shadow: 0 1px 0 rgba(249, 244, 231, 0.4), 0 2px 10px rgba(19, 36, 42, 0.12);
    z-index: 1000;
}

.timer-bar-compact {
    height: 4px;
    width: 100%;
    background-color: var(--ink-faint);
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--carmine), var(--amber) 45%, var(--leaf));
    transition: width 0.1s linear;
}

.quiz-info-bar {
    background: var(--paper-bright);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    gap: 15px;
    flex-wrap: wrap;
}

.question-compact {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 200px;
}

.question-compact #questionLabel {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--ink-soft);
}

.question-compact .target-text {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 600;
    font-size: 21px;
    line-height: 1.2;
    color: var(--carmine);
}

.stats-compact {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    white-space: nowrap;
}

.stat-item strong {
    color: var(--ink);
    font-weight: 700;
}

.stat-divider {
    color: rgba(37, 60, 70, 0.3);
    font-weight: 300;
}

/* ----- Inline answer input (identify modes) ----- */

.answer-input-area-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    margin-top: 2px;
}

.answer-input-compact {
    padding: 8px 12px;
    font-size: 15px;
    border: 1px solid rgba(37, 60, 70, 0.45);
    border-radius: 3px;
    background: var(--paper-bright);
    color: var(--ink);
    flex: 1;
    min-width: 150px;
    max-width: 320px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.answer-input-compact::placeholder {
    color: rgba(93, 112, 120, 0.7);
}

.answer-input-compact:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgba(192, 154, 85, 0.25);
}

.btn-compact {
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.btn-compact:hover {
    filter: brightness(1.05);
}

.btn-compact:active {
    transform: translateY(1px);
}

.btn-compact.submit-btn {
    background: var(--ink);
    border-color: var(--cover-deep);
    color: var(--paper-bright);
}

.btn-compact:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.answer-feedback-compact {
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.answer-feedback-compact.correct {
    padding: 5px 12px;
    background-color: var(--leaf-tint);
    color: var(--leaf-deep);
    border: 1px solid rgba(77, 138, 98, 0.45);
}

.answer-feedback-compact.incorrect {
    padding: 5px 12px;
    background-color: var(--carmine-tint);
    color: var(--carmine-deep);
    border: 1px solid rgba(190, 75, 51, 0.4);
}

/* ----- Header feedback strip ----- */

.header-feedback {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    padding: 7px 15px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    z-index: 999;
    pointer-events: none;
    animation: feedbackSlideIn 0.15s ease-out;
    transition: opacity 0.3s ease;
}

.header-feedback.correct {
    background: rgba(229, 237, 217, 0.97);
    color: var(--leaf-deep);
    border-bottom: 2px solid var(--leaf);
}

.header-feedback.incorrect {
    background: rgba(245, 224, 215, 0.97);
    color: var(--carmine-deep);
    border-bottom: 2px solid var(--carmine);
}

.header-feedback.fade-out {
    opacity: 0;
}

@keyframes feedbackSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   MAP PLATE
   ============================================================ */

.quiz-main {
    width: 100%;
    position: relative;
}

.map-wrapper-fullscreen {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--sea);
    background-image:
        linear-gradient(rgba(37, 60, 70, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 60, 70, 0.05) 1px, transparent 1px);
    background-size: 88px 88px;
    overflow: hidden;
}

.map-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.map-container svg {
    max-width: 100%;
    height: auto;
    background-color: transparent;
    cursor: grab;
    position: relative;
    z-index: 1;
}

.map-container svg:active {
    cursor: grabbing;
}

.quiz-main .map-container {
    width: 100%;
    height: 100%;
}

/* ----- Zoom controls ----- */

.quiz-main .zoom-controls {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 1000;
}

.zoom-btn {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(37, 60, 70, 0.5);
    background-color: var(--paper-bright);
    color: var(--ink);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(19, 36, 42, 0.18);
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.zoom-btn:hover {
    background-color: var(--paper);
}

.zoom-btn:active {
    transform: scale(0.95);
}

/* ===== MAP COUNTRIES =====
   svg + class selectors out-rank the .land rules embedded in the SVG files.
   State rules below the base rule win on document order — keep that order. */

svg .country, svg .land {
    fill: var(--country-fill);
    stroke: var(--country-stroke);
    stroke-width: var(--country-stroke-width);
    cursor: pointer;
    transition: fill 0.2s ease;
    stroke-opacity: 1;
    fill-opacity: 1;
}

/* Non-playable territories: muted, inert */
svg .land:not(.country) {
    fill: #dcd7c6;
    stroke: #94a0a2;
    cursor: default;
}

/* Applied by JS while hovering a micro-state's enlarged hit area */
svg .country.micro-hover {
    fill: var(--country-hover-fill);
}

svg .country:hover {
    fill: var(--country-hover-fill);
}

svg .country.correct, svg .land.correct {
    fill: var(--state-correct);
    animation: statePulse 0.5s ease;
}

svg .country.incorrect, svg .land.incorrect {
    fill: var(--state-incorrect);
    animation: shake 0.5s ease;
}

/* Hint / "here it is" reveal: throb around the shape's own center and
   glow, so even micro-countries pull the eye to the right map region. */
svg .country.hint, svg .land.hint {
    fill: var(--state-hint);
    transform-box: fill-box;
    transform-origin: center;
    animation: hintReveal 1.1s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(226, 166, 61, 0.9))
            drop-shadow(0 0 14px rgba(226, 166, 61, 0.55));
}

/* --hint-scale is set per-country by quiz.js so small shapes visibly grow
   (~12px on screen) while large ones only breathe. */
@keyframes hintReveal {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(var(--hint-scale, 1.14)); }
}

svg .country.completed, svg .land.completed {
    fill: var(--state-correct);
    opacity: 0.3;
}

/* Pulsing highlight for the target country in identify modes */
.country.highlighted {
    fill: var(--state-correct);
    animation: statePulse 1.5s ease-in-out infinite;
}

@keyframes statePulse {
    0%, 100% { fill-opacity: 0.7; }
    50%      { fill-opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-5px); }
    75%      { transform: translateX(5px); }
}

/* Enlarged click targets for micro-states (circles added by JS) */
.micro-state-hit-area {
    fill: var(--micro-hit-fill);
    stroke: var(--micro-hit-stroke);
    stroke-width: 1;
    cursor: pointer;
}

/* Micro-state hit circle during a skip reveal — beacon for the tiny shape */
.micro-state-hit-area.hint {
    fill: rgba(226, 166, 61, 0.5);
    stroke: var(--state-hint);
    stroke-width: 3;
    animation: pulseMicro 1.1s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(226, 166, 61, 0.9));
}

/* Highlighted micro-state hit areas — very visible in identify mode */
.micro-state-hit-area.highlighted-micro {
    fill: rgba(77, 138, 98, 0.6);
    stroke: var(--state-correct);
    stroke-width: 3;
    r: 15;
    animation: pulseMicro 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(77, 138, 98, 0.8));
}

@keyframes pulseMicro {
    0%, 100% { r: 12; fill-opacity: 0.5; }
    50%      { r: 16; fill-opacity: 0.8; }
}

/* ----- Floating controls (legend toolbar) ----- */

.floating-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    z-index: 900;
    padding: 6px;
    background: var(--paper-bright);
    border: 1px solid rgba(37, 60, 70, 0.4);
    border-radius: 3px;
    box-shadow: 0 4px 14px rgba(19, 36, 42, 0.22);
}

.btn-floating {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border: none;
    border-radius: 2px;
    background: transparent;
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease;
}

.btn-floating:hover {
    background-color: rgba(37, 60, 70, 0.08);
}

/* map-legend markers */
.btn-floating::before {
    content: '';
    width: 9px;
    height: 9px;
    flex: none;
}

.btn-floating.hint-btn::before {
    border-radius: 50%;
    background: var(--amber);
    border: 1px solid rgba(37, 60, 70, 0.4);
}

.btn-floating.skip-btn::before {
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--ink-soft);
}

.btn-floating.new-quiz-btn::before {
    background: var(--ink);
}

/* ============================================================
   LETTER GAME
   ============================================================ */

.letter-game-area {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--sea);
    background-image:
        linear-gradient(rgba(37, 60, 70, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 60, 70, 0.05) 1px, transparent 1px);
    background-size: 88px 88px;
    overflow-y: auto;
    padding: 28px 24px 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

/* Ghost letter watermark — the current letter, set by quiz.js as
   data-letter, looms in the sea behind the whole game area. */
.letter-game-area::before {
    content: attr(data-letter);
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: min(58vh, 34vw);
    line-height: 1;
    color: rgba(37, 60, 70, 0.06);
    pointer-events: none;
    user-select: none;
}

.letter-game-area > * {
    position: relative;
    z-index: 1;
}

/* Gazetteer plate */
.letter-hero {
    text-align: center;
    background: var(--paper-bright);
    border: 1px solid rgba(37, 60, 70, 0.45);
    outline: 1px solid rgba(37, 60, 70, 0.2);
    outline-offset: 3px;
    border-radius: 3px;
    padding: 22px 40px 20px;
    min-width: min(460px, 100%);
    box-shadow: 0 8px 24px rgba(19, 36, 42, 0.15);
}

.letter-eyebrow {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--brass);
    margin-bottom: 4px;
}

.big-letter {
    display: flex;
    align-items: center;
    gap: 20px;
    font-family: var(--font-display);
    font-size: 92px;
    font-weight: 800;
    line-height: 1;
    color: var(--brass);
    text-shadow: 0 1px 0 rgba(37, 60, 70, 0.25);
    margin-bottom: 8px;
}

/* plate-heading hairlines flanking the letter */
.big-letter::before,
.big-letter::after {
    content: '';
    flex: 1;
    height: 1px;
    min-width: 30px;
    background: rgba(37, 60, 70, 0.25);
}

.letter-subtitle {
    font-size: 14px;
    color: var(--ink-soft);
    margin-bottom: 12px;
}

.letter-progress-track {
    height: 4px;
    max-width: 250px;
    margin: 0 auto 10px;
    background: var(--ink-faint);
    border-radius: 2px;
    overflow: hidden;
}

.letter-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--leaf), var(--brass));
    border-radius: 2px;
    transition: width 0.35s ease;
}

.letter-progress-text {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--ink);
}

.letter-progress-text span {
    color: var(--leaf-deep);
}

.letter-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    max-width: 560px;
    flex-wrap: wrap;
}

.letter-input-row .answer-input-compact {
    flex: 1;
    font-size: 16px;
    min-width: 180px;
    max-width: none;
}

.btn-compact.hint-btn {
    background: transparent;
    border-color: rgba(37, 60, 70, 0.45);
    color: var(--ink);
}

.btn-compact.hint-btn:hover:not(:disabled) {
    background: rgba(226, 166, 61, 0.18);
    border-color: var(--amber);
}

.btn-compact.give-up-btn {
    background: transparent;
    border-color: rgba(190, 75, 51, 0.5);
    color: var(--carmine-deep);
}

.btn-compact.give-up-btn:hover:not(:disabled) {
    background: var(--carmine-tint);
}

.letter-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 760px;
}

/* ----- Letter game world map: fills in as countries are named ----- */

.btn-compact.map-toggle-btn {
    background: transparent;
    border-color: rgba(37, 60, 70, 0.45);
    color: var(--ink);
}

.btn-compact.map-toggle-btn:hover {
    background: rgba(37, 60, 70, 0.07);
}

.letter-map-wrap {
    width: 100%;
    max-width: 860px;
}

.letter-map-container svg {
    display: block;
    width: 100%;
    height: auto;
}

/* Countries start muted (same treatment as non-playable territories) and
   turn leaf green when named. Progress display only — not clickable. */
.letter-map-container svg .land {
    pointer-events: none;
}

.letter-map-container svg .land.found {
    fill: var(--leaf);
    fill-opacity: 0.9;
}

.letter-map-container svg .land.missed {
    fill: var(--carmine);
    fill-opacity: 0.5;
}

/* fixed-px glow: even a one-pixel island announces where it just lit up */
.letter-map-container svg .land.just-found {
    filter: drop-shadow(0 0 5px rgba(77, 138, 98, 0.95))
            drop-shadow(0 0 12px rgba(77, 138, 98, 0.6));
}

/* Checklist entries styled like gazetteer index lines: paper cards
   with a colored spine rather than tinted pills. */
.letter-checklist-item {
    padding: 8px 12px;
    border-radius: 2px;
    font-size: 13.5px;
    font-weight: 600;
    background: var(--paper-bright);
    border: 1px solid rgba(37, 60, 70, 0.2);
    box-shadow: 0 1px 3px rgba(19, 36, 42, 0.08);
    animation: fadeInUp 0.3s ease-out;
}

.letter-checklist-item.found {
    border-left: 3px solid var(--leaf);
    color: var(--ink);
}

.letter-checklist-item.missed {
    border-left: 3px solid var(--carmine);
    color: var(--carmine-deep);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   COMPLETION PLATE (modal)
   ============================================================ */

.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--paper-bright);
    padding: 30px;
    border-radius: 3px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
    font-size: 1.2em;
    z-index: 9999;
}

.completion-modal {
    background: rgba(16, 28, 33, 0.6);
    backdrop-filter: blur(6px);
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.completion-card {
    background: var(--paper-bright);
    border: 1px solid rgba(37, 60, 70, 0.55);
    outline: 1px solid rgba(37, 60, 70, 0.25);
    outline-offset: 4px;
    padding: 40px 48px;
    border-radius: 3px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    text-align: center;
    max-width: 500px;
    width: 90%;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.completion-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    border: 1px solid rgba(37, 60, 70, 0.35);
    border-radius: 50%;
    background: rgba(210, 224, 227, 0.5);
}

.completion-title {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 8px;
}

.completion-subtitle {
    font-size: 16px;
    color: var(--ink-soft);
    margin: 0 0 28px;
    font-weight: 400;
}

.completion-stats {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-bottom: 30px;
}

.stat-badge {
    background: var(--paper);
    border: 1px solid rgba(37, 60, 70, 0.25);
    border-top: 2px solid var(--brass);
    padding: 16px 26px 14px;
    border-radius: 3px;
    min-width: 120px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--ink);
    margin-bottom: 4px;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 600;
}

.completion-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.completion-btn {
    padding: 12px 26px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.completion-btn:active {
    transform: translateY(1px);
}

.completion-btn.primary {
    background: linear-gradient(var(--brass-bright), var(--brass));
    border: 1px solid rgba(19, 36, 42, 0.5);
    color: var(--cover-deep);
    box-shadow: 0 2px 0 rgba(19, 36, 42, 0.3);
}

.completion-btn.primary:hover {
    filter: brightness(1.06);
}

.completion-btn.secondary {
    background: transparent;
    border: 1px solid rgba(37, 60, 70, 0.5);
    color: var(--ink);
}

.completion-btn.secondary:hover {
    background: rgba(37, 60, 70, 0.07);
}

/* ----- Letter-game completion extras ----- */

.letter-completion-card {
    max-width: 580px !important;
    max-height: 85vh;
    overflow-y: auto;
}

.missed-list {
    margin: 0 0 24px;
    text-align: left;
}

.missed-list-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--ink-soft);
    margin-bottom: 10px;
}

.missed-list-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.missed-pill {
    background: var(--carmine-tint);
    color: var(--carmine-deep);
    border: 1px solid rgba(190, 75, 51, 0.4);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 600;
}

/* ============================================================
   DID YOU MEAN
   ============================================================ */

.dym-yes {
    background: var(--leaf);
    border-color: var(--leaf-deep);
    color: var(--paper-bright);
    margin: 0 4px;
}

.dym-no {
    background: transparent;
    border-color: rgba(37, 60, 70, 0.45);
    color: var(--ink);
    margin: 0 4px;
}

.dym-no:hover {
    background: rgba(37, 60, 70, 0.07);
}

/* ============================================================
   CHALKBOARD MODAL
   ============================================================ */

.chalkboard-modal {
    position: fixed;
    inset: 0;
    background: rgba(16, 28, 33, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.chalkboard-card {
    background:
        radial-gradient(ellipse at 30% 20%, rgba(249, 244, 231, 0.05), transparent 55%),
        #2e453c;
    border: 6px solid #8a6844;
    border-radius: 6px;
    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.35),
        0 20px 60px rgba(0, 0, 0, 0.45);
    padding: 34px 44px;
    text-align: center;
    max-width: 440px;
    width: 90%;
    animation: slideIn 0.25s ease-out;
    color: #e6e2d4;
}

.chalkboard-emoji {
    font-size: 34px;
    line-height: 1;
    color: rgba(230, 226, 212, 0.85);
    margin-bottom: 10px;
}

.chalkboard-instruction {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(230, 226, 212, 0.65);
    margin-bottom: 18px;
}

.chalkboard-target {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 32px;
    font-weight: 600;
    color: #ecd88f;
    margin-bottom: 14px;
    letter-spacing: 0.02em;
}

.chalkboard-dots {
    font-size: 24px;
    letter-spacing: 12px;
    margin-bottom: 20px;
    color: rgba(230, 226, 212, 0.4);
}

.chalkboard-dot {
    transition: color 0.2s ease;
}

.chalkboard-dot.filled {
    color: #ecd88f;
}

.chalkboard-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 19px;
    border: 1px solid rgba(230, 226, 212, 0.35);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.22);
    color: #f2eede;
    text-align: center;
    font-family: var(--font-mono);
    outline: none;
    transition: border-color 0.2s ease;
}

.chalkboard-input::placeholder {
    color: rgba(230, 226, 212, 0.4);
}

.chalkboard-input:focus {
    border-color: #ecd88f;
}

.chalkboard-input.shake {
    animation: shake 0.4s ease;
    border-color: var(--carmine);
}

.btn-compact.submit-btn.chalkboard-submit {
    margin-top: 14px;
    background: transparent;
    border-color: rgba(230, 226, 212, 0.45);
    color: #e6e2d4;
}

.btn-compact.submit-btn.chalkboard-submit:hover {
    background: rgba(230, 226, 212, 0.1);
}

.chalkboard-feedback {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
    min-height: 20px;
}

.chalkboard-feedback.correct {
    color: #9ecfa5;
}

.chalkboard-feedback.incorrect {
    color: #e79a86;
}

.chalkboard-esc-note {
    margin-top: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: rgba(230, 226, 212, 0.45);
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 992px) {
    header {
        padding: 48px 20px;
    }

    .start-controls {
        padding: 24px 22px 22px;
    }
}

@media (max-width: 768px) {
    :root {
        --topbar-h: 88px;
    }

    header::before {
        inset: 10px;
        outline-offset: 3px;
    }

    .cover-eyebrow {
        font-size: 10px;
        letter-spacing: 0.24em;
    }

    .header-subtitle {
        font-size: 14px;
        margin-bottom: 32px;
    }

    .quiz-info-bar {
        padding: 8px 12px;
    }

    .question-compact {
        width: 100%;
    }

    .question-compact .target-text {
        font-size: 18px;
    }

    .stats-compact {
        font-size: 11px;
        gap: 6px;
        width: 100%;
        justify-content: space-between;
    }

    .answer-input-compact {
        font-size: 14px;
        max-width: none;
    }

    .floating-controls {
        bottom: 12px;
    }

    .btn-floating {
        padding: 8px 11px;
        font-size: 11px;
        gap: 6px;
    }

    .letter-game-area {
        padding: 18px 16px 110px;
    }

    .letter-hero {
        padding: 20px 28px 18px;
        align-self: stretch;
    }

    .big-letter {
        font-size: 68px;
    }

    .letter-checklist {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .completion-card {
        padding: 30px 24px;
    }

    .completion-title {
        font-size: 25px;
    }

    .completion-subtitle {
        font-size: 15px;
    }

    .chalkboard-card {
        padding: 26px 22px;
    }

    .chalkboard-target {
        font-size: 26px;
    }
}

@media (max-width: 600px) {
    .completion-stats {
        flex-direction: column;
        gap: 10px;
    }

    .stat-badge {
        min-width: auto;
    }

    .completion-actions {
        flex-direction: column;
    }

    .completion-btn {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .start-controls {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    h1 {
        font-size: 40px;
    }
}

@media (max-width: 480px) {
    .btn-floating {
        padding: 7px 8px;
        font-size: 10px;
        letter-spacing: 0.08em;
    }
}
