:root {
  --ink: #1d2126;
  --panel: rgba(20, 24, 30, 0.72);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f3f5f7;
  --muted: #b6c0ca;
  --accent: #ffcf4a;
  --danger: #ff5a4f;
  --ok: #5ed26a;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #b9d3e6; color: var(--text); }
canvas#scene, canvas#overlay { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#overlay { pointer-events: none; }
[hidden] { display: none !important; }

.screen {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(40, 60, 40, 0.35), rgba(10, 14, 18, 0.75));
  backdrop-filter: blur(3px);
  z-index: 10;
}
.card {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px;
  padding: 28px 28px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.card h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: 0.5px; }
.card h2 { margin: 0 0 8px; }
.tag { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.4; }
label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 6px; }
input {
  width: 100%; padding: 12px 14px; font-size: 18px; border-radius: 9px; border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.08); color: var(--text); outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 207, 74, 0.25); }
button {
  margin-top: 12px; width: 100%; padding: 12px; font-size: 16px; font-weight: 600; border: 0; border-radius: 9px;
  background: var(--accent); color: var(--ink); cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: progress; }
.error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.controls { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 13px; }
kbd { display: inline-block; min-width: 20px; padding: 1px 5px; margin-right: 2px; border-radius: 4px; border: 1px solid var(--panel-border); background: rgba(255, 255, 255, 0.1); color: var(--text); font: 12px ui-monospace, monospace; text-align: center; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#player-card { position: absolute; top: 14px; left: 14px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; padding: 10px 12px; width: 240px; }
#player-name { font-weight: 700; margin-bottom: 6px; }
.bar { position: relative; height: 16px; border-radius: 8px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
#health-fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, #3fc15a, #8be36b); transition: width 0.12s; }
#health-text { position: absolute; inset: 0; font-size: 11px; line-height: 16px; text-align: center; color: #0c1a0e; font-weight: 700; }
#bots-status { margin-top: 4px; font-size: 12px; font-weight: 500; color: #a9d8ff; text-align: right; }
#score { position: absolute; top: 14px; right: 14px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
#killfeed { position: absolute; top: 58px; right: 14px; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
#killfeed li { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 7px; padding: 4px 9px; font-size: 13px; animation: fade 6s forwards; }
#killfeed li b { color: var(--accent); }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
#respawn { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); font-size: 26px; font-weight: 700; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); }
#status { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(160, 60, 30, 0.85); padding: 6px 12px; border-radius: 8px; font-size: 13px; }
#minimap { position: absolute; right: 14px; bottom: 14px; width: 180px; height: 180px; border-radius: 12px; border: 1px solid var(--panel-border); background: rgba(20, 24, 30, 0.6); }
#debug {
  /* bottom-left, above the hint line and left of the centred weapon panel (never over it) */
  position: absolute; left: 14px; bottom: 38px; margin: 0; padding: 10px 12px; max-width: min(520px, calc(50vw - 150px));
  background: rgba(10, 12, 16, 0.8); border: 1px solid var(--panel-border); border-radius: 10px;
  font: 12px/1.45 ui-monospace, Consolas, monospace; color: #d7e3ee; white-space: pre-wrap;
}
#weapon {
  --weapon-color: #ffd35c;
  position: absolute; bottom: 38px; left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 16px; align-items: center;
  min-width: 220px; padding: 8px 16px 9px; background: var(--panel); border: 1px solid var(--panel-border);
  border-bottom: 3px solid var(--weapon-color); border-radius: 12px; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
}
#weapon-label { grid-column: 1; font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
#weapon-name { grid-column: 1; grid-row: 2; font-size: 20px; font-weight: 800; color: var(--weapon-color); text-shadow: 0 0 10px color-mix(in srgb, var(--weapon-color) 45%, transparent); white-space: nowrap; }
#weapon-ammo { grid-column: 2; grid-row: 1 / span 2; justify-self: end; font: 800 30px/1 "Segoe UI", system-ui, sans-serif; font-variant-numeric: tabular-nums; }
#weapon.low #weapon-ammo { color: var(--danger); animation: blink 0.6s steps(2) infinite; }
#boosts { display: flex; gap: 6px; flex-wrap: wrap; }
#boosts:not(:empty) { margin-top: 6px; }
#boosts span {
  --boost-color: #ffd23c;
  padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--boost-color);
  background: color-mix(in srgb, var(--boost-color) 16%, transparent); border: 1px solid var(--boost-color);
}
#boosts span.ending { animation: blink 0.5s steps(2) infinite; }
#weapon-slots { grid-column: 1 / span 2; grid-row: 3; display: flex; gap: 6px; }
#weapon-slots:not(:empty) { margin-top: 6px; }
#weapon-slots span {
  --slot-color: #ffd35c;
  padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 700; white-space: nowrap;
  color: var(--slot-color); border: 1px solid color-mix(in srgb, var(--slot-color) 40%, transparent); opacity: 0.55;
}
#weapon-slots span.active { opacity: 1; background: color-mix(in srgb, var(--slot-color) 18%, transparent); border-color: var(--slot-color); }
@keyframes blink { 50% { opacity: 0.45; } }
#toast {
  --toast-color: var(--accent);
  position: absolute; top: 24%; left: 50%; transform: translateX(-50%);
  padding: 8px 18px; border-radius: 10px; background: var(--panel); border: 1px solid var(--toast-color);
  font-size: 20px; font-weight: 700; color: var(--toast-color); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); white-space: nowrap;
}
#toast.show { animation: toast 2.2s ease-out forwards; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.92); }
  10%, 75% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}
.controls li.wide { flex-basis: 100%; line-height: 1.6; }
.controls .w { font-weight: 700; }
.controls .w.smg { color: #ff9a2e; }
.controls .w.blaster { color: #e04dff; }
.controls .w.rail { color: #3ad0ff; }
#hint { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); font-size: 12px; white-space: nowrap; color: rgba(255, 255, 255, 0.75); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }

@media (max-width: 1000px) { #hint { display: none; } #weapon { bottom: 14px; } #debug { bottom: 14px; font-size: 11px; } }

/* ---------------------------------------------------------------- touch devices (body.touch, main.ts startTouch)
   Compact HUD at the edges so the play area stays visible; the joystick bottom-left, the minimap out of the aiming
   thumb's way (top-right); no page zoom, scroll or text selection while playing; safe areas of notched screens. */
.controls .mobile { display: none; }
@media (pointer: coarse) { .controls .mobile { display: list-item; } .controls .desktop { display: none; } }
#stick { display: none; }
body.touch { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.touch canvas#scene { touch-action: none; }
body.touch #hint { display: none; }
body.touch #stick {
  display: block; position: absolute; left: 0; bottom: 0; width: min(46vw, 260px); height: min(52vh, 300px);
  pointer-events: auto; touch-action: none; z-index: 6;
}
body.touch .stick-base, body.touch .stick-knob { position: absolute; left: 0; top: 0; border-radius: 50%; pointer-events: none; }
body.touch .stick-base { width: 104px; height: 104px; background: rgba(20, 24, 30, 0.28); border: 2px solid rgba(255, 255, 255, 0.35); }
body.touch .stick-knob { width: 52px; height: 52px; background: rgba(255, 255, 255, 0.55); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); }
body.touch #stick.active .stick-base { background: rgba(20, 24, 30, 0.4); }
body.touch #stick.active .stick-knob { background: rgba(255, 224, 102, 0.85); }
body.touch #player-card {
  top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); width: 138px; padding: 6px 8px; border-radius: 8px;
}
body.touch #player-name { font-size: 12px; margin-bottom: 4px; }
body.touch .bar { height: 12px; }
body.touch #health-text { font-size: 9px; line-height: 12px; }
body.touch #boosts span { font-size: 10px; padding: 0 5px; }
body.touch #score { top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); padding: 4px 8px; font-size: 12px; border-radius: 8px; }
body.touch #bots-status { font-size: 10px; }
body.touch #minimap {
  top: calc(42px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); bottom: auto; width: 96px; height: 96px; border-radius: 10px;
}
body.touch #killfeed { top: calc(146px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); }
body.touch #killfeed li { font-size: 11px; padding: 2px 6px; }
body.touch #killfeed li:nth-child(n+4) { display: none; }
body.touch #weapon {
  pointer-events: auto; left: 50%; right: auto; transform: translateX(-50%); bottom: calc(8px + env(safe-area-inset-bottom));
  min-width: 0; padding: 4px 10px 5px; column-gap: 10px; border-radius: 10px; border-bottom-width: 2px; cursor: pointer;
}
body.touch #weapon-label { display: none; }
body.touch #weapon-name { grid-row: 1; font-size: 14px; }
body.touch #weapon-ammo { grid-row: 1; font-size: 18px; }
body.touch #weapon-slots { grid-row: 2; }
body.touch #weapon-slots span { font-size: 10px; padding: 2px 6px; }
body.touch #toast { font-size: 15px; padding: 5px 12px; top: 20%; }
body.touch #respawn { font-size: 18px; }
body.touch #status { font-size: 11px; }
/* a phone held sideways: little height, so the joystick zone is shorter and the minimap smaller */
@media (max-height: 480px) {
  body.touch #minimap { width: 80px; height: 80px; top: calc(36px + env(safe-area-inset-top)); }
  body.touch #killfeed { top: calc(122px + env(safe-area-inset-top)); }
  body.touch #stick { height: 64vh; }
}
@media (max-width: 640px) {
  #player-card { width: 170px; }
  #minimap { width: 120px; height: 120px; }
  #hint { display: none; }
  #weapon { bottom: 14px; left: 14px; transform: none; min-width: 0; }
  #weapon-name { font-size: 16px; }
  #weapon-ammo { font-size: 24px; }
  #debug { bottom: 80px; max-width: calc(100vw - 162px); } /* above the weapon panel, left of the minimap */
}
