*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --accent-border-color: rgba(155, 198, 191, 0.8);
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Dark, low-glare backdrop using the supplied palette */
  background: radial-gradient(circle at top, #28345a 0, #294282 35%, #325c6a 70%, #000000 100%);
  color: #e5e7eb;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow-x: hidden;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: min(1100px, 100%);
  padding: 16px 20px;
}

.app-header {
  padding: 8px 4px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.branding h1 {
  font-size: 1.8rem;
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tagline {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: #9ca3af;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 0 16px;
}

.hud-panel {
  /* Soft teal/blue HUD panel using palette colors */
  background: radial-gradient(circle at top left, #6a9a9e 0, #325c6a 40%, #28345a 100%);
  border-radius: 16px;
  border: 1px solid var(--accent-border-color);
  padding: 10px 14px 12px;
  box-shadow: 0 18px 25px rgba(15, 23, 42, 0.9);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 180ms ease-out;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.hud-row-bottom {
  margin-top: 4px;
}

.hud-group {
  display: flex;
  flex-direction: column;
  min-width: 90px;
}

.hud-group-target {
  min-width: 150px;
}

.hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #cbd5f5;
}

.hud-value {
  font-size: 1rem;
  font-weight: 600;
}

.target-color-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
}

.target-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.9);
  background: transparent;
}

#targetColorName {
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
}

.primary-button,
.secondary-button {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 120ms ease-out, border-color 120ms ease-out, transform 80ms ease-out, color 120ms ease-out;
}

.primary-button {
  /* Accent button with subtle teal gradient */
  background: linear-gradient(to right, #325c6a, #6a9a9e);
  color: #f9fafb;
  border-color: rgba(155, 198, 191, 0.9);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(to right, #28345a, #6a9a9e);
}

.secondary-button {
  background: linear-gradient(to right, #28345a, #294282);
  color: #e5e7eb;
  border-color: rgba(107, 114, 128, 0.9);
}

.secondary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(to right, #28345a, #325c6a);
}

.secondary-button.toggle-on {
  border-color: rgba(155, 198, 191, 0.9);
  background: linear-gradient(to right, #325c6a, #6a9a9e);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: default;
  opacity: 0.5;
  transform: none;
}

.status-message {
  flex: 1;
  font-size: 0.8rem;
  color: #e5e7eb;
  text-align: right;
}

.game-panel {
  flex: 1;
  /* Dark playfield frame with subtle inner glow */
  background: radial-gradient(circle at top, #28345a 0, #28345a 40%, #111827 100%);
  border-radius: 18px;
  border: 1px solid var(--accent-border-color);
  box-shadow: 0 22px 30px rgba(15, 23, 42, 0.95);
  padding: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#gameCanvas {
  width: 100%;
  max-width: 960px;
  height: auto;
  border-radius: 12px;
  /* Solid inner arena color so bubbles are easy to see */
  background-color: #28345a;
  border: 1px solid rgba(15, 23, 42, 0.9);
  touch-action: none;
  -ms-touch-action: none;
  user-select: none;
}

.app-footer {
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 0.75rem;
  color: #6b7280;
}

.app-footer a {
  color: inherit;
  text-decoration: none;
}

.leaderboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.leaderboard-overlay.is-visible {
  display: flex;
}

.leaderboard-panel {
  width: min(420px, 100% - 32px);
  background: radial-gradient(circle at top left, #28345a 0, #020617 70%);
  border-radius: 18px;
  border: 1px solid rgba(155, 198, 191, 0.8);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.9);
  padding: 14px 16px 16px;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.leaderboard-header h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leaderboard-close {
  padding-inline: 10px;
}

.leaderboard-subtitle {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: #cbd5f5;
}

.leaderboard-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  max-height: 220px;
  overflow-y: auto;
}

.leaderboard-list li {
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.leaderboard-score {
  font-weight: 600;
}

.leaderboard-meta {
  font-size: 0.75rem;
  color: #9ca3af;
}

.leaderboard-empty {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #9ca3af;
}

.name-input-row {
  margin: 6px 0 10px;
}

#nameInput {
  width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(155, 198, 191, 0.8);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  font-size: 0.9rem;
  outline: none;
}

#nameInput:focus {
  border-color: rgba(250, 250, 250, 0.9);
}

.name-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px 10px 14px;
  }

  .branding h1 {
    font-size: 1.4rem;
  }

  .hud-row {
    align-items: flex-start;
    gap: 8px;
  }

  .status-message {
    text-align: left;
    margin-top: 4px;
  }
}

