:root {
  --bg: #0b0414; --ink: #f4e9ff; --pink: #ff2bd6; --cyan: #22e8ff; --green: #39ff88; --yellow: #ffd23f; --orange: #ff7a3d; --red: #ff3b5c;
  --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);
  --mono: ui-monospace, "SF Mono", Menlo, "DejaVu Sans Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; position: fixed; inset: 0;
  background: var(--bg); color: var(--ink); font-family: var(--mono);
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%;
}
canvas#game { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; touch-action: none; }
#focus-fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 2; opacity: 0; transition: opacity .25s; mix-blend-mode: screen; }
#focus-fx.on { opacity: 1; }
#dmg { position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255,0,60,0) 45%, rgba(255,0,60,.55) 100%); }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; text-shadow: 0 0 6px rgba(0,0,0,.9); }
#hud-tl { position: absolute; top: calc(8px + var(--safe-t)); left: calc(10px + var(--safe-l)); display: grid; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; }
.lbl { width: 44px; opacity: .85; letter-spacing: .08em; }
.bar { width: clamp(90px, 18vw, 170px); height: 10px; border: 1px solid rgba(255,255,255,.35); border-radius: 3px; background: rgba(10,0,20,.55); overflow: hidden; transform: skewX(-18deg); }
.bar i { display: block; height: 100%; width: 100%; transform-origin: left; transition: width .12s; }
.bar.hp i { background: linear-gradient(90deg, #ff2b6a, #ff7ad9); box-shadow: 0 0 10px #ff2bd6; }
.bar.fo i { background: linear-gradient(90deg, #13c964, #8affc0); box-shadow: 0 0 10px #39ff88; }
.bar-row b { min-width: 28px; font-variant-numeric: tabular-nums; }
#hud-tc { position: absolute; top: calc(6px + var(--safe-t)); left: 50%; transform: translateX(-50%); text-align: center; width: 60vw; }
#stars { font-size: 26px; letter-spacing: 3px; line-height: 1; }
#stars i { font-style: normal; color: rgba(255,255,255,.16); text-shadow: none; transition: color .2s; }
#stars i.on { color: var(--yellow); text-shadow: 0 0 10px #ffb000, 0 0 2px #fff; }
#stars.flash i.on { animation: starflash .5s steps(1) infinite; }
@keyframes starflash { 50% { color: var(--cyan); text-shadow: 0 0 10px #22e8ff; } }
#banner { margin-top: 6px; font-size: 14px; font-weight: 800; letter-spacing: .06em; color: var(--cyan); opacity: 0; transition: opacity .3s; text-shadow: 0 0 10px rgba(34,232,255,.8), 0 0 3px #000; }
#banner.show { opacity: 1; }
#hud-tr { position: absolute; top: calc(6px + var(--safe-t)); right: calc(120px + var(--safe-r)); text-align: right; }
#score { font-size: 22px; font-weight: 800; color: var(--yellow); font-variant-numeric: tabular-nums; text-shadow: 0 0 10px rgba(255,180,0,.6), 0 0 2px #000; }
#mult { font-size: 12px; opacity: .8; color: var(--pink); }
#minimap { position: absolute; top: calc(58px + var(--safe-t)); right: calc(10px + var(--safe-r)); width: 96px; height: 96px; border-radius: 50%; border: 1px solid rgba(34,232,255,.5); box-shadow: 0 0 14px rgba(34,232,255,.25); }
#feed { position: absolute; right: calc(12px + var(--safe-r)); top: calc(160px + var(--safe-t)); display: grid; gap: 3px; justify-items: end; font-size: 12px; font-weight: 800; }
#feed div { padding: 2px 7px; background: rgba(15,0,30,.55); border-left: 2px solid var(--pink); animation: feedin .2s ease-out; }
@keyframes feedin { from { transform: translateX(20px); opacity: 0; } }
#ammo { position: absolute; bottom: calc(14px + var(--safe-b)); left: 50%; transform: translateX(-50%); text-align: center; font-weight: 800; }
#ammo-mag { font-size: 30px; color: var(--cyan); text-shadow: 0 0 10px rgba(34,232,255,.7), 0 0 2px #000; font-variant-numeric: tabular-nums; }
#ammo .sep { opacity: .4; margin: 0 4px; font-size: 18px; }
#ammo-res { font-size: 18px; opacity: .85; font-variant-numeric: tabular-nums; }
#ammo.low #ammo-mag { color: var(--red); text-shadow: 0 0 10px rgba(255,59,92,.8); }
#wpn { font-size: 10px; letter-spacing: .2em; opacity: .55; }
#xhair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --g: 6px; }
#xhair i { position: absolute; background: #fff; box-shadow: 0 0 4px var(--cyan); }
#xhair i:nth-child(1) { width: 2px; height: 7px; left: -1px; bottom: var(--g); }
#xhair i:nth-child(2) { width: 2px; height: 7px; left: -1px; top: var(--g); }
#xhair i:nth-child(3) { height: 2px; width: 7px; top: -1px; right: var(--g); }
#xhair i:nth-child(4) { height: 2px; width: 7px; top: -1px; left: var(--g); }
#hitmark { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; opacity: 0;
  background: linear-gradient(45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%), linear-gradient(-45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%);
  -webkit-mask: radial-gradient(circle, transparent 5px, #000 6px); mask: radial-gradient(circle, transparent 5px, #000 6px); }
#hitmark.on { opacity: 1; }
#hitmark.head { filter: drop-shadow(0 0 3px #ff2b6a) hue-rotate(0deg); background: linear-gradient(45deg, transparent 42%, #ff3b5c 42%, #ff3b5c 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, #ff3b5c 42%, #ff3b5c 58%, transparent 58%); }
#toast { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); font-size: 13px; font-weight: 800; color: var(--green); opacity: 0; transition: opacity .3s; white-space: nowrap; text-shadow: 0 0 8px rgba(57,255,136,.8), 0 0 2px #000; }
#toast.show { opacity: 1; }

#hud-btns { position: fixed; top: calc(6px + var(--safe-t)); right: calc(8px + var(--safe-r)); display: flex; gap: 8px; z-index: 6; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid rgba(34,232,255,.45); background: rgba(12,2,24,.7);
  color: var(--cyan); display: grid; place-items: center; padding: 0; cursor: pointer; touch-action: manipulation; }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn:active { transform: scale(.94); }
#debug-badge { position: fixed; left: 6px; top: 50%; font: 10px var(--mono); background: #ff3b6b; color: #fff; padding: 2px 5px; border-radius: 4px; pointer-events: none; opacity: .7; z-index: 7; }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; z-index: 5; touch-action: none; }
#joy { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(34,232,255,.45);
  background: radial-gradient(circle, rgba(34,232,255,.12), rgba(34,232,255,.02)); left: calc(90px + var(--safe-l)); top: calc(100% - 100px - var(--safe-b)); opacity: .55; pointer-events: none; }
#joy.on { opacity: 1; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(34,232,255,.5); box-shadow: 0 0 16px rgba(34,232,255,.6); }
.tbtn { position: absolute; border-radius: 50%; border: 2px solid rgba(255,43,214,.7); background: rgba(40,0,40,.45); color: #fff;
  font: 800 12px var(--mono); letter-spacing: .06em; padding: 0; touch-action: none; text-shadow: 0 0 6px #000; }
.tbtn.on { background: rgba(255,43,214,.45); transform: scale(.95); }
.tbtn.g { border-color: rgba(57,255,136,.8); color: var(--green); }
.tbtn.g.on, .tbtn.g.active { background: rgba(57,255,136,.35); color: #fff; }
#t-fire { width: 92px; height: 92px; right: calc(26px + var(--safe-r)); bottom: calc(30px + var(--safe-b)); font-size: 15px; border-color: rgba(255,59,92,.9); background: rgba(80,0,20,.45); }
#t-jump { width: 60px; height: 60px; right: calc(132px + var(--safe-r)); bottom: calc(22px + var(--safe-b)); }
#t-reload { width: 56px; height: 56px; right: calc(34px + var(--safe-r)); bottom: calc(136px + var(--safe-b)); }
#t-focus { width: 62px; height: 62px; right: calc(112px + var(--safe-r)); bottom: calc(102px + var(--safe-b)); font-size: 11px; }
body.touch #ammo { left: auto; right: calc(150px + var(--safe-r)); transform: none; bottom: calc(118px + var(--safe-b)); display: none; }
body.touch #ammo { display: block; left: 50%; right: auto; transform: translateX(-50%); bottom: calc(8px + var(--safe-b)); }
body.touch #wpn { display: none; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; overflow-y: auto; z-index: 10;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l));
  background: radial-gradient(ellipse at center, rgba(15,2,30,.25), rgba(10,0,20,.7)); touch-action: pan-y; }
.panel { width: min(430px, 100%); text-align: center; padding: 18px 18px;
  background: linear-gradient(180deg, rgba(30,6,48,.86), rgba(10,2,22,.92));
  border: 1px solid rgba(255,43,214,.45); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 30px rgba(255,43,214,.18), 0 0 40px rgba(34,232,255,.08) inset;
  display: flex; flex-direction: column; align-items: center; gap: 10px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.col { display: flex; flex-direction: column; align-items: center; gap: 9px; width: 100%; }
.logo { width: 70px; height: 70px; filter: drop-shadow(0 4px 18px rgba(255,43,214,.45)); }
.game-name { margin: 0; font-size: clamp(34px, 10vw, 54px); font-weight: 900; letter-spacing: .05em; line-height: 1; font-style: italic;
  color: #fff; text-shadow: 0 0 6px #ff2bd6, 0 0 18px #ff2bd6, 0 0 36px rgba(255,43,214,.6); }
.game-name span { color: var(--green); text-shadow: 0 0 8px #39ff88, 0 0 20px rgba(57,255,136,.7); }
.tag { margin: 0; opacity: .85; font-size: 13px; line-height: 1.4; }
h2 { margin: 0; letter-spacing: .1em; font-size: 28px; color: var(--cyan); text-shadow: 0 0 14px rgba(34,232,255,.7); }
h2.r { color: var(--red); text-shadow: 0 0 14px rgba(255,59,92,.8); }
.btn { width: 100%; max-width: 280px; padding: 13px 18px; font: inherit; font-weight: 800; letter-spacing: .16em; font-size: 16px;
  color: var(--ink); background: rgba(34,232,255,.06); border: 1px solid rgba(34,232,255,.45); border-radius: 10px; cursor: pointer;
  touch-action: manipulation; min-height: 48px; }
.btn:hover { background: rgba(34,232,255,.14); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(90deg, #ff2bd6, #ff7a3d); border-color: transparent; color: #1a0016; box-shadow: 0 0 24px rgba(255,43,214,.5); }
.btn.small { width: auto; padding: 10px 16px; min-height: 44px; }
.btn-row { display: flex; gap: 10px; width: 100%; justify-content: center; }
.btn-row .btn { flex: 1; }
.hint { margin: 0; font-size: 12px; line-height: 1.6; opacity: .7; }
.hint kbd { font: 11px var(--mono); padding: 0 4px; border: 1px solid rgba(244,233,255,.4); border-radius: 3px; }
.rotate-hint { display: none; margin: 0; font-size: 12px; color: var(--yellow); }
@media (orientation: portrait) { body.touch .rotate-hint { display: block; } }
.howto { list-style: none; margin: 0; padding: 0; text-align: left; font-size: 12.5px; line-height: 1.45; display: grid; gap: 6px; width: 100%; }
.howto li { padding-left: 16px; position: relative; opacity: .93; }
.howto li::before { content: ">"; position: absolute; left: 0; color: var(--pink); }
.p { color: var(--pink); } .c { color: var(--cyan); } .g { color: var(--green); } .y { color: var(--yellow); } .r { color: var(--red); }
.scores-box { width: 100%; border: 1px solid rgba(34,232,255,.25); border-radius: 8px; padding: 6px 8px 4px; background: rgba(0,0,0,.3); }
.scores-head { font-size: 11px; opacity: .6; text-align: left; margin-bottom: 2px; }
.scores { list-style: none; margin: 0; padding: 0; width: 100%; font-variant-numeric: tabular-nums; }
.scores li { display: grid; grid-template-columns: 22px 52px 1fr auto; gap: 6px; padding: 3px 6px; border-radius: 4px; font-size: 13px; text-align: left; }
.scores li:nth-child(odd) { background: rgba(255,43,214,.06); }
.scores li .rk { opacity: .5; } .scores li .nm { color: var(--cyan); font-weight: 800; } .scores li .sc { color: var(--yellow); text-align: right; font-weight: 800; }
.scores li .st { color: var(--yellow); opacity: .8; font-size: 11px; }
.scores li.me { outline: 1px solid var(--pink); }
.scores li.empty { display: block; text-align: center; opacity: .5; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.stats div { background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.1); border-radius: 6px; padding: 6px 4px; font-size: 10px; opacity: .95; }
.stats b { display: block; font-size: 17px; color: var(--yellow); }
#initials-form { width: 100%; font-size: 12px; display: grid; gap: 6px; }
.initials-row { display: flex; gap: 8px; justify-content: center; }
#initials { width: 110px; font: 800 20px var(--mono); text-align: center; letter-spacing: .2em; text-transform: uppercase; color: var(--cyan);
  background: rgba(0,0,0,.4); border: 1px solid rgba(34,232,255,.5); border-radius: 8px; padding: 6px; user-select: text; -webkit-user-select: text; }

@media (min-width: 760px) and (min-height: 560px) {
  .title-panel { width: min(820px, 100%); flex-direction: row; align-items: stretch; gap: 22px; padding: 24px; }
  .title-panel .col-a { flex: 1; justify-content: center; }
  .title-panel .col-b { flex: 1; justify-content: center; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .title-panel { width: min(780px, 100%); flex-direction: row; align-items: center; gap: 16px; padding: 12px 16px; }
  .title-panel .col { gap: 6px; }
  .title-panel .col-a, .title-panel .col-b { flex: 1; }
  .logo { width: 46px; height: 46px; }
  .game-name { font-size: 36px; }
  .howto { font-size: 11px; gap: 3px; }
  .scores li { font-size: 12px; padding: 2px 6px; }
  .end-panel { width: min(640px, 100%); padding: 10px 14px; gap: 6px; }
  .stats div { padding: 3px; } .stats b { font-size: 14px; }
  .hint { font-size: 11px; line-height: 1.4; }
  #minimap { width: 76px; height: 76px; top: calc(56px + var(--safe-t)); }
  #feed { top: calc(110px + var(--safe-t)); right: auto; left: calc(10px + var(--safe-l)); top: calc(56px + var(--safe-t)); justify-items: start; }
}
@media (orientation: portrait) and (max-width: 600px) {
  .bar { width: 84px; }
  .lbl { width: 40px; }
  #hud-tc { top: calc(62px + var(--safe-t)); width: 62vw; }
  #stars { font-size: 22px; }
  #banner { font-size: 12px; }
  #score { font-size: 19px; }
  #minimap { width: 72px; height: 72px; top: calc(56px + var(--safe-t)); }
  #feed { top: calc(136px + var(--safe-t)); }
}

/* ---------- look settings ---------- */
.settings { display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: center; align-items: center; width: 100%; }
.set-inv { min-width: 168px; min-height: 44px; letter-spacing: .08em; font-size: 13px; }
.set-inv.on { background: rgba(57,255,136,.18); border-color: var(--green); color: var(--green); box-shadow: 0 0 14px rgba(57,255,136,.3); }
.sens { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 12px; font-weight: 800; letter-spacing: .1em; opacity: .9; }
.set-sens { width: 120px; height: 44px; margin: 0; accent-color: var(--pink); touch-action: manipulation; }
.sens-val { min-width: 34px; font-variant-numeric: tabular-nums; color: var(--cyan); }
@media (max-height: 500px) and (orientation: landscape) {
  .title-panel .settings { gap: 4px 10px; }
  .set-inv { min-width: 150px; padding: 8px 12px; font-size: 12px; }
  .set-sens { width: 100px; }
}
