/* =============================================================================
   Medieval Quest - styles
   Dark iron-and-parchment theme with gold accents. No external requests:
   fonts are self-hosted in /fonts.
   ============================================================================= */

@font-face {
    font-family: 'Cinzel';
    src: url('fonts/cinzel-latin.woff2') format('woff2');
    font-weight: 500 700;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-latin.woff2') format('woff2');
    font-weight: 400 600;
    font-display: swap;
}

:root {
    --bg: #0c0a08;
    --bg-2: #14100c;
    --panel: #1a1510;
    --panel-2: #231c14;
    --panel-3: #2c2318;
    --line: #3d3122;
    --line-strong: #6b5428;
    --gold: #d4a24a;
    --gold-bright: #f2d388;
    --gold-deep: #8a6420;
    --ink: #f0e6d2;
    --ink-soft: #cdbfa5;
    --muted: #9a8d77;
    --red: #c4432f;
    --red-deep: #7d2218;
    --green: #6aaa5c;
    --blue: #5b93cc;
    --purple: #a276d6;
    --rare: #b98cf0;
    --uncommon: #6fc17a;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    --font-title: 'Cinzel', 'Palatino Linotype', Georgia, serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(ellipse at 50% -10%, rgba(212, 162, 74, 0.10), transparent 55%),
        radial-gradient(ellipse at 50% 120%, rgba(125, 34, 24, 0.12), transparent 60%),
        var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
body.night { background-color: #080a10; }

h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
small { font-size: 0.82em; }
kbd {
    font-family: var(--font-body); font-size: 0.75em; padding: 1px 6px; border-radius: 4px;
    background: var(--panel-3); border: 1px solid var(--line-strong); color: var(--gold-bright);
}
.font-title { font-family: var(--font-title); letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.gold { color: var(--gold-bright); font-weight: 600; white-space: nowrap; }
.coin { color: var(--gold); font-size: 0.7em; margin-left: 3px; vertical-align: middle; }
.buffed { color: var(--green); }
.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: fixed; left: 10px; top: -60px; z-index: 2000; background: var(--gold); color: #1a1208;
    padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; transition: top 0.2s;
}
.skip-link:focus { top: 10px; }

:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
::selection { background: var(--gold-deep); color: #fff; }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid var(--bg); }

/* ---------------------------------------------------------------- Boot -- */
.boot {
    position: fixed; inset: 0; z-index: 3000; background: var(--bg); display: grid; place-items: center;
    transition: opacity 0.35s ease;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; color: var(--gold); }
.spinner {
    width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 50%;
    border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { position: fixed; inset: 0; z-index: 4000; background: var(--bg); display: grid; place-items: center; padding: 30px; text-align: center; }

/* ------------------------------------------------------------- Buttons -- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius-sm); cursor: pointer;
    border: 1px solid var(--line-strong);
    background: linear-gradient(180deg, var(--panel-3), var(--panel-2));
    color: var(--ink); font-weight: 500; text-align: center; line-height: 1.25;
    transition: transform 0.12s, border-color 0.15s, background 0.15s, box-shadow 0.15s, filter 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(212, 162, 74, 0.25), 0 4px 14px rgba(0, 0, 0, 0.4); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); filter: brightness(0.95); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-gold:disabled { filter: grayscale(0.85); }
.btn-gold {
    background: linear-gradient(180deg, #e2b457, #a9791f); color: #1b1307; border-color: #f2d388; font-weight: 600;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-gold:hover:not(:disabled) { border-color: #fff0c4; filter: brightness(1.08); }
.btn-danger { background: linear-gradient(180deg, #8d2a1d, #5e1810); border-color: #b3402f; color: #ffe8e2; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-muted { opacity: 0.7; }
.btn-small { padding: 5px 12px; font-size: 0.88em; }
.btn-big { padding: 14px 24px; font-size: 1.05em; flex-direction: column; gap: 2px; }
.btn-big small { font-weight: 400; opacity: 0.8; }
.btn-block { display: flex; width: 100%; }
.icon-btn {
    width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer;
    background: var(--panel-3); border: 1px solid var(--line-strong); color: var(--ink); transition: 0.15s;
}
.icon-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-bright); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.chip {
    padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel-2);
    cursor: pointer; font-size: 0.85em; color: var(--ink-soft);
}
.chip.active { background: var(--gold-deep); border-color: var(--gold); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab {
    padding: 8px 18px; background: transparent; border: 0; border-bottom: 2px solid transparent;
    cursor: pointer; color: var(--muted); font-weight: 500;
}
.tab.active { color: var(--gold-bright); border-bottom-color: var(--gold); }
.tab:hover { color: var(--ink); }

.tag {
    display: inline-block; font-size: 0.68em; text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 8px;
    border-radius: 4px; vertical-align: middle; font-family: var(--font-body); font-weight: 600;
}
.tag-main { background: rgba(212, 162, 74, 0.2); color: var(--gold-bright); border: 1px solid var(--gold-deep); }
.tag-side { background: rgba(91, 147, 204, 0.18); color: #9cc4ec; border: 1px solid #3b6491; }
.tag-boss { background: rgba(196, 67, 47, 0.25); color: #ffb3a6; border: 1px solid var(--red); }

/* --------------------------------------------------------------- Title -- */
.title-screen {
    min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
    background:
        linear-gradient(180deg, rgba(8, 6, 4, 0.55), rgba(8, 6, 4, 0.92)),
        radial-gradient(ellipse at 50% 30%, rgba(212, 162, 74, 0.18), transparent 60%),
        url('images/scenes/throne-room.jpg') center / cover no-repeat;
}
.title-card {
    width: min(560px, 100%); text-align: center; padding: 40px 34px 28px;
    background: linear-gradient(180deg, rgba(26, 21, 16, 0.88), rgba(14, 11, 8, 0.92));
    border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow), inset 0 0 0 4px rgba(0, 0, 0, 0.35), inset 0 0 0 5px rgba(212, 162, 74, 0.18);
    backdrop-filter: blur(6px);
}
.title-kicker { color: var(--gold); letter-spacing: 0.3em; text-transform: uppercase; font-size: 0.78rem; }
.title-name {
    font-size: clamp(2.2rem, 7vw, 3.4rem); margin: 6px 0 8px; line-height: 1.1; font-weight: 700;
    background: linear-gradient(180deg, #fff0c4, #d4a24a 60%, #8a6420); -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}
.title-tag { color: var(--ink-soft); margin-bottom: 26px; font-style: italic; }
.title-menu { display: grid; gap: 10px; }
.title-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.title-row .btn { padding: 10px 8px; font-size: 0.9em; }
.title-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.title-stats dt { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.title-stats dd { font-family: var(--font-title); font-size: 1.25rem; color: var(--gold-bright); }
.back-link { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 0.85rem; text-decoration: none; }
.back-link:hover { color: var(--gold-bright); }

/* ------------------------------------------------------------- Game UI -- */
.game { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 14px; padding: 8px 16px;
    background: linear-gradient(180deg, #1d1710, #130f0a); border-bottom: 1px solid var(--line-strong);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}
.brand { color: var(--gold-bright); font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.brand-mark { color: var(--gold); margin-right: 4px; }
.hud-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.hud-chip {
    padding: 4px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 0.88rem; white-space: nowrap;
}
.top-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.top-btn {
    position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; cursor: pointer;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.88rem; color: var(--ink-soft);
    transition: 0.15s;
}
.top-btn:hover { border-color: var(--gold); color: var(--gold-bright); }
.badge {
    position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
    background: var(--gold); color: #1b1307; font-size: 0.72rem; font-weight: 700; display: grid; place-items: center;
    animation: pulse 1.8s infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(212, 162, 74, 0.25); } }

.game-grid {
    flex: 1; display: grid; grid-template-columns: 290px minmax(0, 1fr) 330px; gap: 16px;
    width: 100%; max-width: 1560px; margin: 0 auto; padding: 16px; align-items: start;
}
.col-right { display: grid; gap: 16px; }
.panel {
    background: linear-gradient(180deg, var(--panel), #130f0b); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 6px 18px rgba(0, 0, 0, 0.35);
}
.panel-title { font-size: 1rem; color: var(--gold); margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: 0.12em; }
.panel-scene { padding: 0; overflow: hidden; min-height: 560px; }
.panel-scene > :not(.scene-hero) { margin-left: 22px; margin-right: 22px; }
.panel-scene > :last-child { margin-bottom: 22px; }
.panel-hero { position: sticky; top: 72px; }
.panel-quests, .panel-log { max-height: 420px; overflow: auto; }

.save-indicator {
    position: fixed; right: 18px; bottom: 14px; padding: 4px 12px; border-radius: 999px; background: rgba(26, 21, 16, 0.9);
    border: 1px solid var(--line-strong); color: var(--gold); font-size: 0.78rem; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 40;
}
.save-indicator.show { opacity: 1; }

/* ---- Hero panel ---- */
.hero-card { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.hero-id { min-width: 0; }
.hero-name { font-size: 1.15rem; color: var(--gold-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-sub { color: var(--ink-soft); font-size: 0.85rem; }
.medallion {
    flex: none; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem;
    background: radial-gradient(circle at 35% 30%, #3b2d1a, #17110b); border: 2px solid var(--gold-deep);
    box-shadow: 0 0 0 3px #0c0a08, 0 0 0 4px var(--line-strong), inset 0 0 12px rgba(0, 0, 0, 0.6);
}
.medallion.big { width: 72px; height: 72px; font-size: 2.3rem; }
.bar {
    position: relative; height: 22px; background: #0a0806; border: 1px solid var(--line-strong); border-radius: 5px; overflow: hidden; margin: 6px 0;
}
.bar-fill { height: 100%; transition: width 0.45s ease; }
.bar-hp .bar-fill { background: linear-gradient(180deg, #d9533c, #8c2418); }
.bar-enemy .bar-fill { background: linear-gradient(180deg, #b9462f, #6d1d12); }
.bar-xp .bar-fill { background: linear-gradient(180deg, #7aa8dc, #3c6aa0); }
.bar-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.74rem; font-weight: 600; text-shadow: 0 1px 2px #000; letter-spacing: 0.03em; }
.max-level { text-align: center; color: var(--gold); font-size: 0.8rem; margin: 6px 0; }
.attr-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 12px 0; }
.attr-list li { text-align: center; padding: 6px 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); }
.attr-list li span { display: block; font-size: 0.66rem; color: var(--muted); letter-spacing: 0.08em; }
.attr-list li b { font-family: var(--font-title); font-size: 1.1rem; }
.derived { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.derived > div { text-align: center; padding: 6px 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.derived.tight { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
.derived dt { font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.derived dd { font-family: var(--font-title); font-size: 1.1rem; color: var(--gold-bright); }
.mini-slots { display: flex; gap: 8px; margin: 12px 0; }
.mini-slot {
    flex: 1; aspect-ratio: 1; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
    background: var(--bg-2); overflow: hidden;
}
.slot-empty { opacity: 0.3; font-size: 1.2rem; }

/* ---- Items ---- */
.item-icon {
    flex: none; width: 46px; height: 46px; display: grid; place-items: center; font-size: 1.5rem; border-radius: var(--radius-sm);
    background: radial-gradient(circle at 40% 30%, #2f2418, #14100b); border: 1px solid var(--line-strong); overflow: hidden;
}
.item-icon.sm { width: 38px; height: 38px; font-size: 1.2rem; }
.item-icon img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: screen; }
.item-icon.rarity-uncommon { border-color: var(--uncommon); }
.item-icon.rarity-rare { border-color: var(--rare); box-shadow: 0 0 10px rgba(185, 140, 240, 0.35); }
.rarity-text-uncommon { color: var(--uncommon); }
.rarity-text-rare { color: var(--rare); }
.qty { color: var(--gold); font-weight: 400; }
.item-info { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.item-info small { color: var(--ink-soft); }
.item-info small.muted { color: var(--muted); }

/* ---- Tracker & log ---- */
.tracker-quest { padding: 10px 12px; margin-bottom: 8px; background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: var(--radius-sm); }
.tracker-quest.main { border-left-color: var(--gold); }
.tracker-quest h4 { font-size: 0.92rem; margin-bottom: 6px; }
.ready-note { color: var(--green); font-weight: 600; font-size: 0.88rem; }
.objectives li { display: flex; gap: 8px; font-size: 0.85rem; color: var(--ink-soft); padding: 2px 0; }
.objectives li.done { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(154, 141, 119, 0.5); }
.objectives .check { color: var(--gold); flex: none; width: 14px; }
.objectives li.done .check { color: var(--green); }
.obj-count { color: var(--gold); font-weight: 600; text-decoration: none; display: inline-block; }
.log-list li { font-size: 0.82rem; padding: 5px 0; border-bottom: 1px dotted var(--line); color: var(--ink-soft); }
.log-list time { color: var(--muted); font-size: 0.74em; margin-right: 4px; }
.log-list .log-good { color: #a7d9a0; }
.log-list .log-bad { color: #e69a8c; }
.log-list .log-quest { color: var(--gold-bright); }
.log-list .log-combat { color: #d9b3a8; }
.empty-state { text-align: center; padding: 22px 12px; color: var(--muted); }
.empty-icon { font-size: 2rem; opacity: 0.7; margin-bottom: 6px; }
.empty-state h3 { font-family: var(--font-title); color: var(--ink-soft); font-size: 1rem; margin-bottom: 4px; }
.empty-state p { font-size: 0.85rem; }

/* ---- Scene ---- */
.scene-hero { position: relative; height: clamp(190px, 28vw, 320px); overflow: hidden; background: var(--bg-2); border-bottom: 1px solid var(--line-strong); }
.skeleton {
    position: absolute; inset: 0; background: linear-gradient(100deg, #1a1510 30%, #2a2116 50%, #1a1510 70%); background-size: 200% 100%;
    animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.scene-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.5s ease, transform 8s ease; transform: scale(1.04); }
.scene-img.loaded { opacity: 1; transform: scale(1); }
.scene-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(12, 10, 8, 0.1) 30%, rgba(12, 10, 8, 0.92)); }
.scene-shade.night { background: linear-gradient(180deg, rgba(8, 12, 40, 0.45) 0%, rgba(8, 8, 20, 0.95)); }
.scene-title { position: absolute; left: 24px; right: 24px; bottom: 16px; }
.scene-kicker { text-transform: uppercase; letter-spacing: 0.2em; font-size: 0.72rem; color: var(--gold); }
.scene-title h1 { font-size: clamp(1.4rem, 3.4vw, 2.2rem); color: var(--gold-bright); text-shadow: 0 2px 10px #000; outline: none; }
.scene-desc { margin-top: 18px; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.65; max-width: 78ch; }
.scene-warning { margin-top: 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: rgba(196, 67, 47, 0.12); border: 1px solid rgba(196, 67, 47, 0.4); color: #f0b3a8; font-size: 0.88rem; }
.section-label {
    margin-top: 22px; margin-bottom: 10px; font-family: var(--font-title); font-size: 0.82rem; font-weight: 600; color: var(--gold);
    text-transform: uppercase; letter-spacing: 0.16em; display: flex; align-items: center; gap: 12px;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }
.npc-row { display: flex; gap: 10px; flex-wrap: wrap; }
.npc-card {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px; cursor: pointer; text-align: left;
    background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius); min-width: 240px; transition: 0.15s;
}
.npc-card:hover { border-color: var(--gold); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
.npc-portrait { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; border: 2px solid var(--gold-deep); background: #120e09; display: grid; place-items: center; flex: none; }
.npc-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.npc-emoji { font-size: 1.7rem; }
.npc-text { display: flex; flex-direction: column; }
.npc-text small { color: var(--muted); }
.npc-marker {
    position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
    font-weight: 800; font-family: var(--font-title); color: #1b1307; background: var(--gold); border: 2px solid #fff0c4; animation: bob 1.6s ease-in-out infinite;
}
.npc-marker.ready { background: #8fd07f; }
.npc-marker.inline { position: static; display: inline-grid; width: 20px; height: 20px; font-size: 0.8rem; animation: none; border-width: 1px; vertical-align: middle; flex: none; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.action-btn {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; text-align: left;
    background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line-strong); border-radius: var(--radius); transition: 0.15s;
}
.action-btn:hover:not(:disabled) { border-color: var(--gold); background: linear-gradient(180deg, var(--panel-3), var(--panel-2)); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.action-btn.danger { border-color: #7d3228; }
.action-btn.danger:hover:not(:disabled) { border-color: var(--red); }
.action-btn.travel { border-style: dashed; }
.action-icon { font-size: 1.5rem; width: 36px; text-align: center; flex: none; }
.action-text { display: flex; flex-direction: column; min-width: 0; }
.action-text small { color: var(--muted); }

.tabbar { display: none; }

/* ---------------------------------------------------------------- Modals -- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 20px;
    background: rgba(5, 4, 3, 0.78); backdrop-filter: blur(3px); animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.modal {
    width: 100%; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; outline: none;
    background: linear-gradient(180deg, #1c1611, #120e0a); border: 1px solid var(--line-strong); border-radius: 14px;
    box-shadow: var(--shadow), inset 0 0 0 3px rgba(0, 0, 0, 0.4), inset 0 0 0 4px rgba(212, 162, 74, 0.14); animation: pop 0.22s ease;
}
.modal-sm { max-width: 440px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 940px; }
.modal-xl { max-width: 1120px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex: none; }
.modal-header h2 { font-size: 1.2rem; color: var(--gold-bright); }
.title-sub { display: block; font-family: var(--font-body); font-size: 0.7em; color: var(--muted); letter-spacing: 0; font-weight: 400; }
.modal-body { padding: 18px 20px 20px; overflow-y: auto; flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .btn { min-width: 120px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.menu-list { display: grid; gap: 8px; }
.menu-list hr { margin: 4px 0; }

/* ---- Toasts ---- */
.toast-root { position: fixed; bottom: 52px; right: 16px; z-index: 1500; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
    display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.9rem;
    background: rgba(26, 21, 16, 0.97); border: 1px solid var(--line-strong); border-left: 4px solid var(--blue); box-shadow: var(--shadow);
    animation: slide 0.3s ease; transition: opacity 0.3s, transform 0.3s;
}
.toast.leaving { opacity: 0; transform: translateX(20px); }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-quest { border-left-color: var(--gold); }
.toast-achievement, .toast-levelup { border-left-color: var(--purple); background: linear-gradient(90deg, rgba(60, 40, 90, 0.5), rgba(26, 21, 16, 0.97)); }
.toast-icon { flex: none; }
@keyframes slide { from { opacity: 0; transform: translateX(30px); } }

/* ----------------------------------------------------- Character creation -- */
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps li { flex: 1; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; }
.steps li.current { border-color: var(--gold); color: var(--gold-bright); background: var(--panel-2); }
.steps li.done { color: var(--green); }
.step-num { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-3); font-weight: 700; font-size: 0.75rem; flex: none; }
.steps li.current .step-num { background: var(--gold); color: #1b1307; }
.creation-grid { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 20px; }
.creation-main .section-label:first-child { margin-top: 0; }
.form-row { margin-bottom: 8px; }
.form-row label { display: block; margin-bottom: 6px; color: var(--ink-soft); font-weight: 500; }
.input-row { display: flex; gap: 8px; }
input[type='text'] {
    flex: 1; padding: 10px 14px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--ink); font-size: 1rem; min-width: 0;
}
input[type='text']:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(212, 162, 74, 0.2); }
input[aria-invalid='true'] { border-color: var(--red); }
.form-error { color: #ff9b8a; min-height: 1.3em; font-size: 0.85rem; margin-top: 4px; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.option-card {
    display: flex; gap: 12px; padding: 12px; cursor: pointer; text-align: left; align-items: flex-start;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); transition: 0.15s;
}
.option-card:hover { border-color: var(--gold-deep); transform: translateY(-1px); }
.option-card.selected { border-color: var(--gold); background: linear-gradient(180deg, #33281a, #251d13); box-shadow: 0 0 0 1px var(--gold), 0 6px 20px rgba(212, 162, 74, 0.15); }
.option-icon { font-size: 1.8rem; width: 42px; text-align: center; flex: none; }
.option-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.option-body b { color: var(--gold-bright); }
.option-body span { color: var(--ink-soft); font-size: 0.86rem; }
.option-body em { font-style: normal; color: var(--green); font-size: 0.8rem; }
.creation-preview { padding: 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); align-self: start; }
.creation-preview .section-label { margin-top: 0; }
.preview-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.preview-head small { display: block; color: var(--muted); }
.preview-attrs li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dotted var(--line); font-size: 0.9rem; }
.preview-attrs b { color: var(--gold-bright); font-family: var(--font-title); }
.preview-attrs .short { display: none; }
.review-card { display: flex; gap: 16px; align-items: center; padding: 16px; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.review-card h3 { color: var(--gold-bright); font-size: 1.4rem; }
.review-gear { margin-top: 12px; }
.creation-nav { justify-content: space-between; }

/* ------------------------------------------------------------- Inventory -- */
.inventory-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; }
.inventory-layout .section-label:first-child, .char-layout .section-label:first-child { margin-top: 0; }
.equip-list { display: grid; gap: 8px; }
.equip-slot { padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); }
.equip-slot.empty { border-style: dashed; }
.slot-name { display: block; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 6px; }
.equip-item { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.equip-item .item-info { flex: 1 1 140px; }
.bag-list, .shop-list, .recipe-list { display: grid; gap: 8px; }
.bag-row, .shop-row, .recipe {
    display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.bag-row:hover, .shop-row:hover { border-color: var(--line-strong); }
.row-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.price { font-size: 0.95rem; }
.price.poor .gold { color: #e08b7e; }
.owned { color: var(--green); }

/* ------------------------------------------------------------- Character -- */
.char-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.points-badge { background: var(--gold); color: #1b1307; padding: 1px 10px; border-radius: 999px; font-family: var(--font-body); font-size: 0.72rem; letter-spacing: 0; text-transform: none; font-weight: 700; }
.attr-table { display: grid; gap: 6px; }
.attr-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.attr-name { flex: 1; display: flex; flex-direction: column; }
.attr-name small { color: var(--muted); }
.attr-value { font-family: var(--font-title); font-size: 1.3rem; color: var(--gold-bright); min-width: 34px; text-align: right; }
.attr-value small { font-family: var(--font-body); font-size: 0.55em; }
.icon-btn.plus { background: var(--gold-deep); border-color: var(--gold); font-size: 1.2rem; font-weight: 700; }
.trait-list li { padding: 6px 0; font-size: 0.88rem; color: var(--ink-soft); border-bottom: 1px dotted var(--line); }
.trait-list b { color: var(--gold-bright); }
.rep-list { display: grid; gap: 10px; }
.rep-row { display: grid; grid-template-columns: 1fr; gap: 4px; font-size: 0.88rem; }
.rep-row small { display: block; color: var(--muted); }
.rep-meter { position: relative; display: block; height: 8px; border-radius: 4px; background: #0a0806; border: 1px solid var(--line-strong); overflow: hidden; }
.rep-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--blue); }
.rep-fill.neg { background: var(--red); }
.rep-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--gold); }
.rep-title { font-size: 0.8rem; color: var(--ink-soft); }
.ach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); opacity: 0.55; }
.ach.got { opacity: 1; border-color: var(--gold-deep); }
.ach-text { display: flex; flex-direction: column; font-size: 0.85rem; }
.ach small { color: var(--muted); }
.ach-icon { font-size: 1.4rem; }

/* --------------------------------------------------------------- Journal -- */
.quest-list { display: grid; gap: 12px; }
.quest-card { padding: 14px 16px; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: var(--radius); }
.quest-card.main { border-left-color: var(--gold); }
.quest-card header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.quest-card h3 { font-size: 1.05rem; color: var(--gold-bright); }
.quest-summary { color: var(--ink-soft); margin-bottom: 8px; }

/* ------------------------------------------------------------------- Map -- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; }
.map-figure { border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; align-self: start; position: sticky; top: 0; }
.map-figure img { width: 100%; height: auto; }
.map-figure figcaption { padding: 6px 10px; text-align: center; font-family: var(--font-title); font-size: 0.8rem; color: var(--gold); background: var(--bg-2); letter-spacing: 0.1em; }
.map-layout .section-label:first-child { margin-top: 0; }
.dest-list { display: grid; gap: 8px; margin-top: 10px; }
.dest-card {
    width: 100%; display: flex; gap: 12px; align-items: center; padding: 10px 12px; cursor: pointer; text-align: left;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); transition: 0.15s;
}
.dest-card:hover:not(:disabled) { border-color: var(--gold); transform: translateX(2px); }
.dest-card.here { border-color: var(--gold-deep); background: var(--panel-3); cursor: default; opacity: 0.85; }
.dest-icon { font-size: 1.5rem; width: 34px; text-align: center; flex: none; }
.dest-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dest-text small { color: var(--muted); }
.dest-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 0.82rem; color: var(--gold-bright); white-space: nowrap; }
.danger-tag { color: #f0a08f; font-size: 0.74rem; }
.new-tag { color: var(--green); font-size: 0.74rem; }

/* ------------------------------------------------------------- Shop/craft -- */
.shop-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; padding: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); }
.shop-portrait { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; object-position: center 20%; border: 2px solid var(--gold-deep); flex: none; }
.shop-quote { flex: 1; }
.shop-quote p { font-style: italic; color: var(--ink-soft); }
.shop-gold { font-size: 1.2rem; }
.shop-list { max-height: 52vh; overflow-y: auto; padding-right: 4px; }
.station-note { padding: 10px 14px; margin-bottom: 12px; border: 1px solid var(--green); border-radius: var(--radius-sm); background: rgba(106, 170, 92, 0.08); color: #b8dfae; }
.station-note.warn { border-color: var(--gold-deep); background: rgba(212, 162, 74, 0.08); color: var(--gold-bright); }
.mats { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.mat { font-size: 0.78rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-strong); }
.mat.ok { color: #b8dfae; border-color: #3f6b37; }
.mat.low { color: #f0a08f; border-color: #7d3228; }
.recipe.locked { opacity: 0.8; }
.recipe .btn { max-width: 150px; }

/* -------------------------------------------------------------- Dialogue -- */
.dialogue-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.dialogue-portrait { width: 120px; height: 120px; border-radius: var(--radius); object-fit: cover; object-position: center 18%; border: 2px solid var(--gold-deep); flex: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); }
.dialogue-portrait.emoji { display: grid; place-items: center; font-size: 3.4rem; background: radial-gradient(circle at 35% 30%, #3b2d1a, #17110b); }
.speech { flex: 1; margin: 0; padding: 14px 16px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); font-size: 1.02rem; line-height: 1.65; color: var(--ink); position: relative; font-style: italic; }
.dialogue-actions { display: grid; gap: 8px; }
.dlg-btn { justify-content: flex-start; text-align: left; }
.dlg-btn.leave { color: var(--muted); }
.dlg-btn.ready { border-color: #4d7a43; }
.dlg-btn.offer { border-color: var(--gold-deep); }
.dlg-notice { color: var(--green); margin-bottom: 8px; }
.quest-offer { padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.quest-offer h4 { color: var(--gold-bright); margin-bottom: 6px; }
.level-warn { color: #f0c27a; font-size: 0.88rem; }
.choice-btn { flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; }
.choice-btn small { color: var(--muted); font-weight: 400; }
.choice-list { display: grid; gap: 8px; margin-top: 14px; }
.result-title { color: var(--gold-bright); font-size: 1.1rem; }
.reward-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.reward-chips li { padding: 4px 12px; border-radius: 999px; background: rgba(212, 162, 74, 0.12); border: 1px solid var(--gold-deep); color: var(--gold-bright); font-size: 0.86rem; }

/* ----------------------------------------------------------------- Events -- */
.event { text-align: center; }
.event-icon { font-size: 3rem; margin-bottom: 8px; }
.event-text { color: var(--ink); font-size: 1.05rem; line-height: 1.7; text-align: left; }
.event .reward-chips { justify-content: center; }
.story-overlay { background: radial-gradient(ellipse at center, rgba(20, 14, 8, 0.88), rgba(4, 3, 2, 0.97)); }
.story { text-align: center; padding: 14px 10px; }
.story h2 { font-size: 1.9rem; color: var(--gold-bright); margin: 6px 0 18px; }
.story-kicker { color: var(--gold); text-transform: uppercase; letter-spacing: 0.25em; font-size: 0.75rem; }
.story-text { font-size: 1.12rem; line-height: 1.85; font-style: italic; color: var(--ink); text-align: left; }
.story .muted { margin-top: 14px; }

/* ----------------------------------------------------------------- Combat -- */
.combat-overlay .modal { max-width: 1000px; }
.combat-overlay .modal-header h2 { text-align: center; flex: 1; }
.combat-overlay .modal-body { padding: 0; }
.combat { position: relative; padding: 18px 20px 20px; background: linear-gradient(180deg, rgba(12, 10, 8, 0.45), rgba(12, 10, 8, 0.95) 78%), var(--arena-bg, none) center / cover; }
.arena { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; padding: 10px 0 18px; }
.vs { font-size: 1.6rem; color: var(--gold); opacity: 0.8; }
.fighter { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.fighter-portrait {
    width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; font-size: 3.6rem;
    background: radial-gradient(circle at 35% 30%, #3f311d, #130e09); border: 3px solid var(--gold-deep);
    box-shadow: 0 0 0 4px #0c0a08, 0 0 0 5px var(--line-strong), 0 10px 30px rgba(0, 0, 0, 0.6);
}
.fighter.enemy .fighter-portrait { border-color: #8c3a2c; font-size: 4rem; box-shadow: 0 0 0 4px #0c0a08, 0 0 0 5px #5e2a20, 0 10px 30px rgba(0, 0, 0, 0.6); }
.fighter.enemy.boss .fighter-portrait { width: 132px; height: 132px; border-color: var(--red); box-shadow: 0 0 0 4px #0c0a08, 0 0 24px rgba(196, 67, 47, 0.5); }
.fighter-info { width: min(100%, 300px); }
.fighter-info h3 { font-size: 1.05rem; color: var(--gold-bright); }
.fighter-portrait.shake { animation: shake 0.4s; }
@keyframes shake { 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.status-row { min-height: 24px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 4px; }
.status { font-size: 0.72rem; padding: 1px 8px; border-radius: 999px; background: rgba(196, 67, 47, 0.18); border: 1px solid #7d3228; color: #f0b3a8; }
.status-stun { background: rgba(212, 162, 74, 0.18); border-color: var(--gold-deep); color: var(--gold-bright); }
.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.float-num {
    position: absolute; left: 50%; top: 30px; font-family: var(--font-title); font-weight: 700; font-size: 2rem; color: #fff; text-shadow: 0 2px 6px #000, 0 0 12px rgba(0, 0, 0, 0.8);
    animation: floatup 1.1s ease-out forwards; margin-left: calc(var(--dx, 0px) - 20px); z-index: 5;
}
.float-num.dmg-enemy { color: #ffd479; }
.float-num.dmg-player { color: #ff7d6a; }
.float-num.crit { color: #ffb02e; font-size: 2.7rem; }
.float-num.crit::after { content: ' Critical!'; font-size: 0.4em; display: block; letter-spacing: 0.1em; }
.float-num.miss { color: #c7bda8; font-size: 1.4rem; }
.float-num.heal { color: #8fe08a; }
.float-num.status { color: var(--gold-bright); font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.1em; }
@keyframes floatup { 0% { opacity: 0; transform: translateY(10px) scale(0.7); } 15% { opacity: 1; transform: translateY(-6px) scale(1.15); } 100% { opacity: 0; transform: translateY(-64px) scale(1); } }
.energy-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 10px; font-size: 0.85rem; color: var(--ink-soft); }
.pips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.pip { width: 14px; height: 14px; border-radius: 3px; transform: rotate(45deg); background: #0a0806; border: 1px solid var(--line-strong); transition: 0.2s; }
.pip.on { background: linear-gradient(135deg, #7ab8f0, #3770b0); border-color: #9bcdf7; box-shadow: 0 0 8px rgba(91, 147, 204, 0.6); }
.combat-log {
    height: 150px; overflow-y: auto; padding: 10px 14px; background: rgba(8, 6, 4, 0.85); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 14px;
}
.combat-log p { padding: 2px 0; color: var(--ink-soft); animation: fade 0.3s; }
.combat-log .log-good { color: #b4e3ad; }
.combat-log .log-bad { color: #f0a597; }
.combat-log .log-crit { color: #ffc15e; font-weight: 600; }
.combat-log .log-warn { color: #f0c27a; }
.combat-log .log-muted { color: var(--muted); font-style: italic; }
.combat-actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.combat-btn { flex-direction: column; padding: 12px 6px; position: relative; font-size: 0.92rem; }
.combat-btn kbd { position: absolute; top: 4px; left: 6px; opacity: 0.7; }
.combat-btn > span[aria-hidden] { font-size: 1.4rem; }
.combat-btn small { color: var(--muted); font-size: 0.72em; }
.item-picker { margin-top: 12px; padding: 12px; background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.item-picker h4 { color: var(--gold-bright); margin-bottom: 8px; }
.item-picker ul { display: grid; gap: 6px; margin-bottom: 10px; max-height: 190px; overflow-y: auto; }
.picker-btn { justify-content: flex-start; text-align: left; gap: 12px; }
.picker-btn span { display: flex; flex-direction: column; }
.picker-btn small { color: var(--muted); font-weight: 400; }
.result { text-align: center; padding: 34px 24px 28px; }
.result-icon { font-size: 3.6rem; }
.result h2 { font-size: 2rem; margin: 6px 0; }
.result.victory h2 { color: var(--gold-bright); }
.result.defeat h2 { color: #f0a08f; }
.result .reward-chips { justify-content: center; }
.loot-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.loot-list li { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.88rem; }
.result .section-label { justify-content: center; }
.result .section-label::after { display: none; }

/* --------------------------------------------------------------- Settings -- */
.settings-form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { color: var(--ink-soft); display: flex; justify-content: space-between; }
.field.check { display: flex; align-items: center; gap: 10px; }
.field.check label { justify-content: flex-start; }
input[type='range'] { width: 100%; accent-color: var(--gold); }
input[type='checkbox'] { width: 18px; height: 18px; accent-color: var(--gold); }
select { padding: 9px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--ink); }
output { color: var(--gold-bright); }

/* ----------------------------------------------------------------- Slots -- */
.slot-list { display: grid; gap: 10px; }
.slot { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.slot.empty { border-style: dashed; opacity: 0.8; }
.slot-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.slot-info small { color: var(--ink-soft); }
.slot-info small.muted { color: var(--muted); }
.slot-actions { display: flex; gap: 8px; flex: none; }

/* ------------------------------------------------------------------ Help -- */
.help ul { display: grid; gap: 8px; color: var(--ink-soft); }
.help .section-label:first-child { margin-top: 0; }
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.keys > div { display: flex; gap: 10px; align-items: center; padding: 6px 10px; background: var(--bg-2); border-radius: var(--radius-sm); }
.keys dt { min-width: 52px; }
.keys dd { color: var(--ink-soft); }

/* ------------------------------------------------------------ Responsive -- */
@media (max-width: 1240px) {
    .game-grid { grid-template-columns: 260px minmax(0, 1fr); }
    .col-right { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
    .panel-hero { position: static; }
    .top-btn-label { display: none; }
    .top-btn { padding: 7px 10px; }
}

@media (max-width: 900px) {
    .topbar { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
    .brand { display: none; }
    .hud-chips { flex: 1; min-width: 0; }
    .hud-time { font-size: 0.78rem; }
    .top-actions { margin-left: 0; }
    .top-actions .top-btn[data-action='open-save'], .top-actions .top-btn[data-action='open-craft'], .top-actions .top-btn[data-action='open-journal'], .top-actions .top-btn[data-action='toggle-mute'] { display: none; }
    .game-grid { display: block; padding: 10px 10px 76px; }
    .game-grid .panel, .game-grid .col-right { display: none; }
    .game[data-panel='scene'] .panel-scene,
    .game[data-panel='hero'] .panel-hero,
    .game[data-panel='quests'] .panel-quests,
    .game[data-panel='log'] .panel-log { display: block; }
    .game[data-panel='quests'] .col-right, .game[data-panel='log'] .col-right { display: block; }
    .panel-quests, .panel-log { max-height: none; }
    .panel-scene { min-height: 0; }
    .panel-scene > :not(.scene-hero) { margin-left: 14px; margin-right: 14px; }
    .tabbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: grid; grid-template-columns: repeat(4, 1fr);
        background: #130f0a; border-top: 1px solid var(--line-strong); padding-bottom: env(safe-area-inset-bottom);
    }
    .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; background: none; border: 0; color: var(--muted); font-size: 0.74rem; cursor: pointer; min-height: 56px; }
    .tabbar button span { font-size: 1.3rem; }
    .tabbar button.active { color: var(--gold-bright); background: linear-gradient(180deg, rgba(212, 162, 74, 0.14), transparent); border-top: 2px solid var(--gold); margin-top: -1px; }
    .toast-root { bottom: 70px; right: 8px; left: 8px; width: auto; }
    .action-grid { grid-template-columns: 1fr; }
    .npc-card { min-width: 0; width: 100%; }
    .modal-overlay { padding: 8px; align-items: end; }
    .modal { max-height: calc(100dvh - 16px); }
    .modal-body { padding: 14px; }
    .creation-grid, .inventory-layout, .char-layout, .map-layout { grid-template-columns: 1fr; }
    .map-figure { position: static; }
    .steps .step-name { display: none; }
    .steps li { justify-content: center; }
    .creation-preview { order: -1; padding: 10px 12px; }
    .creation-preview > .section-label, .creation-preview > .muted { display: none; }
    .preview-head { margin-bottom: 6px; }
    .creation-preview .preview-attrs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
    .preview-attrs li { flex-direction: column; align-items: center; border: 0; padding: 2px 0; }
    .preview-attrs .long { display: none; }
    .preview-attrs .short { display: inline; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.08em; }
    .creation-preview .derived { margin: 6px 0 0; }
    .toast { font-size: 0.82rem; padding: 8px 10px; }
    .pip { width: 10px; height: 10px; }
    .energy-row { flex-direction: column; gap: 6px; }
    .option-grid { grid-template-columns: 1fr; }
    .dialogue-head { flex-direction: column; align-items: center; }
    .dialogue-portrait { width: 96px; height: 96px; }
    .shop-head { flex-wrap: wrap; }
    .shop-row, .bag-row, .recipe { flex-wrap: wrap; }
    .row-actions { width: 100%; justify-content: space-between; }
    .recipe .btn { max-width: none; }
    .arena { grid-template-columns: 1fr 1fr; gap: 8px; }
    .vs { display: none; }
    .fighter-portrait { width: 76px; height: 76px; font-size: 2.4rem; }
    .fighter.enemy .fighter-portrait { font-size: 2.6rem; }
    .fighter.enemy.boss .fighter-portrait { width: 88px; height: 88px; }
    .combat { padding: 12px; }
    .combat-log { height: 120px; }
    .combat-actions { grid-template-columns: repeat(6, 1fr); }
    .combat-btn:nth-child(-n+3) { grid-column: span 2; }
    .combat-btn:nth-child(n+4) { grid-column: span 3; }
    .combat-btn kbd { display: none; }
    .float-num { font-size: 1.5rem; }
    .title-row { grid-template-columns: 1fr; }
    .title-card { padding: 28px 18px 20px; }
    .slot { flex-wrap: wrap; }
    .slot-actions { width: 100%; }
    .slot-actions .btn { flex: 1; }
    .col-right { display: block; }
}

@media (max-width: 480px) {
    .title-stats dd { font-size: 1.05rem; }
    .scene-title { left: 14px; right: 14px; }
    .modal-actions .btn { flex: 1; min-width: 0; }
}

body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important;
}
body.reduce-motion .float-num { animation: none !important; opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    .float-num { animation: none !important; opacity: 1; }
}


/* --------------------------------------------------------------- Landing -- */
.landing-body {
    background:
        linear-gradient(180deg, rgba(8, 6, 4, 0.5), rgba(8, 6, 4, 0.94) 70%),
        url('images/scenes/battlefield-dusk.jpg') center top / cover fixed no-repeat, var(--bg);
}
#embers { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.landing-hero, .landing-main, .landing-footer { position: relative; z-index: 1; }
.landing-hero { min-height: 78vh; display: grid; align-content: center; justify-items: center; text-align: center; padding: 60px 20px 40px; }
.landing-hero .title-name { font-size: clamp(2.6rem, 10vw, 5.6rem); }
.landing-tag { font-size: clamp(1rem, 2.4vw, 1.3rem); color: var(--ink-soft); font-style: italic; margin: 6px 0 30px; max-width: 34ch; }
.landing-cta { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.landing-cta .btn { flex-direction: row; text-decoration: none; padding: 14px 28px; }
.landing-main { max-width: 1100px; margin: 0 auto; padding: 0 20px 40px; }
.landing-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.landing-features article {
    padding: 20px; background: rgba(26, 21, 16, 0.88); border: 1px solid var(--line-strong); border-radius: var(--radius); backdrop-filter: blur(4px);
}
.landing-features span { font-size: 1.8rem; }
.landing-features h2 { color: var(--gold-bright); font-size: 1.1rem; margin: 6px 0; }
.landing-features p { color: var(--ink-soft); font-size: 0.92rem; }
.landing-shot { margin-top: 36px; border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); background: var(--bg-2); }
.landing-shot img { width: 100%; height: auto; }
.landing-footer { text-align: center; padding: 24px 20px 40px; color: var(--muted); font-size: 0.85rem; }