/* ============================================================
   Cómplices — design tokens
   Fond encre profonde + accent "or de carte", cartes façon loteria.
   ============================================================ */
:root {
  --bg: #11151c;
  --surface: #182229;
  --surface-2: #1f2c33;
  --line: rgba(227, 167, 46, 0.28);
  --line-strong: rgba(227, 167, 46, 0.55);
  --text: #f3ecd8;
  --text-dim: #b6ab90;
  --gold: #e3a72e;
  --gold-soft: #f0c869;

  --c-romance: #c97b84;
  --c-gourmand: #d98f3a;
  --c-aventure: #4f7c5d;
  --c-corvee: #5c7a99;
  --c-defi: #7c5ca6;
  --c-coquin: #c6376b;
  --c-pouvoir: #e3a72e;

  --font-display: "Fraunces", "DejaVu Serif", Georgia, serif;
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  background: radial-gradient(120% 120% at 50% -10%, #1a232b 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 2px;
}

input {
  font-family: inherit;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
}
input::placeholder { color: var(--text-dim); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-top: var(--safe-top);
  padding-bottom: calc(72px + var(--safe-bottom));
  position: relative;
}

.hidden { display: none !important; }

/* ---------- Écrans pleine page (join / attente) ---------- */
.center-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  text-align: center;
  gap: 18px;
}

.brand-mark {
  width: 64px; height: 64px;
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--gold-soft);
  position: relative;
}
.brand-mark::before {
  content: "";
  position: absolute; inset: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand-title {
  font-size: 34px;
  letter-spacing: 0.01em;
}
.brand-tagline {
  color: var(--text-dim);
  font-size: 14.5px;
  max-width: 320px;
  line-height: 1.5;
}

.form-stack {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  padding: 14px 18px;
  border-radius: 12px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #1b1305;
}
.btn-primary:disabled { opacity: 0.45; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-danger {
  background: transparent;
  border: 1px solid rgba(198, 55, 107, 0.6);
  color: #f0a3ba;
}

.error-text { color: #f0a3ba; font-size: 13.5px; min-height: 18px; }
.hint-text { color: var(--text-dim); font-size: 13px; line-height: 1.5; }

/* ---------- En-tête de jeu ---------- */
.app-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
  background: rgba(17, 21, 28, 0.92);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.header-top-row {
  display: flex; justify-content: space-between; align-items: baseline;
}
.header-title { font-size: 21px; }
.ticket {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--gold-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 3px 8px;
  white-space: nowrap;
}
.players-row {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 12px;
}
.player-chip {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}
.player-chip .name {
  font-size: 13px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.player-chip .count {
  font-family: var(--font-mono);
  font-size: 12px; color: var(--text-dim);
  margin-top: 2px;
}
.shield-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); display: inline-block;
  box-shadow: 0 0 6px var(--gold);
}

/* ---------- Onglets ---------- */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 560px; margin: 0 auto;
  display: flex;
  background: rgba(17, 21, 28, 0.96);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.tab-btn {
  flex: 1;
  padding: 12px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.tab-btn.active { color: var(--gold-soft); }
.tab-btn .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--c-coquin);
  position: absolute; margin-left: 14px; margin-top: -2px;
}

.view { padding: 18px 18px 10px; }

.section-title {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 18px 2px 10px;
}

.quota-banner {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 4px;
}
.quota-banner .label { font-size: 13px; color: var(--text-dim); }
.quota-banner .value { font-family: var(--font-mono); font-size: 18px; color: var(--gold-soft); }

/* ---------- Grille de cartes ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 6px;
}

.playing-card {
  aspect-ratio: 5 / 7;
  border-radius: 14px;
  padding: 3px;
  background: linear-gradient(160deg, var(--cat-color, var(--gold)) 0%, transparent 40%), var(--surface);
  position: relative;
  text-align: left;
  display: flex;
}
.playing-card .inner {
  flex: 1;
  border: 1px solid color-mix(in srgb, var(--cat-color, var(--gold)) 55%, transparent);
  border-radius: 11px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 30%);
  position: relative;
  overflow: hidden;
}
.playing-card .inner::before,
.playing-card .inner::after {
  content: "";
  position: absolute;
  width: 8px; height: 8px;
  border: 1px solid color-mix(in srgb, var(--cat-color, var(--gold)) 70%, transparent);
}
.playing-card .inner::before { top: 5px; left: 5px; border-width: 1px 0 0 1px; }
.playing-card .inner::after { bottom: 5px; right: 5px; border-width: 0 1px 1px 0; }

.card-cat-icon {
  width: 26px; height: 26px;
  color: var(--cat-color, var(--gold));
}
.card-num {
  position: absolute; top: 8px; right: 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-dim);
}
.card-title {
  font-family: var(--font-display);
  font-size: 13.5px;
  line-height: 1.2;
  margin-top: 8px;
  color: var(--text);
}
.card-cat-label {
  margin-top: auto;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cat-color, var(--gold));
  font-weight: 700;
}

.playing-card.is-status-played,
.playing-card.is-status-blocked,
.playing-card.is-status-countered { opacity: 0.55; }
.playing-card.is-pending { opacity: 0.6; }
.pending-badge {
  position: absolute; top: 6px; left: 6px;
  font-size: 8.5px; font-family: var(--font-mono);
  background: var(--surface-2); color: var(--text-dim);
  border-radius: 6px; padding: 2px 5px;
  border: 1px solid var(--line);
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- Historique (feed) ---------- */
.feed-item {
  display: flex; gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}
.feed-item .icon-badge {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--cat-color, var(--gold));
}
.feed-item .content { flex: 1; }
.feed-item .who { font-size: 12.5px; color: var(--text-dim); }
.feed-item .title { font-family: var(--font-display); font-size: 15px; margin: 2px 0; }
.feed-item .text { font-size: 13px; color: var(--text-dim); line-height: 1.45; }
.feed-item .status-pill {
  display: inline-block; margin-top: 6px;
  font-size: 10.5px; padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.status-pill.countered { color: #f0a3ba; border-color: rgba(198,55,107,0.5); }
.status-pill.blocked { color: var(--gold-soft); border-color: var(--line-strong); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 8, 11, 0.72);
  display: flex; align-items: flex-end;
  z-index: 20;
  animation: fadeIn 0.18s ease;
}
.modal-sheet {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  border-radius: 22px 22px 0 0;
  padding: 22px 22px calc(26px + var(--safe-bottom));
  max-height: 86vh;
  overflow-y: auto;
  animation: slideUp 0.22s ease;
}
.modal-cat-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--cat-color, var(--gold)); font-weight: 700;
}
.modal-title { font-size: 24px; margin: 8px 0 12px; }
.modal-text { font-size: 15.5px; line-height: 1.6; color: var(--text); margin-bottom: 20px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

.counter-pick-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.counter-pick-item {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
}
.counter-pick-item.selected { border-color: var(--gold); background: rgba(227,167,46,0.1); }
.counter-pick-item .t { font-size: 14px; font-weight: 700; }
.counter-pick-item .d { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.toast {
  position: fixed; bottom: calc(84px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  color: var(--text); padding: 10px 16px; border-radius: 12px;
  font-size: 13.5px; z-index: 30;
  animation: fadeIn 0.2s ease;
}

/* ---------- Réglages ---------- */
.settings-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.settings-block h3 { font-size: 14px; margin-bottom: 8px; }
.settings-block p { font-size: 13px; color: var(--text-dim); line-height: 1.55; margin: 0 0 10px; }
.kv-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-top: 1px solid var(--line); }
.kv-row:first-child { border-top: none; }
.kv-row .k { color: var(--text-dim); }

/* Confettis papier découpé (petite touche "papel picado") au moment de jouer une carte */
.confetti-piece {
  position: fixed;
  width: 8px; height: 10px;
  z-index: 40;
  pointer-events: none;
  animation: fall 900ms ease-out forwards;
}
@keyframes fall {
  from { transform: translateY(0) rotate(0deg); opacity: 1; }
  to { transform: translateY(120px) rotate(200deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal-sheet, .toast, .confetti-piece { animation: none !important; }
  .btn:active { transform: none; }
}
