:root {
  --ink: #07090b;
  --slate: #101619;
  --teal: #1d2b2e;
  --moss: #3d4a44;
  --amber: #c9a06a;
  --amber-hot: #ffcf8a;
  --blood: #b8402c;
  --bone: #d8d2c4;
  --bone-dim: rgba(216, 210, 196, 0.55);
  --line: rgba(216, 210, 196, 0.22);
  --glass: rgba(9, 12, 14, 0.42);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --display: 'Big Shoulders', 'Barlow Semi Condensed', sans-serif;
  --text: 'Barlow Semi Condensed', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; background: #05070a; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background:
    radial-gradient(ellipse 76% 72% at 50% 48%, rgba(0,0,0,0) 38%, rgba(0,0,0,0.28) 72%, rgba(0,0,0,0.78) 100%),
    linear-gradient(to bottom, rgba(0,0,0,0.36), rgba(0,0,0,0) 18%, rgba(0,0,0,0) 76%, rgba(0,0,0,0.5));
  transition: opacity 0.35s ease;
}

#grain {
  position: absolute; inset: -40px; pointer-events: none; z-index: 5; opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.9'/%3E%3C/svg%3E");
  animation: grainShift 0.65s steps(3) infinite;
  mix-blend-mode: overlay;
}
@keyframes grainShift {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-12px, 9px); }
  66% { transform: translate(9px, -14px); }
  100% { transform: translate(0, 0); }
}

#flash { position: absolute; inset: 0; pointer-events: none; z-index: 6; background: #cfe2f0; opacity: 0; }
#flash.strike { animation: flashStrike 0.42s steps(1) forwards; }
@keyframes flashStrike {
  0% { opacity: 0.85; }
  8% { opacity: 0.15; }
  13% { opacity: 0.7; }
  22% { opacity: 0.05; }
  30% { opacity: 0.3; }
  100% { opacity: 0; }
}

/* ---------------- HUD ---------------- */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#hud .hud-block { position: absolute; display: flex; align-items: center; gap: 10px; }
#hud button { pointer-events: auto; }

#objective {
  top: calc(var(--safe-t) + 30px);
  left: calc(var(--safe-l) + 26px);
  display: block;
}
.objective-row { display: flex; align-items: center; gap: 12px; }
.obj-rule { width: 1px; height: 19px; background: var(--bone); opacity: 0.8; }
#objective-text {
  font-family: var(--text);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: var(--bone);
  text-shadow: 0 1px 8px rgba(0,0,0,0.9);
}
.floor-tag {
  display: inline-block;
  margin-top: 7px;
  margin-left: 14px;
  padding: 3px 9px 4px;
  border: 1px solid rgba(216,210,196,0.34);
  color: rgba(216,210,196,0.78);
  font-family: var(--font-mono, mono);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  background: rgba(5,7,9,0.35);
}

#top-right {
  top: calc(var(--safe-t) + 16px);
  right: calc(var(--safe-r) + 24px);
  gap: 10px;
}
.players { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; color: var(--bone); letter-spacing: 0.08em; margin-right: 4px; text-shadow: 0 1px 6px #000; }
.person-icon {
  width: 12px; height: 15px; display: inline-block; position: relative;
}
.person-icon::before {
  content: ""; position: absolute; left: 3.5px; top: 0; width: 5px; height: 5px; border-radius: 50%;
  background: var(--bone);
}
.person-icon::after {
  content: ""; position: absolute; left: 0; top: 6px; width: 12px; height: 8px; border-radius: 6px 6px 2px 2px; background: var(--bone);
}
.glyph-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(200,196,184,0.28);
  background: rgba(10,13,15,0.36);
  display: grid; place-items: center;
  backdrop-filter: blur(2px);
  transition: background 0.2s, border-color 0.2s;
}
#top-right .glyph-btn { width: 40px; height: 40px; }
.pause-icon, .pause-bars { display: flex; gap: 4px; }
.pause-bars i { width: 3px; height: 14px; background: var(--bone); display: block; }
.gear { font-family: var(--font-mono, monospace); font-family: "IBM Plex Mono", monospace; font-size: 17px; color: var(--bone); }

/* stick */
#joystick, #stick-zone {
  position: absolute;
  left: calc(var(--safe-l) + 22px);
  bottom: calc(var(--safe-b) + 22px);
  width: clamp(120px, 22vh, 205px);
  height: clamp(120px, 22vh, 205px);
  pointer-events: auto;
}
#sprint-ring {
  position: absolute; inset: -9%;
  border-radius: 50%;
  border: 1px solid rgba(200,196,184,0.16);
  transition: border-color .2s, box-shadow .2s;
}
#sprint-ring.active { border-color: rgba(201,160,106,0.7); box-shadow: 0 0 18px rgba(201,160,106,0.25); }
#stick-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  transform: rotate(0deg);
  transition: transform 0.08s linear;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}
#stick-ring img { width: 100%; height: 100%; object-fit: contain; opacity: 0.92; }

/* right buttons */
#hud #actions {
  position: absolute;
  right: calc(var(--safe-r) + 24px);
  bottom: calc(var(--safe-b) + 22px);
  display: flex; align-items: flex-end; gap: 14px;
}
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, clamp(48px, 6.9vh, 62px));
  grid-template-rows: repeat(2, clamp(48px, 6.9vh, 62px));
  gap: 10px;
}
.action-btn {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 1px solid rgba(200,196,184,0.3);
  background: rgba(8,10,12,0.42);
  display: grid; place-items: center;
  transition: background .15s, border-color .15s, transform .1s;
  backdrop-filter: blur(2px);
}
.action-btn img { width: 66%; height: 66%; object-fit: contain; opacity: 0.96; filter: drop-shadow(0 1px 2px #000); }
.action-btn:active, .action-btn.pressed { transform: scale(0.94); background: rgba(201,160,106,0.20); border-color: rgba(201,160,106,0.65); }
.action-btn.active { border-color: rgba(201,160,106,0.75); background: rgba(201,160,106,0.14); }
.torch-btn {
  width: clamp(72px, 10.5vh, 96px) !important;
  height: clamp(72px, 10.5vh, 96px) !important;
  background: rgba(8,10,12,0.5);
  border-color: rgba(201,160,106,0.32);
  margin-bottom: 0;
}
.torch-inner { width: 66%; height: 66%; display: grid; place-items: center; }
.torch-inner img { width: 100%; height: 100%; object-fit: contain; }
.torch-arc {
  position: absolute; inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from -90deg, rgba(201,160,106,0.95) calc(var(--battery, 1) * 360deg), rgba(80,80,76,0.16) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.4px));
  pointer-events: none;
}
.torch-btn.low .torch-arc { background: conic-gradient(from -90deg, #c04a35 calc(var(--battery, 1) * 360deg), rgba(80,80,76,0.16) 0); }
.torch-btn.off .torch-arc { opacity: 0.4; }
.torch-btn.off .torch-inner { opacity: 0.4; }

/* reticle + prompt */
#reticle {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(216,210,196,0.55);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  opacity: 0.5; transition: transform .12s, opacity .12s, background .12s;
}
#reticle.hot { opacity: 1; transform: scale(1.9); background: var(--amber); }
#interact-prompt {
  position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; color: var(--bone);
  background: rgba(6,8,10,0.6); border: 1px solid rgba(216,210,196,0.2);
  padding: 6px 12px; white-space: nowrap; text-transform: uppercase;
}
#interact-prompt b { color: var(--amber); font-weight: 500; }
#interact-prompt.hidden { display: none; }

/* inventory chips */
#inventory-bar {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 20px); transform: translateX(-50%);
  display: flex; gap: 8px; pointer-events: auto; opacity: 0.85;
}
.chip-btn {
  border: 1px solid rgba(216,210,196,0.22);
  background: rgba(7,9,11,0.45);
  color: rgba(216,210,196,0.72);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.18em;
  padding: 6px 10px;
  backdrop-filter: blur(2px);
}
.chip-btn .key { opacity: .5; margin-left: 3px; }
.chip-btn:active { border-color: var(--amber); color: var(--amber); }

/* subtitle */
#subtitle-wrap {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%);
  width: min(74vw, 680px); text-align: center; pointer-events: none;
  transition: opacity .35s;
}
#subtitle-wrap.hidden { opacity: 0; }
.subtitle-rule { width: 100%; height: 1px; background: rgba(216,210,196,0.28); margin-bottom: 13px; }
#subtitle {
  font-family: var(--text); font-weight: 500; font-size: clamp(16px, 2.2vw, 24px);
  letter-spacing: 0.16em; color: #e7e1d6; text-transform: uppercase;
  text-shadow: 0 2px 12px #000, 0 0 2px #000;
}

#toast {
  position: absolute; left: 50%; top: calc(var(--safe-t) + 84px); transform: translateX(-50%);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.2em; color: var(--bone);
  background: rgba(6,8,10,0.72); border: 1px solid rgba(201,160,106,0.35);
  padding: 8px 14px; opacity: 0; transition: opacity .35s; pointer-events: none; text-align: center;
}
#toast.show { opacity: 1; }
#toast.warn { border-color: rgba(184,64,44,0.7); color: #e8b3a7; }

/* ---------------- TITLE ---------------- */
#title-screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.7s ease, visibility 0.7s;
}
#title-screen.gone { opacity: 0; pointer-events: none; visibility: hidden; }
#title-shade {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 62% 58% at 50% 34%, rgba(0,0,0,0.25), rgba(0,0,0,0.05) 64%, rgba(0,0,0,0) 100%),
    linear-gradient(to bottom, rgba(2,4,6,0.44), rgba(2,4,6,0.05) 32%, rgba(2,4,6,0.08) 68%, rgba(2,4,6,0.42));
}
.title-inner {
  position: relative; z-index: 2; text-align: center;
  padding: 0 4vw;
  transform: translateY(-26vh);
  display: flex; flex-direction: column; align-items: center;
}
#title-lockup {
  width: min(40vw, 620px);
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 24px rgba(0,0,0,0.85)) contrast(1.04);
  opacity: 0; animation: titleIn 1.5s ease 0.35s forwards;
}
@keyframes titleIn { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: scale(1); } }
.title-meta {
  margin-top: clamp(4px, 1.4vh, 16px);
  font-family: var(--text); font-weight: 400;
  font-size: clamp(11px, 1.55vh, 17px);
  letter-spacing: 0.34em;
  color: rgba(216,210,196,0.8); text-indent: 0.34em;
  text-shadow: 0 1px 8px #000;
}
.title-players {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin-top: clamp(8px, 1.8vh, 18px);
  font-family: var(--text); font-size: clamp(11px, 1.5vh, 15px); letter-spacing: 0.22em;
  color: rgba(216,210,196,0.72); text-shadow: 0 1px 8px #000;
}
.title-players .person-icon { transform: scale(0.92); }
.title-players .soon { margin-left: 10px; font-size: 8.5px; letter-spacing: 0.2em; color: rgba(216,210,196,0.36); }
#enter-house {
  margin-top: clamp(10px, 2.4vh, 24px);
  padding: clamp(9px, 1.5vh, 14px) clamp(22px, 3.4vw, 40px);
  border: 1px solid rgba(216,210,196,0.44);
  background: rgba(8,10,12,0.32);
  color: var(--bone);
  font-family: var(--text); font-weight: 500;
  font-size: clamp(12px, 1.8vh, 18px);
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  backdrop-filter: blur(3px);
  transition: background .25s, border-color .25s, letter-spacing .25s;
  box-shadow: 0 0 32px rgba(0,0,0,0.5), inset 0 0 22px rgba(201,160,106,0.05);
}
#enter-house:hover, #enter-house:focus-visible { background: rgba(201,160,106,0.13); border-color: rgba(201,160,106,0.75); letter-spacing: 0.26em; }
.title-note {
  margin-top: clamp(9px, 1.6vh, 16px);
  font-family: var(--text); font-size: clamp(9px, 1.25vh, 12px);
  letter-spacing: 0.12em; color: rgba(216,210,196,0.36);
}

/* ---------------- LOADING ---------------- */
#loading {
  position: absolute; inset: 0; z-index: 40; background: #05070a;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity 0.9s ease, visibility 0.9s;
}
#loading.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-mark { font-family: var(--display); font-weight: 500; font-size: clamp(22px, 4vw, 46px); letter-spacing: 0.18em; color: rgba(216,210,196,0.9); }
.loading-sub { font-family: var(--text); font-size: clamp(10px, 1.4vw, 14px); letter-spacing: 0.52em; color: rgba(201,160,106,0.72); margin-top: 6px; text-indent: .52em; }
.loading-bar { width: min(240px, 46vw); height: 1px; background: rgba(216,210,196,0.15); margin-top: 34px; overflow: hidden; }
.loading-bar i { display: block; height: 100%; width: 4%; background: var(--amber); transition: width .3s ease; }
.loading-text { margin-top: 12px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.24em; color: rgba(216,210,196,0.4); text-align: center; }

/* ---------------- MODALS ---------------- */
.modal { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 4vmin; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,4,6,0.74); backdrop-filter: blur(5px); }
.modal-x {
  position: absolute; top: 10px; right: 12px; width: 34px; height: 34px;
  font-size: 24px; line-height: 1; color: rgba(216,210,196,0.7); font-family: var(--text);
}
.modal-x:hover { color: var(--bone); }

.note-card {
  position: relative; z-index: 2;
  display: flex; gap: clamp(14px, 2.2vw, 34px); align-items: center;
  background: rgba(10,13,15,0.92); border: 1px solid rgba(216,210,196,0.2);
  padding: clamp(16px, 3vw, 34px);
  max-width: min(860px, 92vw);
  box-shadow: 0 30px 90px rgba(0,0,0,0.7);
}
.note-img-wrap { flex: 0 0 auto; width: clamp(150px, 30vw, 320px); background: rgba(0,0,0,0.5); }
.note-img-wrap img { width: 100%; height: auto; display: block; }
.note-text { min-width: 0; }
.note-kicker { font-family: var(--mono); font-size: 9px; letter-spacing: 0.26em; color: var(--amber); }
#note-title { font-family: var(--display); font-size: clamp(24px, 4vw, 46px); letter-spacing: 0.06em; font-weight: 500; margin: 6px 0 8px; color: var(--bone); }
#note-body { font-family: var(--text); font-size: clamp(13px, 1.7vw, 17px); line-height: 1.5; color: rgba(216,210,196,0.76); margin: 0 0 14px; max-width: 44ch; }
.note-foot { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.2em; color: rgba(216,210,196,0.34); }

.keypad {
  position: relative; z-index: 2;
  width: min(330px, 84vw);
  background: rgba(9,12,14,0.96);
  border: 1px solid rgba(216,210,196,0.22);
  padding: 20px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.75);
}
.pad-head { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--mono); letter-spacing: 0.16em; }
#lock-name { font-size: 13px; color: var(--bone); }
.pad-sub { font-size: 8px; color: rgba(216,210,196,0.4); }
#pad-display { display: flex; gap: 10px; justify-content: center; margin: 20px 0 8px; }
#pad-display span {
  width: 44px; height: 56px; display: grid; place-items: center;
  border: 1px solid rgba(201,160,106,0.3); background: rgba(201,160,106,0.05);
  font-family: var(--mono); font-size: 28px; color: var(--amber-hot);
  text-shadow: 0 0 14px rgba(255,190,110,0.6);
}
#pad-display.error span { border-color: rgba(184,64,44,0.8); color: #ff8a72; }
#pad-msg { text-align: center; font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; color: rgba(216,210,196,0.42); margin-bottom: 14px; min-height: 12px; }
.pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad-grid button {
  height: 48px; border: 1px solid rgba(216,210,196,0.18); background: rgba(216,210,196,0.03);
  font-family: var(--mono); font-size: 18px; color: var(--bone); transition: background .15s, border-color .15s;
}
.pad-grid button:active, .pad-grid button:hover { background: rgba(201,160,106,0.12); border-color: rgba(201,160,106,0.5); }

.plan-card {
  position: relative; z-index: 2; max-width: min(700px, 90vw);
  background: rgba(9,12,14,0.94); border: 1px solid rgba(216,210,196,0.18); padding: 14px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.75);
}
.plan-card img { width: 100%; height: auto; display: block; filter: sepia(0.08) contrast(1.02); }
.plan-caption { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; color: rgba(216,210,196,0.5); padding: 10px 2px 2px; }

.pause-card {
  position: relative; z-index: 2; width: min(520px, 90vw);
  background: rgba(8,11,13,0.96); border: 1px solid rgba(216,210,196,0.2);
  padding: clamp(22px, 4vw, 40px);
  box-shadow: 0 30px 90px rgba(0,0,0,0.8);
}
.pause-kicker { font-family: var(--mono); font-size: 9px; letter-spacing: 0.28em; color: var(--amber); }
.pause-card h2 { font-family: var(--display); font-weight: 500; font-size: clamp(34px, 5vw, 58px); letter-spacing: 0.1em; margin: 4px 0 18px; color: var(--bone); }
.pause-actions { display: flex; flex-direction: column; gap: 7px; }
.menu-btn {
  text-align: left; padding: 11px 14px; border: 1px solid rgba(216,210,196,0.18);
  font-family: var(--text); font-size: 13px; font-weight: 500; letter-spacing: 0.16em;
  color: rgba(216,210,196,0.86); background: rgba(216,210,196,0.02);
  transition: background .2s, border-color .2s;
}
.menu-btn:hover { background: rgba(201,160,106,0.1); border-color: rgba(201,160,106,0.4); }
.menu-btn.subtle { color: rgba(216,210,196,0.5); border-color: rgba(216,210,196,0.1); }
.pause-help { margin-top: 18px; border-top: 1px solid rgba(216,210,196,0.12); padding-top: 12px; }
.pause-help p { font-family: var(--text); font-size: 12px; line-height: 1.55; color: rgba(216,210,196,0.48); margin: 0 0 8px; }
.pause-help b { color: rgba(201,160,106,0.9); font-weight: 600; }

.end-inner {
  position: relative; z-index: 2; text-align: center; max-width: min(720px, 90vw);
}
.end-kicker { font-family: var(--mono); font-size: 10px; letter-spacing: 0.42em; color: var(--amber); }
.end-inner h2 { font-family: var(--display); font-weight: 500; font-size: clamp(52px, 11vw, 120px); letter-spacing: 0.14em; margin: 4px 0 0; color: var(--bone); line-height: 1; text-shadow: 0 10px 60px #000; }
.end-rule { width: 120px; height: 1px; background: rgba(216,210,196,0.4); margin: 18px auto; }
#end-line { font-family: var(--text); font-size: clamp(14px, 2vw, 19px); line-height: 1.55; color: rgba(216,210,196,0.7); max-width: 46ch; margin: 0 auto; }
.end-stats { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: rgba(216,210,196,0.45); margin-top: 14px; }
.end-actions { display: flex; gap: 10px; justify-content: center; margin-top: 24px; }
.end-actions .menu-btn { text-align: center; min-width: 150px; }

/* caught */
#caught-overlay {
  position: absolute; inset: 0; z-index: 25; pointer-events: none;
  opacity: 0; transition: opacity .16s ease;
  display: grid; place-items: center;
}
#caught-overlay.on { opacity: 1; }
#caught-overlay.hold { opacity: 1; }
#caught-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 42% 42% at 50% 50%, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.55) 55%, rgba(0,0,0,0.98) 100%);
}
#handprint {
  position: absolute; right: 8%; bottom: 8%; width: min(300px, 34vw);
  opacity: 0; filter: blur(1px) brightness(1.3) saturate(0.2);
  mix-blend-mode: screen;
}
#caught-overlay.on #handprint { animation: handIn 3.4s ease forwards; }
@keyframes handIn { 0% { opacity: 0; transform: scale(1.12); } 18% { opacity: .5; } 60% { opacity: .34; } 100% { opacity: 0; } }
#caught-text { position: relative; z-index: 2; text-align: center; transform: translateY(2vh); }
.caught-rule { width: 60px; height: 1px; background: rgba(216,210,196,0.3); margin: 0 auto 14px; }
#caught-line { font-family: var(--display); font-weight: 500; font-size: clamp(28px, 6vw, 64px); letter-spacing: 0.28em; color: rgba(232,226,214,0.9); text-indent: .28em; }
#caught-sub { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; color: rgba(216,210,196,0.45); margin-top: 10px; }

/* shake */
#app.shake #scene { animation: camShake .42s steps(2) 1; }
@keyframes camShake {
  0% { transform: translate(0,0); }
  20% { transform: translate(-9px, 5px); }
  40% { transform: translate(7px, -6px); }
  60% { transform: translate(-4px, -3px); }
  80% { transform: translate(3px, 4px); }
  100% { transform: translate(0,0); }
}

/* low battery */
#hud.low-battery #objective-text { color: #c9a06a; }
#hud.low-battery .floor-tag { border-color: rgba(201,160,106,0.5); color: rgba(201,160,106,0.8); }
#vignette.danger { background:
    radial-gradient(ellipse 68% 62% at 50% 48%, rgba(0,0,0,0) 30%, rgba(0,0,0,0.48) 66%, rgba(0,0,0,0.94) 100%),
    linear-gradient(to bottom, rgba(0,0,0,0.45), rgba(0,0,0,0) 20%, rgba(0,0,0,0) 70%, rgba(0,0,0,0.6)); }

#app.grayscale #scene { filter: grayscale(0.85) contrast(1.12) brightness(0.72) saturate(0.2); }

@media (max-aspect-ratio: 1/1) {
  #title-lockup { width: min(86vw, 520px); }
  .title-inner { transform: translateY(-18vh); }
  #objective { left: calc(var(--safe-l) + 16px); top: calc(var(--safe-t) + 14px); }
  #objective-text { font-size: 12.5px; }
  .floor-tag { font-size: 8px; margin-left: 12px; }
  #top-right { right: calc(var(--safe-r) + 12px); top: calc(var(--safe-t) + 10px); gap: 7px; flex-direction: column; align-items: flex-end; }
  #top-right .players { margin-right: 0; }
  #top-right .glyph-btn { width: 34px; height: 34px; }
  .players { font-size: 11px; }
  #stick-zone { left: calc(var(--safe-l) + 12px); bottom: calc(var(--safe-b) + 16px); width: clamp(112px, 19vh, 160px); height: clamp(112px, 19vh, 160px); }
  #hud #actions { right: calc(var(--safe-r) + 12px); bottom: calc(var(--safe-b) + 14px); gap: 9px; }
  .action-grid { grid-template-columns: repeat(2, 42px); grid-template-rows: repeat(2, 42px); gap: 7px; }
  .torch-btn { width: 62px !important; height: 62px !important; }
  #subtitle-wrap { bottom: calc(var(--safe-b) + 86px); width: 86vw; }
  #inventory-bar { display: none; }
  .note-card { flex-direction: column; align-items: flex-start; }
  .note-img-wrap { width: min(64vw, 260px); }
  #note-title { font-size: 28px; }
  .end-actions { flex-direction: column; align-items: center; }
  .pause-card { max-height: 86vh; overflow-y: auto; }
}

@media (max-height: 460px) {
  #title-lockup { width: min(44vw, 520px); }
  .title-inner { transform: translateY(-2vh); }
  .title-note { display: none; }
  #hud #actions { bottom: calc(var(--safe-b) + 8px); }
  #stick-zone { width: clamp(96px, 26vh, 140px); height: clamp(96px, 26vh, 140px); bottom: calc(var(--safe-b) + 8px); }
  #hud #actions { right: calc(var(--safe-r) + 12px); }
  .action-grid { grid-template-columns: repeat(2, 38px); grid-template-rows: repeat(2, 38px); gap: 6px; }
  .torch-btn { width: 56px !important; height: 56px !important; }
  #inventory-bar { bottom: calc(var(--safe-b) + 8px); }
  #subtitle-wrap { bottom: calc(var(--safe-b) + 62px); }
}


/* title state keeps the reference HUD, locked and quiet */
#hud.title #inventory-bar { display: none; }
#hud.title #reticle,
#hud.title #interact-prompt { display: none; }
#hud.title { opacity: 0.96; }
#hud.locked button,
#hud.locked #stick-zone { pointer-events: none; }

/* phones: the glass is composited over a live 3D canvas every frame.
   Blur reads that canvas back, and an animated full-screen grain repaints it,
   so both are the first things to go while every other mark stays. */
@media (pointer: coarse) {
  #grain { animation: none; opacity: 0.038; }
  .action-btn, .glyph-btn, .chip-btn, #enter-house { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
