:root {
  --bar-w: 240px;
  --hp: #4ade80;
  --hp-low: #ef4444;
  --ink: #e8f2ec;
  --accent: #7dd3fc;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #05070a; }
body {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--ink);
  cursor: none;
  user-select: none;
  -webkit-user-select: none;
}
canvas { display: block; }

#ui { position: fixed; inset: 0; pointer-events: none; }

/* Everything that toggles `hidden` means the same thing by it. Without this the
   class is inert wherever a rule was not written for that one element. */
.hidden { display: none; }


#hud-left { position: absolute; top: 18px; left: 18px; }
.label { font-size: 11px; letter-spacing: 2px; opacity: .55; margin-bottom: 5px; }
#hpbar {
  width: min(calc(var(--bar-w) * var(--hp-scale, 1)), calc(100vw - 36px)); height: 14px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.45);
  padding: 2px;
  transition: width .25s ease;
}
#hpfill {
  position: relative; overflow: hidden;
  height: 100%; width: 100%;
  background: var(--hp);
  transition: width .12s linear, background .2s linear;
}

/* Only while it is actually climbing: the bar goes quiet for the seconds after
   a hit, which is the regen delay made visible. */
#hpbar.healing { border-color: rgba(74,222,128,.55); box-shadow: 0 0 13px rgba(74,222,128,.3); }
#hpbar.healing #hpfill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 18%, rgba(255,255,255,.5) 50%, transparent 82%);
  animation: healSweep 2s linear infinite;
}
@keyframes healSweep { from { transform: translateX(-110%); } to { transform: translateX(110%); } }

/* Rises off the bar it belongs to and fades, so a tick reads without taking any
   room — the row below it never moves. */
#hp-gain {
  position: absolute; left: 0; top: 22px;
  font-size: 13px; font-weight: 700; letter-spacing: 1px; color: var(--hp);
  text-shadow: 0 0 12px rgba(74,222,128,.55); opacity: 0; pointer-events: none;
  white-space: nowrap;
}
#hp-gain.show { animation: hpGain 1s ease-out; }
@keyframes hpGain {
  0%   { opacity: 0; transform: translateY(6px) scale(.9); }
  18%  { opacity: 1; transform: translateY(0) scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

#dashpips { display: flex; gap: 4px; width: var(--bar-w); margin-top: 5px; }
#dashpips .pip {
  flex: 1; height: 8px; padding: 2px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.45);
}
#dashpips .pip i { display: block; height: 100%; width: 0;
                   background: #2f6d85; transition: width .1s linear; }
#dashpips .pip.on i { background: #4cc9f0; }


#hud-right { position: absolute; top: 18px; right: 18px; text-align: right; }
#substats { font-size: 12px; opacity: .6; letter-spacing: 1px; }

#wave-banner {
  position: absolute; top: 22%; left: 0; right: 0;
  text-align: center; font-size: 42px; font-weight: 700; letter-spacing: 8px;
  opacity: 0; transition: opacity .35s ease;
  text-shadow: 0 0 24px rgba(125,211,252,.6);
  color: var(--accent);
}
#wave-banner.show { opacity: 1; }

#crosshair {
  position: absolute; width: 26px; height: 26px;
  margin-left: -13px; margin-top: -13px;
  left: 0; top: 0;
  /* No transition: easing the crosshair is rendered input lag. */
  will-change: transform;
  transform: translate3d(-100px, -100px, 0);
}

body:not([data-mode="playing"]) #crosshair { display: none; }

#ch-arc { position: absolute; left: 0; top: 0; width: 92px; height: 92px;
          margin: -46px 0 0 -46px; overflow: visible; pointer-events: none;
          will-change: transform; transform: translate3d(-200px, -200px, 0);
          opacity: 0; transition: opacity .16s linear; }
body:not([data-mode="playing"]) #ch-arc { display: none; }
#ch-arc.show { opacity: 1; }
/* butt caps: round ones bleed each segment into its neighbour. */
#ch-arc path { fill: none; stroke-linecap: butt; }
#ch-arc .track { stroke: rgba(255,255,255,.16); stroke-width: 4; }
#ch-arc .fill { stroke: #ffffff; stroke-width: 4; transition: stroke .2s linear; }
/* Winding up is its own colour: white/grey already means ammo, so a charge
   building must not read as a magazine filling. */
#ch-arc.wind .track { stroke: rgba(154,92,255,.24); }
#ch-arc.wind .fill { stroke: #b98cff; }
#ch-arc.dry .fill { stroke: #ff6b5e; }
/* Winding into the red zone is heat, not an empty gun, so it warns in amber. */
#ch-arc.wind.dry .track { stroke: rgba(190,140,20,.4); }
#ch-arc.wind.dry .fill { stroke: #ffc21e; }

#ch-arc.dry .track { stroke: rgba(255,90,74,.5); }

#ch-note { position: absolute; left: 0; top: 0; margin: 50px 0 0 -60px; width: 120px;
           text-align: center; font-size: 10px; letter-spacing: 2px; color: #ffc21e;
           text-shadow: 0 0 6px rgba(0,0,0,.9); pointer-events: none;
           will-change: transform; transform: translate3d(-200px, -200px, 0);
           opacity: 0; transition: opacity .18s linear; }
#ch-note.show { opacity: .95; }
body:not([data-mode="playing"]) #ch-note { display: none; }

#gunlist { margin-top: 10px; display: flex; gap: 5px; --slot: 40px; }

#gunrack { display: flex; gap: 8px; justify-content: center; pointer-events: auto;
           --slot: 56px; }
.rack-panel { display: flex; flex-direction: column; align-items: center; gap: 8px;
              margin: 4px 0 2px; }
.rack-help { font-size: 10px; letter-spacing: 1.5px; opacity: .4; line-height: 1.8; }
.rack-help b { color: var(--accent); }
.gun-slot {
  position: relative; width: var(--slot); height: var(--slot);
  border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.45); cursor: pointer;
}
.gun-slot .gico { width: calc(var(--slot) * .64); height: calc(var(--slot) * .64);
                  fill: none; stroke: currentColor;
                  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.gun-slot .k { position: absolute; top: 1px; left: 3px; font-size: 9px; opacity: .5; }
#gunrack .gun-slot:hover { border-color: rgba(255,255,255,.5); }

.gun-slot.on { color: #fff; border-color: #fff; background: rgba(255,255,255,.13); }
.gun-slot.empty { border-style: dashed; cursor: default; }
#gunrack .gun-slot.empty:hover { border-color: rgba(255,255,255,.2); }

#gunrack.moving .gun-slot.empty { border-color: var(--accent); cursor: pointer; }
.gun-slot.off { opacity: .38; }

.gun-slot.off::after {
  content: ''; position: absolute; left: 4px; right: 4px; top: 50%; height: 1px;
  background: #ff4436; transform: rotate(-35deg);
}

.gun-slot.held { border-color: var(--accent); border-style: dashed; }
.gun-slot.held .gico { opacity: .35; }

#gun-tip {
  position: fixed; z-index: 6; display: none; pointer-events: none;
  width: 218px; padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(6,10,14,.95);
  font-size: 11px; letter-spacing: .5px; line-height: 1.5;
}
#gun-ghost {
  position: fixed; left: 0; top: 0; z-index: 7; display: none; pointer-events: none;
  width: 56px; height: 56px; opacity: .9;
  border: 1px solid var(--accent); background: rgba(6,10,14,.9); color: #fff;
  align-items: center; justify-content: center;
}
#gun-ghost .gico { width: 36px; height: 36px; fill: none; stroke: currentColor;
                   stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

#gun-tip .tip-name { font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--accent); }
#gun-tip .tip-desc { opacity: .65; margin: 5px 0 8px; }
#gun-tip .tip-stat { display: flex; justify-content: space-between; opacity: .8; }
#gun-tip .tip-stat span { color: #fff; font-weight: 700; }
#gun-tip .tip-hint { margin-top: 8px; padding-top: 7px; font-size: 10px; opacity: .4;
                     border-top: 1px solid rgba(255,255,255,.12); }

#crosshair .sym { position: absolute; inset: 0; display: none; }
#crosshair[data-sym="cross"] .sym.cross { display: block; }
#crosshair[data-sym="circle"] .sym.circle { display: block; }
#crosshair[data-sym="spread"] .sym.spread { display: block; }
#crosshair[data-sym="lance"] .sym.lance { display: block; }

.sym.cross::before, .sym.cross::after {
  content: ''; position: absolute; background: rgba(255,255,255,.85);
}
.sym.cross::before { left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
.sym.cross::after  { top: 50%; left: 0; height: 2px; width: 100%; margin-top: -1px; }

.sym.spread::before, .sym.spread::after {
  content: ''; position: absolute; box-sizing: border-box; top: 50%;
  width: 9px; height: 17px; margin-top: -8.5px;
  border-top: 2px solid rgba(255,255,255,.85);
  border-bottom: 2px solid rgba(255,255,255,.85);
}
.sym.spread::before { left: -1px; border-left: 2px solid rgba(255,255,255,.85); }
.sym.spread::after  { right: -1px; border-right: 2px solid rgba(255,255,255,.85); }

.sym.circle::before {
  content: ''; position: absolute; box-sizing: border-box; left: 50%; top: 50%;
  width: 19px; height: 19px; margin: -9.5px 0 0 -9.5px;
  border: 2px solid rgba(255,255,255,.85); border-radius: 50%;
}

@keyframes dryPulse {
  0%   { transform: scale(1);    opacity: 1; }
  40%  { transform: scale(1.45); opacity: .7; }
  100% { transform: scale(1);    opacity: 1; }
}
#crosshair.dry .sym { animation: dryPulse .38s ease-out infinite; }
#crosshair.dry .sym.cross::before, #crosshair.dry .sym.cross::after,
#crosshair.dry .sym.circle::before { background: #ff4436; border-color: #ff4436; }
#crosshair.dry .sym.spread::before, #crosshair.dry .sym.spread::after,
#crosshair.dry .sym.lance::before {
  border-color: #ff4436;
}
#crosshair.dry .sym.lance::after { background: #ff4436; }

/* The lance cuts a line and has to be aimed down one: a diamond gate that comes
   to a point above and below, around the spot the beam will pass through. */
.sym.lance::before {
  content: ''; position: absolute; box-sizing: border-box; left: 50%; top: 50%;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid rgba(255,255,255,.85); transform: rotate(45deg);
}
.sym.lance::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px;
  background: rgba(255,255,255,.9);
}

#hurt {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255,0,0,0) 42%, rgba(255,20,20,.7) 100%);
  transition: opacity .18s ease-out;
}

.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(3,6,10,.82);
  backdrop-filter: blur(3px);
  pointer-events: auto;
  text-align: center;
  gap: 14px;
  cursor: default;
}
.overlay.hidden { display: none; }

/* Nothing of the game is loaded on a phone, so the rest of the layer would sit
   there half-built behind the notice. */
html.no-game #ui > *:not(#mobile) { display: none; }
.mobile-panel {
  width: min(430px, 88vw); padding: 30px 30px 26px;
  border: 1px solid #24333d; border-left: 3px solid var(--accent); border-radius: 4px;
  background: rgba(6,10,14,.94); text-align: left;
}
.mobile-panel .title { font-size: 27px; letter-spacing: 6px; line-height: 1.15; }
.mobile-panel .title .sub { margin-top: 10px; font-size: 10px; letter-spacing: 5px; color: #5f7a88; }
.mobile-panel p {
  margin: 20px 0 24px; font-size: 13px; line-height: 1.75; color: #8fa3ae; letter-spacing: .5px;
}
.mobile-panel .btn {
  display: block; margin: 0; padding: 14px 18px; text-align: center;
  text-decoration: none; font-size: 13px; letter-spacing: 3px; border-radius: 3px;
}
.title { font-size: 52px; font-weight: 800; letter-spacing: 10px; }
.title .sub { display: block; font-size: 13px; letter-spacing: 5px; opacity: .5; margin-top: 10px; font-weight: 400; }
.btn {
  margin-top: 18px; padding: 13px 34px;
  border: 1px solid var(--accent); color: var(--accent);
  background: rgba(125,211,252,.08);
  font-family: inherit; font-size: 15px; letter-spacing: 3px; cursor: pointer;
}
.btn:hover { background: rgba(125,211,252,.2); }

#nowplaying {
  position: absolute; bottom: 40px; left: 0; right: 0; text-align: center;
  font-size: 12px; letter-spacing: 3px; color: var(--accent);
  opacity: 0; transition: opacity .6s ease;
}
#nowplaying.show { opacity: .75; }

#extract { position: absolute; left: 0; right: 0; bottom: 78px; text-align: center;
           pointer-events: none; }
#extract.hidden { display: none; }

.ex-label { font-size: 12px; letter-spacing: 3px; color: var(--accent); opacity: .85;
            text-shadow: 0 1px 4px rgba(0,0,0,.9); }
.ex-bar { width: 200px; height: 4px; margin: 7px auto 0; background: rgba(0,0,0,.5);
          border: 1px solid rgba(255,255,255,.2); }
#ex-fill { height: 100%; width: 0%; background: var(--accent); transition: width .08s linear; }
#extract.charging .ex-label { color: #7ee0a1; }
#extract.charging #ex-fill { background: #7ee0a1; }

.hptag { position: absolute; left: 0; top: 0; font-size: 11px; letter-spacing: 1px;
          color: #cfe3ec; text-shadow: 0 1px 3px rgba(0,0,0,.95); pointer-events: none;
          white-space: nowrap; }

#floaters { position: absolute; inset: 0; pointer-events: none; }
.dmg {
  position: absolute; top: 0; left: 0; will-change: transform, opacity;
  font-weight: 600; letter-spacing: 1px; line-height: 1;
  color: #fdf3d0; text-shadow: 0 0 4px rgba(0,0,0,.9), 0 1px 2px rgba(0,0,0,.9);
}
.dmg.hot { color: #ffe9a8; text-shadow: 0 0 6px rgba(255,190,90,.5), 0 1px 2px rgba(0,0,0,.95); }
.dmg.coin { color: #ffd970; text-shadow: 0 0 6px rgba(255,190,60,.6), 0 1px 2px rgba(0,0,0,.9); }
.dmg.hurt { color: #ff6b5e; font-weight: 700;
            text-shadow: 0 0 7px rgba(255,60,40,.6), 0 1px 3px rgba(0,0,0,.95); }

.dmg.crit { color: #ff4436; font-weight: 800; letter-spacing: 0;
            text-shadow: 0 0 10px rgba(255,60,40,.9), 0 0 22px rgba(255,40,20,.5),
                         0 1px 3px rgba(0,0,0,.95); }

.btn.locked, .btn:disabled { opacity: .3; cursor: not-allowed; }
.btn.ghost { border-color: rgba(255,255,255,.22); color: rgba(255,255,255,.6);
             background: rgba(255,255,255,.04); }
.btn.ghost:hover { border-color: rgba(255,255,255,.4); color: #fff; }
.btn.warn { border-color: #ff8f7e; color: #ff8f7e; background: rgba(255,143,126,.08); }

#pause-actions { display: flex; gap: 12px; align-items: center; }
#pause-actions .btn { margin-top: 0; }
#btn-music.off { opacity: .45; }


#debugmenu {
  position: absolute; top: 18px; left: 18px; width: 336px;
  max-height: calc(100vh - 36px); overflow-y: auto;
  background: rgba(6, 10, 14, .94); border: 1px solid #24333d; border-radius: 6px;
  padding: 13px 15px; font-size: 12px; display: none; pointer-events: auto;
}
#debugmenu.shown { display: block; }
#debugmenu h3 { font-size: 11px; letter-spacing: 3px; opacity: .55; margin-bottom: 6px; font-weight: 500; }
#debugmenu label { display: block; margin: 8px 0 4px; }
#debugmenu label > span { display: flex; justify-content: space-between; opacity: .75; }
#debugmenu label > span b { color: var(--accent); font-weight: 500; }
#debugmenu input[type=range] { width: 100%; height: 14px; }
.dbg-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-bottom: 6px; }
.dbg-lbl { opacity: .55; font-size: 10.5px; width: 44px; }
.dbg-row button {
  font: inherit; font-size: 10.5px; letter-spacing: .5px; background: #16222b;
  color: var(--accent); border: 1px solid #2d4451; border-radius: 3px;
  padding: 5px 8px; cursor: pointer;
}
.dbg-row button:hover { background: #1f313d; }
.dbg-row button.on { background: #2b4b5c; color: #d6f2ff; border-color: #4d7f99; }
.dbg-num {
  width: 52px; font: inherit; font-size: 11px; text-align: center;
  background: #0f1920; color: var(--accent); border: 1px solid #2d4451;
  border-radius: 3px; padding: 4px 2px;
}
.dbg-note { font-size: 10px; opacity: .5; line-height: 1.5; margin: -2px 0 8px; }

.dbg-sec { font-size: 9.5px; letter-spacing: 2.5px; opacity: .42;
           margin: 12px 0 6px; padding-top: 7px; border-top: 1px solid #1c2a33; }
#debugmenu h3 + .mix-hint + .dbg-sec { margin-top: 6px; border-top: none; padding-top: 0; }

.dbg-mods { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; margin-bottom: 7px; }
.dbg-mod { display: flex; align-items: center; gap: 4px; }
.dbg-mod-name { flex: 1; font-size: 10px; opacity: .45; white-space: nowrap;
                overflow: hidden; text-overflow: ellipsis; }
.dbg-mod-name.on { opacity: .9; color: var(--accent); }
.dbg-mod button {
  background: #16242c; color: #cfe6f2; border: 1px solid #2c3d47; border-radius: 4px;
  font: inherit; font-size: 10px; padding: 1px 5px; cursor: pointer; min-width: 20px;
}
.dbg-mod button:hover { background: #1f313d; }
#dbg-stat { margin-top: 9px; font-size: 10.5px; opacity: .5; }

#mixer {
  position: absolute; top: 50%; right: 18px; transform: translateY(-50%);
  width: 366px; max-height: 88vh; overflow-y: auto;
  background: rgba(6, 10, 14, .94); border: 1px solid #24333d; border-radius: 6px;
  padding: 14px 16px; font-size: 12px; display: none; pointer-events: auto;
}
#mixer.shown { display: block; }
#mixer h3 { font-size: 11px; letter-spacing: 3px; opacity: .55; margin-bottom: 6px; font-weight: 500; }
.mix-hint { opacity: .38; font-size: 10.5px; line-height: 1.5; margin-bottom: 10px; }
.mix-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.mix-name { width: 74px; opacity: .8; }
.mix-row input[type=range] { flex: 1; height: 14px; }
.mix-val { width: 34px; text-align: right; color: var(--accent); }
.mix-play, .mix-pad { width: 24px; }
.mix-play { background: #16222b; color: var(--accent); border: 1px solid #2d4451;
            border-radius: 3px; cursor: pointer; font: inherit; font-size: 10px; padding: 2px 0; }
.mix-play:hover { background: #1f313d; }
.mix-sep { height: 1px; background: #22313a; margin: 9px 0; }
.mix-bar { display: flex; gap: 6px; margin-top: 11px; }
.mix-bar button { flex: 1; font: inherit; font-size: 10.5px; letter-spacing: 1px;
                  background: #16222b; color: var(--accent); border: 1px solid #2d4451;
                  border-radius: 3px; padding: 6px 4px; cursor: pointer; }
.mix-bar button:hover { background: #1f313d; }

#mix-out { margin-top: 9px; background: #05090c; border: 1px solid #1c272e; border-radius: 4px;
           padding: 8px; font-size: 9.5px; line-height: 1.45; color: #8fb4c4;
           white-space: pre-wrap; word-break: break-word; max-height: 240px; user-select: text; }
body.mixer-open { cursor: default; }
body.mixer-open #crosshair { display: none; }

.hint { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; font-size: 11px; opacity: .35; letter-spacing: 2px; }
