* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-deep: #0a0e17;
  --bg-panel: rgba(15, 20, 35, 0.92);
  --accent: #6366f1;
  --accent-glow: #818cf8;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(99, 102, 241, 0.3);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  touch-action: none;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10, 14, 23, 0.7) 0%, rgba(10, 14, 23, 0.95) 100%);
  z-index: 10;
  backdrop-filter: blur(4px);
}

.hidden {
  display: none !important;
}

.overlay.hidden {
  display: none;
}

#shop-modal,
#auth-modal {
  z-index: 20;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: 0 0 60px rgba(99, 102, 241, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 420px;
  width: 90%;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 2rem;
  color: var(--accent-glow);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.logo h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo .accent {
  color: var(--accent-glow);
}

.tagline {
  color: var(--text-muted);
  margin-bottom: 1.8rem;
  font-size: 0.95rem;
}

#nickname {
  width: 100%;
  padding: 0.85rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#nickname:focus {
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 0.9rem 1.5rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
  color: white;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(99, 102, 241, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.hint {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.death-panel h2 {
  font-size: 1.8rem;
  margin-bottom: 0.8rem;
  color: #f87171;
}

.death-stats {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.death-stats strong {
  color: var(--accent-glow);
}

.death-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

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

#hud.hidden {
  display: none;
}

#score-display {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.4rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.4rem 1.2rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#boost-indicator {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.4);
  padding: 0.25rem 0.7rem;
  border-radius: 12px;
  animation: boostPulse 0.6s ease-in-out infinite;
}

#boost-indicator.hidden {
  display: none;
}

@keyframes boostPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

#leaderboard {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  min-width: 160px;
  font-size: 0.82rem;
}

#leaderboard h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.15rem 0;
}

.lb-row.me {
  color: var(--accent-glow);
  font-weight: 600;
}

.lb-rank {
  color: var(--text-muted);
  min-width: 1.2rem;
}

#minimap-wrap {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(99, 102, 241, 0.4);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#minimap {
  width: 100%;
  height: 100%;
}

/* Auth & shop */
.auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.auth-status {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.btn-secondary {
  width: 100%;
  padding: 0.75rem 1.5rem;
  margin-top: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-glow);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: rgba(99, 102, 241, 0.25);
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

.auth-panel, .shop-panel {
  position: relative;
  max-width: 380px;
  padding: 2rem 2rem 2.2rem;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 0.65rem 0.5rem;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.active {
  background: transparent;
  color: var(--accent-glow);
  border-bottom-color: var(--accent-glow);
}

.auth-form .field {
  margin-bottom: 0.75rem;
}

.auth-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 2.8rem;
}

.password-toggle {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 0;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.password-toggle svg {
  width: 1.15rem;
  height: 1.15rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle:hover {
  color: var(--accent-glow);
  background: rgba(99, 102, 241, 0.12);
}

.auth-form .btn-primary {
  margin-top: 0.4rem;
}

.btn-link {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
}

.btn-link:hover {
  color: var(--accent-glow);
}

.form-error {
  color: #f87171;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.verify-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.verify-hint strong {
  color: var(--text);
  word-break: break-all;
}

.dev-code {
  font-size: 0.8rem;
  color: #facc15;
  margin-top: 0.5rem;
}

.shop-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.shop-login-hint {
  color: #facc15;
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
}

.shop-packages {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.shop-pack {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.shop-pack:hover {
  background: rgba(99, 102, 241, 0.22);
}

.pack-lives {
  font-weight: 600;
  color: #f87171;
}

.pack-price {
  color: var(--accent-glow);
  font-weight: 700;
}

.lives-display {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 0.4rem 0.8rem;
  background: rgba(15, 20, 35, 0.85);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 10px;
  color: #f87171;
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 5;
}

.hit-flash {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.25);
  pointer-events: none;
  z-index: 4;
  animation: hitFade 0.4s ease-out forwards;
}

@keyframes hitFade {
  from { opacity: 1; }
  to { opacity: 0; }
}
