* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

.hidden { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0b1020;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8f3ff;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  height: 100dvh;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#stats {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 14px;
  padding: 10px 16px;
  background: rgba(10, 14, 26, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  backdrop-filter: blur(4px);
  min-width: 160px;
}

#name { font-size: 13px; color: #9fb6d8; font-weight: 600; }

#score {
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 14px rgba(80, 220, 255, 0.8);
}

.dim { font-size: 12px; color: #8fa3c2; margin-top: 2px; }

#lb {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 14px;
  list-style: none;
  background: rgba(10, 14, 26, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 14px;
  width: 194px;
  font-size: 13px;
  backdrop-filter: blur(4px);
}

#lb::before {
  content: "Leaderboard";
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  color: #6d81a6;
  text-transform: uppercase;
  margin-bottom: 4px;
}

#lb li { display: flex; justify-content: space-between; padding: 3px 0; color: #cfe0f5; }
#lb li.me { color: #fff; font-weight: 700; }
#lb li:first-of-type span:first-child { color: #ffd166; }
#lb li:nth-of-type(2) span:first-child { color: #c9d7f2; }
#lb li:nth-of-type(3) span:first-child { color: #e07b39; }

#statusLead {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  padding: 10px 22px;
  background: rgba(10, 14, 26, 0.85);
  border-radius: 10px;
  display: none;
}

#hint {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 12px;
  color: #5c6f8f;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

#death {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 7;
  pointer-events: none;
}
#death.hidden { display: none; }

#deathTxt {
  font-size: 26px;
  font-weight: 800;
  color: #ff5f6d;
  background: rgba(10, 14, 26, 0.85);
  padding: 12px 28px;
  border-radius: 14px;
  border: 1px solid rgba(255, 95, 109, 0.35);
  text-shadow: 0 0 18px rgba(255, 60, 90, 0.8);
}

.panel {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(circle at 50% 30%, #16233f, #0b1020 78%);
  z-index: 10;
}

.panel h1 {
  font-size: 46px;
  letter-spacing: 1px;
  font-weight: 900;
  background: linear-gradient(90deg, #3ddcff, #7eff9f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.panel .sub { color: #7f93b8; font-size: 14px; }

#nameInput {
  padding: 12px 18px;
  width: 260px;
  max-width: 80vw;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #121a2c;
  color: #fff;
  font-size: 16px;
  text-align: center;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}
#nameInput:focus { border-color: #3ddcff; }
#nameInput.invalid { border-color: #ff5f6d; box-shadow: 0 0 0 2px rgba(255, 95, 109, 0.18); }

.name-error { min-height: 16px; color: #ff7b86; font-size: 12px; }

#colors {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 320px;
}
#colors .sw {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  touch-action: manipulation;
}
#colors .sw.rgb { background: conic-gradient(#ff4d6d, #ffd166, #3dffad, #00e5ff, #b388ff, #ff4d6d); }
#colors .sw.on { border-color: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, 0.6); }

#startBtn {
  padding: 13px 48px;
  font-size: 17px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: #0b1020;
  background: linear-gradient(90deg, #3ddcff, #7eff9f);
  box-shadow: 0 6px 24px rgba(80, 240, 255, 0.35);
  touch-action: manipulation;
}
#startBtn:hover { filter: brightness(1.1); }

.panel .small { font-size: 12px; color: #5c6f8f; line-height: 1.6; text-align: center; }

@media (max-width: 640px), (max-height: 480px) {
  .panel h1 { font-size: 34px; }
  .panel .sub { font-size: 12px; }
  #stats { min-width: 0; padding: 7px 12px; }
  #name { font-size: 12px; }
  #score { font-size: 24px; }
#lb { width: 160px; max-height: 136px; overflow: hidden; font-size: 12px; padding: 8px 10px; right: 10px; top: calc(14px + env(safe-area-inset-top, 0px)); }
  #hint { font-size: 11px; }
  #deathTxt { font-size: 21px; padding: 10px 18px; }
}
