:root {
  --bg: #0d0f10; --panel: rgba(14, 16, 17, 0.86); --line: rgba(255, 255, 255, 0.1);
  --text: #e9e6df; --muted: #9aa0a3; --accent: #e8a33a; --red: #ff4d3d; --green: #7fd36b;
  --hud: 'Rajdhani', 'Arial Narrow', system-ui, sans-serif; --ui: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; color: var(--text); font-family: var(--ui); }
body { touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

/* ---------------- loading ---------------- */
#loading { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 22px;
  background: radial-gradient(ellipse at 50% 40%, #1d1a15 0%, #0b0c0d 70%); transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
.brand { display: flex; flex-direction: column; align-items: flex-start; }
.brand span { font-family: var(--hud); font-weight: 700; font-size: clamp(42px, 8vw, 84px); letter-spacing: .18em; line-height: .9; color: #f1ede4; }
.brand small { font-size: 13px; letter-spacing: .32em; text-transform: uppercase; color: var(--accent); margin-top: 8px; }
#loading .brand { align-items: center; }
#loadbar { width: min(420px, 76vw); height: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
#loadbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.loadline { width: min(420px, 76vw); display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); letter-spacing: .04em; }

/* ---------------- menu ---------------- */
#menu { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(180deg, rgba(8,9,10,.55), rgba(8,9,10,.82)); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#menu.hidden { display: none; }
.panel { width: min(1060px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 22px 26px;
  touch-action: pan-y; user-select: text; }
.panel header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
#start { font-family: var(--hud); font-weight: 700; font-size: 22px; letter-spacing: .18em; padding: 14px 40px; border: 0; border-radius: 3px; cursor: pointer;
  background: var(--accent); color: #1a1206; transition: transform .1s, filter .2s; }
#start:disabled { filter: grayscale(1) brightness(.6); cursor: default; }
#start:not(:disabled):hover { filter: brightness(1.1); }
#start:not(:disabled):active { transform: scale(.97); }
.cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; padding-top: 16px; }
h3 { font-family: var(--hud); font-weight: 600; letter-spacing: .2em; text-transform: uppercase; font-size: 14px; color: var(--muted); margin: 6px 0 10px; }
#wcards { display: grid; gap: 8px; }
.wc { display: grid; grid-template-columns: 26px 1fr auto; gap: 4px 12px; align-items: baseline; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: rgba(255,255,255,.02); }
.wc .k { font-family: var(--hud); font-weight: 700; color: var(--accent); font-size: 18px; }
.wc .n { font-weight: 600; font-size: 15px; }
.wc .c { font-size: 12px; color: var(--muted); text-align: right; }
.wc .s { grid-column: 2 / 4; font-size: 12px; color: #c4c0b7; line-height: 1.45; }
.wc .s em { font-style: normal; color: var(--muted); }
.keys div { font-size: 13px; line-height: 1.5; color: #d6d2c9; margin-bottom: 4px; }
kbd { font-family: var(--hud); font-weight: 600; font-size: 13px; padding: 1px 6px; border: 1px solid rgba(255,255,255,.22); border-bottom-width: 2px; border-radius: 3px; color: #fff; background: rgba(255,255,255,.04); }
.keys.mob { display: none; }
body.mobile .keys.pc { display: none; } body.mobile .keys.mob { display: block; }
label { display: grid; grid-template-columns: 130px 1fr 48px; gap: 10px; align-items: center; font-size: 13px; margin: 8px 0; color: #d6d2c9; }
label.chk { grid-template-columns: 22px 1fr; }
label b { font-family: var(--hud); font-weight: 600; color: var(--accent); text-align: right; }
input[type=range] { width: 100%; accent-color: var(--accent); }
select { background: #1a1c1d; color: var(--text); border: 1px solid var(--line); padding: 6px; border-radius: 3px; grid-column: 2 / 4; }
#qualNote { color: var(--accent); font-size: 12px; }
footer { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; color: var(--muted); }
footer summary { cursor: pointer; letter-spacing: .06em; }
footer p { line-height: 1.55; }
footer a { color: #d9c08f; }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; display: none; font-family: var(--hud); z-index: 10; }
#hud.on { display: block; }
#dot { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.6); opacity: 0; }
#hitmark { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; opacity: 0; transition: opacity .12s; }
#hitmark.on { opacity: 1; transition: none; }
#hitmark i { position: absolute; width: 9px; height: 2px; background: #fff; box-shadow: 0 0 2px #000; }
#hitmark i:nth-child(1) { left: 0; top: 4px; transform: rotate(45deg); } #hitmark i:nth-child(2) { right: 0; top: 4px; transform: rotate(-45deg); }
#hitmark i:nth-child(3) { left: 0; bottom: 4px; transform: rotate(-45deg); } #hitmark i:nth-child(4) { right: 0; bottom: 4px; transform: rotate(45deg); }
#scope { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
#hud.scoped #ammoBox, #hud.scoped #feed { opacity: .65; }

#topbar { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; gap: 18px; align-items: center; font-size: 15px; color: #f1ede4; text-shadow: 0 1px 2px rgba(0,0,0,.8); }
#wind { display: flex; align-items: center; gap: 8px; }
#wind svg { width: 26px; height: 26px; fill: #f1ede4; filter: drop-shadow(0 1px 1px rgba(0,0,0,.7)); transition: transform .3s; }
#wind small, #breath small { display: block; font-size: 10px; letter-spacing: .25em; color: var(--muted); }
#wind b { font-weight: 600; font-size: 17px; }
#stats { font-size: 15px; letter-spacing: .03em; } #stats b { color: var(--accent); font-weight: 700; }
#stance { margin-left: auto; font-size: 13px; letter-spacing: .25em; color: var(--muted); }
#wlist { position: absolute; top: max(48px, calc(env(safe-area-inset-top) + 36px)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; pointer-events: auto; }
.wchip { font-family: var(--hud); font-weight: 600; font-size: 13px; letter-spacing: .08em; color: #e6e2d9; background: rgba(10,10,10,.45); border: 1px solid rgba(255,255,255,.14); border-radius: 3px; padding: 4px 10px; cursor: pointer; }
.wchip span { color: var(--muted); margin-right: 6px; }
.wchip.on { background: rgba(232,163,58,.9); color: #1b1307; border-color: transparent; } .wchip.on span { color: #3d2a0c; }
body:not(.touch) #wlist { pointer-events: none; opacity: .8; }

#ammoBox { position: absolute; right: max(22px, env(safe-area-inset-right)); bottom: 22px; text-align: right; text-shadow: 0 1px 3px rgba(0,0,0,.85); min-width: 230px; }
#wName { font-size: 22px; font-weight: 700; letter-spacing: .06em; color: #f4f0e8; }
#wCal { font-size: 13px; color: #c9c4b9; letter-spacing: .06em; margin-bottom: 2px; }
.ammoRow { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; }
#ammo { font-size: 54px; font-weight: 700; line-height: 1; color: #fff; }
#ammo.low { color: var(--red); }
#ammoCap { font-size: 20px; color: #bdb8ad; }
#wMode { font-style: normal; font-size: 12px; letter-spacing: .2em; color: var(--accent); margin-left: 6px; }
#pips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px; margin-top: 6px; max-width: 260px; margin-left: auto; }
#pips i { width: 5px; height: 14px; border-radius: 1px; background: rgba(255,255,255,.18); }
#pips i.f { background: #e9c27a; box-shadow: 0 0 1px rgba(0,0,0,.6); }
#pips.many i { width: 4px; height: 10px; }
#zeroBox { margin-top: 6px; font-size: 14px; color: #d9d4ca; display: none; } #zeroBox b { color: var(--accent); }
#breath { position: absolute; left: 50%; bottom: 36px; transform: translateX(-50%); width: 200px; display: none; text-align: center; text-shadow: 0 1px 2px #000; }
#breath span { display: block; height: 4px; background: rgba(255,255,255,.18); margin-top: 4px; }
#breath i { display: block; height: 100%; background: #9fd4ff; transition: width .1s; }
#breath.ex i { background: var(--red); }

#feed { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: 22px; display: flex; flex-direction: column; gap: 6px; max-width: min(520px, 46vw); }
.fi { background: rgba(10,10,10,.55); border-left: 3px solid var(--accent); padding: 6px 10px; color: #f1ede4; animation: fin .25s ease-out; transition: opacity 1s; }
.fi.old { opacity: .35; }
.fi b { color: var(--accent); font-size: 18px; margin-right: 8px; }
.fi span { font-size: 15px; } .fi small { display: block; font-family: var(--ui); font-size: 11.5px; color: #c8c3b8; margin-top: 2px; }
@keyframes fin { from { transform: translateX(-12px); opacity: 0; } }
#hint { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-family: var(--ui); font-size: 14px; color: #f4f0e8; background: rgba(0,0,0,.5); padding: 8px 14px; border-radius: 3px; opacity: 0; transition: opacity .5s; max-width: 80vw; text-align: center; }
#hint.on { opacity: 1; }

#spot, #tcam { position: absolute; right: max(22px, env(safe-area-inset-right)); top: 76px; width: min(330px, 30vw); border: 1px solid rgba(255,255,255,.35); background: rgba(0,0,0,.3); opacity: 0; transition: opacity .3s; box-shadow: 0 4px 18px rgba(0,0,0,.5); }
#tcam { aspect-ratio: 16 / 9; background: transparent; }
#spot.on, #tcam.on { opacity: 1; }
#spot canvas { display: block; width: 100%; }
#spot b, #tcam b { position: absolute; left: 0; top: -22px; font-size: 13px; letter-spacing: .08em; color: #f1ede4; text-shadow: 0 1px 2px #000; white-space: nowrap; }
#bcam { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); font-size: 15px; letter-spacing: .3em; color: #fff; opacity: 0; text-shadow: 0 1px 3px #000; }
#bcam.on { opacity: .85; }

/* ---------------- touch ---------------- */
#touch { position: fixed; inset: 0; z-index: 12; display: none; }
body.touch #touch { display: block; }
#lookZone { position: absolute; left: 38%; right: 0; top: 0; bottom: 0; }
#stick { position: absolute; left: calc(max(22px, env(safe-area-inset-left)) + 10px); bottom: 26px; width: 150px; height: 150px; border-radius: 50%; border: 2px solid rgba(255,255,255,.22); background: rgba(0,0,0,.18); }
#knob { position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px; border-radius: 50%; background: rgba(255,255,255,.28); border: 1px solid rgba(255,255,255,.4); }
.tb { position: absolute; font-family: var(--hud); font-weight: 700; font-size: 13px; letter-spacing: .08em; color: #fff; background: rgba(0,0,0,.32); border: 1.5px solid rgba(255,255,255,.35); border-radius: 50%;
  width: 58px; height: 58px; display: flex; align-items: center; justify-content: center; padding: 0; touch-action: none; }
.tb svg { width: 60%; height: 60%; fill: currentColor; }
.tb.on { background: rgba(232,163,58,.55); }
.tb.active { background: rgba(232,163,58,.8); color: #1b1307; }
.tb.big { width: 92px; height: 92px; right: calc(max(26px, env(safe-area-inset-right)) + 70px); bottom: 34px; border-color: rgba(255,255,255,.55); background: rgba(160,30,20,.35); }
#tFire2 { right: calc(max(26px, env(safe-area-inset-right)) + 6px); bottom: 150px; width: 52px; height: 52px; }
#tAim { right: calc(max(26px, env(safe-area-inset-right)) + 0px); bottom: 34px; width: 64px; height: 64px; font-size: 11px; }
#tReload { right: calc(max(26px, env(safe-area-inset-right)) + 176px); bottom: 34px; }
#tCrouch { right: calc(max(26px, env(safe-area-inset-right)) + 186px); bottom: 104px; font-size: 11px; width: 50px; height: 50px; }
#tProne { right: calc(max(26px, env(safe-area-inset-right)) + 240px); bottom: 70px; font-size: 11px; width: 50px; height: 50px; }
#tJump { right: calc(max(26px, env(safe-area-inset-right)) + 120px); bottom: 150px; width: 46px; height: 46px; }
#tBreath { right: calc(max(26px, env(safe-area-inset-right)) + 62px); bottom: 150px; font-size: 10px; width: 52px; height: 52px; }
#tZin { right: calc(max(26px, env(safe-area-inset-right)) + 4px); top: 120px; width: 44px; height: 44px; font-size: 22px; }
#tZout { right: calc(max(26px, env(safe-area-inset-right)) + 54px); top: 120px; width: 44px; height: 44px; font-size: 22px; }
#tZeroUp { right: calc(max(26px, env(safe-area-inset-right)) + 4px); top: 170px; width: 44px; height: 44px; font-size: 9px; }
#tZeroDn { right: calc(max(26px, env(safe-area-inset-right)) + 54px); top: 170px; width: 44px; height: 44px; font-size: 9px; }
#tMode { right: calc(max(26px, env(safe-area-inset-right)) + 62px); bottom: 150px; font-size: 10px; width: 52px; height: 52px; }
#tClay { right: calc(max(26px, env(safe-area-inset-right)) + 62px); bottom: 150px; font-size: 9px; width: 56px; height: 56px; }
#tReset { left: calc(max(22px, env(safe-area-inset-left)) + 176px); bottom: 30px; font-size: 9px; width: 50px; height: 50px; }
#pauseBtn { left: calc(max(14px, env(safe-area-inset-left))); top: 44px; width: 40px; height: 40px; border-radius: 6px; font-size: 13px; }
body.touch #ammoBox { bottom: auto; top: 92px; right: auto; left: max(16px, env(safe-area-inset-left)); text-align: left; transform: scale(.78); transform-origin: top left; }
body.touch .ammoRow, body.touch #pips { justify-content: flex-start; margin-left: 0; }
body.touch #feed { left: 50%; right: auto; bottom: auto; top: 84px; max-width: 46vw; transform: translateX(-50%) scale(.8); transform-origin: top center; }
body.touch #spot, body.touch #tcam { top: auto; bottom: 200px; right: auto; left: 50%; transform: translateX(-50%); width: min(260px, 32vw); }
body.touch #stats { font-size: 12px; } body.touch #topbar { left: 70px; }

#keys { position: fixed; inset: 0; z-index: 45; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.5); }
#keys.show { display: flex; }
#keys > div { background: var(--panel); border: 1px solid var(--line); padding: 20px 26px; border-radius: 6px; text-align: center; line-height: 1.8; }
#keys button { margin-top: 10px; background: var(--accent); border: 0; padding: 8px 20px; font-family: var(--hud); font-weight: 700; letter-spacing: .1em; border-radius: 3px; }
#rotate { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; background: #0b0c0d; color: #fff; text-align: center; font-size: 16px; }
#rotate.on { display: flex; }

@media (max-width: 820px) {
  .cols { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .panel header { flex-direction: column; align-items: stretch; }
  label { grid-template-columns: 110px 1fr 44px; }
}
@media (max-height: 520px) {
  .panel { padding: 12px 16px; }
  .brand span { font-size: 40px; }
  .wc { padding: 6px 10px; }
  .wc .s { display: none; }
}
