* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #050811;
  color: #f1f5f9;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  width: 100dvw;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* 1. Universal Top HUD */
.hud-bar {
  height: 54px;
  background: #0a0f1d;
  border-bottom: 2px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

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

.hud-btn {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: #334155;
  border-color: #475569;
}

.hud-btn:active {
  transform: scale(0.97);
}

.hub-btn {
  background: #0284c7;
  border-color: #0369a1;
}

.hub-btn:hover {
  background: #0369a1;
}

.restart-btn {
  background: #16a34a;
  border-color: #15803d;
}

.restart-btn:hover {
  background: #15803d;
}

.sound-btn {
  background: #475569;
}

.hud-title {
  font-weight: 700;
  font-size: 15px;
  color: #00f0ff;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-scoreboard {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
}

.score.p1 {
  color: #00f0ff;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.8);
}

.score.p2 {
  color: #ff0077;
  text-shadow: 0 0 12px rgba(255, 0, 119, 0.8);
}

.score-divider {
  color: #64748b;
  font-size: 16px;
}

.hud-target {
  font-size: 9px;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 1.5px;
}

.hud-badge {
  font-size: 12px;
  padding: 4px 8px;
  background: #1e293b;
  border-radius: 6px;
  border: 1px solid #334155;
  color: #cbd5e1;
}

/* 2. Main Game Container */
#game-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, #0a1124 0%, #03060d 100%);
  touch-action: none;
  padding: 4px;
}

/* Online Floating Status Pill */
#online-pill-banner {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid #38bdf8;
  box-shadow: 0 4px 15px rgba(0, 240, 255, 0.3);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 50;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#btn-pill-open-modal {
  background: #0284c7;
  color: white;
  border: none;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
}

#btn-pill-open-modal:hover {
  background: #0369a1;
}

#gameCanvas {
  background: #070a13;
  display: block;
  touch-action: none;
  border-radius: 14px;
  box-shadow: 0 0 35px rgba(0, 240, 255, 0.2), 0 0 70px rgba(255, 0, 119, 0.15);
  max-width: 100%;
  max-height: 100%;
}

/* 3. Victory & Modal Overlays */
#victory-overlay,
#online-modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#victory-overlay.active,
#online-modal.active {
  display: flex;
}

.victory-card,
.modal-card {
  position: relative;
  background: #0f172a;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.35);
  border-radius: 18px;
  padding: 20px 16px;
  max-width: 410px;
  width: 100%;
  max-height: calc(100dvh - 24px);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
  margin: auto;
  animation: popIn 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Close button in top-right */
.modal-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
  z-index: 10;
}
.modal-close-btn:hover {
  background: #e11d48;
  border-color: #f43f5e;
  color: white;
}

.victory-title {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 10px;
}

.victory-score {
  font-size: 17px;
  color: #94a3b8;
  margin-bottom: 20px;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #00f0ff);
  color: #04101e;
  font-weight: 800;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.4);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-2px);
}

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

/* Modal Content Details */
.modal-tabs {
  display: flex;
  gap: 6px;
  background: #090e1a;
  padding: 4px;
  border-radius: 10px;
  margin: 10px 0 12px 0;
  border: 1px solid #1e293b;
}

.modal-tab {
  flex: 1;
  padding: 8px 6px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-tab.active {
  background: #0284c7;
  color: white;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.modal-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.room-code-badge {
  display: inline-block;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #00f0ff;
  background: #1e293b;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px dashed #38bdf8;
  margin: 6px 0;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
}

.qr-box {
  background: white;
  padding: 10px;
  border-radius: 10px;
  display: inline-block;
  margin: 6px 0;
}

.btn-action {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-copy { background: #3b82f6; color: white; }
.btn-share { background: #10b981; color: white; }
.btn-close { background: #475569; color: white; }

/* Responsive tweaks for mobile */
@media (max-width: 600px) {
  .hud-bar {
    height: 48px;
    padding: 0 8px;
  }
  .hud-title {
    display: none;
  }
  .hud-scoreboard {
    font-size: 19px;
  }
  .hud-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
  .hud-badge {
    display: none;
  }
  .modal-card {
    padding: 16px 12px;
    border-radius: 14px;
  }
  .room-code-badge {
    font-size: 21px;
    padding: 6px 12px;
  }
  .btn-action {
    font-size: 12px;
    padding: 8px 10px;
  }
}
