@import url('data:text/css,');

:root {
  --ink: #24271f;
  --paper: #eee6d2;
  --paper-deep: #d8c9a9;
  --muted: #777966;
  --moss: #58664a;
  --moss-dark: #35402f;
  --red: #a34a36;
  --line: rgba(58, 57, 44, .24);
  --shadow: 0 24px 70px rgba(12, 16, 10, .32);
  --serif: "Songti SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #22291f; }
body { font-family: var(--sans); color: var(--paper); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible { outline: 2px solid #e7c983; outline-offset: 4px; }
[hidden] { display: none !important; }

#app { position: relative; width: 100%; height: 100%; overflow: hidden; isolation: isolate; }
#viewport, #viewport canvas { width: 100%; height: 100%; display: block; }
#viewport { position: absolute; inset: 0; background: linear-gradient(#9fb1ad, #d9d0ae 64%, #8d865d); }
#viewport canvas { touch-action: none; cursor: grab; }
#viewport canvas:active { cursor: grabbing; }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 48%, rgba(13, 19, 12, .12) 76%, rgba(13, 19, 12, .44) 120%); z-index: 2; }
.grain { position: absolute; inset: -40%; width: 180%; height: 180%; z-index: 3; pointer-events: none; opacity: .065; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E"); animation: grain 1.2s steps(3) infinite; }
@keyframes grain { 0% { transform: translate(0, 0); } 25% { transform: translate(2%, -3%); } 50% { transform: translate(-3%, 2%); } 75% { transform: translate(3%, 4%); } }

.loading { position: absolute; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; background: #283023; transition: opacity .8s ease, visibility .8s; text-align: center; }
.loading.done { opacity: 0; visibility: hidden; }
.loading strong { margin-top: 22px; font: 400 26px var(--serif); letter-spacing: .2em; }
.loading p { margin: 10px 0 24px; color: #b4b49d; font-size: 12px; letter-spacing: .12em; }
.loading-mark { display: flex; gap: 7px; align-items: end; height: 30px; }
.loading-mark span { width: 7px; height: 19px; background: #d1c29f; transform: skewY(-26deg); animation: loading-rise 1s ease-in-out infinite alternate; }
.loading-mark span:nth-child(2) { height: 28px; animation-delay: .16s; }
.loading-mark span:nth-child(3) { height: 22px; animation-delay: .32s; }
@keyframes loading-rise { to { transform: skewY(26deg) translateY(-7px); opacity: .4; } }
.loading-track { width: 180px; height: 1px; background: #4d5543; }
.loading-track i { display: block; width: 12%; height: 100%; background: #d7c9a8; transition: width .3s ease; }

.intro { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; padding: clamp(28px, 7vw, 110px); background: #283020; transition: opacity 1s ease, visibility 1s; }
.intro.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(25, 32, 23, .96) 0%, rgba(31, 37, 26, .82) 36%, rgba(31, 37, 26, .26) 74%, rgba(31, 37, 26, .2)); }
.intro-content { position: relative; width: min(690px, 100%); }
.intro-kicker, .eyebrow { font: 500 10px/1.4 var(--sans); letter-spacing: .26em; text-transform: uppercase; color: #d7c6a5; }
.intro h1 { margin: 20px 0 22px; font: 400 clamp(76px, 12vw, 154px)/.92 var(--serif); letter-spacing: -.1em; color: #f0e7d2; text-shadow: 0 6px 30px rgba(0,0,0,.18); }
.intro-lead { max-width: 580px; margin: 0 0 40px; color: #d0cfba; font: 400 clamp(15px, 1.45vw, 19px)/1.9 var(--serif); letter-spacing: .08em; }
.enter-button { display: inline-flex; align-items: center; gap: 42px; border: 1px solid rgba(238,230,210,.65); padding: 16px 20px 16px 26px; background: rgba(238,230,210,.06); color: #f0e7d2; font-size: 13px; letter-spacing: .18em; cursor: pointer; transition: background .25s, color .25s, transform .25s; }
.enter-button span { font-size: 20px; transition: transform .25s; }
.enter-button:hover { background: #e8dfcb; color: #31382b; transform: translateY(-2px); }
.enter-button:hover span { transform: translateX(5px); }
.intro-note { margin: 18px 0 0; color: #a9ac95; font-size: 10px; letter-spacing: .2em; }
.intro-footer { position: absolute; left: clamp(28px, 7vw, 110px); right: clamp(28px, 7vw, 110px); bottom: 28px; display: flex; justify-content: space-between; color: #aeb09d; font-size: 10px; letter-spacing: .12em; }

.hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.hud-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: max(22px, env(safe-area-inset-top)) 28px 36px; background: linear-gradient(rgba(22,27,19,.58), transparent); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 190px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid rgba(238,230,210,.55); font: 400 22px var(--serif); background: rgba(36,43,31,.4); }
.brand strong, .location-card strong { display: block; font: 400 15px var(--serif); letter-spacing: .12em; }
.brand small, .location-card small { display: block; margin-top: 4px; color: #cfceb9; font-size: 9px; letter-spacing: .14em; }
.location-card { display: flex; align-items: center; gap: 15px; max-width: 520px; padding: 10px 20px; border-left: 1px solid rgba(238,230,210,.35); border-right: 1px solid rgba(238,230,210,.35); background: rgba(27,33,24,.18); text-shadow: 0 1px 6px rgba(0,0,0,.5); }
.location-card > span { font: 400 11px var(--serif); color: #d9c49c; white-space: nowrap; }
.location-card small { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-actions { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.icon-button, .map-button { height: 38px; border: 1px solid rgba(238,230,210,.32); background: rgba(28,34,25,.36); backdrop-filter: blur(8px); cursor: pointer; transition: background .2s, border-color .2s; }
.icon-button:hover, .map-button:hover { background: rgba(54,64,43,.8); border-color: rgba(238,230,210,.68); }
.icon-button { width: 38px; display: grid; place-items: center; position: relative; }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-button span { position: absolute; top: 43px; left: 50%; transform: translateX(-50%); font-size: 9px; white-space: nowrap; color: #e2ddca; }
.icon-button[aria-pressed="true"] { border-color: #d9c08e; background: rgba(105,104,66,.7); }
.map-button { display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: 11px; letter-spacing: .1em; }
.map-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; }
kbd { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 4px; border: 1px solid rgba(238,230,210,.45); background: rgba(24,30,21,.35); color: #e6dfcb; font: 10px/1 var(--sans); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.map-button kbd { margin-left: 6px; font-size: 8px; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; transform: translate(-50%, -50%); opacity: .65; }
.crosshair i { position: absolute; background: rgba(255,255,235,.85); box-shadow: 0 0 2px #000; }
.crosshair i:first-child { width: 10px; height: 1px; top: 9px; left: 5px; }
.crosshair i:last-child { width: 1px; height: 10px; top: 5px; left: 9px; }
.interaction { position: absolute; left: 50%; top: calc(50% + 38px); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 9px 13px; background: rgba(25,31,22,.76); border: 1px solid rgba(239,228,203,.32); backdrop-filter: blur(6px); color: #f0e6ce; font-size: 12px; letter-spacing: .06em; white-space: nowrap; }
.interaction kbd { background: #e8dfc8; color: #30372a; border-color: #e8dfc8; }
.coordinates { position: absolute; left: 28px; bottom: 26px; color: rgba(238,230,210,.76); font-size: 9px; letter-spacing: .14em; text-shadow: 0 1px 5px #000; }
.controls-hint { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; padding: 7px 12px; background: rgba(24,30,21,.24); color: rgba(238,230,210,.82); font-size: 9px; letter-spacing: .06em; white-space: nowrap; }
.controls-hint span { display: flex; align-items: center; gap: 3px; }
.controls-hint kbd { min-width: 17px; height: 17px; font-size: 8px; }
.minimap-wrap { position: absolute; right: 26px; bottom: 24px; width: 150px; pointer-events: auto; }
.minimap-wrap canvas { display: block; width: 150px; height: 150px; border: 1px solid rgba(238,230,210,.42); background: rgba(30,37,27,.74); box-shadow: 0 8px 24px rgba(0,0,0,.16); }
.minimap-wrap > div { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 9px; color: #ded7c2; }
.minimap-wrap button { border: 0; padding: 0; background: none; color: inherit; cursor: pointer; letter-spacing: .1em; }
.minimap-wrap button:hover { color: #fff7e4; }
.mobile-controls { display: none; }

.modal { position: absolute; inset: 0; z-index: 15; display: grid; place-items: center; padding: 30px; background: rgba(18,23,16,.64); backdrop-filter: blur(9px); opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s; pointer-events: auto; }
.modal.open { opacity: 1; visibility: visible; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.modal-head h2 { margin: 6px 0 0; color: var(--ink); font: 400 30px var(--serif); letter-spacing: .08em; }
.close-button { width: 34px; height: 34px; border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 23px; line-height: 1; cursor: pointer; transition: background .2s; }
.close-button:hover { background: rgba(70,75,55,.12); }
.modal-intro { margin: 18px 0 22px; color: #6b6b58; font: 400 14px/1.8 var(--serif); }
.map-sheet, .info-sheet, .shop-sheet, .research-sheet { width: min(1120px, 100%); max-height: calc(100dvh - 60px); overflow: auto; padding: 30px 34px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.map-sheet::before, .info-sheet::before, .shop-sheet::before, .research-sheet::before { content: ""; position: absolute; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(220px, .7fr); gap: 30px; }
.large-map { position: relative; aspect-ratio: 1; min-height: 460px; background: #d8d1b9; border: 1px solid rgba(67,68,51,.25); overflow: hidden; }
.large-map canvas { width: 100%; height: 100%; display: block; }
.map-marker { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; border: 1px solid #eee7d1; background: var(--moss-dark); color: #f0e7d2; cursor: pointer; display: grid; place-items: center; font: 12px var(--serif); box-shadow: 0 3px 10px rgba(35,40,29,.25); transition: transform .2s, background .2s; }
.map-marker:hover { transform: translate(-50%, -50%) scale(1.12); background: var(--red); }
.map-marker.active { background: var(--red); }
.location-list { display: flex; flex-direction: column; gap: 0; align-content: start; }
.location-entry { display: grid; grid-template-columns: 30px 1fr; gap: 11px; align-items: start; width: 100%; padding: 14px 8px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.location-entry:hover { background: rgba(77,83,61,.08); }
.location-entry > span { font: 400 12px var(--serif); color: #7d775f; padding-top: 2px; }
.location-entry strong { display: block; font: 400 17px var(--serif); letter-spacing: .08em; }
.location-entry small { display: block; margin-top: 5px; color: #777662; font-size: 10px; line-height: 1.65; }
.info-sheet { width: min(650px, 100%); }
#info-content { color: #565a49; font: 400 15px/1.95 var(--serif); }
#info-content p { margin: 20px 0 0; }
.object-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.object-facts div { color: #77745f; font-size: 10px; line-height: 1.7; }
.object-facts strong { display: block; margin-bottom: 4px; color: #3d4434; font-size: 11px; font-weight: 500; }
.info-signature { margin-top: 28px; color: #91896e; font-size: 9px; letter-spacing: .18em; }
.shop-sheet { width: min(860px, 100%); }
.shop-content { display: grid; grid-template-columns: 1fr 230px; gap: 30px; }
.shop-products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.product { position: relative; display: grid; grid-template-columns: 58px 1fr; gap: 13px; min-height: 84px; align-items: center; padding: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.16); color: var(--ink); text-align: left; cursor: pointer; }
.product:hover { border-color: #73765d; background: rgba(255,255,255,.42); }
.product:disabled { opacity: .48; cursor: not-allowed; }
.product-icon { width: 58px; height: 58px; display: grid; place-items: center; background: #ded4bc; color: #62644e; }
.product-icon svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.product strong { display: block; font: 400 16px var(--serif); }
.product small { display: block; margin-top: 5px; color: #76725c; font-size: 10px; line-height: 1.5; }
.product-price { display: block; margin-top: 7px; color: var(--red); font-size: 11px; }
.shop-summary { padding: 20px; background: #ded4bc; align-self: start; }
.shop-summary h3 { margin: 0 0 18px; font: 400 17px var(--serif); letter-spacing: .1em; }
.wallet-row, .receipt-total { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 12px; border-bottom: 1px solid rgba(60,62,46,.2); color: #6f6b56; font-size: 11px; }
.wallet-row strong { color: var(--ink); font: 400 27px var(--serif); }
.receipt-items { min-height: 108px; margin: 12px 0; color: #66634e; font-size: 10px; line-height: 1.9; }
.receipt-items p { margin: 0; display: flex; justify-content: space-between; gap: 12px; }
.receipt-empty { color: #938a70 !important; font-family: var(--serif); }
.pay-button { width: 100%; margin-top: 16px; border: 0; padding: 13px; background: var(--moss-dark); color: var(--paper); font-size: 11px; letter-spacing: .18em; cursor: pointer; }
.pay-button:hover:not(:disabled) { background: #4b593e; }
.pay-button:disabled { opacity: .4; cursor: not-allowed; }
.shop-note { margin: 12px 0 0; color: #8b8166; font-size: 9px; line-height: 1.7; }
.research-sheet { width: min(760px, 100%); }
.research-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 24px; }
.research-grid h3 { margin: 0 0 10px; font: 400 18px var(--serif); color: #424b38; }
.research-grid p, .research-grid li { color: #656553; font: 400 13px/1.85 var(--serif); }
.research-grid ul { margin: 0; padding-left: 17px; }
.research-note { grid-column: 1 / -1; margin-top: 6px; padding-top: 18px; border-top: 1px solid var(--line); color: #81785f; font-size: 10px; line-height: 1.8; }
.toast { position: absolute; left: 50%; bottom: 92px; z-index: 40; transform: translate(-50%, 12px); padding: 12px 20px; background: rgba(31,38,27,.94); border: 1px solid rgba(238,230,210,.34); color: #f0e7d2; font-size: 12px; letter-spacing: .06em; opacity: 0; visibility: hidden; transition: opacity .25s, transform .25s, visibility .25s; pointer-events: none; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.webgl-error { position: absolute; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; padding: 30px; background: #283023; text-align: center; }
.webgl-error h2 { font: 400 32px var(--serif); }
.webgl-error p { color: #b8bba6; max-width: 460px; line-height: 1.8; }
.webgl-error button { margin-top: 18px; border: 1px solid #bdb59d; background: transparent; color: #ece4ce; padding: 11px 24px; cursor: pointer; }

@media (max-width: 980px) {
  .hud-top { padding-left: 18px; padding-right: 18px; }
  .brand { min-width: auto; }
  .brand > div { display: none; }
  .location-card { max-width: 310px; }
  .location-card small { max-width: 210px; }
  .icon-button span { display: none; }
  .controls-hint { display: none; }
  .minimap-wrap { width: 124px; right: 18px; bottom: 18px; }
  .minimap-wrap canvas { width: 124px; height: 124px; }
  .coordinates { left: 18px; bottom: 20px; }
}

@media (max-width: 680px) {
  .intro { align-items: center; padding: 26px; }
  .intro-shade { background: linear-gradient(0deg, rgba(25,32,23,.96), rgba(31,37,26,.5) 70%, rgba(31,37,26,.36)); }
  .intro-content { align-self: flex-end; margin-bottom: 72px; }
  .intro h1 { font-size: clamp(66px, 20vw, 100px); margin: 14px 0 18px; }
  .intro-lead { font-size: 13px; line-height: 1.8; margin-bottom: 26px; }
  .intro-kicker { font-size: 9px; }
  .enter-button { padding: 13px 18px; gap: 30px; }
  .intro-footer { left: 26px; right: 26px; bottom: 22px; justify-content: center; }
  .intro-footer span:last-child { display: none; }
  .hud-top { padding: max(12px, env(safe-area-inset-top)) 12px 28px; align-items: flex-start; }
  .brand-mark { width: 31px; height: 31px; font-size: 18px; }
  .location-card { position: absolute; top: 58px; left: 12px; max-width: calc(100vw - 24px); padding: 8px 11px; border: 1px solid rgba(238,230,210,.24); background: rgba(28,34,25,.32); backdrop-filter: blur(5px); }
  .location-card > span { font-size: 9px; }
  .location-card strong { font-size: 12px; }
  .location-card small { display: none; }
  .hud-actions { gap: 5px; margin-left: auto; }
  .icon-button, .map-button { height: 32px; }
  .icon-button { width: 32px; }
  .map-button { padding: 0 8px; font-size: 10px; gap: 5px; }
  .map-button kbd { display: none; }
  #research-button { display: none; }
  .crosshair { opacity: .45; }
  .minimap-wrap { width: 94px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .minimap-wrap canvas { width: 94px; height: 94px; }
  .minimap-wrap > div { font-size: 8px; }
  .coordinates { display: none; }
  .interaction { top: auto; bottom: 168px; font-size: 11px; }
  .mobile-controls { display: block; position: absolute; inset: 0; pointer-events: none; }
  .joystick { position: absolute; left: 24px; bottom: calc(25px + env(safe-area-inset-bottom)); width: 100px; height: 100px; border: 1px solid rgba(238,230,210,.35); border-radius: 50%; background: rgba(30,37,27,.2); pointer-events: auto; touch-action: none; }
  .joystick i { position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; transform: translate(-50%, -50%); border: 1px solid rgba(238,230,210,.6); border-radius: 50%; background: rgba(238,230,210,.22); }
  .look-zone { position: absolute; left: 145px; right: 118px; bottom: 30px; height: 90px; display: grid; place-items: center; color: rgba(238,230,210,.3); font-size: 9px; letter-spacing: .2em; pointer-events: auto; touch-action: none; }
  .mobile-interact { position: absolute; right: 24px; bottom: calc(143px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border: 1px solid rgba(238,230,210,.5); border-radius: 50%; background: rgba(38,46,32,.42); color: #f0e7d2; font-size: 11px; letter-spacing: .1em; pointer-events: auto; }
  .modal { padding: 10px; }
  .map-sheet, .info-sheet, .shop-sheet, .research-sheet { padding: 22px 18px; max-height: calc(100dvh - 20px); }
  .modal-head h2 { font-size: 24px; }
  .modal-head .eyebrow { font-size: 8px; }
  .modal-intro { font-size: 12px; }
  .map-layout { grid-template-columns: 1fr; gap: 14px; }
  .large-map { min-height: 0; }
  .location-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .location-entry { grid-template-columns: 20px 1fr; padding: 10px 4px; gap: 6px; }
  .location-entry strong { font-size: 14px; }
  .location-entry small { font-size: 9px; }
  .object-facts { grid-template-columns: 1fr; gap: 10px; }
  .shop-content { grid-template-columns: 1fr; gap: 18px; }
  .shop-products { grid-template-columns: 1fr; }
  .shop-summary { padding: 16px; }
  .receipt-items { min-height: 0; }
  .research-grid { grid-template-columns: 1fr; gap: 20px; }
  .research-note { grid-column: auto; }
  .toast { bottom: 220px; width: max-content; max-width: calc(100vw - 32px); text-align: center; }
}

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