/* DartsFriends — styles de base + thèmes + shell mobile */

:root {
  --bg: #f5f7fb;
  --bg-card: #ffffff;
  --bg-alt: #eef1f7;
  --text: #1a1f2e;
  --text-muted: #5b6577;
  --border: #dde2eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --accent: #8b5cf6;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

[data-theme="dark"] {
  --bg: #0f1419;
  --bg-card: #1a1f2e;
  --bg-alt: #242b3d;
  --text: #e6e8ef;
  --text-muted: #9199a8;
  --border: #2d3548;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --success: #22c55e;
  --danger: #f87171;
  --warning: #fbbf24;
  --accent: #a78bfa;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─────────── App shell mobile ─────────── */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100dvh);   /* hauteur réellement visible, mesurée en JS (window.innerHeight) */
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 52px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-title {
  font-weight: 700;
  font-size: 1.05rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 1rem;
  text-decoration: none;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--bg-alt); text-decoration: none; }
.profile-link { padding: 4px; }
.avatar-mini {
  width: 28px; height: 28px;
  border-radius: 50%;
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-content {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  padding-bottom: 20px;
}

.app-nav {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 6px 4px 8px;
  min-height: 58px;
  transition: color 0.15s, background 0.15s;
}
.nav-item:hover { text-decoration: none; background: var(--bg-alt); color: var(--text); }
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon { transform: scale(1.1); }
.nav-icon {
  font-size: 1.35rem;
  line-height: 1;
  transition: transform 0.15s;
}
.nav-label { line-height: 1; }

/* ─────────── Cards & éléments communs ─────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card h1, .card h2, .card h3 { margin: 0 0 10px 0; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

.muted { color: var(--text-muted); font-size: 0.9rem; }
.text-small { font-size: 0.85rem; }
.text-center { text-align: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: white;
  touch-action: manipulation;
  transition: background 0.15s, transform 0.05s;
  min-height: 48px;
}
.btn:active { transform: scale(0.98); }
.btn:hover { background: var(--primary-hover); text-decoration: none; color: white; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary { background: var(--bg-alt); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger); filter: brightness(1.1); }
.btn.success { background: var(--success); }
.btn.success:hover { background: var(--success); filter: brightness(1.1); }
.btn.block { width: 100%; }
.btn.lg { padding: 16px 22px; font-size: 1.1rem; min-height: 56px; }

.input, select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  min-height: 44px;
}
.input:focus, select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; }
.field { margin-bottom: 14px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }

.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.alert-error { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid var(--danger); }
.alert-info { background: rgba(37,99,235,0.1); color: var(--primary); border: 1px solid var(--primary); }
.alert-success { background: rgba(16,185,129,0.1); color: var(--success); border: 1px solid var(--success); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-alt);
  border-radius: 10px;
  margin-bottom: 8px;
}
.checkbox-row input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}
.checkbox-row label { margin: 0; cursor: pointer; flex: 1; }

/* ─────────── Splash / Welcome (écran d'accueil avec citation) ─────────── */
.welcome-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-alt) 100%);
}
.welcome-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px 26px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  text-align: center;
}
.welcome-logo {
  font-size: 3.4rem;
  line-height: 1;
  animation: welcomeSpin 2.4s cubic-bezier(0.3, 0.1, 0.3, 1);
}
@keyframes welcomeSpin {
  0%   { transform: rotate(0deg) scale(0.7); opacity: 0; }
  50%  { transform: rotate(200deg) scale(1.1); opacity: 1; }
  100% { transform: rotate(360deg) scale(1); opacity: 1; }
}
.welcome-title {
  font-weight: 900;
  font-size: 1.8rem;
  margin-top: 6px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}
.welcome-quote {
  background: var(--bg-alt);
  border-left: 4px solid var(--primary);
  padding: 16px 16px 14px;
  border-radius: 12px;
  margin: 8px 0 22px;
  position: relative;
  animation: quoteFadeIn 0.7s ease-out 0.5s backwards;
}
@keyframes quoteFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.welcome-quote .quote-mark {
  font-size: 2.6rem;
  line-height: 0.5;
  color: var(--primary);
  opacity: 0.35;
  font-family: Georgia, serif;
  position: absolute;
  top: 14px;
  left: 10px;
}
.welcome-quote .quote-text {
  font-size: 1rem;
  line-height: 1.45;
  font-style: italic;
  color: var(--text);
  padding: 0 4px 0 24px;
  font-weight: 500;
}
.welcome-quote .quote-source {
  text-align: right;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 8px;
  padding-right: 4px;
}
.welcome-actions {
  margin-top: 14px;
}
.welcome-actions .theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-height: 600px) {
  .welcome-logo { font-size: 2.4rem; }
  .welcome-title { font-size: 1.4rem; }
  .welcome-sub { margin-bottom: 14px; }
  .welcome-quote { padding: 12px 12px 10px; margin-bottom: 14px; }
  .welcome-quote .quote-text { font-size: 0.9rem; }
}

/* ─────────── Login (standalone, pas de shell) ─────────── */

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-title { text-align: center; font-size: 1.8rem; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-muted); margin-bottom: 20px; font-size: 0.9rem; }

/* ─────────── Éléments métier ─────────── */

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.player-row:last-child { border-bottom: none; }
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  flex-shrink: 0;
}

.action-tile {
  display: block;
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 10px;
  transition: border-color 0.15s, transform 0.1s;
}
.action-tile:hover { border-color: var(--primary); text-decoration: none; color: var(--text); }
.action-tile:active { transform: scale(0.98); }
.action-tile .tile-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.action-tile .tile-icon {
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.action-tile .tile-text { flex: 1; }
.action-tile .tile-title { font-weight: 700; font-size: 1rem; }
.action-tile .tile-sub { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }
.action-tile .tile-arrow { color: var(--text-muted); font-size: 1.2rem; }
.action-tile.disabled { opacity: 0.55; pointer-events: none; }

/* Tuile avec action secondaire (ex: bouton annuler) */
.tile-with-action {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 10px;
}
.tile-cancel { margin: 0; display: flex; }
.btn-tile-cancel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--danger);
  font-size: 1.1rem;
  font-weight: 700;
  width: 56px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn-tile-cancel:hover {
  background: rgba(239,68,68,0.12);
  border-color: var(--danger);
}
.btn-tile-cancel:active { transform: scale(0.95); }

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 14px 4px 8px;
  font-weight: 700;
}

/* Big CTA — home */
.home-hero {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.home-hero .hello { opacity: 0.9; font-size: 0.9rem; }
.home-hero .title { font-size: 1.5rem; font-weight: 800; margin: 4px 0 12px; }
.home-hero .btn {
  background: white;
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}
.home-hero .btn:hover { background: white; filter: brightness(0.95); color: var(--primary); }

/* Stats compact */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.stat-cell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.stat-cell .num { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.stat-cell .lbl { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; }

table.leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.leaderboard th {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
table.leaderboard th.num { text-align: right; }
table.leaderboard td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.leaderboard td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.leaderboard tr:last-child td { border-bottom: none; }
table.leaderboard th.highlight { color: var(--primary); }
table.leaderboard td.rank { font-weight: 700; color: var(--text-muted); }

/* Pill group (tri / filtres) */
.pill-group {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 12px;
}
.pill {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
  min-height: 38px;
}
.pill:hover { color: var(--text); }
.pill.active {
  background: var(--primary);
  color: white;
}
.pill.active:hover { color: white; }

/* Fine tune content padding to not hide under nav scroll momentum */
.app-content > :last-child { margin-bottom: 8px; }

/* Indicateur de version en bas à droite (toujours visible) */
.version-tag {
  position: fixed;
  bottom: 4px;
  right: 4px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 0.62rem;
  font-family: monospace;
  border-radius: 4px;
  z-index: 999;
  pointer-events: none;
  opacity: 0.5;
}
.version-tag::before {
  content: "🎯 ";
}

/* ─────────── Pull-to-refresh ─────────── */
.ptr-indicator {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, 0);
  opacity: 0;
  margin-top: -50px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 5;
}
.ptr-indicator.ready { color: var(--primary); border-color: var(--primary); }
.ptr-indicator.ready .ptr-spinner { transform: rotate(180deg); }
.ptr-indicator .ptr-spinner { display: inline-block; transition: transform 0.2s; }
.ptr-indicator.refreshing .ptr-spinner {
  animation: ptrSpin 0.8s linear infinite;
}
@keyframes ptrSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ─────────── Install banner PWA ─────────── */
.install-banner {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom));
  transform: translate(-50%, 30px);
  width: calc(100% - 20px);
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--primary);
  border-radius: 14px;
  padding: 10px 10px 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}
.install-banner.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.install-icon {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
}
.install-text {
  flex: 1;
  min-width: 0;
}
.install-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.2;
}
.install-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 2px;
}
.install-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  min-height: 38px;
}
.install-btn:active { transform: scale(0.96); }
.install-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
  min-height: 38px;
  line-height: 1;
}
.install-close:hover { color: var(--text); }

@media (max-width: 380px) {
  .install-title { font-size: 0.82rem; }
  .install-sub { font-size: 0.7rem; }
  .install-btn { padding: 8px 10px; font-size: 0.78rem; }
}

/* ─────────── Badges nav ─────────── */
.nav-item { position: relative; }
.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
