* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0f17; font-family: 'Segoe UI', system-ui, sans-serif; color: #fff; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(20,40,90,.55), rgba(5,8,15,.92)); z-index: 10; }
#overlay .panel { width: min(560px, calc(100% - 32px)); text-align: center; }
.kicker { letter-spacing: .3em; font-size: 11px; color: #8fb3ff; margin-bottom: 10px; }
h1 { font-size: clamp(40px, 8vw, 72px); font-weight: 900; letter-spacing: .04em; line-height: .95;
  background: linear-gradient(180deg, #fff 30%, #9cc0ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
h1 span { display: block; font-size: .42em; letter-spacing: .5em; color: #e33; -webkit-text-fill-color: #ff3b3b; margin-top: 6px; }
#load-wrap { margin: 28px auto 18px; width: 80%; }
#load-bar { height: 4px; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; }
#load-fill { height: 100%; width: 0; background: linear-gradient(90deg, #3b6cff, #ff3b3b); transition: width .2s; }
#load-text { font-size: 12px; color: #9aa7c0; margin-top: 8px; }
#play { font: inherit; font-weight: 800; letter-spacing: .2em; font-size: 16px; padding: 14px 44px; border: 0; border-radius: 4px;
  background: #ff3b3b; color: #fff; cursor: pointer; box-shadow: 0 6px 30px rgba(255,59,59,.35); }
#play:disabled { background: #333a48; box-shadow: none; cursor: default; color: #8892a6; }
.controls { margin-top: 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; text-align: left; font-size: 13px; color: #c6d0e4; }
.controls div:nth-last-child(2) { grid-column: 1 / -1; }
kbd { display: inline-block; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-bottom-width: 2px;
  border-radius: 3px; padding: 1px 6px; font-size: 11px; font-family: inherit; margin-right: 3px; color: #fff; }
.credits { margin-top: 22px; font-size: 10px; color: #6b768c; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; }
#crosshair::before, #crosshair::after { content: ''; position: absolute; background: rgba(255,255,255,.85); box-shadow: 0 0 3px rgba(0,0,0,.6); }
#crosshair::before { left: 10px; top: 3px; width: 2px; height: 16px; clip-path: polygon(0 0,100% 0,100% 30%,0 30%,0 70%,100% 70%,100% 100%,0 100%); }
#crosshair::after { top: 10px; left: 3px; height: 2px; width: 16px; clip-path: polygon(0 0,30% 0,30% 100%,0 100%,0 0,70% 0,100% 0,100% 100%,70% 100%); }
#laser-vignette { position: absolute; inset: 0; opacity: 0; transition: opacity .15s;
  background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(255,40,20,.35) 100%); }
#speed-lines { position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 45%, rgba(200,220,255,.18) 100%); }
#boom-flash { position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(255,255,255,.95) 0%, rgba(225,235,255,.7) 55%, rgba(200,215,255,.35) 100%); }
#hud-top { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.pill { background: rgba(8,12,22,.55); border: 1px solid rgba(255,255,255,.12); padding: 5px 12px; border-radius: 20px;
  font-size: 12px; letter-spacing: .08em; backdrop-filter: blur(4px); }
#hud-rank { display: flex; align-items: center; gap: 10px; padding: 5px 14px 5px 8px; }
#hud-rank .rank { font-size: 18px; font-weight: 800; color: #ffd34d; width: 26px; height: 26px; line-height: 26px; text-align: center;
  border-radius: 50%; background: rgba(255,211,77,.12); border: 1px solid rgba(255,211,77,.45); }
#hud-rank .xp { display: flex; flex-direction: column; gap: 3px; min-width: 150px; }
#hud-rank .xp-text { font-size: 10px; letter-spacing: .06em; color: #c6d0e4; }
#hud-rank .pts { font-size: 10px; font-weight: 700; letter-spacing: .12em; color: #7dff9a; }
#hud-rank .pts:empty { display: none; }
.xp-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffb13b, #ffd34d); transition: width .35s; }
#toast { position: absolute; top: 72px; left: 50%; transform: translateX(-50%); text-align: center; opacity: 0; pointer-events: none;
  text-shadow: 0 2px 10px rgba(0,0,0,.8); }
#toast b { display: block; font-size: 30px; font-weight: 800; letter-spacing: .18em; color: #ffd34d; }
#toast span { font-size: 12px; letter-spacing: .14em; color: #e8eefc; }
#toast.show { animation: toast 3.2s ease-out forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -8px) scale(1.15); } 8% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; } 100% { opacity: 0; } }
#tech { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5,8,16,.72);
  backdrop-filter: blur(6px); z-index: 20; color: #e8eefc; padding: 16px; }
#tech.hidden { display: none; }
.tech-panel { width: min(860px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: rgba(12,18,32,.92);
  border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 18px 20px; }
.tech-title { display: flex; justify-content: space-between; align-items: center; letter-spacing: .3em; font-size: 12px; color: #8fb3ff; margin-bottom: 14px; gap: 12px; }
#tech button { background: rgba(255,211,77,.14); color: #ffd34d; border: 1px solid rgba(255,211,77,.5); border-radius: 8px;
  padding: 7px 12px; font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .12em; cursor: pointer; }
#tech button:hover { background: rgba(255,211,77,.26); }
.tech-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.tech-rank { display: flex; align-items: center; gap: 14px; }
.tech-rank .big, .tech-pts .big { font-size: 44px; font-weight: 800; color: #ffd34d; line-height: 1; }
.tech-rank small, .tech-pts small { font-size: 11px; color: #9fb0cc; letter-spacing: .06em; }
.tech-rank .xp-bar { width: 220px; margin: 6px 0 4px; }
.ranks span { display: inline-block; width: 22px; text-align: center; font-weight: 700; font-size: 12px; color: #55607a; }
.ranks span.past { color: #a88c3a; }
.ranks span.now { color: #ffd34d; }
.tech-pts { text-align: right; display: flex; flex-direction: column; }
.tech-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.tech-col h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: .3em; color: #8fb3ff; text-transform: uppercase; }
.node { position: relative; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; background: rgba(255,255,255,.03); }
.node:not(:last-child)::after { content: ""; position: absolute; left: 22px; bottom: -13px; width: 2px; height: 12px; background: rgba(255,255,255,.15); }
.node.owned { border-color: rgba(125,255,154,.5); background: rgba(125,255,154,.06); }
.node.ready { border-color: rgba(255,211,77,.6); }
.node.locked { opacity: .55; }
.node-head { display: flex; justify-content: space-between; align-items: baseline; }
.node-head b { font-size: 14px; }
.cost { font-size: 11px; color: #ffd34d; }
.node p { margin: 6px 0 8px; font-size: 12px; color: #b9c4da; line-height: 1.4; }
.node-foot { display: flex; justify-content: space-between; align-items: center; }
.tag { font-size: 10px; letter-spacing: .12em; color: #9fb0cc; }
.node.owned .tag { color: #7dff9a; }
.req { font-size: 10px; color: #6f7c96; }
.tech-dev { margin-top: 6px; padding-top: 12px; border-top: 1px dashed rgba(255,255,255,.12); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tech-dev span { font-size: 10px; letter-spacing: .2em; color: #6f7c96; margin-right: auto; }
#hud-bottom { position: absolute; left: 22px; bottom: 20px; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
#hud-mode { font-size: 12px; letter-spacing: .3em; color: #8fb3ff; font-weight: 700; }
#hud-speed { font-size: 38px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
#hud-speed small { font-size: 14px; font-weight: 600; color: #b8c4da; }
#hud-alt { font-size: 12px; color: #b8c4da; letter-spacing: .1em; font-variant-numeric: tabular-nums; }
#hud-help { position: absolute; right: 18px; bottom: 18px; font-size: 12px; text-align: right; color: #d8e0f0; line-height: 1.7;
  background: rgba(8,12,22,.5); padding: 8px 12px; border-radius: 6px; }
#hud-help b { color: #fff; }
#fps { position: absolute; top: 8px; right: 12px; font-size: 11px; color: #9aa7c0; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .controls { grid-template-columns: 1fr; }
  #hud-help { display: none; }
}

#target { position: absolute; left: 50%; top: calc(50% + 24px); transform: translateX(-50%); font-size: 10px; font-weight: 700;
  letter-spacing: .25em; color: #e8eefc; text-shadow: 0 1px 3px rgba(0,0,0,.8); white-space: nowrap; }


/* ---- street events: objective, messages, world markers ---- */
#objective { position: absolute; top: 64px; left: 16px; max-width: 300px; padding: 10px 14px; border-radius: 10px;
  background: rgba(8,12,22,.55); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(4px); font-size: 12px; color: #dfe6f5; line-height: 1.6; }
#objective.hidden { display: none; }
#objective b { display: block; font-size: 11px; letter-spacing: .24em; color: #ff8a5c; margin-bottom: 2px; }
#objective .done { color: #7dff9a; }
#objective .fail { color: #7c8598; text-decoration: line-through; }
#event-msg { position: absolute; top: 132px; left: 50%; transform: translateX(-50%); text-align: center; opacity: 0; pointer-events: none;
  text-shadow: 0 2px 10px rgba(0,0,0,.85); }
#event-msg b { display: block; font-size: 22px; font-weight: 800; letter-spacing: .16em; color: #ff8a5c; }
#event-msg span { font-size: 12px; letter-spacing: .12em; color: #e8eefc; }
#event-msg.show { animation: toast 3.4s ease-out forwards; }
#markers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.marker { position: absolute; left: 0; top: 0; margin: -34px 0 0 -60px; width: 120px; text-align: center; white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0,0,0,.9); will-change: transform; }
.marker b { display: block; font-size: 11px; font-weight: 800; letter-spacing: .18em; }
.marker span { font-size: 10px; color: #dfe6f5; }
.marker::after { content: ""; display: block; width: 9px; height: 9px; margin: 3px auto 0; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 10px currentColor; }
.marker.thief { color: #ff5a4a; }
.marker.victim { color: #ffd34d; }
.marker.goal { color: #7dff9a; }
.marker.purse { color: #ffb36b; }
.marker.police { color: #6aa4ff; }
.marker.hospital { color: #ff6b6b; }
.marker.edge { opacity: .85; }

/* boss: name, threat level and health across the top */
#boss-bar { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); width: min(560px, 70vw); text-align: center; transition: opacity .4s; }
#boss-bar.hidden { opacity: 0; }
#boss-bar .boss-name { font-size: 22px; font-weight: 900; letter-spacing: .3em; color: #ff4b3a; text-shadow: 0 2px 0 #000, 0 0 14px rgba(255, 60, 40, .5); }
#boss-bar .boss-sub { font-size: 10px; letter-spacing: .22em; color: #ffd0b8; margin: 2px 0 6px; }
#boss-bar .boss-hp { height: 10px; border: 2px solid #1a0505; background: rgba(40, 6, 6, .75); border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255, 90, 60, .5); }
#boss-bar .boss-fill { height: 100%; width: 100%; background: linear-gradient(#ff6a3d, #c4160f); transition: width .25s; }
/* Vargan's rage: the bar pulses, faster when he's furious */
#boss-bar.rage1 .boss-hp { animation: rage-pulse 1.1s ease-in-out infinite; }
#boss-bar.rage2 .boss-hp { animation: rage-pulse .45s ease-in-out infinite; }
#boss-bar.rage1 .boss-sub, #boss-bar.rage2 .boss-sub { color: #ff6a4a; font-weight: 700; }
#boss-bar.rage2 .boss-name { animation: rage-shake .12s linear infinite; }
@keyframes rage-pulse { 50% { box-shadow: 0 0 0 1px rgba(255, 90, 60, .9), 0 0 18px rgba(255, 40, 20, .85); } }
@keyframes rage-shake { 25% { transform: translate(1px, -1px); } 75% { transform: translate(-1px, 1px); } }
.marker.boss { color: #ff3b2a; }

/* hero health: bottom left, above the mode / speed readout; a red flash when hit */
#hud-hp { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#hud-hp .hp-bar { width: 220px; height: 9px; background: rgba(10, 12, 20, .65); border: 1px solid rgba(255, 255, 255, .25); border-radius: 2px; overflow: hidden; }
#hud-hp .hp-fill { height: 100%; width: 100%; background: linear-gradient(#7dff9a, #2fbf55); transition: width .15s; }
#hud-hp.low .hp-fill { background: linear-gradient(#ffb36b, #e5541c); }
#hud-hp.critical .hp-fill { background: linear-gradient(#ff6a5c, #c4160f); animation: hp-pulse .6s infinite alternate; }
@keyframes hp-pulse { from { opacity: 1; } to { opacity: .45; } }
#hud-hp .hp-num { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: #e8eefc; min-width: 70px; }
#hurt-flash { position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, transparent 35%, rgba(200, 10, 0, .55) 100%); }
