/* ───────────── Meteor Shower ───────────── */
:root {
  --deep: #02061a;
  --navy: #071443;
  --blue: #1e6bff;
  --cyan: #00e1ff;
  --ice: #d8ecff;
  --mute: #6f8cc8;
  --red: #ff3b4e;
  --green: #3dff7a;
  --gold: #ffc93a;
  --silver: #c9d6ef;
  --px: "Silkscreen", ui-monospace, Menlo, monospace;
  --s: 4px; /* one "pixel" of HUD chrome */
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: var(--deep); color: var(--ice); font-family: var(--px); color-scheme: dark; -webkit-font-smoothing: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
body.playing { cursor: none; }
[hidden] { display: none !important; }
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: var(--s) solid var(--cyan); outline-offset: 2px; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
.scan { position: fixed; inset: 0; pointer-events: none; background: repeating-linear-gradient(transparent 0 3px, rgba(0, 0, 0, .14) 3px 4px); mix-blend-mode: multiply; }
.hurt { position: fixed; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 0 12px var(--red), inset 0 0 160px rgba(255, 40, 70, .7); }
.hurt.on { animation: hurt .45s steps(4) forwards; }
@keyframes hurt { 0% { opacity: 1; } 100% { opacity: 0; } }

/* crosshair (pixel art, built from boxes) */
.cross { position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 30; display: none; }
body.playing .cross { display: block; }
.cross i { position: absolute; background: var(--cyan); box-shadow: 0 0 0 2px var(--deep); }
.cross i:nth-child(1) { left: -2px; top: -22px; width: 4px; height: 12px; }
.cross i:nth-child(2) { left: -2px; top: 10px; width: 4px; height: 12px; }
.cross i:nth-child(3) { top: -2px; left: -22px; width: 12px; height: 4px; }
.cross i:nth-child(4) { top: -2px; left: 10px; width: 12px; height: 4px; }
.cross b { position: absolute; left: -2px; top: -2px; width: 4px; height: 4px; background: #fff; }
.cross.fire i { background: #fff; }
.cross.fire i:nth-child(1) { transform: translateY(-4px); }
.cross.fire i:nth-child(2) { transform: translateY(4px); }
.cross.fire i:nth-child(3) { transform: translateX(-4px); }
.cross.fire i:nth-child(4) { transform: translateX(4px); }
.cross.hit b { background: var(--gold); box-shadow: 0 0 0 4px var(--gold); }
.cross.core b { background: #fff; box-shadow: 0 0 0 4px var(--red), 0 0 0 8px #fff; }

/* floating damage / points numbers */
.pops { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 700; font-size: 14px; color: var(--ice); text-shadow: 2px 2px 0 var(--deep); animation: pop .75s steps(8) forwards; white-space: nowrap; }
.pop.pts { font-size: 20px; color: var(--cyan); }
.pop.pts.silver { color: var(--silver); }
.pop.pts.gold { color: var(--gold); font-size: 26px; }
.pop.core { color: var(--gold); font-size: 18px; }
.pop.blk { color: var(--mute); font-size: 12px; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(1.3); } 100% { transform: translate(-50%, -190%); opacity: 0; } }

/* ── HUD ── */
.hud-top, .hud-bot { position: fixed; left: 0; right: 0; z-index: 10; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px clamp(12px, 2.4vw, 28px); pointer-events: none; text-shadow: 2px 2px 0 var(--deep); }
.hud-top { top: 0; }
.hud-bot { bottom: 0; align-items: flex-end; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
body:not(.ingame) .hud-top, body:not(.ingame) .hud-bot { opacity: 0; }
.score small, .laser small { display: block; font-size: 10px; letter-spacing: .12em; color: var(--mute); }
.score b { font-size: clamp(22px, 3.4vw, 34px); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.score b.bump { animation: bump .25s steps(3); }
@keyframes bump { 50% { color: var(--cyan); transform: translateY(-3px); } }
.score.r { text-align: right; }
.score.r b { font-size: 18px; color: var(--mute); }
.top-r { display: flex; gap: 10px; align-items: flex-start; pointer-events: auto; }
.icon { height: 34px; min-width: 40px; padding: 0 8px; border: 0; background: var(--navy); box-shadow: 0 0 0 var(--s) var(--blue) inset; font-size: 11px; color: var(--ice); cursor: pointer; }
.icon:hover { background: var(--blue); }
.icon.off { color: var(--mute); text-decoration: line-through; }
body.playing .icon { cursor: pointer; }

.boss { flex: 0 1 520px; text-align: center; }
.boss-name { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 700; color: var(--bc, var(--red)); }
.boss-name span:last-child { color: var(--ice); font-weight: 400; }
.boss-bar { height: 16px; margin-top: 6px; background: var(--deep); box-shadow: 0 0 0 var(--s) var(--ice), 4px 4px 0 var(--s) var(--deep); overflow: hidden; }
.boss-bar i { display: block; height: 100%; width: 100%; background: var(--bc, var(--red)); background-image: repeating-linear-gradient(90deg, transparent 0 8px, rgba(0,0,0,.25) 8px 10px); transition: width .2s steps(4); }
.boss.shield .boss-bar i { filter: saturate(.25) brightness(1.4); }
.boss-phase { margin-top: 8px; font-size: 11px; letter-spacing: .08em; color: var(--ice); min-height: 1.2em; }
.boss-phase.hot { color: var(--gold); animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }

.hull { width: min(360px, 44vw); }
.lbl { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.lbl span:first-child { color: var(--mute); }
.bar { height: 18px; background: var(--deep); box-shadow: 0 0 0 var(--s) var(--blue), 4px 4px 0 var(--s) var(--deep); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--cyan); background-image: repeating-linear-gradient(90deg, transparent 0 10px, rgba(0,0,0,.2) 10px 12px); transition: width .25s steps(5), background-color .3s; }
.bar i.mid { background-color: var(--gold); }
.bar i.low { background-color: var(--red); animation: blink .4s steps(2) infinite; }
.next { font-size: 11px; color: var(--mute); text-align: center; padding-bottom: 2px; }
.next b { color: var(--ice); font-weight: 400; }
.laser { text-align: right; }
.laser b { display: block; font-size: 22px; color: var(--cyan); line-height: 1.1; }
.laser span { font-size: 10px; color: var(--mute); }
.laser.up b { animation: bump .3s steps(3) 4; }

.banner { position: fixed; left: 50%; top: 30%; z-index: 15; transform: translate(-50%, -50%); width: max-content; max-width: 92vw; text-align: center; pointer-events: none; font-size: clamp(18px, 3.2vw, 34px); font-weight: 700; line-height: 1.3; text-shadow: 3px 3px 0 var(--deep); opacity: 0; }
.banner.on { animation: banner var(--dur, 2.2s) steps(24) forwards; }
.banner small { display: block; font-size: .45em; font-weight: 400; color: var(--ice); margin-top: 8px; }
.banner.warn { color: var(--bc, var(--red)); }
.banner.warn::before, .banner.warn::after { content: ""; display: block; height: 10px; margin: 10px auto; width: 100%; background: repeating-linear-gradient(-45deg, var(--bc, var(--red)) 0 10px, transparent 10px 20px); }
.banner.good { color: var(--cyan); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -40%); } 8% { opacity: 1; transform: translate(-50%, -50%); } 85% { opacity: 1; } 100% { opacity: 0; } }

/* ── screens ── */
.screen { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 14px; padding: 24px; text-align: center; background: rgba(2, 6, 26, .62); overflow: auto; }
.exit { position: absolute; left: clamp(12px, 2.4vw, 28px); top: 16px; font-size: 13px; text-decoration: none; color: var(--mute); }
.exit:hover { color: var(--ice); }
.kick { font-size: 12px; letter-spacing: .2em; color: var(--cyan); }
.screen h1 { font-size: clamp(40px, 8vw, 84px); font-weight: 700; line-height: .95; color: var(--ice); text-shadow: 4px 4px 0 var(--blue), 8px 8px 0 var(--deep); }
.screen h2 { font-size: clamp(36px, 8vw, 72px); font-weight: 700; line-height: 1; text-shadow: 4px 4px 0 var(--blue), 8px 8px 0 var(--deep); }
.sub { max-width: 46ch; font-size: 13px; line-height: 1.7; color: var(--ice); opacity: .85; }
.warn { max-width: 46ch; font-size: 12px; line-height: 1.7; color: var(--red); }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 6px 0; }
.legend li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--navy); box-shadow: 0 0 0 var(--s) var(--blue) inset; font-size: 12px; }
.legend b { color: var(--cyan); }
.legend i { width: 16px; height: 16px; box-shadow: 4px 0 0 var(--c), -4px 0 0 var(--c), 0 4px 0 var(--c), 0 -4px 0 var(--c); background: var(--c); transform: scale(.75); }
.m-normal { --c: #6879a6; } .m-silver { --c: var(--silver); } .m-gold { --c: var(--gold); }
.go { display: inline-block; min-width: 240px; padding: 16px 28px; border: 0; background: var(--blue); color: #fff; font-size: 18px; font-weight: 700; text-decoration: none; cursor: pointer; box-shadow: 0 0 0 var(--s) var(--ice) inset, 6px 6px 0 var(--deep); transition: transform .08s steps(2); }
.go:hover { background: var(--cyan); color: var(--deep); }
.go:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--s) var(--ice) inset, 2px 2px 0 var(--deep); }
.go.ghost { background: var(--navy); font-size: 14px; color: var(--ice); box-shadow: 0 0 0 var(--s) var(--blue) inset, 6px 6px 0 var(--deep); }
.go.ghost:hover { background: var(--blue); color: #fff; }
.keys { font-size: 11px; color: var(--mute); }
.keys span { color: var(--ice); }
.final { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.final small { font-size: 11px; color: var(--mute); }
.final b { font-size: clamp(40px, 8vw, 64px); color: var(--cyan); text-shadow: 4px 4px 0 var(--deep); }
.final span { font-size: 12px; color: var(--gold); min-height: 1em; }

/* overheat */
.heat { position: relative; width: 150px; height: 10px; margin: 8px 0 0 auto; background: var(--deep); box-shadow: 0 0 0 3px var(--blue); }
.heat i { display: block; height: 100%; width: 0; background: var(--cyan); }
.heat em { position: absolute; right: calc(100% + 8px); top: -3px; font-size: 9px; font-style: normal; color: var(--mute); }
.heat.hot i { background: var(--gold); }
.heat.over { box-shadow: 0 0 0 3px var(--red); }
.heat.over i { background: var(--red); animation: blink .3s steps(2) infinite; }
.heat.over em { color: var(--red); }
.cross u { position: absolute; left: -16px; top: 26px; width: 32px; height: 4px; background: var(--deep); opacity: 0; transition: opacity .2s; }
.cross u s { display: block; height: 100%; width: 0; background: var(--cyan); }
.cross.warm u { opacity: 1; }
.cross.hot i, .cross.hot u s { background: var(--gold); }
.cross em { position: absolute; left: 0; top: 36px; transform: translateX(-50%); font-size: 11px; font-style: normal; font-weight: 700; color: var(--red); text-shadow: 2px 2px 0 var(--deep); white-space: nowrap; display: none; }
.cross.over em { display: block; animation: blink .3s steps(2) infinite; }
.cross.over i, .cross.over u s { background: var(--red); }
.cross.over u { opacity: 1; }

/* combo */
.left { display: flex; gap: 22px; align-items: flex-start; }
.combo { opacity: .35; transition: opacity .2s; }
.combo small { display: block; font-size: 10px; letter-spacing: .12em; color: var(--mute); }
.combo b { display: block; font-size: 26px; line-height: 1; color: var(--gold); }
.combo i { display: block; width: 70px; height: 6px; margin-top: 6px; background: var(--deep); box-shadow: 0 0 0 2px var(--blue); }
.combo i u { display: block; height: 100%; width: 0; background: var(--gold); transition: width .1s steps(3); }
.combo.on { opacity: 1; }
.combo.up b { animation: bump .3s steps(3); }
.combo.max b { color: #fff; text-shadow: 2px 2px 0 var(--red); animation: blink .5s steps(2) infinite; }
.pop.combo { font-size: 22px; color: var(--gold); }
.pop.lost { font-size: 14px; color: var(--red); }

/* ice + low hull overlays */
.frost { position: fixed; inset: 0; pointer-events: none; z-index: 6; opacity: 0; transition: opacity .3s; box-shadow: inset 0 0 0 10px rgba(180, 235, 255, .6), inset 0 0 150px rgba(140, 220, 255, .55); }
body.frozen .frost { opacity: 1; }
body.frozen .cross i { background: #bfeaff; }
.alarm { position: fixed; inset: 0; pointer-events: none; z-index: 6; opacity: 0; box-shadow: inset 0 0 130px rgba(255, 40, 70, .6); }
body.lowhp .alarm { animation: alarm .85s steps(4) infinite; }
@keyframes alarm { 0%, 100% { opacity: .15; } 50% { opacity: 1; } }

/* menu: legend hints */
.legend { display: grid; grid-template-columns: repeat(3, minmax(0, 190px)); gap: 8px; margin: 2px 0; }
.legend li { flex-wrap: wrap; gap: 0 8px; padding: 7px 10px; font-size: 11px; }
.legend li b { margin-left: auto; }
.legend em { flex-basis: 100%; font-style: normal; font-size: 9px; color: var(--mute); text-align: left; padding-left: 24px; }
.tips { list-style: none; padding: 0; display: grid; gap: 5px; max-width: 560px; font-size: 11px; line-height: 1.5; text-align: left; color: var(--ice); opacity: .9; }
.tips b { display: inline-block; width: 64px; color: var(--gold); }
.m-explosive { --c: #ff5a1f; } .m-ice { --c: #bfeaff; } .m-armored { --c: #5a6688; }

/* end screen: stats + top 5 */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: min(580px, 100%); }
.stats div { padding: 8px 6px; background: var(--navy); box-shadow: 0 0 0 3px var(--blue) inset; }
.stats small { display: block; font-size: 9px; color: var(--mute); }
.stats b { font-size: 18px; color: var(--ice); }
.top { list-style: none; padding: 0; width: min(440px, 100%); display: grid; gap: 4px; font-size: 12px; }
.top li { display: grid; grid-template-columns: 34px 1fr 56px; gap: 8px; padding: 5px 10px; background: rgba(7, 20, 67, .75); text-align: left; }
.top li.head { background: none; color: var(--mute); font-size: 9px; padding-bottom: 0; }
.top li.me { background: var(--blue); color: #fff; }
.top i { font-style: normal; color: var(--mute); }
.top li.me i { color: #fff; }

/* loot inventory */
.mid { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.inv { display: flex; gap: 10px; pointer-events: auto; }
.slot { position: relative; width: 74px; padding: 6px 4px 5px; border: 0; background: var(--navy); box-shadow: 0 0 0 var(--s) var(--c) inset, 4px 4px 0 var(--deep); color: var(--ice); text-align: center; text-shadow: 2px 2px 0 var(--deep); }
button.slot { cursor: pointer; }
.slot small { display: block; font-size: 9px; color: var(--c); }
.slot b { display: block; font-size: 18px; line-height: 1.2; }
.slot kbd { position: absolute; top: -9px; right: -7px; padding: 1px 4px; font: inherit; font-size: 9px; background: var(--c); color: var(--deep); text-shadow: none; }
.slot.empty { opacity: .35; box-shadow: 0 0 0 var(--s) var(--line, #1a2a5c) inset; }
.slot.empty small { color: var(--mute); }
.slot.got { animation: got .5s steps(4) 2; }
@keyframes got { 50% { background: var(--c); color: var(--deep); } }
.lt { color: #ffe14a; }
.pop.loot { font-size: 18px; color: #ffe14a; }
.pop.heal { font-size: 20px; color: #5dff9c; }
.flashw { position: fixed; inset: 0; pointer-events: none; background: #fff; opacity: 0; z-index: 5; }
.flashw.on { animation: hurt .35s steps(4) forwards; }

@media (max-width: 640px) {
  .slot { width: 58px; }
  .hud-top { flex-wrap: wrap; }
  .boss { order: 3; flex-basis: 100%; }
  .next { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .tips b { display: block; width: auto; }
  .left { gap: 12px; }
  .hud-bot { flex-wrap: wrap; }
  .mid { order: -1; flex-basis: 100%; }
  .laser span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scan { display: none; }
}
