/* MDT BACKROOMS - the MDT look (near-black glass, gold for the main actions)
   gone damp and yellow: a typewriter face for the found notes, the level's
   accent (--acc) on the HUD, film grain and a VHS edge over everything. */
:root {
  --ink: #f4ecd6; --mute: #b5aa8c; --faint: #6f6650; --bg: #0b0905; --glass: rgba(16, 13, 8, 0.9); --glass2: rgba(28, 24, 16, 0.8);
  --line: rgba(255, 236, 180, 0.1); --line2: rgba(255, 236, 180, 0.22);
  --gold: #f0c868; --gold2: #ffd98a; --goldInk: #2a1c04; --acc: #e8d27a; --good: #46e39a; --bad: #ff5a5a;
  --font: Inter, -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif; --type: 'Special Elite', 'Courier New', monospace;
  --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);
  --tb: 64px;
}
body[data-btn="small"] { --tb: 52px; } body[data-btn="large"] { --tb: 78px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input { -webkit-user-select: text; user-select: text; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { flex: none; }
#buildTag { position: fixed; right: 6px; bottom: calc(4px + var(--safe-b)); font: 10px system-ui, sans-serif; color: rgba(255, 255, 255, 0.35); z-index: 95; pointer-events: none; }
.muted { color: var(--mute); } .small { font-size: 13px; }
.kick { display: block; font-size: 11.5px; font-weight: 800; letter-spacing: 1.8px; text-transform: uppercase; color: var(--acc); }
h2 { font: 800 24px/1.15 var(--font); margin: 4px 0 6px; letter-spacing: -0.2px; }
h3 { font: 800 14px/1.2 var(--font); margin: 16px 0 4px; color: var(--gold2); letter-spacing: 1px; text-transform: uppercase; }
p { margin: 6px 0; }
kbd { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.07); font: 700 12px var(--font); text-align: center; }

/* --- screen effects */
#vignette { position: fixed; inset: 0; z-index: 3; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.85) 100%); opacity: 0.6; transition: opacity 0.4s; }
#vignette.chase { background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0) 38%, rgba(40, 0, 0, 0.9) 100%); }
#grain { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; opacity: 0.07; mix-blend-mode: overlay; image-rendering: pixelated; }
body.noGrain #grain { display: none; }
#vhs { position: fixed; inset: 0; z-index: 4; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, rgba(0, 0, 0, 0) 1px 3px); mix-blend-mode: multiply; }
#vhs::after { content: ''; position: absolute; inset: 0; box-shadow: inset 3px 0 0 rgba(255, 0, 60, 0.05), inset -3px 0 0 rgba(0, 200, 255, 0.05); animation: roll 7s linear infinite; background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.025) 50%, rgba(255, 255, 255, 0) 52%); background-size: 100% 300%; }
@keyframes roll { from { background-position: 0 0; } to { background-position: 0 300%; } }
body.noVhs #vhs { display: none; }
body[data-phase="title"] #vignette { opacity: 0.85 !important; }
#flash { position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0; }
#flash.red { background: radial-gradient(circle, rgba(255, 0, 0, 0.1), rgba(120, 0, 0, 0.75)); opacity: 1; animation: red 0.12s steps(2) infinite; }
@keyframes red { 50% { opacity: 0.6; } }
#flash.glitch { opacity: 1; background: repeating-linear-gradient(0deg, rgba(232, 210, 122, 0.25) 0 2px, rgba(0, 0, 0, 0) 2px 9px); animation: gl 0.08s steps(3) infinite; }
@keyframes gl { 33% { transform: translateX(-8px); } 66% { transform: translateX(6px); } }
#fade { position: fixed; inset: 0; z-index: 70; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.6s; }
#fade.on { opacity: 1; pointer-events: auto; }

/* --- loading */
#loading { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: radial-gradient(circle at 50% 42%, #2a2410, var(--bg) 68%); transition: opacity 0.5s; }
#loading.gone { opacity: 0; pointer-events: none; }
.ld { text-align: center; width: 270px; }
.ld b { display: block; font: 900 34px var(--font); letter-spacing: 7px; color: #e8d27a; text-shadow: 0 0 18px rgba(232, 210, 122, 0.45); }
.ld .bar { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); margin: 16px 0 10px; overflow: hidden; }
.ld .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #e8d27a, var(--gold)); transition: width 0.3s; }
.ld span { color: var(--mute); font: 14px var(--type); }

/* --- buttons */
.btn { flex: 1; min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.07); font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; transition: transform 0.12s, background 0.2s; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; }
.btn.gold { background: linear-gradient(180deg, var(--gold2), var(--gold) 60%, #d9a640); border-color: rgba(255, 230, 160, 0.7); color: var(--goldInk); box-shadow: 0 6px 20px rgba(240, 200, 104, 0.2); }
.btn.big { min-height: 54px; font-size: 17px; }
.btn.sm { flex: none; min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(255, 90, 90, 0.14); border-color: rgba(255, 90, 90, 0.5); color: #ffb8b8; }
.btns { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }
.link { background: none; border: 0; color: var(--gold); padding: 8px 0; font-weight: 650; }
.err { color: var(--bad); min-height: 18px; font-size: 13px; margin: 4px 0; }
.card input:not([type=range]) { width: 100%; height: 48px; border-radius: 13px; border: 1px solid var(--line2); background: rgba(0, 0, 0, 0.35); color: var(--ink); padding: 0 14px; font: inherit; margin-bottom: 8px; }
form { margin: 0; }

/* --- the title card */
#title { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; padding: calc(var(--mdts-h, 52px) + 20px) 6vw calc(24px + var(--safe-b)); background: linear-gradient(90deg, rgba(11, 9, 5, 0.9), rgba(11, 9, 5, 0.5) 46%, rgba(11, 9, 5, 0) 72%); overflow-y: auto; }
.tCard { max-width: 500px; }
.tKick { font-size: 12px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; color: var(--gold); }
.tLogo { position: relative; margin: 2px 0 10px; font: 900 clamp(46px, 10vw, 86px)/0.95 var(--font); letter-spacing: 4px; color: #efe0a0; text-shadow: 0 0 24px rgba(232, 210, 122, 0.35); }
.tLogo::before, .tLogo::after { content: attr(data-text); position: absolute; inset: 0; pointer-events: none; }
.tLogo::before { color: rgba(255, 40, 80, 0.7); clip-path: inset(0 0 60% 0); opacity: 0; animation: glA 4.2s steps(1) infinite; }
.tLogo::after { color: rgba(40, 220, 255, 0.7); clip-path: inset(55% 0 0 0); opacity: 0; animation: glB 3.7s steps(1) infinite; }
@keyframes glA { 0%, 92% { opacity: 0; transform: none; } 93% { opacity: 1; transform: translate(-7px, 1px); } 95% { opacity: 1; transform: translate(4px, -1px); } 97% { opacity: 0; } }
@keyframes glB { 0%, 88% { opacity: 0; transform: none; } 89% { opacity: 1; transform: translate(8px, 0); } 91% { opacity: 1; transform: translate(-5px, 1px); } 93% { opacity: 0; } }
.tTag { font: 16px/1.5 var(--type); color: #e4d8b8; margin: 0 0 14px; }
.tWorld { font-size: 14px; color: var(--mute); padding: 10px 13px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); }
.tWorld b { color: var(--ink); }
.tWorld .link { padding: 0; }
i.live { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #46e39a; box-shadow: 0 0 10px #46e39a; margin-right: 7px; animation: blink 1.6s infinite; }
i.live.off { background: #6f6650; box-shadow: none; animation: none; }
@keyframes blink { 50% { opacity: 0.35; } }
#title .btns { max-width: 360px; }
.tLinks { display: flex; gap: 22px; }
.tLevels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tLevels span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 99px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); font-size: 12px; font-weight: 650; }
.tLevels span.dim { color: var(--faint); }
.tLevels i { width: 7px; height: 7px; border-radius: 50%; }
.tLevels span.dim i { background: #3a352a !important; }
@media (max-width: 640px) {
  #title { align-items: flex-end; background: linear-gradient(0deg, rgba(11, 9, 5, 0.96), rgba(11, 9, 5, 0.65) 60%, rgba(11, 9, 5, 0.1)); }
  .tTag { font-size: 14.5px; }
}

/* --- the HUD */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#hud button { pointer-events: auto; }
#lvlPill { position: fixed; top: calc(12px + var(--safe-t)); left: calc(12px + var(--safe-l)); display: flex; flex-direction: column; padding: 7px 13px 8px; border-radius: 12px; background: rgba(8, 7, 4, 0.55); border-left: 3px solid var(--acc); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); max-width: 46vw; }
#lvlPill b { font: 800 11px var(--font); letter-spacing: 2.4px; color: var(--acc); }
#lvlPill span { font: 15px var(--type); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#compass { position: fixed; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(380px, 44vw); height: 30px; overflow: hidden; border-radius: 10px; background: rgba(8, 7, 4, 0.45); -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); }
#compassTape { position: absolute; left: 0; top: 0; height: 100%; }
#compassTape span { position: absolute; top: 7px; transform: translateX(-50%); font: 700 11px var(--font); color: rgba(244, 236, 214, 0.4); }
#compassTape span.big { color: var(--ink); font-size: 13px; top: 6px; } #compassTape span.mid { color: rgba(244, 236, 214, 0.7); }
#compass > i { position: absolute; left: 50%; bottom: 0; width: 2px; height: 7px; background: var(--acc); transform: translateX(-50%); }
#compass .marks em { position: absolute; top: 3px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; }
#compass .marks em.trk { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
#compass .marks em.png { background: #ff5ad2; box-shadow: 0 0 8px #ff5ad2; }
#compass .marks em.ext { background: #3cff8a; border-radius: 2px; box-shadow: 0 0 8px #3cff8a; }
#mini { position: fixed; top: calc(70px + var(--safe-t)); left: calc(12px + var(--safe-l)); width: 120px; height: 120px; opacity: 0.92; }
#mini.large { width: 190px; height: 190px; }
.hRight { position: fixed; top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); display: flex; gap: 8px; }
.hb { position: relative; width: 44px; height: 44px; border-radius: 13px; border: 1px solid var(--line2); background: rgba(8, 7, 4, 0.55); display: grid; place-items: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.hb svg { width: 22px; height: 22px; fill: var(--ink); }
.hb b { position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--acc); color: #1a1508; font: 800 10.5px/18px var(--font); }
#cross { position: fixed; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); box-shadow: 0 0 3px #000; }
#prompt { position: fixed; left: 50%; top: 60%; transform: translateX(-50%); padding: 9px 16px; border-radius: 12px; background: rgba(8, 7, 4, 0.7); text-align: center; font: 15px var(--type); max-width: 80vw; }
#prompt b.ex { color: #3cff8a; font: 900 13px var(--font); letter-spacing: 2px; margin-right: 6px; }
#prompt span { display: block; font: 600 12px var(--font); color: var(--mute); margin-top: 2px; }
#subs { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); padding: 6px 14px; border-radius: 8px; background: rgba(0, 0, 0, 0.6); font: 15px var(--type); color: #f4ecd6; opacity: 0; transition: opacity 0.4s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#subs.on { opacity: 1; }
#meters { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#stam { width: 180px; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, 0.5); overflow: hidden; }
#stam i { display: block; height: 100%; background: var(--ink); border-radius: 3px; transition: background 0.3s; }
#stam.tired i { background: var(--bad); }
#icons { display: flex; gap: 6px; }
#icons span { font: 800 10px var(--font); letter-spacing: 1.5px; padding: 2px 7px; border-radius: 5px; background: rgba(0, 0, 0, 0.55); color: var(--acc); }
#distTxt { font: 12px var(--type); color: rgba(244, 236, 214, 0.55); }
#fps { position: fixed; right: 10px; bottom: calc(18px + var(--safe-b)); font: 11px monospace; color: #9f9; background: rgba(0, 0, 0, 0.5); padding: 2px 6px; border-radius: 4px; }
#lockHint { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); padding: 10px 18px; border-radius: 12px; background: rgba(8, 7, 4, 0.75); font-weight: 600; font-size: 14px; }
body.touch #meters { bottom: calc(30px + var(--safe-b)); }
body.touch #subs { bottom: calc(240px + var(--safe-b)); }

/* --- touch buttons: a column on the right, clear of the stick bottom-left */
#controls { position: fixed; right: calc(14px + var(--safe-r)); bottom: calc(24px + var(--safe-b)); z-index: 21; display: grid; grid-template-columns: repeat(2, var(--tb)); gap: 10px; }
.tb { width: var(--tb); height: var(--tb); border-radius: 50%; border: 1px solid rgba(255, 236, 180, 0.3); background: rgba(8, 7, 4, 0.5); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; touch-action: none; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.tb svg { width: 40%; height: 40%; fill: var(--ink); stroke: var(--ink); stroke-width: 0; }
.tb span { font: 700 9.5px var(--font); letter-spacing: 0.5px; color: var(--mute); }
.tb.on { background: rgba(232, 210, 122, 0.35); border-color: var(--acc); }
.tb.big { grid-column: 2; grid-row: 1 / span 2; height: calc(var(--tb) * 2 + 10px); border-radius: calc(var(--tb) / 2); }
#tUse { grid-column: 1 / span 2; width: auto; height: 44px; border-radius: 22px; flex-direction: row; gap: 6px; }

/* --- the level card, caught */
#lcard { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; pointer-events: none; text-align: center; animation: lc 2.6s ease both; }
#lcard b { font: 900 14px var(--font); letter-spacing: 6px; color: var(--acc); }
#lcard h2 { font: 400 clamp(28px, 6vw, 48px) var(--type); margin: 6px 0; }
#lcard span { color: var(--mute); font-size: 14px; letter-spacing: 1px; }
@keyframes lc { 0% { opacity: 0; } 20%, 80% { opacity: 1; } 100% { opacity: 0.9; } }
#caught { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 20px; }
#caught .card { max-width: 420px; text-align: center; background: none; border: 0; box-shadow: none; }
#caught .kick { color: var(--bad); }
#caught h2 { font: 400 32px var(--type); }
.cgStats { display: flex; gap: 10px; justify-content: center; margin: 16px 0 4px; }
.cgStats div { flex: 1; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.cgStats b { display: block; font-size: 18px; } .cgStats span { font-size: 12px; color: var(--mute); }

/* --- toasts and notes */
#toast { position: fixed; left: 50%; top: calc(56px + var(--safe-t)); transform: translate(-50%, -12px); z-index: 90; padding: 9px 16px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line2); font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: 0.3s; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#note { position: fixed; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translate(-50%, 10px); z-index: 30; width: min(460px, 90vw); padding: 14px 18px; border-radius: 4px; background: #e9e0c6; color: #2a2414; font: 15.5px/1.45 var(--type); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); opacity: 0; transition: 0.4s; pointer-events: none; }
#note.on { opacity: 1; transform: translate(-50%, 0) rotate(-0.6deg); }
#note b { color: #000; } #note em { font-style: normal; font-weight: 800; color: #8a5a00; font-family: var(--font); font-size: 13px; }
#note .nk { display: block; font: 800 10.5px var(--font); letter-spacing: 1.6px; text-transform: uppercase; color: #7a6a3a; margin-bottom: 3px; }
body.touch #note { bottom: auto; top: calc(80px + var(--safe-t)); }

/* --- sheets */
.screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.card { position: relative; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px 22px 20px; border-radius: 20px; background: var(--glass); border: 1px solid var(--line2); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); -webkit-user-select: text; user-select: text; }
.card .x { position: absolute; right: 10px; top: 10px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.06); font-size: 20px; line-height: 1; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 6px 0; }
.keys div { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; } .keys span { color: var(--mute); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.tabs button { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line2); background: transparent; font-size: 13px; font-weight: 650; }
.tabs button.on { background: var(--acc); color: #1a1508; border-color: var(--acc); }
.list { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.row > div { flex: 1; min-width: 0; }
.row b { display: block; font-size: 14px; } .row b em { font-style: normal; font-size: 11px; color: var(--gold); margin-left: 4px; }
.row span { display: block; font-size: 13px; color: var(--mute); font-family: var(--type); }
.row > i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #3a352a; }
.row > i.egg { background: var(--gold); box-shadow: 0 0 8px var(--gold); } .row > i.cr { background: var(--bad); }
.row.dim b { color: var(--faint); } .row.me { border-color: var(--line2); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stats div { padding: 9px 11px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.stats span { display: block; font-size: 12px; color: var(--mute); } .stats b { font-size: 16px; }
.mxcBox { margin-top: 12px; padding: 11px 13px; border-radius: 12px; background: rgba(240, 200, 104, 0.08); border: 1px solid rgba(240, 200, 104, 0.3); font-size: 13.5px; }
.mxcBox .link { padding: 0; }
@media (max-width: 520px) { .keys, .stats { grid-template-columns: 1fr; } }
/* phones: the compass drops below the top row, beside the map */
@media (max-width: 620px) {
  #compass { top: calc(66px + var(--safe-t)); left: auto; right: calc(10px + var(--safe-r)); transform: none; height: 26px; width: calc(100vw - 136px - var(--safe-r) - var(--safe-l)); }
  #compassTape span { top: 5px; }
  #mini { top: calc(66px + var(--safe-t)); width: 100px; height: 100px; }
  #mini.large { width: 160px; height: 160px; }
}
