/* ============================================================
   Mushroom Archers - Stylesheet
   Responsive layout for desktop & mobile devices
   Forest Night / Glowing Spores Aesthetic
   ============================================================ */

:root {
  --bg-dark: #0a0f18;
  --bg-panel: #111827;
  --bg-card: #1f293d;
  --primary: #10b981;
  --primary-hover: #059669;
  --accent-gold: #f59e0b;
  --accent-red: #ef4444;
  --accent-blue: #38bdf8;
  --accent-purple: #a855f7;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.12);
  --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 30%, #17253b 0%, #080c14 100%);
}

/* ------------------------------------------------------------
   Top HUD
   ------------------------------------------------------------ */
.hud-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(10, 15, 24, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}

.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-title {
  font-size: 17px;
  font-weight: 800;
  background: linear-gradient(135deg, #34d399, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

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

.hud-btn.home-btn {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.hud-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
  letter-spacing: 0.5px;
}

.scoreboard {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.player-score-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.player-score-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ------------------------------------------------------------
   Game Canvas
   ------------------------------------------------------------ */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  touch-action: none;
}

/* ------------------------------------------------------------
   Mobile Touch Controls Overlay
   ------------------------------------------------------------ */
#touch-controls {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  height: 90px;
  z-index: 15;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.touch-cluster-left, .touch-cluster-right {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(6px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 24px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.08s ease, background 0.08s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.touch-btn:active, .touch-btn.active {
  background: rgba(16, 185, 129, 0.6);
  border-color: #34d399;
  transform: scale(0.92);
}

.touch-btn.jump-btn {
  background: rgba(56, 189, 248, 0.4);
  border-color: rgba(56, 189, 248, 0.5);
}

.touch-btn.jump-btn:active, .touch-btn.jump-btn.active {
  background: rgba(56, 189, 248, 0.8);
}

/* ------------------------------------------------------------
   Modal Overlays
   ------------------------------------------------------------ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 18, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: none !important;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 30px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  text-align: center;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header h2 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #34d399, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 22px;
}

/* Mode Selection Cards */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 540px) {
  .mode-grid {
    grid-template-columns: 1fr;
  }
}

.mode-card {
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 16px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mode-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
  transform: translateY(-2px);
}

.mode-card.active {
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--primary);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.2);
}

.mode-icon {
  font-size: 32px;
}

.mode-name {
  font-weight: 700;
  font-size: 15px;
}

.mode-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Customizer Bar */
.customizer-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.custom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.custom-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.hat-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hat-pill {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.hat-pill:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hat-pill.active {
  background: var(--primary);
  color: black;
  font-weight: bold;
  border-color: var(--primary);
}

/* Action Buttons */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

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

.btn-secondary {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-top: 8px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Lobby Waiting Screen */
.lobby-status-pill {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-gold);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.player-lobby-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.player-lobby-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

/* Victory / Game Over */
.victory-icon {
  font-size: 64px;
  margin-bottom: 8px;
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.victory-title {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 8px;
}

.victory-title.winner {
  color: #34d399;
}

.victory-title.defeated {
  color: #f87171;
}

/* In-game Floating Damage & Hits */
.floating-hit-text {
  position: absolute;
  font-weight: 900;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  animation: floatUp 0.8s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-40px) scale(0.9); }
}

/* Share Code Pill */
.share-code-box {
  background: rgba(0,0,0,0.4);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  padding: 10px;
  border-radius: 10px;
  font-family: monospace;
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--accent-blue);
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
