:root {
  --bg: #0b1120;
  --card: #131c31;
  --card-line: #243049;
  --text: #e7ecf5;
  --muted: #94a3b8;
  --accent: #fbbf24;
  --yes: #22c55e;
  --maybe: #f59e0b;
  --no: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #0c1426;
  border-bottom: 1px solid var(--card-line);
}

.brand { font-weight: 800; font-size: 18px; }

.pseudo-zone { display: flex; gap: 8px; }

.pseudo-zone input {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-line);
  background: #0b1426;
  color: var(--text);
  font-size: 15px;
  min-width: 150px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 14px;
  background: #1f2a44;
  color: var(--text);
  transition: transform .05s ease, filter .15s ease;
}
button:hover { filter: brightness(1.15); }
button:active { transform: scale(.97); }

main { max-width: 1100px; margin: 0 auto; padding: 18px; }

.intro { color: var(--muted); }

.hint {
  margin: 8px 0 18px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(251,191,36,.12);
  border: 1px solid rgba(251,191,36,.35);
  color: #fde68a;
  font-size: 14px;
}
.hint.ok { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); color: #bbf7d0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card.fav { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(251,191,36,.35); }

.thumb {
  aspect-ratio: 4 / 3;
  background: #0a1020;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }

.card-body { padding: 12px 14px 14px; }
.card-name { font-weight: 700; font-size: 17px; }
.card-slogan { color: var(--muted); font-size: 13px; min-height: 18px; }

.votes { display: flex; gap: 6px; margin-top: 12px; }
.votes button { flex: 1; opacity: .85; padding: 9px 6px; line-height: 1.15; text-align: center; min-height: 44px; }
.votes button.sel { opacity: 1; outline: 2px solid currentColor; }
.v-yes { background: rgba(34,197,94,.18); color: var(--yes); }
.v-maybe { background: rgba(245,158,11,.18); color: var(--maybe); }
.v-no { background: rgba(239,68,68,.18); color: var(--no); }

.fav-btn { margin-top: 8px; width: 100%; background: #1a2440; color: var(--accent); }
.fav-btn.sel { background: var(--accent); color: #1a1206; }

.tally { display: flex; gap: 12px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.tally b { color: var(--text); }

.results-head { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 12px; }
.results-head h2 { margin: 0; }

.results { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 12px;
}
.rank { font-weight: 800; color: var(--accent); text-align: center; }
.row .meta { font-size: 13px; color: var(--muted); }
.bar { height: 8px; border-radius: 6px; background: #0a1020; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--yes); }

/* Proposer */
.proposer {
  margin: 8px 0 22px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 14px;
  overflow: hidden;
}
.proposer summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
  list-style: none;
}
.proposer summary::-webkit-details-marker { display: none; }
.proposer-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.type-toggle { display: flex; gap: 18px; color: var(--muted); }
.type-toggle label { cursor: pointer; }
.proposer-body input[type="text"] {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--card-line);
  background: #0b1426; color: var(--text); font-size: 15px;
}
.file-label {
  display: inline-block; padding: 10px 12px; border-radius: 10px;
  border: 1px dashed var(--card-line); background: #0b1426; color: var(--muted);
  cursor: pointer; font-size: 14px;
}
.file-label input { display: block; margin-top: 8px; color: var(--muted); }
#p-send { background: var(--accent); color: #1a1206; align-self: flex-start; }
.p-msg { font-size: 14px; color: var(--muted); min-height: 18px; }

/* Sections */
.block { margin-top: 26px; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.block-head h2 { margin: 0; }
.refresh { background: #1f2a44; }
.rank-title { color: var(--muted); font-size: 15px; margin: 22px 0 10px; }

/* Carte "nom" sans image : compacte, pas de format 4/3 */
.thumb-name {
  aspect-ratio: auto;
  min-height: 96px;
  font-size: 28px; font-weight: 800; color: var(--accent);
  text-align: center; padding: 22px 12px; letter-spacing: .5px;
  background: linear-gradient(160deg, #16213b, #0a1020);
  word-break: break-word;
}

/* Commentaires */
.comments { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 150px; overflow-y: auto; }
.comment { font-size: 13px; background: #0b1426; border: 1px solid var(--card-line); border-radius: 8px; padding: 6px 9px; }
.comment b { color: var(--accent); }
.comment-actions { float: right; display: inline-flex; gap: 4px; }
.comment-actions button {
  background: transparent; padding: 2px 5px; font-size: 12px;
  min-height: 0; border-radius: 6px; color: var(--muted);
}
.comment-actions button:hover { filter: none; color: var(--text); }
.no-comment { font-size: 13px; color: var(--muted); }
.comment-add { display: flex; gap: 6px; margin-top: 8px; }
.comment-add input {
  flex: 1; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--card-line);
  background: #0b1426; color: var(--text); font-size: 13px;
}
.comment-add button { background: #1f2a44; padding: 8px 12px; }

.del-btn {
  margin-top: 10px; width: 100%; background: transparent;
  color: var(--muted); border: 1px solid var(--card-line);
  font-size: 13px; font-weight: 600; min-height: 38px;
}
.del-btn:hover { color: var(--no); border-color: var(--no); filter: none; }

.foot { text-align: center; color: var(--muted); padding: 30px 0; font-size: 13px; }

/* ---------- Mobile ---------- */
@media (max-width: 680px) {
  main { padding: 14px 12px 24px; }

  .topbar { padding: 11px 14px; gap: 10px; }
  .brand { font-size: 16px; }
  .pseudo-zone { flex: 1; }
  .pseudo-zone input { flex: 1; min-width: 0; font-size: 16px; }

  .intro { font-size: 14px; }

  /* 1 colonne, cartes pleine largeur */
  .grid { grid-template-columns: 1fr; gap: 14px; }

  .card-name { font-size: 16px; }
  .thumb-name { font-size: 26px; padding: 18px 10px; }

  /* Boutons de vote : tactiles, texte court sur 2 lignes si besoin */
  .votes { gap: 5px; }
  .votes button { font-size: 12.5px; padding: 8px 4px; min-height: 46px; }
  .fav-btn { min-height: 44px; }

  .tally { flex-wrap: wrap; gap: 6px 12px; font-size: 12px; }

  /* Champs : 16px pour éviter le zoom auto iOS */
  .proposer-body input[type="text"],
  .comment-add input { font-size: 16px; }
  .comment-add { flex-wrap: wrap; }
  .comment-add input { flex: 1 1 100%; }
  .comment-add button { width: 100%; min-height: 42px; }

  /* Classement plus compact */
  .row { grid-template-columns: 22px 1fr; gap: 8px 10px; padding: 9px 11px; }
  .row > .meta:last-child {
    grid-column: 2; justify-self: start; margin-top: 2px;
    color: var(--accent); font-weight: 600;
  }
  .row .meta { font-size: 12px; }

  .block-head h2 { font-size: 19px; }
  .refresh { padding: 7px 11px; font-size: 13px; }
}

/* Désactive l'effet hover sur écrans tactiles (évite l'état "collé") */
@media (hover: none) {
  button:hover { filter: none; }
}

/* ── Bouton d'installation PWA ── */
.install-btn {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  right: 16px;
  display: none;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  color: #0b1120;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  z-index: 100;
  animation: installPulse 2.2s ease-in-out 1s 2;
}
.install-btn svg { display: block; }
@keyframes installPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); box-shadow: 0 10px 30px rgba(251, 191, 36, 0.5); }
}

/* ── Modale d'installation iOS ── */
#ios-install {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  align-items: flex-end;
  justify-content: center;
}
#ios-install.open { display: flex; }
.ios-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 18px 18px 0 0;
  padding: 24px 22px calc(32px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 500px;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.ios-card h3 { margin: 0 0 6px; color: var(--accent); font-size: 1.15rem; }
.ios-card .ios-close {
  position: absolute; top: 14px; right: 16px;
  background: transparent; border: none; font-size: 1.4rem;
  cursor: pointer; color: var(--muted);
}
.ios-steps { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: ios; }
.ios-steps li {
  counter-increment: ios;
  padding: 10px 0 10px 42px;
  position: relative;
  font-size: 0.93rem;
  color: var(--text);
  line-height: 1.5;
  border-bottom: 1px solid var(--card-line);
}
.ios-steps li:last-child { border-bottom: none; }
.ios-steps li::before {
  content: counter(ios);
  position: absolute; left: 0; top: 10px;
  width: 28px; height: 28px;
  background: var(--accent); color: #0b1120;
  border-radius: 50%; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
}
.ios-steps strong { color: var(--accent); }
