/* ── Reset & base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0f;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* Only disable touch actions on game canvas, not on the join form inputs */
#game-screen {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ── JOIN SCREEN ── */
#join-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0f;
  z-index: 100;
  touch-action: auto;
}

.join-container {
  width: 90%;
  max-width: 380px;
  text-align: center;
  padding: 24px;
}

.join-title {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: -2px;
  margin-bottom: 4px;
  color: #fff;
  text-shadow:
    0 0 20px rgba(0, 240, 255, 0.5),
    0 0 60px rgba(0, 240, 255, 0.2);
}

.accent {
  color: #00f0ff;
}

.join-subtitle {
  font-size: 0.95rem;
  color: #888;
  margin-bottom: 32px;
}

.input-group {
  margin-bottom: 14px;
}

.input-group input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #222;
  border-radius: 12px;
  background: #111118;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: #00f0ff;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.15);
}

.input-group input::placeholder {
  color: #555;
}

#join-btn {
  width: 100%;
  padding: 16px;
  margin-top: 8px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #00f0ff, #b44aff);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 24px rgba(0, 240, 255, 0.25);
}

#join-btn:active {
  transform: scale(0.97);
}

#join-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.join-tips {
  margin-top: 28px;
  font-size: 0.82rem;
  color: #666;
  line-height: 1.6;
}

.join-tips strong {
  color: #999;
}

/* ── GAME SCREEN ── */
/* touch-action and user-select already set above */
#game-screen {
  position: fixed;
  inset: 0;
}

/* Prevent text selection and context menus in game */
#game-canvas {
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0a0a0f;
}

/* ── HUD ── */
#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 12px;
  z-index: 10;
}

#player-count, #score-display, #round-number {
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ccc;
  border: 1px solid rgba(255,255,255,0.06);
}

#round-timer {
  background: rgba(10, 10, 15, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #00f0ff;
  border: 1px solid rgba(0, 240, 255, 0.2);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

#round-timer.warning {
  color: #ff3860;
  border-color: rgba(255, 56, 96, 0.3);
  text-shadow: 0 0 12px rgba(255, 56, 96, 0.5);
  animation: pulse-warn 0.8s ease-in-out infinite;
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── ROUND END OVERLAY ── */
#round-end {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 50;
  animation: fadeIn 0.4s ease-out;
}

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

.round-end-box {
  background: rgba(15, 15, 25, 0.95);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 16px;
  padding: 28px 32px;
  text-align: center;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.1);
}

.round-end-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: #00f0ff;
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.round-end-winner {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffe600;
  margin-bottom: 18px;
  text-shadow: 0 0 12px rgba(255, 230, 0, 0.3);
}

#round-end-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px 0;
  text-align: left;
}

#round-end-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #ccc;
  margin-bottom: 4px;
}

#round-end-list li:nth-child(1) {
  background: rgba(255, 230, 0, 0.1);
  color: #ffe600;
  font-weight: 700;
}

#round-end-list li:nth-child(2) {
  background: rgba(192, 192, 192, 0.08);
  color: #c0c0c0;
  font-weight: 600;
}

#round-end-list li:nth-child(3) {
  background: rgba(205, 127, 50, 0.08);
  color: #cd7f32;
  font-weight: 600;
}

#round-end-list .rank { min-width: 28px; }
#round-end-list .name { flex: 1; }
#round-end-list .stats { font-size: 0.78rem; color: #888; font-variant-numeric: tabular-nums; }

.round-end-next {
  font-size: 1rem;
  color: #888;
  margin-top: 4px;
}

#round-countdown {
  color: #00f0ff;
  font-weight: 800;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

/* ── LEADERBOARD ── */
#leaderboard {
  position: fixed;
  top: 12px;
  right: 12px;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 150px;
  z-index: 10;
}

.lb-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #00f0ff;
  margin-bottom: 6px;
}

#lb-list {
  list-style: none;
  padding: 0;
}

#lb-list li {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 2px 0;
  color: #bbb;
}

#lb-list li .lb-score {
  color: #888;
  font-variant-numeric: tabular-nums;
  margin-left: 12px;
}

#lb-list li.me {
  color: #00f0ff;
  font-weight: 700;
}

/* ── MINIMAP ── */
#minimap-container {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 10;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(10, 10, 15, 0.7);
}

#minimap {
  display: block;
}

/* ── DEATH NOTICE ── */
#death-notice {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 20;
  animation: fadeInUp 0.3s ease-out;
}

.death-text {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ff3860;
  text-shadow: 0 0 20px rgba(255, 56, 96, 0.5);
  margin-bottom: 6px;
}

.death-sub {
  font-size: 0.9rem;
  color: #888;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, -40%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* ── POWERUP HUD ── */
#powerup-hud {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 230, 0, 0.4);
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffe600;
  text-shadow: 0 0 10px rgba(255, 230, 0, 0.5);
  z-index: 15;
  white-space: nowrap;
}

#powerup-toast {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 15, 0.9);
  border-radius: 14px;
  padding: 10px 24px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  z-index: 25;
  pointer-events: none;
  animation: toastPop 0.3s ease-out;
}

@keyframes toastPop {
  from { opacity: 0; transform: translateX(-50%) scale(0.8); }
  to   { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* ── VIRTUAL JOYSTICK ── */
#joystick-zone {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 130px;
  height: 130px;
  z-index: 20;
  touch-action: none;
}

@media (pointer: coarse) {
  #joystick-zone {
    display: block;
  }
}

#joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#joystick-thumb {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.55);
  border: 2px solid rgba(0, 240, 255, 0.9);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.5);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.1s;
  pointer-events: none;
}

#joystick-zone.active #joystick-thumb {
  background: rgba(0, 240, 255, 0.75);
}

/* ── Mobile adjustments ── */
@media (max-width: 600px) {
  .join-title { font-size: 2.6rem; }
  #leaderboard { min-width: 120px; padding: 8px 10px; }
  .lb-title { font-size: 0.6rem; }
  #lb-list li { font-size: 0.7rem; }
  #minimap-container { bottom: 8px; right: 8px; }
  #minimap { width: 100px; height: 100px; }
  #hud { top: 8px; left: 8px; gap: 6px; flex-wrap: wrap; }
  #player-count, #score-display, #round-number { font-size: 0.72rem; padding: 5px 10px; }
  #round-timer { font-size: 1rem; padding: 6px 14px; }
  .round-end-box { padding: 20px 18px; }
  .round-end-title { font-size: 1.3rem; }
  #round-end-list li { padding: 6px 8px; font-size: 0.82rem; }
}
