* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #05060a; font-family: -apple-system, "Segoe UI", system-ui, sans-serif; }
#game { display: block; }

/* atmospheric overlays */
#vignette { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 220px 60px rgba(0,0,0,0.85); z-index: 2; }
#scanlines { position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: 0.05;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(255,255,255,0.5) 2px 3px); }

#hud { position: fixed; inset: 0; pointer-events: none; color: #d8e4e0; z-index: 3;
  text-shadow: 0 2px 6px rgba(0,0,0,0.9); font-variant-numeric: tabular-nums; }
.lbl { font-size: 11px; opacity: 0.55; letter-spacing: 2px; font-weight: 600; }

/* crosshair — dynamic gap via --gap */
#crosshair { --gap: 6px; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 48px; height: 48px; z-index: 3; transition: opacity 0.12s; }
.ch { position: absolute; background: rgba(120,255,220,0.9); box-shadow: 0 0 4px rgba(0,0,0,0.8); }
#chT { left: 50%; bottom: calc(50% + var(--gap)); width: 2px; height: 8px; transform: translateX(-50%); }
#chB { left: 50%; top: calc(50% + var(--gap)); width: 2px; height: 8px; transform: translateX(-50%); }
#chL { top: 50%; right: calc(50% + var(--gap)); height: 2px; width: 8px; transform: translateY(-50%); }
#chR { top: 50%; left: calc(50% + var(--gap)); height: 2px; width: 8px; transform: translateY(-50%); }
#chDot { top: 50%; left: 50%; width: 2px; height: 2px; transform: translate(-50%,-50%); border-radius: 50%; }

#hitmarker { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) rotate(45deg); width: 22px; height: 22px; z-index: 4; opacity: 0; transition: opacity 0.08s, transform 0.12s cubic-bezier(.2,.8,.3,1); }
#hitmarker div { position: absolute; background: #ff5252; box-shadow: 0 0 3px #000; }
#hitmarker.crit div { background: #ffd93d; }
#hmT { left: 50%; top: -4px; width: 2px; height: 7px; transform: translateX(-50%); }
#hmB { left: 50%; bottom: -4px; width: 2px; height: 7px; transform: translateX(-50%); }
#hmL { top: 50%; left: -4px; height: 2px; width: 7px; transform: translateY(-50%); }
#hmR { top: 50%; right: -4px; height: 2px; width: 7px; transform: translateY(-50%); }

/* damage direction indicator */
#dmgdir { position: fixed; top: 50%; left: 50%; width: 130px; height: 130px; transform: translate(-50%,-50%); z-index: 3; pointer-events: none; opacity: 0; transition: opacity 0.4s; }
#dmgdirArc { position: absolute; inset: 0; border-radius: 50%; border: 4px solid transparent; border-top-color: rgba(255,40,40,0.95); filter: drop-shadow(0 0 6px rgba(255,0,0,0.7)); }

.panel { position: fixed; }
#scoreWrap { top: 20px; left: 26px; }
#score { font-size: 30px; font-weight: 700; letter-spacing: 1px; }
#kills { font-size: 18px; font-weight: 700; opacity: 0.85; }
#waveWrap { top: 20px; right: 26px; text-align: right; }
#wave { font-size: 24px; font-weight: 700; }
#enemiesLeft { font-size: 16px; font-weight: 700; color: #ff8a8a; }
#radar { margin-top: 10px; border-radius: 50%; background: rgba(8,12,20,0.55);
  border: 1px solid rgba(120,255,220,0.25); box-shadow: 0 0 14px rgba(0,0,0,0.6) inset; }
#ammoWrap { bottom: 26px; right: 30px; text-align: right; display: flex; align-items: flex-end; gap: 4px; flex-direction: column; }
#ammo { font-size: 40px; font-weight: 800; line-height: 1; }
#ammo .res { font-size: 20px; opacity: 0.5; font-weight: 600; }
#hpWrap { bottom: 30px; left: 30px; width: 230px; }
#hpBar { width: 100%; height: 12px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.15); border-radius: 2px; overflow: hidden; margin-top: 5px; }
#hpFill { height: 100%; width: 100%; background: linear-gradient(90deg,#1dd1a1,#48dbfb); transition: width 0.2s, background 0.3s; }
#hpFill.low { background: linear-gradient(90deg,#d63031,#ff7675); }
#stBar { width: 70%; height: 6px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden; margin-top: 4px; }
#stFill { height: 100%; width: 100%; background: linear-gradient(90deg,#fdcb6e,#ffeaa7); transition: width 0.1s; }

#waveBanner { position: fixed; top: 36%; left: 50%; transform: translateX(-50%); font-size: 44px; font-weight: 800; letter-spacing: 4px; color: #fff; text-shadow: 0 0 20px rgba(72,219,251,0.6); opacity: 0; transition: opacity 0.4s; z-index: 3; }
#waveSub { position: fixed; top: calc(36% + 56px); left: 50%; transform: translateX(-50%); font-size: 15px; font-weight: 600; letter-spacing: 3px; color: #9fb8c8; opacity: 0; transition: opacity 0.4s; z-index: 3; }
#combo { position: fixed; top: 58%; left: 50%; transform: translateX(-50%); font-size: 22px; font-weight: 800; letter-spacing: 2px; color: #ffd93d; text-shadow: 0 0 14px rgba(255,217,61,0.5); opacity: 0; transition: opacity 0.25s, transform 0.15s; z-index: 3; }

/* banner multi-uccisione */
#multikill { position: fixed; top: 46%; left: 50%; transform: translateX(-50%); font-size: 34px; font-weight: 900; letter-spacing: 4px; color: #ff5252; opacity: 0; z-index: 3; pointer-events: none;
  text-shadow: 0 0 10px rgba(255,60,60,0.8), 0 0 30px rgba(255,40,40,0.5), 0 2px 6px #000;
  transition: opacity 0.2s, transform 0.12s cubic-bezier(.2,.9,.3,1.2); }

/* killfeed: colonna in alto a destra sotto il radar */
#killfeed { position: fixed; top: 270px; right: 26px; z-index: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; }
.kf { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; letter-spacing: 1px;
  color: #d8e4e0; background: rgba(8,12,20,0.5); border: 1px solid rgba(120,255,220,0.18); border-radius: 4px;
  padding: 3px 9px; text-shadow: 0 1px 3px #000; opacity: 1; transition: opacity 0.4s; }
.kf .kfw { font-size: 10px; opacity: 0.6; letter-spacing: 1px; }
.kf .kfIco { color: #7bed9f; font-weight: 900; }
.kf .kfVic { color: #ff8a8a; }
.kf.critkf { border-color: rgba(255,217,61,0.5); }
.kf.critkf .kfIco { color: #ffd93d; }
.kf.critkf .kfVic { color: #ffd93d; }
#pickupMsg { position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%); font-size: 15px; font-weight: 700; letter-spacing: 2px; color: #7bed9f; text-shadow: 0 1px 6px #000; opacity: 0; transition: opacity 0.3s; z-index: 3; }

#hitflash { position: fixed; inset: 0; background: radial-gradient(ellipse at center, transparent 30%, rgba(200,20,20,0.55) 100%); opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 2; }
#lowhp { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.6s; z-index: 2;
  box-shadow: inset 0 0 160px 40px rgba(180,0,0,0.55); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100%{opacity:var(--lhp,0);} 50%{opacity:calc(var(--lhp,0)*0.4);} }

/* ============ MENU INIZIALE — neon violaceo ============ */
#overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #f1eafe; text-align: center; z-index: 10;
  background:
    radial-gradient(ellipse 70% 55% at 50% 38%, rgba(124,58,237,0.22), transparent 70%),
    radial-gradient(ellipse at center, rgba(16,8,30,0.94), rgba(5,3,12,0.985));
}
/* griglia prospettica sul fondo */
#overlay::before { content:''; position:absolute; inset:0; pointer-events:none; opacity:0.16;
  background:
    repeating-linear-gradient(0deg, transparent 0 46px, rgba(177,92,255,0.5) 46px 47px),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(177,92,255,0.35) 46px 47px);
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, #000 30%, transparent 75%);
}
#menuCard { position: relative; display: flex; flex-direction: column; align-items: center;
  padding: 34px 56px 38px; border-radius: 18px;
  background: rgba(14,8,26,0.55);
  border: 1px solid rgba(177,92,255,0.35);
  box-shadow: 0 0 35px rgba(124,58,237,0.25), inset 0 0 60px rgba(124,58,237,0.07);
  backdrop-filter: blur(3px);
}
/* foto del personaggio, cornice neon pulsante */
#portraitWrap { position: relative; width: 200px; height: 200px; margin-bottom: 20px; border-radius: 16px;
  border: 2px solid #b15cff; overflow: hidden;
  box-shadow: 0 0 18px rgba(177,92,255,0.8), 0 0 55px rgba(124,58,237,0.45), inset 0 0 22px rgba(177,92,255,0.3);
  animation: portraitGlow 2.6s ease-in-out infinite;
}
#portrait { width: 100%; height: 100%; object-fit: cover; display: block;
  filter: contrast(1.08) saturate(1.05); }
#portraitScan { position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(177,92,255,0.12) 3px 4px),
    linear-gradient(180deg, rgba(232,121,249,0.12), transparent 30%, transparent 70%, rgba(124,58,237,0.25));
}
@keyframes portraitGlow {
  0%,100% { box-shadow: 0 0 18px rgba(177,92,255,0.8), 0 0 55px rgba(124,58,237,0.45), inset 0 0 22px rgba(177,92,255,0.3); }
  50%     { box-shadow: 0 0 26px rgba(232,121,249,0.95), 0 0 80px rgba(124,58,237,0.6), inset 0 0 30px rgba(177,92,255,0.4); }
}
#overlay h1 { font-size: 52px; letter-spacing: 6px; font-weight: 800; color: #f5edff;
  text-shadow: 0 0 8px #c084fc, 0 0 22px #a855f7, 0 0 55px #7c3aed, 0 0 90px #7c3aed;
  animation: neonFlicker 3.2s linear infinite; }
@keyframes neonFlicker {
  0%, 18%, 21%, 62%, 65%, 100% { opacity: 1; }
  19%, 63% { opacity: 0.6; }
  20%, 64% { opacity: 0.85; }
}
#menuSub { font-size: 12px; letter-spacing: 7px; color: #c9a7f5; opacity: 0.85; margin: 6px 0 16px; }
#overlay p { font-size: 13px; opacity: 0.7; max-width: 560px; line-height: 1.8; margin-bottom: 4px; }
/* campo nome giocatore */
#nameRow { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 6px 0 16px; }
#nameRow label { font-size: 11px; letter-spacing: 4px; color: #c9a7f5; font-weight: 700; }
#playerName { width: 280px; padding: 12px 16px; text-align: center; font-size: 19px; font-weight: 800;
  letter-spacing: 3px; text-transform: uppercase; color: #f5edff; caret-color: #e879f9;
  background: rgba(20,10,38,0.7); border: 2px solid rgba(177,92,255,0.55); border-radius: 8px; outline: none;
  font-family: inherit; transition: border-color 0.2s, box-shadow 0.2s;
}
#playerName::placeholder { color: rgba(201,167,245,0.35); }
#playerName:focus { border-color: #e879f9;
  box-shadow: 0 0 14px rgba(232,121,249,0.55), inset 0 0 12px rgba(124,58,237,0.25); }
#overlay .start { margin-top: 16px; font-size: 17px; padding: 15px 48px; border: 2px solid #b15cff; border-radius: 8px;
  color: #e9d5ff; font-weight: 800; letter-spacing: 2px; cursor: pointer; user-select: none;
  text-shadow: 0 0 10px rgba(177,92,255,0.8);
  box-shadow: 0 0 16px rgba(124,58,237,0.35), inset 0 0 14px rgba(124,58,237,0.15);
  transition: all 0.2s;
}
#overlay .start:hover { background: rgba(124,58,237,0.22); border-color: #e879f9; color: #fff;
  box-shadow: 0 0 30px rgba(177,92,255,0.7), inset 0 0 20px rgba(177,92,255,0.25); transform: translateY(-1px); }
#stats { display: flex; gap: 34px; margin-bottom: 14px; }
#stats:empty { display: none; }
#stats .st { text-align: center; }
#stats .st b { display: block; font-size: 28px; color: #c084fc; text-shadow: 0 0 12px rgba(168,85,247,0.6); }
#stats .st span { font-size: 11px; letter-spacing: 2px; opacity: 0.6; }
#hudName { color: #c9a7f5; opacity: 0.9; letter-spacing: 3px; font-weight: 800; }
@media (max-height: 760px){
  #portraitWrap { width: 150px; height: 150px; margin-bottom: 12px; }
  #overlay h1 { font-size: 40px; }
  #menuCard { padding: 22px 40px 26px; }
}
.hidden { display: none !important; }
kbd { background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.18); padding: 3px 9px; border-radius: 4px; font-size: 13px; font-weight: 600; }
#reloadHint { position: fixed; bottom: 90px; right: 30px; font-size: 14px; color: #ffd93d; opacity: 0; transition: opacity 0.2s; z-index: 3; font-weight: 600; letter-spacing: 1px; text-shadow: 0 1px 4px #000; }
