/* Pages de jeu du Clic Réflexe : solo, multijoueur, défi du jour.
   Ces règles étaient recopiées dans un <style> de chaque page. */

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

body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: linear-gradient(135deg, #431407, #7c2d12, #1c0a00);
  color: #e0e0e0;
  padding: 16px;
}

#app {
  position: relative; z-index: 1;
  background: rgba(20, 20, 35, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 28px 24px 24px;
  max-width: 700px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  text-align: center;
}
/* Défi du jour : 800 px au minimum, comme toutes les pages de défi du réseau */
.page-defi #app { max-width: 800px; }

h1.titre-page { font-size: 1.35rem; font-weight: 800; color: #f1f5f9; margin-bottom: 6px; }
h1.titre-page span { color: #fb923c; }
.sous-titre-page { color: #94a3b8; font-size: 0.88rem; margin-bottom: 14px; }

.top-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.back-link { font-size: 0.85rem; color: #fb923c; text-decoration: none; font-weight: 600; transition: color 0.2s; }
.back-link:hover { color: #fdba74; }
.top-bar-droite { display: flex; align-items: center; gap: 10px; color: #94a3b8; font-size: 0.85rem; }
.btn-son {
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 1.1rem;
  background: rgba(100,116,139,0.15); border: 1px solid rgba(100,116,139,0.3); color: #e2e8f0;
}
.btn-son:hover { background: rgba(100,116,139,0.28); }

.game-info { margin-bottom: 12px; color: #94a3b8; font-size: 0.9rem; }
.game-info span { color: #fb923c; font-weight: 700; }

/* Badges rounds (solo) */
.rounds-list { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
.round-badge {
  min-width: 44px; height: 44px; padding: 0 4px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: #94a3b8;
  background: rgba(100,116,139,0.15); border: 1px solid rgba(100,116,139,0.25);
  transition: all 0.3s;
}
.round-badge.fait { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.3); color: #4ade80; }
.round-badge.echec { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.3); color: #f87171; }
.round-badge.actif { border-color: #fb923c; background: rgba(249,115,22,0.12); color: #fb923c; }

/* Zone de jeu : elle occupe la hauteur disponible, pour qu'on la touche sans viser. */
.reaction-zone {
  width: 100%;
  min-height: clamp(260px, calc(100dvh - 330px), 520px);
  border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background .15s;
  font-size: 1.5rem; font-weight: 700; color: #fff; margin: 12px 0;
}
.reaction-zone.etat-attente,
.reaction-zone.etat-message { background: rgba(100,116,139,0.12); border: 2px dashed rgba(249,115,22,0.25); }
.reaction-zone.etat-message { cursor: default; }
.reaction-zone.etat-rouge { background: linear-gradient(135deg, #991b1b, #dc2626); border: 2px solid #ef4444; }
/* Pas de transition vers le vert : il doit apparaître d'un coup, à l'image mesurée. */
.reaction-zone.etat-vert { background: #16a34a; border: 2px solid #4ade80; transition: none; }
.reaction-zone.etat-trop-tot { background: linear-gradient(135deg, #7c2d12, #ea580c); border: 2px solid #f97316; }
.reaction-zone.etat-interrompu { background: rgba(100,116,139,0.25); border: 2px solid rgba(148,163,184,0.5); }
.reaction-zone.etat-resultat,
.reaction-zone.etat-fin { background: rgba(100,116,139,0.12); border: 2px solid rgba(249,115,22,0.25); }
.reaction-zone .instruction { font-size: 1rem; font-weight: 400; color: rgba(255,255,255,0.75); margin-top: 8px; max-width: 30em; }
.reaction-zone .decompte { font-size: 4rem; }

.aide-clavier { color: #64748b; font-size: 0.78rem; margin-top: -4px; }
.aide-clavier kbd { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; padding: 1px 6px; font-family: inherit; }
@media (pointer: coarse) { .aide-clavier { display: none; } }

/* Overlay résultats : il défile quand l'écran est trop bas (mobile en paysage, petit
   téléphone) ; en position fixe sans overflow, le score et les boutons sortaient de l'écran. */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(8px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px;
}
.overlay.visible { display: flex; }
.overlay-card {
  margin: auto;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(249,115,22,0.2); border-radius: 20px;
  padding: 26px 24px; max-width: 440px; width: 100%; text-align: center;
}
.overlay-card h2 { font-size: 1.3rem; color: #f1f5f9; margin-bottom: 4px; }
.score-big { font-size: 3rem; font-weight: 800; color: #fb923c; margin: 10px 0 2px; line-height: 1.1; }
.score-label { color: #94a3b8; font-size: 0.9rem; }
.res-stats { display: flex; justify-content: center; gap: 18px; margin-top: 10px; color: #94a3b8; font-size: 0.85rem; }
.res-stats strong { color: #e2e8f0; }
.detail-rounds { margin: 16px 0; text-align: left; }
.detail-round { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid rgba(249,115,22,0.08); color: #cbd5e1; font-size: 0.88rem; }
.detail-round .val { color: #fb923c; font-weight: 600; }
.detail-round .best { color: #4ade80; }
.overlay-btns { margin-top: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.btn-overlay { display: inline-block; padding: 11px 24px; border-radius: 30px; font-weight: 700; cursor: pointer; border: none; font-size: 0.95rem; transition: transform .15s; text-decoration: none; font-family: inherit; }
.btn-overlay:hover { transform: scale(1.05); }
.btn-overlay:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary-ov { background: linear-gradient(135deg, #c2410c, #ea580c); color: #fff; }
.btn-secondary-ov { background: rgba(100,116,139,0.2); color: #cbd5e1; border: 1px solid rgba(100,116,139,0.3); }

.save-msg { margin-top: 10px; font-size: 0.85rem; color: #4ade80; }
.save-msg.erreur { color: #f87171; }

.auth-cta { margin-top: 14px; padding: 14px 16px; border-radius: 14px; background: rgba(249,115,22,0.08); border: 1px solid rgba(249,115,22,0.18); }
.auth-cta .auth-cta-alerte { color: #f87171; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; }
.auth-cta p { color: #cbd5e1; font-size: 0.86rem; margin-bottom: 10px; }
.auth-cta .btn-cta-inscription { display: inline-block; padding: 10px 24px; border-radius: 12px; background: linear-gradient(135deg, #ea580c, #f97316); color: #fff; font-weight: 700; font-size: 0.92rem; text-decoration: none; box-shadow: 0 4px 15px rgba(249,115,22,0.35); }
.auth-cta .btn-cta-connexion { display: inline-block; margin-top: 8px; color: #94a3b8; font-size: 0.82rem; text-decoration: none; }
.auth-cta .btn-cta-connexion:hover { color: #cbd5e1; text-decoration: underline; }

/* Invitation au défi du jour en fin de partie solo */
.cta-defi { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: linear-gradient(135deg, rgba(251,191,36,0.12), rgba(245,158,11,0.08)); border: 1px solid rgba(251,191,36,0.3); }
.cta-defi p { color: #fcd9a0; font-size: 0.85rem; margin-bottom: 8px; }
.cta-defi a { display: inline-block; padding: 8px 18px; border-radius: 10px; font-weight: 700; font-size: 0.85rem; text-decoration: none; background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #1f1300; }

.hidden { display: none !important; }

/* === Multijoueur === */
h2.titre-salle { font-size: 1.3rem; color: #f1f5f9; margin-bottom: 12px; }
.code-partie { font-size: 2.2rem; font-weight: 800; letter-spacing: 10px; color: #fb923c; font-family: monospace; margin: 12px 0; user-select: all; }
.btn-copier { padding: 7px 18px; border-radius: 20px; border: 1px solid rgba(249,115,22,0.3); background: rgba(249,115,22,0.1); color: #fb923c; cursor: pointer; font-size: 0.82rem; transition: all 0.2s; font-family: inherit; }
.btn-copier:hover { background: rgba(249,115,22,0.2); }
.joueurs-liste { margin: 18px 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.joueur-tag { display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border-radius: 18px; background: rgba(249,115,22,0.08); border: 1px solid rgba(249,115,22,0.18); color: #e2e8f0; font-size: 0.85rem; }
.joueur-tag .dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
.joueur-tag.moi { border-color: #fb923c; font-weight: 700; }
.btn-lancer { padding: 12px 32px; border-radius: 30px; background: linear-gradient(135deg, #c2410c, #ea580c); color: #fff; font-weight: 700; font-size: 1rem; border: none; cursor: pointer; margin-top: 14px; transition: transform .15s; font-family: inherit; text-decoration: none; display: inline-block; }
.btn-lancer:hover { transform: scale(1.05); }
.btn-lancer:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-lancer.secondaire { background: rgba(100,116,139,0.2); color: #cbd5e1; border: 1px solid rgba(100,116,139,0.3); }
.msg-attente { color: #94a3b8; font-size: 0.85rem; margin-top: 10px; }
.zone-rejoindre { margin: 18px auto 4px; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.zone-rejoindre input { padding: 11px 14px; border-radius: 12px; border: 1px solid rgba(249,115,22,0.3); background: rgba(255,255,255,0.06); color: #f1f5f9; font-size: 1rem; text-align: center; font-family: inherit; }
.zone-rejoindre input:disabled { opacity: 0.7; }
.zone-rejoindre .btn-lancer { margin-top: 0; }
.erreur-rejoindre, .erreur-multi { color: #f87171; font-size: 0.85rem; min-height: 1em; margin-top: 6px; }

.progression { margin: 8px auto 0; max-width: 420px; text-align: left; }
.progression-ligne { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px solid rgba(249,115,22,0.08); font-size: 0.86rem; color: #e2e8f0; }
.statut-termine { color: #4ade80; }
.statut-en_jeu, .statut-attente { color: #fbbf24; }
.statut-abandon { color: #f87171; }

.classement-final { margin: 16px 0; text-align: left; }
.classement-row { display: grid; grid-template-columns: 36px 1fr 90px 90px; padding: 9px 12px; align-items: center; border-bottom: 1px solid rgba(249,115,22,0.08); color: #e2e8f0; font-size: 0.88rem; }
.classement-row.header { color: #94a3b8; font-weight: 700; font-size: 0.75rem; text-transform: uppercase; background: rgba(249,115,22,0.06); border-radius: 8px 8px 0 0; }
.classement-row.top1 { background: rgba(255,215,0,0.06); }
.classement-row.moi { outline: 1px solid rgba(249,115,22,0.5); }
.classement-row .rank { font-weight: 700; color: #94a3b8; }
.classement-row .temps { color: #fb923c; font-weight: 700; text-align: right; }
.classement-row .meilleur { color: #cbd5e1; text-align: right; }
.revanche-info { color: #fdba74; font-size: 0.88rem; margin-top: 12px; }

/* === Défi du jour === */
.date-defi { font-size: 0.9rem; color: #94a3b8; margin-bottom: 18px; }
.cta-inscription { margin: 16px auto; max-width: 560px; padding: 16px; border-radius: 14px; background: rgba(249,115,22,0.08); border: 1px solid rgba(249,115,22,0.2); }
.cta-inscription p { color: #cbd5e1; font-size: 0.9rem; margin-bottom: 12px; }
.defi-deja-fait { padding: 20px; background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.2); border-radius: 14px; text-align: center; margin-bottom: 16px; }
.defi-deja-fait h3 { color: #4ade80; margin-bottom: 8px; }
.defi-deja-fait .score { font-size: 2.5rem; font-weight: 800; color: #fb923c; }
.defi-deja-fait .label { color: #94a3b8; font-size: 0.9rem; }
.btn-demarrer { padding: 14px 36px; border-radius: 30px; background: linear-gradient(135deg, #c2410c, #ea580c); color: #fff; font-weight: 700; font-size: 1.1rem; border: none; cursor: pointer; transition: transform .15s; font-family: inherit; }
.btn-demarrer:hover { transform: scale(1.05); }
.btn-demarrer:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.avertissement { color: #94a3b8; font-size: 0.85rem; margin-top: 8px; }
.defi-actions { margin-top: 8px; }
#partage-score { margin-top: 12px; }

/* Encadré du classement du jour (même allure que les autres pages de défi du réseau) */
.classement-section {
  margin: 24px auto 0; max-width: 800px; padding: 18px 16px 16px;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 18px;
  background: rgba(148, 163, 184, 0.09); box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  text-align: left;
}
.classement-section h3 { font-size: 1.1rem; font-weight: 700; color: #f1f5f9; margin-bottom: 12px; }
.classement-cta-compte { margin-top: 10px; font-size: 0.82rem; color: #94a3b8; text-align: center; }
.lien-classement-complet { display: block; text-align: center; margin-top: 14px; font-size: 0.85rem; font-weight: 600; color: #94a3b8; text-decoration: none; }
.lien-classement-complet:hover { color: #fb923c; text-decoration: underline; }

/* === Solo : choix du format, record, progression === */
.choix-format { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }
.choix-format .format { padding: 7px 14px; border-radius: 12px; font-size: 0.85rem; font-weight: 700; color: #cbd5e1; text-decoration: none; background: rgba(100,116,139,0.15); border: 1px solid rgba(100,116,139,0.3); }
.choix-format .format span { font-weight: 400; color: #94a3b8; }
.choix-format .format.actif { color: #fff; border-color: #fb923c; background: rgba(249,115,22,0.18); }
body.en-jeu .choix-format { opacity: 0.35; pointer-events: none; }
.mon-record { color: #fdba74; font-size: 0.85rem; margin-bottom: 8px; }
.res-rang { margin-top: 8px; color: #fde68a; font-size: 0.92rem; font-weight: 700; }
.lien-classement-fin { display: inline-block; margin-top: 10px; color: #fb923c; font-size: 0.88rem; font-weight: 600; text-decoration: none; }
.lien-classement-fin:hover { text-decoration: underline; }
.res-percentile { margin-top: 10px; color: #fdba74; font-size: 0.9rem; font-weight: 600; }
.res-progression { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(249,115,22,0.07); border: 1px solid rgba(249,115,22,0.18); color: #cbd5e1; font-size: 0.82rem; }
.courbe { display: block; width: 100%; max-width: 280px; height: 60px; margin: 8px auto 0; }
.courbe polyline { fill: none; stroke: #fb923c; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.courbe circle { fill: #4ade80; }

.presentation-mode { margin: 20px auto 0; max-width: 620px; text-align: left; color: #94a3b8; font-size: 0.88rem; line-height: 1.65; }
.presentation-mode h2 { font-size: 1.05rem; color: #f1f5f9; margin: 14px 0 6px; }
.presentation-mode ul { padding-left: 18px; margin: 6px 0; }
.presentation-mode a { color: #fb923c; }
.presentation-mode kbd, .noms-joueurs kbd, .moitie kbd { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18); border-radius: 4px; padding: 0 6px; font-family: inherit; }

/* === Go/No-Go : le bleu se distingue aussi par le texte et l'icône, pas seulement la couleur === */
.reaction-zone.etat-nogo { background: repeating-linear-gradient(45deg, #1d4ed8, #1d4ed8 18px, #1e40af 18px, #1e40af 36px); border: 2px solid #60a5fa; transition: none; }
.reaction-zone.etat-erreur { background: linear-gradient(135deg, #7c2d12, #ea580c); border: 2px solid #f97316; }
.round-badge.retenu { background: rgba(59,130,246,0.15); border-color: rgba(96,165,250,0.4); color: #93c5fd; }
.serie { margin-top: 8px; color: #fdba74; font-weight: 700; font-size: 0.9rem; }

/* === À deux sur un écran === */
.noms-joueurs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.noms-joueurs label { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: #94a3b8; }
.noms-joueurs input { padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(249,115,22,0.3); background: rgba(255,255,255,0.06); color: #f1f5f9; font-size: 1rem; font-family: inherit; }
.manche-info { color: #94a3b8; font-size: 0.88rem; margin-bottom: 8px; }
.duo { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 0; min-height: clamp(280px, calc(100dvh - 300px), 540px); border-radius: 20px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; background: rgba(100,116,139,0.12); border: 2px solid rgba(249,115,22,0.25); }
.moitie { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; padding: 16px 10px; cursor: pointer; }
.moitie + .moitie { border-left: 2px dashed rgba(255,255,255,0.25); }
.moitie-nom { font-weight: 800; color: #f1f5f9; font-size: 1rem; }
.moitie-score { font-size: 2.4rem; font-weight: 800; color: #fb923c; line-height: 1; }
.moitie-touche { font-size: 0.75rem; color: rgba(255,255,255,0.7); }
.duo-message { position: absolute; left: 0; right: 0; bottom: 18%; display: flex; flex-direction: column; align-items: center; pointer-events: none; padding: 0 12px; font-size: 1.4rem; font-weight: 800; color: #fff; text-align: center; }
.duo-message .instruction { font-size: 0.95rem; font-weight: 400; color: rgba(255,255,255,0.85); margin-top: 6px; }
.duo.etat-rouge { background: linear-gradient(135deg, #991b1b, #dc2626); border-color: #ef4444; }
.duo.etat-vert { background: #16a34a; border-color: #4ade80; }
.duo.etat-gagne-0 .moitie:first-child, .duo.etat-gagne-1 .moitie:last-child { background: rgba(34,197,94,0.25); }
@media (pointer: coarse) { .moitie-touche kbd { display: none; } }

/* === Duel en ligne === */
.duel-bloc { margin: 8px auto 0; max-width: 480px; }
.duel-choix { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.duel-code { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.duel-code input { width: 110px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(249,115,22,0.3); background: rgba(255,255,255,0.06); color: #f1f5f9; font-size: 1.1rem; text-align: center; text-transform: uppercase; letter-spacing: 4px; font-family: monospace; }
.duel-code .btn-lancer { margin-top: 0; }
.duel-tableau { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 6px; }
.duel-joueur { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 110px; }
.duel-nom { font-weight: 800; color: #f1f5f9; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-points { display: flex; gap: 5px; }
.duel-points .point { width: 12px; height: 12px; border-radius: 50%; background: rgba(148,163,184,0.25); }
.duel-points .point.gagne { background: #fb923c; }
.duel-contre { color: #64748b; font-size: 0.8rem; }
.duel-statut { color: #fdba74; font-size: 0.85rem; min-height: 1.2em; }

footer { margin-top: 24px; }
footer p { color: #64748b; font-size: 0.75rem; }
footer a { color: #94a3b8; text-decoration: none; }

/* Mobile : le haut de page dégage la barre de compte repliée (sans toucher au padding
   horizontal de #app, dont dépendent les marges négatives du bandeau). */
@media (max-width: 600px) {
  body { padding: 44px 8px 16px; }
  #app { padding-top: 22px; padding-bottom: 18px; }
  .classement-row { grid-template-columns: 28px 1fr 74px 74px; padding: 9px 6px; }
}

/* Téléphone en paysage : la zone de jeu doit tenir dans l'écran dès le départ. */
@media (orientation: landscape) and (max-height: 500px) {
  body { padding-top: 8px; }
  .jeu-banner { display: none; }
  .game-info { margin-bottom: 4px; }
  .rounds-list { margin-bottom: 4px; }
  .round-badge { height: 30px; min-width: 34px; }
  .reaction-zone { min-height: calc(100dvh - 150px); margin: 6px 0; }
  .duo { min-height: calc(100dvh - 90px); }
  .titre-page, .manche-info { display: none; }
  .score-big { font-size: 2.2rem; }
}
