:root {
  --bg-deep: #0b1020;
  --bg-panel: rgba(15, 23, 42, 0.78);
  --bg-panel-strong: rgba(15, 23, 42, 0.92);
  --border-subtle: rgba(148, 163, 184, 0.18);
  --border-glow: rgba(56, 189, 248, 0.45);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-cyan: #00e5ff;
  --accent-pink: #ff5e7e;
  --accent-violet: #b388ff;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#arenaCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.reconnect-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 94, 126, 0.9);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-panel {
  pointer-events: auto;
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Player Card (Top-Left) */
.player-card {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 280px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-cyan);
  background: #1e293b;
  flex-shrink: 0;
}

.player-meta {
  min-width: 0;
  flex: 1;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.player-display {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-handle {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--border-glow);
}

.player-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.metric-val {
  font-size: 0.88rem;
  font-weight: 700;
}

.boost-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.boost-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.boost-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.boost-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet));
  transition: width 0.08s linear;
}

/* Leaderboard (Top-Right, compact Top 7) */
.leaderboard-card {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 190px;
  padding: 8px 10px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(15, 23, 42, 0.56);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e2e8f0;
}

.online-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 229, 255, 0.14);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 229, 255, 0.28);
}

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

.lb-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 5px;
  border-radius: 7px;
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.025);
}

.lb-item.is-me {
  background: rgba(0, 229, 255, 0.16);
  border: 1px solid rgba(0, 229, 255, 0.35);
}

.lb-rank {
  width: 13px;
  font-weight: 800;
  font-size: 0.64rem;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.lb-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #1e293b;
}

.lb-handle {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.lb-followers {
  font-weight: 700;
  font-size: 0.66rem;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

/* Bottom-Left Minimap + Minimal Length (Slither.io layout) */
.bottom-left-cluster {
  position: fixed;
  bottom: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

.minimal-length {
  font-size: 0.78rem;
  color: rgba(226, 232, 240, 0.82);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  padding-left: 4px;
}

.minimal-length strong {
  color: #ffffff;
  font-weight: 800;
}

.minimap-card {
  padding: 4px;
  border-radius: 50%;
  line-height: 0;
  background: rgba(15, 23, 42, 0.54);
}

#minimapCanvas {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  display: block;
}

/* Mobile-only Sprint Button (compact, hidden on desktop mouse devices) */
.mobile-boost-btn {
  display: none;
  position: fixed;
  right: 14px;
  bottom: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 229, 255, 0.65);
  background: rgba(15, 23, 42, 0.68);
  color: #00e5ff;
  font-size: 1.15rem;
  pointer-events: auto;
  touch-action: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.mobile-boost-btn.active {
  background: rgba(255, 94, 126, 0.85);
  border-color: #ffffff;
  color: #ffffff;
  transform: scale(0.94);
}

@media (hover: none) and (pointer: coarse) {
  .mobile-boost-btn {
    display: flex;
  }
  .hover-tooltip {
    display: none !important;
  }
  .overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(7, 10, 22, 0.92);
  }
}

/* Badges */
.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #1d9bf0;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  flex-shrink: 0;
}

.tier-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  width: fit-content;
}

/* ---------- Hover Tooltip ---------- */
.hover-tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  min-width: 215px;
  padding: 11px 13px;
  border-radius: 14px;
  background: rgba(10, 15, 30, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 9px;
  transform: translate(16px, -50%);
}

.tooltip-header {
  display: flex;
  align-items: center;
  gap: 9px;
}

.tooltip-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-cyan);
  background: #1e293b;
}

.tooltip-display-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tooltip-display {
  font-weight: 700;
  font-size: 0.88rem;
}

.tooltip-handle {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.tooltip-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tooltip-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

/* ---------- Join / Auth Overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(11, 16, 32, 0.62), rgba(7, 10, 22, 0.88));
  backdrop-filter: blur(8px);
  overflow-y: auto;
}

.join-card {
  width: 100%;
  max-width: 490px;
  background: var(--bg-panel-strong);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 24px;
  padding: 26px 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.logo-x {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #00e5ff, #7c4dff 60%, #ff5e7e);
  color: #090d1a;
  box-shadow: 0 6px 22px rgba(0, 229, 255, 0.35);
}

.logo-text {
  font-family: 'Fredoka', 'Plus Jakarta Sans', sans-serif;
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.05;
  background: linear-gradient(95deg, #69f0ae 0%, #00e5ff 45%, #b388ff 85%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 16px rgba(0, 229, 255, 0.35));
}

.logo-accent {
  background: linear-gradient(135deg, #ffd740, #ff5e7e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tagline {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 380px;
}

.brand-tagline strong {
  color: var(--text-main);
}

.auth-notice {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  background: rgba(255, 183, 77, 0.14);
  border: 1px solid rgba(255, 183, 77, 0.35);
  color: #ffe0b2;
}

.connected-x-box {
  background: rgba(29, 155, 240, 0.12);
  border: 1px solid rgba(29, 155, 240, 0.4);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.connected-x-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.connected-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #1d9bf0;
}

.connected-info {
  flex: 1;
  min-width: 0;
}

.connected-name {
  font-weight: 700;
  font-size: 0.98rem;
}

.connected-handle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.connected-followers {
  text-align: right;
  display: flex;
  flex-direction: column;
}

.connected-followers span {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--accent-cyan);
}

.connected-followers small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.connected-actions {
  display: flex;
  gap: 8px;
}

.oauth-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.oauth-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px;
  border-radius: 13px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
}

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

.btn-full {
  width: 100%;
}

.btn-x {
  background: #ffffff;
  color: #0f1419;
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.14);
}

.btn-x:hover {
  background: #e7e9ea;
}

.btn-primary {
  background: linear-gradient(135deg, #00e5ff, #3b82f6 55%, #8b5cf6);
  color: #061021;
  box-shadow: 0 8px 24px rgba(0, 229, 255, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.x-svg {
  width: 18px;
  height: 18px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* Demo Presets */
.presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.preset-chip {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.preset-chip:hover {
  background: rgba(0, 229, 255, 0.14);
  border-color: var(--accent-cyan);
}

.preset-chip span {
  color: var(--accent-cyan);
  margin-left: 4px;
  font-weight: 800;
}

/* Form */
.demo-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
}

.field small {
  color: var(--text-muted);
  font-weight: 400;
}

.field input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(2, 6, 23, 0.65);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus {
  border-color: var(--accent-cyan);
}

.input-prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  font-weight: 700;
}

.input-prefix-wrap input {
  padding-left: 25px;
}

/* Size Preview */
.size-preview {
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-meta,
.preview-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.preview-title {
  font-weight: 700;
  color: #e2e8f0;
}

#previewCanvas {
  width: 100%;
  height: 72px;
  border-radius: 8px;
  display: block;
}

/* ---------- Death / Respawn Card ---------- */
.death-card {
  max-width: 400px;
  text-align: center;
  align-items: center;
  gap: 14px;
}

.death-badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 94, 126, 0.16);
  border: 1px solid rgba(255, 94, 126, 0.45);
  color: #ff5e7e;
}

.death-title {
  font-size: 1.5rem;
  font-weight: 800;
}

.death-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.death-stats-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.death-stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.death-stat-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.death-social-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.btn-outline-x {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

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

.death-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.death-secondary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .leaderboard-card {
    top: 10px;
    right: 10px;
    width: 156px;
    padding: 7px 9px;
    gap: 5px;
    border-radius: 13px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .panel-title {
    font-size: 0.64rem;
  }
  .online-badge {
    font-size: 0.58rem;
    padding: 1px 5px;
  }
  .leaderboard-list {
    gap: 2px;
  }
  .lb-item {
    gap: 5px;
    padding: 2px 4px;
    font-size: 0.65rem;
    border-radius: 6px;
  }
  .lb-rank {
    width: 12px;
    font-size: 0.6rem;
  }
  .lb-avatar {
    width: 15px;
    height: 15px;
  }
  .lb-followers {
    font-size: 0.62rem;
  }
  .bottom-left-cluster {
    bottom: 10px;
    left: 10px;
    gap: 5px;
  }
  .minimal-length {
    font-size: 0.64rem;
  }
  #minimapCanvas {
    width: 76px;
    height: 76px;
  }
}
