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

body {
  overflow: hidden;
  background: #6aaa7a;
  font-family: system-ui, sans-serif;
  color: #2a3040;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* HUD */
#hud {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 0 8px;
  min-width: 320px;
}

#score-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 10px 16px 4px;
  font-size: 42px;
  font-weight: bold;
}

#score-left {
  color: #5b9bff;
}

#score-right {
  color: #ff5b6b;
}

#score-divider, #score-divider-right {
  color: rgba(255,255,255,0.3);
  font-size: 24px;
}

#event-emoji {
  font-size: 28px;
  line-height: 1;
}

#event-name {
  font-size: 13px;
  color: #ffcc55;
  text-transform: uppercase;
  letter-spacing: 2px;
  min-width: 120px;
  text-align: center;
}

#event-timer-bar {
  width: 90%;
  height: 3px;
  background: rgba(255,255,255,0.15);
  margin: 0 auto 8px;
  border-radius: 2px;
  overflow: hidden;
}

#event-timer-fill {
  width: 100%;
  height: 100%;
  background: #ffaa33;
  transition: width 0.3s linear;
}

#message-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  font-weight: bold;
  color: #2a3040;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.3s;
}

#message-overlay.visible {
  opacity: 1;
}

/* Menu */
#menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(60, 100, 70, 0.5);
  backdrop-filter: blur(12px);
  z-index: 100;
}

#menu-card {
  background: white;
  border-radius: 12px;
  padding: 32px 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  text-align: center;
  max-width: 420px;
  width: 90vw;
}

#menu-logo {
  max-width: 100%;
  height: auto;
  margin-bottom: 12px;
}

#menu .subtitle {
  font-size: 13px;
  color: #7a8090;
  margin-bottom: 16px;
  line-height: 1.5;
}

#name-input {
  margin-bottom: 14px;
}

#player-name {
  padding: 10px 16px;
  font-size: 16px;
  font-family: system-ui, sans-serif;
  border: 2px solid #ddd;
  border-radius: 6px;
  width: 100%;
  text-align: center;
  outline: none;
  box-sizing: border-box;
}

#player-name:focus {
  border-color: #8855dd;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px 24px;
  font-family: system-ui, sans-serif;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  background: #f68402;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover {
  background: #d97202;
}

#menu-divider {
  height: 1px;
  background: #e8e8e8;
  margin: 14px 0;
}

#secondary-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-secondary {
  padding: 8px 14px;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #6a7080;
  background: transparent;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: #3a4050;
  border-color: #3a4050;
  color: #fff;
}

#menu-settings-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 22px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
  line-height: 1;
}

#menu-settings-btn:hover {
  opacity: 1;
}

/* Room Browser Overlay */
#room-browser {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
}

#room-browser-card {
  background: white;
  border-radius: 12px;
  padding: 24px 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  max-width: 400px;
  width: 90vw;
}

#room-browser-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: bold;
  color: #2a3040;
}

#room-browser-close {
  font-size: 22px;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
}

#room-browser-close:hover {
  color: #333;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e8e8e8;
  border-top-color: #f68402;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 500px) {
  #menu-card {
    padding: 24px 20px;
  }
  #secondary-buttons {
    gap: 6px;
  }
  .btn-secondary {
    font-size: 11px;
    padding: 7px 10px;
  }
}

/* Settings Menu */
#settings-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  z-index: 200;
}

#settings-card {
  background: white;
  border-radius: 12px;
  padding: 30px 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  text-align: left;
  min-width: 280px;
}

#settings-card h2 {
  margin-bottom: 20px;
  text-align: center;
  color: #2a3040;
}

#settings-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 15px;
  color: #3a4050;
  cursor: pointer;
}

#settings-card label input {
  margin-right: 8px;
}

#settings-close {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 10px;
  font-family: system-ui, sans-serif;
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  background: #3a4050;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

#settings-close:hover {
  background: #555;
}

#join-room-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

#room-code {
  padding: 10px 14px;
  font-size: 14px;
  font-family: system-ui, sans-serif;
  font-weight: bold;
  letter-spacing: 3px;
  text-transform: uppercase;
  border: 2px solid #ddd;
  border-radius: 6px;
  flex: 1;
  min-width: 0;
  text-align: center;
  outline: none;
}

#room-code:focus {
  border-color: #f68402;
}

/* Room list */
#room-list-header {
  font-size: 12px;
  font-weight: bold;
  color: #8890a0;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  text-align: left;
}

#room-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

#room-table thead th {
  font-size: 11px;
  font-weight: 600;
  color: #aab0b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 6px;
  border-bottom: 1px solid #eee;
}

#room-table tbody td {
  padding: 6px;
  border-bottom: 1px solid #f4f4f4;
  color: #3a4050;
}

#room-table tbody tr:hover:not(.room-empty-row) {
  background: #f5f8fa;
}

.room-empty-row td {
  color: #bbb;
  text-align: center;
  padding: 16px 6px;
  font-style: italic;
}

.room-join-btn {
  padding: 3px 12px;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: bold;
  color: #f68402;
  background: transparent;
  border: 1.5px solid #f68402;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.room-join-btn:hover {
  background: #f68402;
  color: #fff;
}


.online-status {
  margin-top: 6px;
  margin-bottom: 0;
  font-size: 11px;
  color: #8a90a0;
  min-height: 14px;
}

.copy-link {
  cursor: pointer;
  text-decoration: underline;
  opacity: 0.7;
  font-weight: normal;
  font-size: 12px;
}

.copy-link:hover {
  opacity: 1;
}


/* Settings hint */
#settings-hint {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 15;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.15s;
}

#settings-hint:hover {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

/* Coin display */
#coin-display {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 15;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  border-radius: 8px;
  padding: 8px 16px;
  pointer-events: none;
}

#coin-count {
  font-size: 28px;
  font-weight: bold;
  color: #ffcc33;
  letter-spacing: 2px;
}

#coin-count::before {
  content: '\2B50\00a0';
}

/* Death screen */
#death-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
}

#death-content {
  text-align: center;
}

#death-title {
  font-size: 72px;
  font-weight: 900;
  color: #dd2222;
  text-shadow: 0 4px 20px rgba(200, 0, 0, 0.5);
  margin-bottom: 16px;
}

#death-timer {
  font-size: 48px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 24px;
}

#death-upgrades {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.death-upgrade-btn {
  padding: 12px 20px;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.death-upgrade-btn:hover:not(:disabled) {
  background: rgba(136, 85, 221, 0.5);
  border-color: #8855dd;
}

.death-upgrade-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.death-upgrade-btn.maxed {
  border-color: #55aa55;
  color: #55aa55;
}

#death-respawn {
  font-size: 20px;
  color: #fff;
  animation: pulse 1s ease-in-out infinite;
}

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

/* Shop overlay */
#shop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
}

#shop-card {
  background: white;
  border-radius: 12px;
  padding: 24px 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  text-align: center;
  min-width: 340px;
}

#shop-header {
  font-size: 20px;
  font-weight: bold;
  color: #2a3040;
  margin-bottom: 16px;
}

#shop-coins {
  color: #dd8800;
}

#shop-coins::before {
  content: '\2B50\00a0';
}

#shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.shop-btn {
  padding: 16px 12px;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  font-weight: bold;
  color: #3a4050;
  background: #f5f3f0;
  border: 2px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  line-height: 1.4;
}

.shop-btn .shop-emoji {
  font-size: 28px;
  display: block;
  margin-bottom: 4px;
}

.shop-btn:hover:not(:disabled) {
  background: #ece8ff;
  border-color: #8855dd;
}

.shop-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.shop-btn.maxed {
  border-color: #55aa55;
  color: #55aa55;
}

#shop-close-hint {
  font-size: 13px;
  color: #999;
  margin-top: 4px;
}

/* Ball type indicator */
#ball-type-indicator {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  font-weight: bold;
  border-radius: 4px;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.4s;
  text-shadow: 0 0 6px currentColor;
}

#ball-type-indicator.visible {
  opacity: 1;
}

/* Power-up spawn indicator */
#powerup-warning {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  font-family: system-ui, sans-serif;
  font-size: 16px;
  font-weight: bold;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.3s;
}

#powerup-warning.visible {
  opacity: 1;
}

#controls-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: #8a90a0;
  pointer-events: none;
  z-index: 10;
}

/* Portal tooltip */
#portal-tooltip {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(88, 55, 170, 0.85);
  color: #fff;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  z-index: 30;
  pointer-events: none;
  backdrop-filter: blur(4px);
  text-align: center;
}

/* Game stats overlay */
#game-stats {
  position: fixed;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #ccc;
  z-index: 20;
  pointer-events: none;
  backdrop-filter: blur(4px);
  min-width: 140px;
}
#game-stats div { white-space: nowrap; }

/* Leaderboard sidebar */
#leaderboard {
  position: fixed;
  top: 60px;
  right: 12px;
  width: 180px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  padding: 8px 10px;
  z-index: 20;
  font-size: 13px;
  color: #ddd;
  backdrop-filter: blur(4px);
}
#leaderboard-header {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 1px;
  color: #aaa;
  margin-bottom: 6px;
  text-transform: uppercase;
}
#player-count {
  color: #8f8;
  font-weight: normal;
}
.lb-row {
  display: flex;
  align-items: center;
  padding: 2px 0;
  gap: 6px;
}
.lb-me {
  color: #ffcc00;
  font-weight: bold;
}
.lb-rank {
  width: 18px;
  text-align: right;
  color: #888;
  font-size: 11px;
}
.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-score {
  color: #fff;
  font-weight: bold;
  min-width: 24px;
  text-align: right;
}
.lb-bot {
  color: #888;
}
.lb-empty {
  color: #666;
  font-style: italic;
  text-align: center;
  padding: 8px 0;
}
