:root {
    color-scheme: dark;
    --paper: #d9caa4;
    --paper-ink: #241d16;
    --paper-soft: #efe3c7;
    --charcoal: #151719;
    --charcoal-2: #202326;
    --rust: #a94d32;
    --amber: #d7a84f;
    --green: #6f8f68;
    --rail: #343739;
    --line: rgba(36, 29, 22, 0.42);
    --safe: #8dbb74;
    --danger: #c76052;
    --objective: #d8b75a;
    --focus: #f1d27a;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    width: 100%;
    background: #101214;
    color: var(--paper-soft);
    font-family: Georgia, "Times New Roman", serif;
}

body {
    overflow: hidden;
    touch-action: manipulation;
}

button {
    min-width: 44px;
    min-height: 46px;
    border: 1px solid rgba(239, 227, 199, 0.22);
    background: rgba(21, 23, 25, 0.86);
    color: var(--paper-soft);
    font: inherit;
    cursor: pointer;
}

button:hover,
button:focus {
    border-color: var(--focus);
    outline: 2px solid rgba(241, 210, 122, 0.2);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.app-shell {
    width: 100vw;
    height: 100svh;
    min-width: 0;
    position: relative;
    display: grid;
    grid-template-rows: auto auto 1fr;
    background:
        linear-gradient(rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.2)),
        radial-gradient(circle at 18% 22%, rgba(215, 168, 79, 0.18), transparent 32%),
        #121416;
}

.resource-row {
    display: grid;
    grid-template-columns: minmax(250px, 2.2fr) repeat(6, minmax(86px, 1fr));
    gap: 8px;
    padding: 10px 12px;
    background: rgba(18, 20, 22, 0.96);
    border-bottom: 1px solid rgba(239, 227, 199, 0.15);
    min-width: 0;
    max-width: 100vw;
}

.resource-tab {
    min-height: 50px;
    padding: 8px 10px;
    background: #2a261d;
    border: 1px solid rgba(239, 227, 199, 0.22);
    min-width: 0;
}

.resource-tab strong {
    display: block;
    font-size: 12px;
    letter-spacing: 0;
    color: #e5c878;
}

.resource-tab span {
    display: block;
    margin-top: 4px;
    font-size: 18px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.clock-tab {
    background: #3a241f;
    border-color: rgba(229, 200, 120, 0.48);
}

.clock-tab strong {
    font-size: 13px;
}

.clock-tab span {
    display: block;
    margin-top: 4px;
}

.clock-deadline {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    color: #f0d78f;
}

.clock-stamp {
    font-size: 16px;
    color: #efe3c7;
}

.clock-meta {
    font-size: 13px;
    color: rgba(239, 227, 199, 0.8);
}

.map-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.map-layer {
    position: absolute;
    inset: 0 476px 0 0;
    overflow: auto;
    padding: 26px;
    background:
        linear-gradient(90deg, rgba(36, 29, 22, 0.08) 1px, transparent 1px),
        linear-gradient(0deg, rgba(36, 29, 22, 0.08) 1px, transparent 1px),
        var(--paper);
    background-size: 44px 44px;
    color: var(--paper-ink);
}

.map-spacer {
    position: relative;
    pointer-events: none;
}

.node-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    pointer-events: none;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.route-line {
    position: absolute;
    height: 3px;
    background: rgba(93, 69, 45, 0.34);
    transform-origin: left center;
    pointer-events: none;
}

.route-line.visited {
    background: var(--rust);
}

.route-line.ghost {
    background: rgba(54, 62, 68, 0.35);
    border-top: 1px dashed rgba(54, 62, 68, 0.45);
}

.node-button {
    position: absolute;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #f2e6c9;
    color: var(--paper-ink);
    border: 2px solid #594630;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 4px 0 rgba(36, 29, 22, 0.18);
}

.node-button.reachable {
    border-color: var(--objective);
}

.node-button.current {
    background: var(--objective);
    border-color: var(--rust);
}

.node-button.visited {
    background: #e6d9bb;
}

.node-button.unknown {
    background: #ded3b7;
    border-style: dashed;
}

.node-button.danger-green {
    box-shadow: 0 0 0 4px rgba(111, 143, 104, 0.28);
}

.node-button.danger-yellow {
    box-shadow: 0 0 0 4px rgba(215, 168, 79, 0.26);
}

.node-button.danger-red {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(199, 96, 82, 0.24);
}

.node-button.unknown.danger-red {
    background: #ead9d1;
}

.node-button.unknown.danger-yellow {
    background: #eadfc2;
}

.node-label {
    position: absolute;
    width: 120px;
    margin-left: -33px;
    margin-top: 58px;
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
    color: #2d251b;
    pointer-events: none;
}

.map-note {
    position: absolute;
    left: 24px;
    bottom: 24px;
    max-width: 360px;
    padding: 14px 16px;
    background: rgba(239, 227, 199, 0.9);
    color: var(--paper-ink);
    border-left: 4px solid var(--rust);
}

.story-panel {
    position: absolute;
    top: 18px;
    right: 18px;
    bottom: 18px;
    width: min(440px, calc(100vw - 36px));
    overflow: auto;
    padding: 22px;
    background: rgba(239, 227, 199, 0.96);
    color: var(--paper-ink);
    border: 1px solid rgba(36, 29, 22, 0.35);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
    z-index: 10;
}

.story-panel h1,
.overlay-panel h2 {
    margin: 0 0 10px;
    font-size: 26px;
    line-height: 1.1;
}

.story-panel p {
    font-size: 18px;
    line-height: 1.45;
}

.goal-strip {
    margin: 12px 0;
    padding: 10px 12px;
    background: rgba(36, 29, 22, 0.08);
    border-left: 3px solid var(--rust);
    font-size: 16px;
}

.choice-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.choice-button {
    width: 100%;
    padding: 12px 14px;
    text-align: left;
    background: #2b2924;
    color: var(--paper-soft);
}

.choice-button small {
    display: block;
    margin-top: 4px;
    color: #d4c39b;
    font-size: 13px;
}

.result-text {
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(169, 77, 50, 0.12);
    border-left: 3px solid var(--rust);
}

.mode-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(18, 20, 22, 0.96);
    border-bottom: 1px solid rgba(239, 227, 199, 0.15);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100vw;
}

.tool-button {
    flex: 0 0 auto;
    height: 44px;
    min-height: 44px;
    padding: 8px 12px;
    white-space: nowrap;
}

.tool-button.active {
    border-color: var(--focus);
    color: var(--focus);
}

.overlay-stack {
    position: absolute;
    inset: 18px 20px 20px auto;
    width: min(980px, calc(100vw - 40px));
    pointer-events: none;
    z-index: 30;
}

.overlay-panel {
    width: min(420px, 100%);
    margin-left: auto;
    max-height: 100%;
    overflow: auto;
    padding: 18px;
    background: #202326;
    color: var(--paper-soft);
    border: 1px solid rgba(239, 227, 199, 0.18);
    pointer-events: auto;
}

.overlay-close {
    position: sticky;
    top: 0;
    z-index: 5;
    display: block;
    margin: 0 0 12px auto;
    background: #3a241f;
    border-color: rgba(215, 168, 79, 0.5);
}

.overlay-panel ul {
    padding-left: 18px;
}

.overlay-panel li {
    margin: 7px 0;
}

#inventory-panel,
#combat-panel {
    width: 100%;
}

.inventory-rpg-window {
    display: grid;
    grid-template-columns: minmax(360px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 14px;
    min-height: 0;
    padding: 12px;
    background:
        linear-gradient(135deg, rgba(239, 227, 199, 0.08), rgba(21, 23, 25, 0)),
        #141516;
    border: 1px solid rgba(215, 168, 79, 0.26);
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.36);
}

.inventory-left,
.inventory-right {
    min-width: 0;
}

.inventory-left {
    display: grid;
    grid-template-rows: auto auto;
    gap: 12px;
}

.inventory-right {
    display: grid;
    grid-template-rows: auto auto;
    gap: 12px;
    overflow: hidden;
}

.inventory-paper-doll {
    position: relative;
    min-height: 430px;
    height: min(58svh, 560px);
    background:
        linear-gradient(90deg, rgba(239, 227, 199, 0.05) 1px, transparent 1px),
        linear-gradient(0deg, rgba(239, 227, 199, 0.05) 1px, transparent 1px),
        #222326;
    background-size: 36px 36px;
    border: 1px solid rgba(239, 227, 199, 0.18);
    box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.55);
}

.paper-doll-figure {
    position: absolute;
    left: 50%;
    top: 46%;
    width: 92px;
    height: 220px;
    transform: translate(-50%, -50%);
    opacity: 0.62;
}

.paper-doll-head,
.paper-doll-body,
.paper-doll-legs {
    margin: 0 auto;
    border: 1px solid rgba(215, 168, 79, 0.28);
    background: rgba(239, 227, 199, 0.08);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6);
}

.paper-doll-head {
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.paper-doll-body {
    width: 78px;
    height: 96px;
    margin-top: 12px;
}

.paper-doll-legs {
    width: 62px;
    height: 58px;
    margin-top: 10px;
}

.equipment-slot,
.belt-cell,
.pack-cell {
    position: relative;
    display: grid;
    place-items: center;
    padding: 4px;
    background:
        radial-gradient(circle at 30% 20%, rgba(239, 227, 199, 0.12), transparent 42%),
        #101112;
    border: 1px solid rgba(239, 227, 199, 0.26);
    color: var(--paper-soft);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.equipment-slot:hover,
.belt-cell:hover,
.pack-cell.filled:hover,
.pack-cell.selected {
    border-color: var(--focus);
    background:
        radial-gradient(circle at 30% 20%, rgba(241, 210, 122, 0.22), transparent 48%),
        #171819;
}

.equipment-slot {
    position: absolute;
    width: 78px;
    height: 96px;
}

.equipment-slot-mainHand { left: 14px; top: 106px; height: 150px; }
.equipment-slot-head { left: 50%; top: 18px; transform: translateX(-50%); height: 76px; }
.equipment-slot-torso { left: 50%; top: 124px; transform: translateX(-50%); width: 90px; height: 122px; }
.equipment-slot-legs { right: 14px; top: 112px; height: 128px; }
.equipment-slot-feet { left: 50%; top: 276px; transform: translateX(-50%); height: 78px; }
.equipment-slot-hands { left: 14px; top: 268px; height: 78px; }
.equipment-slot-extra { left: 14px; top: 18px; height: 76px; }
.equipment-slot-quick { right: 14px; top: 268px; height: 78px; }

.slot-label,
.slot-item,
.item-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-label {
    position: absolute;
    left: 5px;
    top: 4px;
    right: 5px;
    font-size: 10px;
    color: rgba(239, 227, 199, 0.66);
}

.slot-icon,
.item-mark {
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    color: var(--amber);
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.7);
}

.equipment-slot.filled .slot-icon,
.pack-cell.filled .item-mark,
.belt-cell.filled {
    color: #f0d58a;
}

.slot-item {
    position: absolute;
    left: 5px;
    right: 5px;
    bottom: 5px;
    font-size: 11px;
}

.inventory-belt {
    display: grid;
    grid-template-columns: repeat(8, minmax(44px, 1fr));
    gap: 4px;
    padding: 8px;
    background: #171819;
    border: 1px solid rgba(239, 227, 199, 0.18);
}

.belt-cell {
    min-width: 0;
    min-height: 46px;
    height: 46px;
}

.inventory-pack {
    display: grid;
    grid-template-columns: repeat(12, minmax(44px, 1fr));
    grid-auto-rows: 48px;
    gap: 3px;
    padding: 10px;
    max-height: min(48svh, 520px);
    overflow: auto;
    background:
        linear-gradient(90deg, rgba(239, 227, 199, 0.04) 1px, transparent 1px),
        linear-gradient(0deg, rgba(239, 227, 199, 0.04) 1px, transparent 1px),
        #0d0e0f;
    background-size: 42px 42px;
    border: 1px solid rgba(215, 168, 79, 0.26);
}

.pack-cell {
    min-width: 0;
    min-height: 46px;
    height: 48px;
}

.pack-cell.empty {
    opacity: 0.58;
}

.pack-cell.filled {
    cursor: pointer;
}

.item-count {
    position: absolute;
    right: 3px;
    bottom: 2px;
    min-width: 16px;
    padding: 1px 3px;
    background: rgba(0, 0, 0, 0.66);
    color: var(--paper-soft);
    font-size: 11px;
}

.item-name {
    position: absolute;
    left: 3px;
    right: 3px;
    bottom: 2px;
    font-size: 9px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.pack-cell:hover .item-name,
.pack-cell.selected .item-name {
    opacity: 1;
}

.inventory-inspector {
    min-height: 170px;
    min-width: 0;
    padding: 12px;
    background: #202326;
    border: 1px solid rgba(239, 227, 199, 0.18);
    overflow-wrap: anywhere;
}

.inventory-inspector h3 {
    margin: 0 0 8px;
    color: var(--focus);
    overflow-wrap: anywhere;
}

.inventory-inspector p {
    margin: 0 0 10px;
    line-height: 1.35;
}

.inventory-inspector dl {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 5px 10px;
    margin: 0 0 10px;
    font-size: 14px;
}

.inventory-inspector dt {
    color: var(--amber);
}

.inventory-inspector dd {
    margin: 0;
}

.inventory-action {
    margin-top: 8px;
}

.combat-duel-window {
    display: grid;
    grid-template-columns: minmax(210px, 28%) 1fr minmax(210px, 28%);
    grid-template-rows: minmax(390px, 1fr) auto;
    gap: 12px;
    min-height: 560px;
    padding: 12px;
    background:
        linear-gradient(135deg, rgba(239, 227, 199, 0.08), rgba(21, 23, 25, 0)),
        #141516;
    border: 1px solid rgba(215, 168, 79, 0.26);
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.36);
}

.combat-fighter,
.combat-controls,
.combat-log {
    min-width: 0;
    background: #202326;
    border: 1px solid rgba(239, 227, 199, 0.18);
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.48);
}

.combat-fighter {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 10px;
    padding: 10px;
}

.combat-controls {
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    gap: 12px;
    padding: 14px;
}

.combat-hp-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    font-size: 13px;
}

.combat-hp-label strong {
    color: var(--focus);
}

.combat-hp-track {
    height: 14px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(239, 227, 199, 0.2);
    overflow: hidden;
}

.combat-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #517c44, #83bd64);
}

.combat-portrait {
    position: relative;
    min-height: 310px;
    background:
        linear-gradient(90deg, rgba(239, 227, 199, 0.05) 1px, transparent 1px),
        linear-gradient(0deg, rgba(239, 227, 199, 0.05) 1px, transparent 1px),
        #101112;
    background-size: 34px 34px;
    border: 1px solid rgba(239, 227, 199, 0.14);
    overflow: hidden;
}

.combat-figure {
    position: absolute;
    left: 50%;
    top: 52%;
    width: 86px;
    height: 210px;
    transform: translate(-50%, -50%);
    opacity: 0.58;
}

.combat-slots {
    position: absolute;
    inset: 0;
}

.combat-slot,
.combat-zone-hint,
.combat-quick-cell {
    display: grid;
    place-items: center;
    min-width: 0;
    background:
        radial-gradient(circle at 30% 20%, rgba(239, 227, 199, 0.12), transparent 42%),
        #101112;
    border: 1px solid rgba(239, 227, 199, 0.24);
    color: var(--paper-soft);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55);
}

.combat-slot {
    position: absolute;
    width: 58px;
    height: 66px;
    padding: 3px;
}

.combat-slot-mainHand { left: 8px; top: 76px; height: 122px; }
.combat-slot-head { left: 50%; top: 10px; transform: translateX(-50%); }
.combat-slot-torso { left: 50%; top: 94px; transform: translateX(-50%); width: 70px; height: 92px; }
.combat-slot-legs { right: 8px; top: 92px; height: 100px; }
.combat-slot-hands { left: 8px; top: 220px; }
.combat-slot-quick { right: 8px; top: 220px; }

.combat-slot span,
.combat-zone-hint span {
    font-size: 9px;
    color: rgba(239, 227, 199, 0.66);
}

.combat-slot strong,
.combat-zone-hint strong {
    font-size: 20px;
    line-height: 1;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    color: var(--amber);
}

.combat-enemy-zones {
    position: absolute;
    inset: 24px;
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
}

.combat-zone-hint.guarded {
    border-color: rgba(241, 210, 122, 0.7);
}

.combat-fighter-note {
    margin: 0;
    min-height: 48px;
    line-height: 1.3;
    font-size: 13px;
    color: rgba(239, 227, 199, 0.82);
}

.combat-result-line {
    min-height: 48px;
    padding: 10px;
    background: rgba(169, 77, 50, 0.12);
    border-left: 3px solid var(--rust);
    line-height: 1.35;
}

.combat-order-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
    padding: 8px 10px;
    background: rgba(239, 227, 199, 0.08);
    border: 1px solid rgba(239, 227, 199, 0.16);
    font-size: 14px;
}

.combat-order-summary strong {
    grid-column: 1 / -1;
    color: var(--focus);
}

.combat-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 18px;
    align-content: center;
}

.combat-choice-grid h3 {
    margin: 0 0 10px;
    text-align: center;
    color: var(--focus);
}

.combat-radio-list {
    display: grid;
    gap: 8px;
}

.combat-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 7px 9px;
    text-align: left;
    background: #101112;
}

.combat-radio.selected {
    border-color: var(--focus);
    background: rgba(215, 168, 79, 0.14);
}

.radio-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(239, 227, 199, 0.6);
    background: rgba(0, 0, 0, 0.34);
}

.combat-radio.selected .radio-dot {
    background: var(--focus);
}

.combat-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.combat-finish-state {
    display: grid;
    align-content: center;
    gap: 16px;
    min-height: 220px;
}

.combat-finish-note {
    padding: 12px;
    background: rgba(239, 227, 199, 0.08);
    border: 1px solid rgba(239, 227, 199, 0.16);
    text-align: center;
}

.combat-finish-note strong {
    display: block;
    margin-bottom: 8px;
    color: var(--focus);
}

.combat-finish-note p {
    margin: 0;
}

.combat-reward-box {
    padding: 12px;
    background: rgba(239, 227, 199, 0.08);
    border: 1px solid rgba(239, 227, 199, 0.16);
    text-align: center;
}

.combat-reward-box strong {
    display: block;
    margin-bottom: 8px;
    color: var(--focus);
}

.combat-reward-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
}

.combat-actions-finish {
    grid-template-columns: minmax(220px, 320px);
    justify-content: center;
}

.combat-actions-finish .choice-button {
    justify-self: center;
    width: 100%;
}

#reward-panel {
    width: min(520px, 100%);
}

#search-panel {
    width: min(620px, 100%);
}

.search-copy {
    margin: 0 0 14px;
    line-height: 1.4;
}

.search-meter {
    height: 18px;
    overflow: hidden;
    border: 1px solid rgba(239, 227, 199, 0.24);
    background: rgba(10, 12, 16, 0.72);
}

.search-meter span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--focus), var(--danger));
    transition: width 160ms ease;
}

.search-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(88px, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.search-stats div,
.search-found,
.search-log {
    padding: 10px;
    border: 1px solid rgba(239, 227, 199, 0.14);
    background: rgba(239, 227, 199, 0.06);
}

.search-stats strong,
.search-found strong {
    display: block;
    color: var(--focus);
}

.search-stats span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.82rem;
}

.search-found ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.search-found p,
.search-log p {
    margin: 0;
}

.search-log {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.reward-panel-copy {
    margin: 0 0 14px;
    line-height: 1.4;
}

.reward-summary {
    padding: 12px;
    background: rgba(239, 227, 199, 0.08);
    border: 1px solid rgba(239, 227, 199, 0.16);
}

.reward-summary strong {
    display: block;
    margin-bottom: 8px;
    color: var(--focus);
}

.reward-summary p {
    margin: 0;
}

.reward-list {
    margin: 0;
    padding-left: 18px;
}

.reward-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.combat-quick-row {
    display: grid;
    grid-template-columns: repeat(8, minmax(40px, 1fr));
    gap: 4px;
}

.combat-quick-cell {
    min-height: 40px;
    color: var(--amber);
}

@media (max-width: 980px) {
    .resource-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .clock-tab {
        grid-column: 1 / -1;
    }

    .story-panel {
        width: min(380px, calc(100vw - 24px));
        top: 12px;
        right: 12px;
        bottom: 12px;
        padding: 16px;
    }

    .map-layer {
        right: 404px;
    }

    .overlay-stack {
        inset: 12px;
        width: auto;
    }
}

@media (max-width: 1200px) {
    .inventory-rpg-window {
        grid-template-columns: 1fr;
    }

    .inventory-paper-doll {
        height: auto;
        min-height: 430px;
    }

    .inventory-pack {
        grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
        max-height: min(46svh, 460px);
    }
}

@media (max-width: 760px), (max-height: 620px) {
    body {
        overflow: hidden;
    }

    .app-shell {
        grid-template-rows: auto auto minmax(0, 1fr);
    }

    .resource-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding: 6px;
        overflow: hidden;
    }

    .resource-tab {
        min-height: 44px;
        padding: 6px 8px;
    }

    .resource-tab strong {
        font-size: 11px;
    }

    .resource-tab span {
        font-size: 15px;
        line-height: 1.15;
        word-break: break-all;
    }

    .clock-deadline {
        font-size: 20px;
    }

    .clock-stamp {
        font-size: 14px;
    }

    .clock-meta {
        font-size: 12px;
    }

    .mode-toolbar {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        padding: 6px;
        width: 100%;
        overflow-x: visible;
    }

    .tool-button {
        width: 100%;
        height: 40px;
        min-height: 40px;
        padding: 7px 6px;
        font-size: 14px;
        white-space: normal;
    }

    .map-layer {
        inset: 0;
        padding: 16px 14px 48svh 14px;
    }

    .story-panel {
        left: 8px;
        right: 8px;
        top: auto;
        bottom: 8px;
        width: auto;
        max-height: min(46svh, 360px);
        padding: 14px;
    }

    .story-panel h1,
    .overlay-panel h2 {
        font-size: 22px;
    }

    .story-panel p {
        font-size: 16px;
    }

    .choice-list {
        gap: 8px;
    }

    .choice-button {
        min-height: 46px;
        padding: 10px 12px;
    }

    .map-note {
        left: 10px;
        right: 10px;
        bottom: calc(46svh + 18px);
        max-width: none;
        padding: 10px 12px;
        font-size: 13px;
    }

    .node-button {
        width: 48px;
        height: 48px;
        font-size: 10px;
    }

    .node-label {
        width: 96px;
        margin-left: -24px;
        margin-top: 52px;
        font-size: 10px;
    }

    .overlay-stack {
        inset: 0;
        width: auto;
        z-index: 60;
    }

    .overlay-panel {
        width: 100%;
        min-height: 100svh;
        max-height: 100svh;
        margin-left: 0;
        padding: 14px;
        border-left: 0;
        border-right: 0;
    }

    #inventory-panel,
    #combat-panel,
    #search-panel,
    #reward-panel {
        width: 100%;
    }

    .inventory-rpg-window,
    .combat-duel-window {
        min-height: 0;
        padding: 8px;
    }

    .inventory-rpg-window {
        grid-template-columns: 1fr;
    }

    .inventory-left,
    .inventory-right {
        grid-template-rows: auto;
    }

    .inventory-paper-doll {
        min-height: 360px;
    }

    .equipment-slot {
        width: 70px;
        height: 84px;
    }

    .equipment-slot-mainHand { left: 10px; top: 92px; height: 120px; }
    .equipment-slot-head { top: 14px; height: 66px; }
    .equipment-slot-torso { top: 108px; width: 84px; height: 106px; }
    .equipment-slot-legs { right: 10px; top: 102px; height: 112px; }
    .equipment-slot-feet { top: 232px; height: 70px; }
    .equipment-slot-hands { left: 10px; top: 250px; height: 70px; }
    .equipment-slot-extra { left: 10px; top: 14px; height: 66px; }
    .equipment-slot-quick { right: 10px; top: 240px; height: 70px; }

    .inventory-belt,
    .combat-quick-row {
        grid-template-columns: repeat(4, minmax(44px, 1fr));
    }

    .inventory-pack {
        grid-template-columns: repeat(6, minmax(44px, 1fr));
        max-height: 44svh;
        overflow: auto;
    }

    .inventory-inspector dl {
        grid-template-columns: 78px 1fr;
    }

    .combat-duel-window {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .combat-controls {
        order: 1;
        grid-template-rows: auto;
    }

    .combat-hero {
        order: 2;
    }

    .combat-enemy {
        order: 3;
    }

    .combat-log {
        order: 4;
        grid-column: auto;
        max-height: 180px;
    }

    .combat-portrait {
        min-height: 250px;
    }

    .combat-choice-grid,
    .combat-actions,
    .reward-actions {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .combat-order-summary,
    .search-stats {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 420px) {
    .resource-row {
        grid-template-columns: 1fr 1fr;
    }

    .resource-tab span {
        font-size: 14px;
    }

    .mode-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .clock-deadline {
        font-size: 18px;
    }

    .story-panel {
        max-height: min(34svh, 280px);
        padding: 10px;
    }

    .map-layer {
        inset: 0;
        padding: 12px 10px 38svh 10px;
    }

    .map-note {
        display: none;
    }

    .inventory-pack {
        grid-template-columns: repeat(5, minmax(44px, 1fr));
    }

    .search-stats {
        grid-template-columns: 1fr;
    }
}

.combat-log {
    grid-column: 1 / -1;
    min-height: 104px;
    max-height: 150px;
    overflow: auto;
    padding: 10px 12px;
}

.combat-log strong {
    display: block;
    margin-bottom: 6px;
    color: var(--focus);
}

.combat-log p,
.combat-log ol {
    margin: 0;
}

.combat-log ol {
    padding-left: 20px;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    padding: 6px 8px;
    background: rgba(239, 227, 199, 0.12);
    border: 1px solid rgba(239, 227, 199, 0.18);
}

/* ── Transitions & Animations ──────────────────────────────────────── */

button {
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

/* Node buttons — hover scale + shadow pop */
.node-button {
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.node-button:hover:not(:disabled) {
    transform: scale(1.16);
    box-shadow: 0 8px 22px rgba(36, 29, 22, 0.38), 0 0 0 3px rgba(215, 168, 79, 0.22);
}

/* Current node — slow amber glow pulse */
.node-button.current {
    animation: currentPulse 2.6s ease-in-out infinite;
}

@keyframes currentPulse {
    0%, 100% { box-shadow: 0 4px 0 rgba(36, 29, 22, 0.18), 0 0 0 0   rgba(215, 168, 79, 0);    }
    50%       { box-shadow: 0 4px 0 rgba(36, 29, 22, 0.18), 0 0 0 12px rgba(215, 168, 79, 0.28); }
}

/* Reachable nodes — soft border flicker */
.node-button.reachable:not(.current) {
    animation: reachablePulse 1.8s ease-in-out infinite;
}

@keyframes reachablePulse {
    0%, 100% { border-color: var(--objective); }
    50%       { border-color: rgba(216, 183, 90, 0.45); }
}

/* Route lines — fade in on visited */
.route-line {
    transition: background 0.4s ease;
}

/* Overlay panels — slide in from right + fade when shown */
.overlay-panel:not([hidden]) {
    animation: overlayIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes overlayIn {
    from { transform: translateX(22px) scale(0.97); }
    to   { transform: translateX(0)   scale(1);    }
}

/* Story panel — title drops in, text fades up */
.story-panel h1 {
    animation: storyTitleIn 0.3s ease-out both;
}

.story-panel > p {
    animation: storyFadeIn 0.38s ease-out 0.07s both;
}

.goal-strip {
    animation: storyFadeIn 0.38s ease-out 0.12s both;
}

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

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

/* Result text — drops down */
.result-text {
    animation: resultIn 0.28s ease-out both;
}

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

/* Choice buttons — staggered slide from right */
.choice-button {
    transition: background 0.15s ease, transform 0.12s ease;
    animation: choiceIn 0.3s ease-out both;
    opacity: 0;
    animation-fill-mode: both;
}

.choice-button:hover {
    background: #3a3528;
    transform: translateX(5px);
}

.choice-list .choice-button:nth-child(1) { animation-delay: 0.10s; }
.choice-list .choice-button:nth-child(2) { animation-delay: 0.17s; }
.choice-list .choice-button:nth-child(3) { animation-delay: 0.24s; }
.choice-list .choice-button:nth-child(4) { animation-delay: 0.31s; }
.choice-list .choice-button:nth-child(5) { animation-delay: 0.38s; }
.choice-list .choice-button:nth-child(6) { animation-delay: 0.45s; }

@keyframes choiceIn {
    from { opacity: 0; transform: translateX(14px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Resource tabs — hover lift */
.resource-tab {
    transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
    cursor: default;
}

.resource-tab:hover {
    background: #35311f;
    transform: translateY(-2px);
    border-color: rgba(239, 227, 199, 0.38);
}

/* Tool buttons — active state transition */
.tool-button {
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

/* ── End Animations ─────────────────────────────────────────────────── */

/* ── Overview Map ───────────────────────────────────────────────────── */

.overview-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 32px;
    background: rgba(8, 9, 10, 0.72);
    animation: overviewFade 0.25s ease-out both;
}

.overview-overlay[hidden] {
    display: none;
}

@keyframes overviewFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.overview-inner {
    width: min(900px, 100%);
    max-height: 100%;
    overflow: auto;
    padding: 28px 30px;
    background:
        radial-gradient(circle at 20% 0%, rgba(215, 168, 79, 0.12), transparent 40%),
        var(--paper);
    color: var(--paper-ink);
    border: 1px solid rgba(36, 29, 22, 0.4);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    animation: overviewRise 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes overviewRise {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.overview-inner h2 {
    margin: 0 0 14px;
    font-size: 28px;
}

.overview-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 24px;
}

.overview-summary span {
    padding: 6px 12px;
    background: rgba(36, 29, 22, 0.08);
    border: 1px solid rgba(36, 29, 22, 0.18);
    font-size: 14px;
}

.overview-summary strong {
    color: var(--rust);
}

.overview-track {
    display: flex;
    align-items: flex-start;
    margin: 8px 0 26px;
}

.overview-region {
    flex: 0 0 auto;
    width: 120px;
    text-align: center;
    padding-top: 4px;
}

.overview-dot {
    width: 34px;
    height: 34px;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: #e6d9bb;
    border: 3px solid #594630;
}

.overview-region.completed .overview-dot {
    background: var(--safe);
    border-color: #4f7044;
}

.overview-region.current .overview-dot {
    background: var(--objective);
    border-color: var(--rust);
    animation: currentPulse 2.6s ease-in-out infinite;
}

.overview-region.locked {
    opacity: 0.45;
}

.overview-region.locked .overview-dot {
    border-style: dashed;
}

.overview-name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.overview-status {
    margin-top: 3px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(36, 29, 22, 0.6);
}

.overview-road {
    flex: 1 1 auto;
    height: 3px;
    margin-top: 19px;
    min-width: 24px;
    background: rgba(54, 62, 68, 0.4);
    border-top: 2px dashed rgba(54, 62, 68, 0.35);
}

.overview-road.done {
    background: var(--rust);
    border-top: 0;
}

/* ── End Overview Map ───────────────────────────────────────────────── */

@media (max-width: 760px) {
    .resource-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .clock-tab {
        grid-column: 1 / -1;
    }

    .map-layer {
        inset: 0;
        padding: 16px 14px 48svh 14px;
    }

    .story-panel {
        top: auto;
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        max-height: min(46svh, 360px);
    }

    .story-panel h1,
    .overlay-panel h2 {
        font-size: 22px;
    }

    .story-panel p {
        font-size: 17px;
    }

    .mode-toolbar {
        gap: 6px;
        padding: 6px;
    }

    .overlay-stack {
        inset: 0;
        width: auto;
        z-index: 60;
    }

    .overlay-panel,
    #inventory-panel,
    #combat-panel,
    #search-panel,
    #reward-panel {
        width: 100%;
        min-height: 100svh;
        max-height: 100svh;
        margin-left: 0;
    }

    .inventory-rpg-window {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .inventory-paper-doll {
        min-height: 360px;
    }

    .equipment-slot {
        width: 70px;
        height: 78px;
    }

    .equipment-slot-mainHand { left: 10px; top: 92px; height: 112px; }
    .equipment-slot-head { top: 14px; height: 68px; }
    .equipment-slot-torso { top: 106px; width: 82px; height: 108px; }
    .equipment-slot-legs { right: 10px; top: 94px; height: 114px; }
    .equipment-slot-feet { top: 226px; height: 68px; }
    .equipment-slot-hands { left: 10px; top: 230px; height: 68px; }
    .equipment-slot-extra { left: 10px; top: 14px; height: 68px; }
    .equipment-slot-quick { right: 10px; top: 230px; height: 68px; }

    .inventory-pack {
        grid-template-columns: repeat(6, minmax(44px, 1fr));
        grid-auto-rows: 46px;
        max-height: 44svh;
        overflow: auto;
    }

    .pack-cell {
        min-height: 46px;
        height: 46px;
    }

    .combat-duel-window {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        min-height: 0;
    }

    .combat-controls {
        order: 1;
    }

    .combat-hero {
        order: 2;
    }

    .combat-enemy {
        order: 3;
    }

    .combat-log {
        order: 4;
        grid-column: auto;
    }

    .combat-choice-grid {
        grid-template-columns: 1fr;
    }

    .combat-portrait {
        min-height: 280px;
    }
}

@media (max-width: 760px), (max-height: 620px) {
    .overlay-stack {
        inset: 0;
        width: auto;
    }

    .overlay-panel,
    #inventory-panel,
    #combat-panel,
    #search-panel,
    #reward-panel {
        width: 100%;
        min-height: 100%;
        max-height: 100%;
        margin-left: 0;
        padding: 12px;
        border-left: 0;
        border-right: 0;
    }

    .overlay-close {
        margin-bottom: 8px;
    }
}

@media (max-height: 620px) and (orientation: landscape) {
    .app-shell {
        grid-template-rows: auto auto minmax(0, 1fr);
    }

    .resource-row {
        grid-template-columns: minmax(170px, 1.5fr) repeat(6, minmax(70px, 1fr));
        gap: 4px;
        padding: 4px 6px;
    }

    .clock-tab {
        grid-column: auto;
    }

    .resource-tab {
        min-height: 38px;
        padding: 4px 6px;
    }

    .resource-tab strong {
        font-size: 10px;
    }

    .resource-tab span {
        margin-top: 2px;
        font-size: 13px;
        line-height: 1.05;
        word-break: normal;
    }

    .clock-deadline {
        font-size: 16px;
    }

    .clock-stamp {
        font-size: 13px;
    }

    .clock-meta {
        font-size: 11px;
    }

    .mode-toolbar {
        display: flex;
        gap: 6px;
        padding: 5px 6px;
        overflow-x: auto;
    }

    .tool-button {
        width: auto;
        height: 44px;
        min-height: 44px;
        padding: 4px 9px;
        font-size: 13px;
        white-space: nowrap;
    }

    .map-layer {
        inset: 0 438px 0 0;
        padding: 12px;
    }

    .story-panel {
        top: 8px;
        right: 8px;
        bottom: 8px;
        left: auto;
        width: min(430px, calc(100vw - 16px));
        max-height: none;
        padding: 8px;
    }

    .story-panel h1,
    .overlay-panel h2 {
        font-size: 16px;
        line-height: 1.05;
    }

    .story-panel p {
        font-size: 13px;
        line-height: 1.22;
    }

    .goal-strip {
        margin: 6px 0;
        padding: 6px 8px;
        font-size: 12px;
        line-height: 1.22;
    }

    .choice-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
        margin-top: 8px;
    }

    .choice-button {
        min-height: 46px;
        padding: 6px 8px;
        font-size: 13px;
        line-height: 1.18;
    }

    .choice-button small {
        margin-top: 2px;
        font-size: 11px;
    }

    .map-note {
        display: none;
    }

    .inventory-rpg-window,
    .combat-duel-window {
        padding: 8px;
    }

    .inventory-paper-doll {
        min-height: 320px;
    }
}

@media (max-width: 420px) and (orientation: portrait) {
    .resource-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
        padding: 4px;
    }

    .clock-tab {
        grid-column: 1 / -1;
        min-height: 58px;
    }

    .resource-tab {
        min-height: 40px;
        padding: 4px 6px;
    }

    .resource-tab strong {
        font-size: 10px;
    }

    .resource-tab span {
        margin-top: 2px;
        font-size: 12px;
        line-height: 1.05;
        word-break: normal;
    }

    .clock-deadline {
        font-size: 16px;
    }

    .clock-stamp {
        font-size: 12px;
    }

    .clock-meta {
        font-size: 11px;
    }

    .mode-toolbar {
        display: flex;
        gap: 4px;
        padding: 4px;
        overflow-x: auto;
        width: 100%;
    }

    .tool-button {
        flex: 0 0 auto;
        width: auto;
        height: 42px;
        min-height: 42px;
        padding: 4px 10px;
        font-size: 13px;
        white-space: nowrap;
    }

    .map-layer {
        inset: 0;
        padding: 10px 8px 36svh 8px;
    }

    .story-panel {
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        max-height: min(34svh, 260px);
        padding: 10px;
    }

    .story-panel h1 {
        font-size: 18px;
        margin-bottom: 6px;
    }

    .story-panel p {
        font-size: 14px;
        line-height: 1.25;
    }

    .goal-strip {
        margin: 8px 0;
        padding: 8px 10px;
        font-size: 14px;
    }

    .choice-list {
        gap: 6px;
        margin-top: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}
