:root {
  --primary-accent: #ff477e;
  --secondary-accent: #00f2fe;
  --bg-dark: #10101a;
  --panel-bg: rgba(20, 20, 36, 0.82);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text-main: #ffffff;
  --text-muted: #9ba0be;
  --gold: #ffd166;
  --neon-green: #00ff88;
  --cyan: #00f2fe;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  touch-action: manipulation;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 20%, #1e1e38 0%, #0c0c16 100%);
}

canvas#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Top UI Bar */
#top-bar {
  position: absolute;
  top: env(safe-area-inset-top, 16px);
  left: 0;
  right: 0;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.top-stats-row {
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}

.score-container {
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.score-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-muted);
}

#score-display {
  font-size: 2.75rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(180deg, #fff 30%, #ffd166 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
  transition: transform 0.15s ease-out;
}

.level-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: auto;
}

.level-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.level-badge {
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
  color: var(--cyan);
  background: rgba(0, 242, 254, 0.12);
  border: 1px solid rgba(0, 242, 254, 0.4);
  padding: 4px 10px;
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.25);
  font-family: 'Share Tech Mono', monospace, sans-serif;
}

.score-bounce {
  transform: scale(1.2);
}

.top-actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.icon-btn {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.15);
}

/* Combo Toast */
#combo-toast {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  backdrop-filter: blur(12px);
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 1px;
  box-shadow: 0 0 25px rgba(255, 71, 126, 0.5);
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#combo-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

.streak-badge {
  background: linear-gradient(135deg, #ff477e, #ff7096);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Level-Up Announcement Toast */
.level-toast {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 26px;
  background: rgba(16, 16, 32, 0.9);
  border: 1.5px solid var(--gold);
  border-radius: 20px;
  backdrop-filter: blur(16px);
  box-shadow: 0 0 35px rgba(255, 209, 102, 0.45), 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 25;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.level-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.05);
}

.level-banner-chip {
  background: linear-gradient(135deg, #ffd166, #ff7096);
  color: #10101a;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 2px;
  padding: 3px 12px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.level-banner-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-icon {
  font-size: 1.5rem;
}

.level-title {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.level-desc {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--cyan);
  text-align: center;
}

/* Modals & Overlays */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 18, 0.72);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 30;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: auto;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#name-modal {
  z-index: 50; /* Above all other overlays & leaderboard */
}

.overlay-card {
  position: relative;
  background: rgba(20, 20, 36, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  padding: 32px 28px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 71, 126, 0.12);
  animation: cardPopIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto;
}

@keyframes cardPopIn {
  from {
    opacity: 0;
    transform: scale(0.88) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.game-title {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1.1;
}

.game-title .highlight {
  color: var(--primary-accent);
  text-shadow: 0 0 20px rgba(255, 71, 126, 0.6);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: -8px;
}

/* Instructions */
.instructions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
}

.inst-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #ddd;
}

.step-icon {
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.08);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}

.challenge-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
}

.challenge-preview-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.challenge-pills {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.challenge-pill {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Player Profile Badge in Start Screen */
.player-profile-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.35);
  border-radius: 30px;
  padding: 8px 18px;
  margin: 0 auto;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.player-profile-badge:hover {
  background: rgba(0, 242, 254, 0.2);
  border-color: rgba(0, 242, 254, 0.65);
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.3);
  transform: translateY(-1px);
}

.player-profile-badge:active {
  transform: scale(0.97);
}

.profile-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--cyan);
  pointer-events: none;
}

.profile-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.profile-edit-btn {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 4px 9px;
  border-radius: 8px;
  cursor: pointer;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.profile-edit-btn:hover, .profile-edit-btn:active {
  background: var(--cyan);
  color: #0c0c16;
  border-color: var(--cyan);
}

.high-score-tag {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--gold);
}

/* Game Over Styles */
.game-over-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ff477e;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-box .label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.result-box .val {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
}

.result-box-wide {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.1), rgba(255, 71, 126, 0.1));
  border: 1px solid rgba(0, 242, 254, 0.35);
}

.result-box-wide .val {
  font-size: 1.35rem;
  color: var(--cyan);
}

/* Generic Buttons */
.btn {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 16px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}

.btn:active {
  transform: scale(0.96);
}

.primary-btn {
  background: linear-gradient(135deg, #ff477e 0%, #ff7096 100%);
  color: #fff;
  box-shadow: 0 8px 25px rgba(255, 71, 126, 0.4);
}

.primary-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 10px 30px rgba(255, 71, 126, 0.6);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #eee;
  font-size: 0.85rem;
  padding: 12px;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Name Modal Specifics */
.name-modal-card {
  position: relative;
  max-width: 390px;
  border-color: rgba(0, 242, 254, 0.35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 45px rgba(0, 242, 254, 0.2);
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.15s ease;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.modal-chip {
  align-self: center;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--neon-green);
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  padding: 4px 12px;
  border-radius: 20px;
}

.name-modal-title {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.4;
  margin-top: -6px;
}

.name-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
}

.name-input {
  flex: 1;
  background: rgba(12, 12, 22, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  outline: none;
  transition: all 0.2s ease;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
}

.name-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.35);
  background: rgba(15, 15, 28, 0.95);
}

.dice-btn {
  font-size: 1.3rem;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.dice-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.name-error {
  font-size: 0.78rem;
  color: #ff477e;
  margin-top: 6px;
  text-align: left;
}

.modal-btn-row {
  margin-top: 10px;
  display: flex;
  gap: 10px;
}

.modal-btn-row .btn {
  flex: 1;
}

.cancel-btn {
  padding: 14px;
}

.pulse-glow {
  animation: pulseGlowBtn 2s infinite ease-in-out;
}

@keyframes pulseGlowBtn {
  0%, 100% {
    box-shadow: 0 8px 25px rgba(255, 71, 126, 0.4);
  }
  50% {
    box-shadow: 0 10px 32px rgba(255, 71, 126, 0.7);
  }
}

/* -------------------------------------------------------------
 * RIGHT-SIDE ACTIVE USERS ONLINE & LIVE LEADERBOARD
 * z-index is set to 40 so it stays above overlays (z-index: 30)
 * ------------------------------------------------------------- */
.online-panel {
  position: absolute;
  top: 74px;
  right: 20px;
  width: 260px;
  max-height: calc(100vh - 96px);
  max-height: calc(100dvh - 96px);
  background: rgba(14, 15, 26, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  z-index: 40; /* Above overlays so buttons are fully clickable */
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 242, 254, 0.1);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, width 0.3s ease;
  overflow: hidden;
  user-select: none;
  pointer-events: auto;
}

.online-panel.collapsed {
  transform: translateX(calc(100% + 25px));
  opacity: 0;
  pointer-events: none;
}

.online-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-title-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #e0e8ff;
}

.count-badge {
  background: rgba(0, 255, 136, 0.15);
  border: 1px solid rgba(0, 255, 136, 0.4);
  color: var(--neon-green);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
}

.panel-collapse-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.panel-collapse-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* User's own status bar inside panel */
.user-self-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0, 242, 254, 0.08);
  border-bottom: 1px solid rgba(0, 242, 254, 0.22);
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
}

.user-self-bar:hover {
  background: rgba(0, 242, 254, 0.16);
}

.self-avatar-pill {
  background: linear-gradient(135deg, var(--cyan), #0072ff);
  color: #060c18;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 3px 6px;
  border-radius: 6px;
  flex-shrink: 0;
  pointer-events: none;
}

.self-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.self-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.self-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-icon-btn {
  background: rgba(0, 242, 254, 0.15);
  border: 1px solid rgba(0, 242, 254, 0.35);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  padding: 3px 7px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  transition: all 0.15s ease;
}

.mini-icon-btn:hover {
  background: var(--cyan);
  color: #0c0c16;
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

.self-best-caption {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.self-best-caption strong {
  color: var(--gold);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
}

/* Leaderboard column headers */
.leaderboard-col-headers {
  display: flex;
  padding: 8px 14px 4px 14px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.col-rank {
  width: 32px;
  flex-shrink: 0;
}

.col-player {
  flex: 1;
}

.col-score {
  text-align: right;
  width: 50px;
}

/* Scroll area & list */
.leaderboard-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 6px 8px 6px;
  max-height: 380px;
}

/* Custom scrollbar */
.leaderboard-scroll-area::-webkit-scrollbar {
  width: 4px;
}

.leaderboard-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: all 0.2s ease;
  font-size: 0.82rem;
}

.leaderboard-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.leaderboard-item.is-self {
  background: rgba(0, 242, 254, 0.1);
  border-color: rgba(0, 242, 254, 0.35);
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.12);
  cursor: pointer;
}

.leaderboard-item.is-self:hover {
  background: rgba(0, 242, 254, 0.2);
  border-color: rgba(0, 242, 254, 0.6);
}

.leaderboard-item.rank-1 .rank-badge {
  background: linear-gradient(135deg, #ffd166, #ff9f43);
  color: #1a1002;
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.5);
}

.leaderboard-item.rank-2 .rank-badge {
  background: linear-gradient(135deg, #f1f2f6, #a4b0be);
  color: #1e272e;
}

.leaderboard-item.rank-3 .rank-badge {
  background: linear-gradient(135deg, #e67e22, #d35400);
  color: #fff;
}

.rank-badge {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 10px;
}

.player-info-cell {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-item-name {
  font-weight: 700;
  color: #f0f0f8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-item.is-self .player-item-name {
  color: var(--cyan);
}

.live-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--neon-green);
  box-shadow: 0 0 6px var(--neon-green);
  flex-shrink: 0;
  animation: matrixPulse 1.4s infinite ease-in-out;
}

.score-badge {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  text-align: right;
  flex-shrink: 0;
  margin-left: 8px;
}

.leaderboard-empty-state {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Floating Mobile Leaderboard Button */
.mobile-board-toggle {
  display: none;
  position: absolute;
  top: 74px;
  right: 16px;
  z-index: 40; /* Above overlays */
  background: rgba(14, 15, 26, 0.9);
  border: 1px solid rgba(0, 242, 254, 0.35);
  border-radius: 20px;
  padding: 7px 14px;
  color: #fff;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 1px;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 242, 254, 0.2);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.mobile-board-toggle:active {
  transform: scale(0.94);
}

/* Bottom Matrix Counter - hidden since online count is inside the right-side panel */
.matrix-counter {
  display: none !important;
}

.matrix-counter:active {
  transform: scale(0.96);
}

.matrix-dot {
  width: 6.5px;
  height: 6.5px;
  background-color: #00ff66;
  border-radius: 50%;
  box-shadow: 0 0 8px #00ff66, 0 0 12px #00ff66;
  animation: matrixPulse 1.4s infinite ease-in-out;
}

.matrix-label {
  font-weight: 600;
  opacity: 0.88;
}

.matrix-val {
  font-weight: 700;
  min-width: 26px;
  text-align: right;
  color: #55ff88;
  text-shadow: 0 0 8px #00ff66, 0 0 16px rgba(0, 255, 102, 0.6);
}

@keyframes matrixPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 8px #00ff66, 0 0 14px #00ff66;
  }
  50% {
    opacity: 0.25;
    transform: scale(0.75);
    box-shadow: 0 0 3px #00ff66;
  }
}

.hidden {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .mobile-board-toggle {
    display: flex;
  }

  .online-panel {
    top: 0;
    right: 0;
    bottom: 0;
    width: 290px;
    max-width: 86vw;
    max-height: 100dvh;
    border-radius: 0;
    border-left: 1px solid rgba(0, 242, 254, 0.3);
    border-top: none;
    border-right: none;
    border-bottom: none;
    transform: translateX(100%);
    box-shadow: -15px 0 40px rgba(0, 0, 0, 0.8);
    z-index: 45;
  }

  .online-panel.mobile-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .online-panel-header {
    padding-top: calc(env(safe-area-inset-top, 14px) + 12px);
  }
}

@media (max-width: 480px) {
  #score-display {
    font-size: 2.3rem;
  }
  .overlay-card {
    padding: 24px 18px;
  }
  .game-title {
    font-size: 2rem;
  }
  .matrix-counter {
    font-size: 0.72rem;
    padding: 5px 9px;
  }
}
