:root {
  color-scheme: dark;
  font-family: 'DM Sans', Arial, sans-serif;
  background: #080a0b;
  color: #e8e5df;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --paper: #e8e5df;
  --muted: #858783;
  --rust: #b55c3b;
  --amber: #d4a768;
  --line: rgba(232, 229, 223, 0.17);
}

* { box-sizing: border-box; }
html, body, #game-shell { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { min-width: 320px; background: #080a0b; }
button { font: inherit; }
#game-shell { position: relative; isolation: isolate; background: #080a0b; }
#game-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
.screen-grain, .screen-vignette, .alert-wash { position: absolute; inset: 0; pointer-events: none; }
.screen-grain { z-index: 2; opacity: .14; mix-blend-mode: soft-light; 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='.91' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E"); }
.screen-vignette { z-index: 3; background: radial-gradient(ellipse at center, transparent 34%, rgba(0, 0, 0, .27) 72%, rgba(0, 0, 0, .83) 125%); }
.alert-wash { z-index: 4; opacity: 0; transition: opacity .3s ease; background: radial-gradient(ellipse at center, transparent 34%, rgba(123, 19, 22, .16) 76%, rgba(123, 19, 22, .46) 120%); }
#game-shell.escape-running::after { content: ''; position: absolute; z-index: 4; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 40%, rgba(10, 8, 7, .2) 73%, rgba(10, 8, 7, .72) 125%); animation: escape-pulse .22s ease-in-out infinite alternate; }
@keyframes escape-pulse { from { opacity: .55; } to { opacity: 1; } }
.hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .45s ease; }
.hud.active { opacity: 1; }
.hud-topline { position: absolute; top: 28px; left: 34px; right: 34px; display: flex; align-items: center; justify-content: space-between; }
.brand-mark, .eyebrow, .hud .floor-readout, .stamina-heading, .item-state, .threat-state, .bottom-hint, .sound-button, .menu-kicker, .menu-stats span, .menu-footnote, .menu-side-note, .control-note { font-family: 'DM Mono', monospace; letter-spacing: .11em; }
.brand-mark { color: rgba(233, 230, 222, .66); font-size: 10px; }
.brand-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: #b5533d; box-shadow: 0 0 14px rgba(208, 70, 45, .72); vertical-align: 1px; }
.brand-divider { color: #a2523d; margin: 0 7px; }
.sound-button { pointer-events: auto; border: 1px solid rgba(235, 229, 215, .25); color: rgba(235, 229, 215, .74); background: rgba(10, 12, 13, .34); padding: 9px 12px; font-size: 9px; cursor: pointer; transition: background .2s, border .2s; }
.sound-button:hover { background: rgba(166, 79, 54, .24); border-color: rgba(235, 177, 123, .48); }
.hud-left { position: absolute; top: 18%; left: 34px; width: 245px; }
.objective-card { padding: 14px 16px 15px; border-left: 1px solid rgba(212, 167, 104, .75); background: linear-gradient(90deg, rgba(10, 12, 13, .75), rgba(10, 12, 13, .12)); }
.eyebrow { display: block; color: #c18d57; font-size: 9px; line-height: 1.4; }
.objective-card strong { display: block; margin-top: 7px; color: #f0ede5; font-size: 14px; font-weight: 500; line-height: 1.45; }
.objective-sub { display: block; margin-top: 5px; color: rgba(228, 224, 214, .57); font-size: 11px; }
.floor-readout { display: flex; align-items: center; gap: 10px; margin: 23px 0 0 2px; color: rgba(239, 234, 224, .8); font-size: 10px; }
.floor-icon { width: 13px; height: 13px; display: inline-block; border: 1px solid #c18d57; transform: rotate(45deg) scale(.7); box-shadow: 0 0 10px rgba(193, 141, 87, .3); }
.stamina-wrap { width: 160px; margin: 28px 0 0 2px; }
.stamina-heading { display: flex; justify-content: space-between; margin-bottom: 7px; color: rgba(236, 231, 220, .54); font-size: 8px; }
.stamina-track { height: 2px; background: rgba(231, 229, 219, .2); }
.stamina-fill { width: 100%; height: 100%; background: #c4915c; transition: width .12s linear; }
.hud-right { position: absolute; top: 19%; right: 35px; display: grid; gap: 11px; min-width: 105px; }
.item-state { display: grid; grid-template-columns: 18px auto auto; align-items: center; gap: 8px; color: rgba(235, 231, 221, .5); font-size: 8px; }
.item-state b { justify-self: end; color: rgba(235, 231, 221, .48); font-size: 8px; font-weight: 400; }
.item-state.owned { color: #e5bc7e; }
.item-state.owned b { color: #e5bc7e; }
.item-glyph { display: block; position: relative; width: 13px; height: 13px; opacity: .7; }
.key-glyph::before { content: ''; position: absolute; top: 1px; left: 1px; width: 6px; height: 6px; border: 1px solid currentColor; border-radius: 50%; }
.key-glyph::after { content: ''; position: absolute; top: 7px; left: 6px; width: 7px; height: 1px; background: currentColor; transform: rotate(42deg); transform-origin: left center; box-shadow: 4px 2px 0 -0.2px currentColor; }
.bone-glyph::before, .bone-glyph::after { content: ''; position: absolute; top: 0; width: 6px; height: 6px; border: 1px solid currentColor; border-radius: 50%; }
.bone-glyph::before { left: 0; box-shadow: 7px 7px 0 -1px rgba(0,0,0,0), 0 0 0 0 currentColor; }
.bone-glyph::after { right: 0; top: 7px; }
.bone-glyph { border-top: 1px solid currentColor; width: 12px; top: 5px; transform: rotate(45deg); }
.detector-glyph::before { content: ''; position: absolute; left: 0; bottom: 0; width: 8px; height: 5px; border: 1px solid currentColor; border-radius: 50%; }
.detector-glyph::after { content: ''; position: absolute; right: 1px; top: 0; width: 1px; height: 9px; background: currentColor; transform: rotate(18deg); box-shadow: -2px 8px 0 -0.2px currentColor; }
.shovel-glyph::before { content: ''; position: absolute; left: 5px; top: 0; width: 1px; height: 11px; background: currentColor; transform: rotate(32deg); }
.shovel-glyph::after { content: ''; position: absolute; left: 1px; bottom: 0; width: 7px; height: 4px; border: 1px solid currentColor; transform: rotate(-25deg); }
.note-glyph::before { content: ''; position: absolute; left: 2px; top: 1px; width: 9px; height: 11px; border: 1px solid currentColor; transform: skewY(-10deg); }
.note-glyph::after { content: ''; position: absolute; left: 4px; top: 5px; width: 6px; height: 1px; background: currentColor; box-shadow: 0 3px 0 currentColor; }
.detector-signal { padding: 8px 9px; border-left: 1px solid rgba(212, 167, 104, .58); background: rgba(9, 11, 11, .42); }
.signal-heading { display: flex; justify-content: space-between; gap: 8px; color: rgba(232, 226, 215, .55); font: 7px 'DM Mono', monospace; letter-spacing: .06em; }
.signal-heading b { color: #c7a174; font-weight: 400; }
.signal-track, .dig-track { height: 3px; margin-top: 7px; background: rgba(232, 229, 223, .18); }
.signal-track i, .dig-track i { display: block; width: 0; height: 100%; background: #bd8b55; transition: width .15s linear; }
.detector-signal.strong .signal-track i { background: #d85c3d; box-shadow: 0 0 10px rgba(218, 75, 49, .72); }
.threat-state { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: rgba(232, 229, 222, .43); font-size: 8px; }
.threat-dot { display: block; width: 6px; height: 6px; border-radius: 50%; background: #58685d; box-shadow: 0 0 9px rgba(86, 128, 91, .35); }
.threat-state.warn { color: #d3a371; }
.threat-state.warn .threat-dot { background: #d19550; box-shadow: 0 0 12px rgba(238, 152, 63, .8); }
.threat-state.resting { color: #9fbd95; }
.threat-state.resting .threat-dot { background: #769a6e; box-shadow: 0 0 10px rgba(118, 154, 110, .52); }
.threat-state.danger { color: #d86a53; }
.threat-state.danger .threat-dot { background: #cb4439; box-shadow: 0 0 15px rgba(245, 64, 48, .9); animation: threat-pulse .7s infinite alternate; }
@keyframes threat-pulse { to { opacity: .3; transform: scale(.75); } }
.crosshair { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; opacity: .7; transform: translate(-50%, -50%); }
.crosshair span, .crosshair i { position: absolute; background: rgba(232, 225, 211, .72); }
.crosshair span { left: 6px; top: 2px; width: 1px; height: 10px; }
.crosshair i { left: 2px; top: 6px; width: 10px; height: 1px; }
.interaction-prompt { position: absolute; left: 50%; top: calc(50% + 33px); transform: translateX(-50%); padding: 9px 13px; color: #f0e9db; background: rgba(12, 13, 13, .74); border: 1px solid rgba(214, 174, 121, .42); font-size: 12px; white-space: nowrap; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.interaction-prompt strong { color: #e5b874; font-family: 'DM Mono', monospace; font-size: 10px; font-weight: 500; margin-right: 8px; }
.toast { position: absolute; left: 50%; top: 17%; transform: translate(-50%, -8px); opacity: 0; padding: 10px 16px; color: #eee6d6; background: rgba(8, 10, 10, .83); border-left: 2px solid #c18d57; font-size: 12px; transition: opacity .22s, transform .22s; white-space: nowrap; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.bone-charge { position: absolute; left: 50%; bottom: 23%; width: min(240px, calc(100vw - 40px)); padding: 9px 12px; transform: translateX(-50%); border: 1px solid rgba(212, 167, 104, .4); background: rgba(8, 10, 10, .8); color: #e8ddc8; font: 8px 'DM Mono', monospace; letter-spacing: .1em; text-align: center; }
.bone-charge[hidden] { display: none; }
.bone-charge-track { height: 4px; margin-top: 7px; background: rgba(232, 229, 223, .18); }
.bone-charge-track i { display: block; width: 0; height: 100%; background: #d1a565; transition: width .04s linear; }
.dig-progress { position: absolute; left: 50%; bottom: 17%; width: min(300px, calc(100vw - 40px)); padding: 12px 14px; transform: translateX(-50%); border: 1px solid rgba(212, 167, 104, .42); background: rgba(8, 10, 10, .83); color: #e8ddc8; font: 9px 'DM Mono', monospace; letter-spacing: .1em; text-align: center; }
.dig-progress[hidden] { display: none; }
.dig-track { height: 4px; }
.dig-track i { background: #d1a565; }
.level-transition { position: absolute; inset: 0; background: #050607; opacity: 0; transition: opacity .25s; }
.bottom-hint { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); color: rgba(224, 221, 212, .37); font-size: 8px; white-space: nowrap; }
.bottom-hint span:first-child { color: rgba(232, 226, 213, .72); }
.hint-separator { margin: 0 8px; color: #a85c3c; }

.overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 48% 42%, rgba(8, 10, 10, .38), rgba(5, 7, 8, .83) 66%, rgba(3, 4, 5, .95)); }
.overlay[hidden] { display: none; }
.menu-overlay { justify-content: flex-start; padding-left: clamp(32px, 12vw, 180px); }
.menu-panel { width: min(510px, calc(100vw - 48px)); padding: 35px 40px 29px; border: 1px solid rgba(235, 230, 218, .13); background: linear-gradient(135deg, rgba(16, 19, 19, .85), rgba(10, 12, 12, .62)); box-shadow: 0 22px 90px rgba(0, 0, 0, .35); backdrop-filter: blur(8px); position: relative; }
.menu-panel::before { content: ''; position: absolute; top: -1px; left: -1px; width: 76px; height: 2px; background: #b95f3d; }
.menu-kicker { color: #c7905b; font-size: 8px; line-height: 1.5; }
.menu-panel h1 { margin: 24px 0 14px; color: #eeeae0; font-family: 'Oswald', Impact, sans-serif; font-weight: 500; font-size: clamp(52px, 7vw, 82px); letter-spacing: .025em; line-height: .92; text-shadow: 0 5px 34px rgba(0, 0, 0, .55); }
.menu-panel h1 em { color: #c9945c; font-style: normal; }
.menu-lead { max-width: 380px; margin: 18px 0 25px; color: rgba(231, 228, 219, .69); font-size: 13px; line-height: 1.7; }
.menu-rule { height: 1px; background: linear-gradient(90deg, rgba(211, 169, 112, .54), rgba(211, 169, 112, 0)); }
.menu-stats { display: grid; grid-template-columns: .72fr 1.25fr 1fr; gap: 14px; padding: 18px 0 22px; }
.menu-stats div { display: flex; flex-direction: column; gap: 7px; }
.menu-stats span { color: rgba(224, 218, 203, .43); font-size: 7px; }
.menu-stats strong { color: rgba(239, 232, 216, .86); font-size: 10px; font-weight: 500; line-height: 1.4; }
.primary-button { width: 100%; min-height: 48px; padding: 0 16px 0 19px; display: flex; justify-content: space-between; align-items: center; border: 1px solid rgba(220, 172, 113, .57); color: #f3e8d5; background: linear-gradient(100deg, rgba(129, 68, 46, .83), rgba(84, 48, 36, .78)); font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .16em; cursor: pointer; transition: transform .2s ease, background .2s ease, border .2s ease; }
.primary-button:hover { transform: translateY(-2px); background: linear-gradient(100deg, rgba(158, 79, 50, .95), rgba(104, 56, 37, .9)); border-color: rgba(239, 194, 133, .9); }
.primary-button b { color: #edc186; font-size: 16px; font-weight: 400; }
.menu-secondary-button { display: block; width: 100%; margin-top: 10px; padding: 10px 0 4px; border: 0; color: rgba(235, 229, 215, .82); background: transparent; text-align: left; font-family: 'DM Mono', monospace; font-size: 9px; letter-spacing: .13em; cursor: pointer; }
.menu-secondary-button span { margin-left: 10px; color: rgba(224, 219, 208, .36); font-size: 7px; letter-spacing: .08em; }
.menu-secondary-button:hover { color: #e5b874; }
.menu-footnote { margin: 12px 0 0; color: rgba(224, 219, 208, .35); font-size: 7px; }
.menu-side-note { position: absolute; right: 34px; bottom: 29px; display: flex; gap: 20px; color: rgba(230, 223, 211, .34); font-size: 8px; writing-mode: vertical-rl; }
.settings-overlay { background: radial-gradient(ellipse at 48% 42%, rgba(8, 10, 10, .48), rgba(5, 7, 8, .91) 72%); backdrop-filter: blur(5px); }
.settings-panel { width: min(520px, calc(100vw - 40px)); padding: 36px 40px 29px; border: 1px solid rgba(225, 217, 202, .15); background: rgba(15, 17, 17, .91); box-shadow: 0 28px 90px rgba(0, 0, 0, .45); }
.settings-panel h2 { margin: 10px 0 4px; color: #efe9dd; font-family: 'Oswald', Impact, sans-serif; font-size: 48px; font-weight: 400; }
.settings-intro { margin: 0 0 22px; color: rgba(227, 222, 211, .56); font-size: 12px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 0; border-top: 1px solid rgba(232, 229, 223, .1); cursor: pointer; }
.setting-row > span { display: flex; flex-direction: column; gap: 5px; }
.setting-row strong { color: #e9e4d9; font-size: 12px; font-weight: 500; }
.setting-row small { color: rgba(227, 222, 211, .45); font-size: 10px; }
.setting-row select { min-width: 116px; padding: 9px 26px 9px 10px; border: 1px solid rgba(220, 172, 113, .34); border-radius: 0; outline: none; color: #eee5d6; background: #202322; font: 10px 'DM Mono', monospace; cursor: pointer; }
.setting-row select:focus { border-color: #c9945c; }
.range-control { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.range-control input { width: 132px; accent-color: #c9945c; cursor: pointer; }
.range-control output { min-width: 35px; color: #e5b874; font: 10px 'DM Mono', monospace; }
.performance-button { display: flex; width: 100%; flex-direction: column; gap: 6px; margin-top: 13px; padding: 11px 12px; border: 1px solid rgba(212, 167, 104, .28); color: #e7dcc8; background: rgba(110, 74, 42, .16); text-align: left; cursor: pointer; }
.performance-button strong { font: 9px 'DM Mono', monospace; letter-spacing: .11em; }
.performance-button span { color: rgba(227, 222, 211, .46); font-size: 9px; }
.performance-button:hover, .performance-button.active { border-color: rgba(228, 169, 101, .72); background: rgba(148, 91, 47, .3); }
.settings-panel .primary-button { margin-top: 12px; }
.settings-note { margin: 14px 0 0; color: rgba(224, 219, 208, .36); font: 8px 'DM Mono', monospace; line-height: 1.6; }
#game-shell.performance-mode .screen-grain, #game-shell.performance-mode .screen-vignette, #game-shell.performance-mode .alert-wash { display: none; }
.pause-overlay { background: rgba(4, 6, 6, .78); backdrop-filter: blur(6px); }
.pause-panel { width: min(420px, calc(100vw - 42px)); padding: 40px; border: 1px solid rgba(225, 217, 202, .15); background: rgba(15, 17, 17, .84); box-shadow: 0 28px 90px rgba(0, 0, 0, .45); }
.pause-panel h2 { margin: 13px 0 7px; color: #efe9dd; font-family: 'Oswald', Impact, sans-serif; font-size: 54px; font-weight: 400; }
.pause-panel p { color: rgba(227, 222, 211, .6); font-size: 13px; line-height: 1.6; margin: 0 0 22px; }
.pause-panel .primary-button { margin-top: 22px; }
.code-overlay { background: rgba(3, 5, 6, .86); backdrop-filter: blur(7px); }
.code-panel-ui { width: min(390px, calc(100vw - 40px)); padding: 34px; border: 1px solid rgba(212, 167, 104, .38); background: rgba(13, 16, 16, .96); box-shadow: 0 28px 90px rgba(0, 0, 0, .62); }
.code-panel-ui h2 { margin: 9px 0; color: #efe9dd; font-family: 'Oswald', Impact, sans-serif; font-size: 38px; font-weight: 400; }
.code-panel-ui p { margin: 0 0 20px; color: rgba(227, 222, 211, .6); font-size: 12px; line-height: 1.6; }
.code-input-label { display: block; margin-bottom: 8px; color: #c18d57; font: 8px 'DM Mono', monospace; letter-spacing: .13em; }
#code-input { width: 100%; height: 54px; border: 1px solid rgba(212, 167, 104, .5); outline: none; color: #e8d5b2; background: rgba(3, 6, 6, .8); font: 24px 'DM Mono', monospace; letter-spacing: .45em; text-align: center; }
#code-input:focus { border-color: #d4a768; box-shadow: 0 0 18px rgba(212, 167, 104, .16); }
.code-panel-ui .code-feedback { min-height: 18px; margin: 9px 0 2px; color: #d9795a; font: 9px 'DM Mono', monospace; letter-spacing: .06em; }
.code-panel-ui .primary-button { margin-top: 7px; }
.code-panel-ui .code-cancel { text-align: center; }
.control-note { margin: 22px 0 0 !important; color: rgba(225, 220, 209, .4) !important; font-size: 8px !important; line-height: 2 !important; }
.ending-panel h2 { font-size: 48px; }
.ending-panel .primary-button { margin-top: 25px; }

.mobile-controls { display: none; position: absolute; z-index: 7; inset: auto 0 max(16px, env(safe-area-inset-bottom)) 0; justify-content: space-between; align-items: flex-end; padding: 0 20px; pointer-events: none; }
.mobile-controls button { pointer-events: auto; color: rgba(239, 234, 225, .88); background: rgba(11, 13, 13, .55); border: 1px solid rgba(230, 219, 197, .3); border-radius: 50%; backdrop-filter: blur(4px); touch-action: none; }
.move-pad { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.move-pad > button, .move-pad div button { width: 43px; height: 43px; font-size: 12px; }
.move-pad div { display: flex; gap: 5px; }
.touch-actions { width: 148px; display: grid; grid-template-columns: repeat(2, 54px); justify-content: end; gap: 8px; }
.touch-actions button { width: 54px; height: 54px; font-family: 'DM Mono', monospace; font-size: 10px; }
.touch-actions button[data-action='sprint'], .touch-actions button[data-action='crouch'] { border-radius: 20px; font-size: 7px; }
.touch-look-hint { display: none; position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%); color: rgba(237, 231, 218, .45); font: 8px 'DM Mono', monospace; letter-spacing: .1em; white-space: nowrap; pointer-events: none; }
.mobile-controls button:active, .mobile-controls button.pressed { background: rgba(155, 82, 53, .75); }

@media (max-width: 760px) {
  .menu-overlay { justify-content: center; padding: 18px; }
  .menu-panel { padding: 29px 25px 24px; }
  .settings-panel { padding: 28px 23px 22px; }
  .code-panel-ui { padding: 25px 22px; }
  .code-panel-ui h2 { font-size: 34px; }
  .settings-panel h2 { font-size: 42px; }
  .setting-row { gap: 10px; }
  .setting-row small { max-width: 185px; font-size: 9px; line-height: 1.45; }
  .setting-row select { min-width: 92px; padding-right: 16px; font-size: 9px; }
  .range-control { min-width: 115px; gap: 5px; }
  .range-control input { width: 82px; }
  .range-control output { min-width: 29px; font-size: 9px; }
  .menu-panel h1 { font-size: clamp(55px, 16vw, 78px); }
  .menu-stats { gap: 7px; }
  .menu-stats strong { font-size: 9px; }
  .menu-side-note { right: 12px; bottom: 10px; font-size: 6px; }
  .hud-topline { top: 13px; left: 14px; right: 14px; }
  .brand-mark { font-size: 7px; }
  .sound-button { padding: 7px 8px; font-size: 7px; }
  .hud-left { top: 13%; left: 14px; width: min(210px, 57vw); }
  .objective-card { padding: 10px 11px; }
  .objective-card strong { font-size: 12px; }
  .objective-sub { font-size: 9px; }
  .floor-readout { margin-top: 15px; font-size: 8px; }
  .stamina-wrap { margin-top: 16px; width: 125px; }
  .hud-right { top: 13%; right: 14px; min-width: 83px; gap: 8px; }
  .item-state { grid-template-columns: 14px auto auto; gap: 5px; font-size: 7px; }
  .threat-state { font-size: 7px; }
  .bottom-hint { display: none; }
  .mobile-controls { display: flex; }
  .touch-look-hint { display: block; }
  .interaction-prompt { top: 56%; max-width: calc(100vw - 28px); white-space: normal; font-size: 10px; }
  .toast { top: 22%; max-width: 90vw; white-space: normal; text-align: center; font-size: 10px; }
  .pause-panel { padding: 30px 25px; }
}
@media (max-height: 620px) and (min-width: 761px) {
  .menu-panel { padding-top: 23px; padding-bottom: 20px; }
  .menu-panel h1 { font-size: 57px; margin-top: 14px; }
  .menu-lead { margin: 13px 0 17px; }
  .menu-stats { padding: 13px 0 15px; }
}
