/*
 * Casse-brique : pages où l'on joue (solo, défi, semaine, classique,
 * entraînement, duels) et zone de jeu.
 *
 * Contraintes du réseau :
 *   - #app reste à 800 px hors partie : au-delà, les blocs latéraux fixes
 *     (Infos, Jeux à la une) recouvrent le contenu dès 1280 px.
 *   - padding horizontal de #app jamais sous 24 px : le banner partagé sort
 *     du conteneur avec des marges négatives calées sur cette valeur.
 *
 * Pendant une partie (body.cb-en-partie), la zone de jeu occupe toute la
 * fenêtre, au-dessus de la barre de compte : le plateau se cale sur la
 * hauteur disponible et rien ne le recouvre, sur tous les écrans.
 */

* { box-sizing: border-box; }

body.page-casse-brique {
  margin: 0;
  background: radial-gradient(120% 80% at 50% 0%, #2a1a10 0%, #17120f 55%, #0e0c0b 100%);
  color: #f1e9e2;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.page-casse-brique #app {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.page-casse-brique h1 { font-size: 1.6rem; color: #fdba74; margin: 8px 0 12px; text-align: center; }
.page-casse-brique h2 { font-size: 1.1rem; color: #fb923c; margin: 18px 0 8px; }
.page-casse-brique #app a { color: #fcd34d; }
.page-casse-brique footer { text-align: center; font-size: 0.82rem; color: #a8a29e; margin-top: 30px; line-height: 1.7; }
.page-casse-brique #app footer a { color: #d6ccc4; }

.setup-intro {
  color: #d6ccc4;
  line-height: 1.6;
  font-size: 0.95rem;
  text-align: center;
  margin: 0 auto 18px;
  max-width: 62ch;
}
.message-partie { min-height: 1.2em; text-align: center; color: #fcd34d; font-size: 0.92rem; margin: 10px 0; }
.date-titre { text-align: center; color: #fdba74; margin: 0 0 16px; font-weight: 600; }
.liens-modes { text-align: center; margin: 22px 0 6px; line-height: 1.9; font-size: 0.93rem; }

/* ---- Boutons ------------------------------------------------------------- */
.cb-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0 0; }
.cb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 20px;
  border: 0;
  border-radius: 12px;
  background: #ea580c;
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
}
.page-casse-brique #app a.cb-btn, .cb-jeu a.cb-btn { color: #fff; }
.cb-btn.secondaire { background: rgba(255, 255, 255, 0.12); }
.cb-btn-grand { min-height: 56px; padding: 12px 34px; font-size: 1.15rem; }
.cb-btn:focus-visible { outline: 3px solid #fde68a; outline-offset: 2px; }
.cb-btn[hidden] { display: none; }
.cb-btn:disabled { opacity: 0.55; cursor: default; }

/* ---- Écran d'avant-partie ------------------------------------------------ */
.cb-campagne {
  max-width: 460px;
  margin: 0 auto 6px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.35);
  text-align: center;
  line-height: 1.6;
}
.cb-campagne p { margin: 4px 0; }
.cb-campagne-titre { font-weight: 800; color: #fdba74; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.8rem; }
.cb-alerte { color: #fca5a5; font-size: 0.9rem; }
.cb-erreur { color: #fca5a5; text-align: center; }
.cb-info-ok { color: #86efac; text-align: center; font-size: 0.92rem; }
.cb-etat { text-align: center; font-size: 1rem; margin: 6px 0; line-height: 1.5; }
.cb-etat strong, .cb-campagne strong { color: #fde68a; }
.cb-records { text-align: center; color: #d6ccc4; font-size: 0.9rem; margin: 16px 0 0; line-height: 1.6; }

.cb-liste-niveaux { list-style: none; padding: 0; margin: 10px auto 0; max-width: 460px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 0.92rem; }
.cb-niveau { padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); color: #d6ccc4; }
.cb-niveau.fait { color: #86efac; }
.cb-niveau.courant { background: rgba(249, 115, 22, 0.2); color: #fff; font-weight: 700; }
.cb-niveau-num { display: inline-block; min-width: 1.4em; font-weight: 800; color: #fdba74; }

.cb-choix-niveaux { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 12px 0 10px; }
.cb-niveau-carte {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 104px; padding: 12px 10px;
  border-radius: 14px; border: 2px solid #c2410c; background: #2a1a10; color: #f1e9e2;
  font: inherit; cursor: pointer; text-align: center;
}
.cb-niveau-carte:hover, .cb-niveau-carte:focus-visible { background: #3a2415; outline: none; border-color: #fdba74; }
.cb-niveau-carte.verrouille { opacity: 0.55; cursor: not-allowed; border-style: dashed; }
.cb-niveau-carte .cb-niveau-num { font-size: 1.6rem; line-height: 1; }
.cb-niveau-nom { font-weight: 700; font-size: 0.95rem; }
.cb-niveau-info { font-size: 0.8rem; color: #d6ccc4; }

/* Choix de la difficulté (contre l'ordinateur) et salon (duel en ligne) */
.cb-difficultes { display: grid; gap: 12px; max-width: 460px; margin: 14px auto; }
.cb-difficulte {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 14px 18px; border-radius: 14px; border: 0; color: #fff; font: inherit; cursor: pointer;
}
.cb-difficulte strong { font-size: 1.05rem; }
.cb-difficulte span { font-size: 0.85rem; opacity: 0.9; }
.cb-difficulte.facile { background: linear-gradient(135deg, #059669, #10b981); }
.cb-difficulte.normal { background: linear-gradient(135deg, #f97316, #ea580c); }
.cb-difficulte.difficile { background: linear-gradient(135deg, #dc2626, #991b1b); }
.cb-difficulte:focus-visible { outline: 3px solid #fde68a; outline-offset: 2px; }

.cb-salon { max-width: 460px; margin: 0 auto; padding: 18px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); text-align: center; }
.cb-salon-statut { min-height: 1.5em; margin: 0 0 12px; line-height: 1.5; }
/* minmax(0, 1fr) : sans lui la colonne prend la largeur naturelle du champ et déborde sur téléphone. */
.cb-salon-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.cb-salon-actions[hidden], .cb-salon-prive[hidden] { display: none; }
.cb-salon-code { display: flex; gap: 8px; }
.cb-salon-code input {
  flex: 1 1 0; min-width: 0; width: 100%; text-align: center; text-transform: uppercase; letter-spacing: 0.2em;
  font: inherit; font-weight: 800; font-size: 1.05rem; padding: 10px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.3); color: #fde68a;
}
.cb-salon-code .cb-btn { flex: 1 1 0; min-width: 0; background: #059669; }
.cb-salon-prive { margin: 6px 0 12px; }
.cb-code { display: inline-block; font-size: 2rem; font-weight: 900; letter-spacing: 0.25em; color: #fde68a; background: rgba(251, 191, 36, 0.12); padding: 8px 18px 8px 24px; border-radius: 12px; }
.cb-rond { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #f97316; vertical-align: -2px; animation: cb-tourne 0.8s linear infinite; }
@keyframes cb-tourne { to { transform: rotate(360deg); } }
.cb-pseudo-visiteur { text-align: center; color: #a8a29e; font-size: 0.85rem; margin: 0 0 12px; }

/* Encadré explicatif du défi et cadre du classement du jour (convention des pages de défi) */
.defi-intro {
  margin: 18px 0; padding: 14px 18px; border-radius: 14px;
  background: rgba(249, 115, 22, 0.07); border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.55; font-size: 0.95rem;
}
.defi-intro h2 { margin-top: 0; }
.defi-intro ul { padding-left: 20px; margin: 8px 0 0; }
.defi-intro li { margin: 4px 0; }
.defi-compte { text-align: center; margin: 14px 0 20px; line-height: 1.5; }
.classement-section {
  max-width: 800px; margin: 24px auto 10px; padding: 16px 18px;
  background: rgba(148, 163, 184, 0.09); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.classement-section[hidden] { display: none; }
.classement-section h3 { margin: 0 0 10px; text-align: center; color: #fdba74; }
.classement-invite, .classement-lien { text-align: center; font-size: 0.9rem; margin: 10px 0 0; }

/* Pastilles du banner : trois briques */
.deco-banner.brique-a, .deco-banner.brique-b, .deco-banner.brique-c { width: 30px; height: 14px; border-radius: 3px; }
.deco-banner.brique-a { background: #ef4444; }
.deco-banner.brique-b { background: #f97316; }
.deco-banner.brique-c { background: #fbbf24; }

/* ========================================================================== */
/* Zone de jeu                                                                */

.cb-jeu { display: none; }
body.cb-en-partie { overflow: hidden; }
body.cb-en-partie .cb-jeu {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 2000;               /* au-dessus de la barre de compte (1000), sous les annonces du site */
  background: #0b0d14;
  color: #f1e9e2;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.cb-hud {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: max(4px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 4px max(10px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  font-size: 0.95rem;
}
.cb-vies { display: flex; gap: 4px; align-items: center; flex: none; }
.cb-vie { width: 18px; height: 7px; border-radius: 4px; background: linear-gradient(90deg, #f97316, #fbbf24); }
.cb-vie.perdue { background: rgba(255, 255, 255, 0.14); }
.cb-vie-plus { font-size: 0.8rem; color: #fde68a; }
.cb-titre { flex: 1 1 auto; min-width: 0; text-align: center; color: #fdba74; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-score { flex: none; color: #fde68a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cb-score-lib { color: #a8a29e; font-weight: 600; }
.cb-combo { display: inline-block; margin-right: 10px; padding: 2px 8px; border-radius: 999px; background: rgba(251, 191, 36, 0.18); color: #fbbf24; font-size: 0.85rem; }
.cb-combo.max { background: rgba(239, 68, 68, 0.25); color: #fca5a5; }
.cb-combo[hidden] { display: none; }
.cb-outils { display: flex; gap: 6px; flex: none; }
.cb-outils button {
  width: 44px; height: 44px; padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 12px;
  background: rgba(255, 255, 255, 0.06); color: #fff; font-size: 19px; line-height: 1; cursor: pointer;
}
.cb-outils button[hidden] { display: none; }
.cb-outils button:focus-visible { outline: 3px solid #fde68a; outline-offset: 2px; }

/* Le plateau : centré, calé en hauteur par le script. La zone entière reçoit
 * la souris et le doigt, y compris sous le plateau. */
.cb-zone {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  touch-action: none;
  cursor: crosshair;
}
.cb-zone canvas { display: block; border-radius: 8px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1); touch-action: none; }

.cb-revoir {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 3;
  min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(15, 23, 42, 0.92); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.cb-revoir[hidden] { display: none; }

/* ---- Voiles (début, pause, fin, décompte, rotation) ---------------------- */
.cb-voile {
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
  background: rgba(5, 6, 12, 0.72);
  -webkit-user-select: text; user-select: text;
}
.cb-voile[hidden] { display: none; }
.cb-carte {
  position: relative;
  max-width: 460px; width: 100%; max-height: 100%; overflow: auto;
  padding: 22px 22px 20px;
  border-radius: 18px;
  background: #1c1917;
  border: 1px solid rgba(253, 186, 116, 0.45);
  text-align: center;
}
.cb-carte h2 { margin: 0 0 8px; font-size: 1.45rem; color: #fdba74; }
.cb-carte p { margin: 6px 0; line-height: 1.5; }
.cb-carte a { color: #fcd34d; }
.cb-sous-titre { color: #d6ccc4; }
.cb-note { font-size: 0.86rem; color: #a8a29e; }
.cb-commandes { font-size: 0.9rem; color: #d6ccc4; }
.cb-commandes kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.08); font: inherit; font-size: 0.85em;
}
.cb-jeu.mode-tactile .cb-clavier-seul { display: none; }
.cb-jeu:not(.mode-tactile) .cb-tactile-seul { display: none; }
.cb-fermer {
  position: absolute; top: 6px; right: 6px; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: none; color: #a8a29e; font-size: 26px; line-height: 1; cursor: pointer;
}
.cb-fermer:hover, .cb-fermer:focus-visible { color: #fff; background: rgba(255, 255, 255, 0.1); outline: none; }

.cb-fin-titre.gagne { color: #86efac; }
.cb-fin-titre.perdu { color: #fca5a5; }
.cb-fin-score { font-size: 2rem; font-weight: 900; color: #fde68a; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.cb-fin-score small { font-size: 0.95rem; font-weight: 600; color: #d6ccc4; }
.cb-fin-detail { color: #d6ccc4; font-size: 0.92rem; }
.cb-fin-statut { min-height: 1.3em; font-size: 0.93rem; }
.cb-fin-statut.attente { color: #a8a29e; }
.cb-fin-statut.ok { color: #e7e5e4; }
.cb-fin-statut.erreur { color: #fca5a5; }
.cb-fin-statut strong { color: #fde68a; }
.cb-record { color: #86efac; font-weight: 800; }
.cb-lien-classement { font-weight: 700; }
.cb-fin-duel { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 10px 0; }
.cb-fin-duel span { display: flex; flex-direction: column; min-width: 0; }
.cb-fin-duel small { color: #a8a29e; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.cb-fin-duel strong { font-size: 1.7rem; color: #fde68a; font-variant-numeric: tabular-nums; }
.cb-fin-duel .cb-fin-vs { color: #a8a29e; font-size: 0.85rem; }
.cb-carte .partage-score { margin-top: 12px; }
/* Encart « défi du jour » (module partagé) : son bouton garde un texte sombre sur fond doré. */
.cb-carte a.cta-ddj-btn { color: #1f1300; font-weight: 800; border-radius: 10px; }
.cb-carte #cta-defi-du-jour { margin: 12px 0 4px; padding: 12px; }

.cb-tourner { background: #0b0d14; z-index: 6; flex-direction: column; text-align: center; }
.cb-tourner .icone { font-size: 56px; display: block; margin-bottom: 8px; }

/* ---- Duel ---------------------------------------------------------------- */
.cb-hud-duel { justify-content: space-between; }
.cb-camp { display: flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 0; }
.cb-camp.adv { justify-content: flex-end; }
.cb-nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cb-camp.moi .cb-nom { color: #86efac; }
.cb-camp.adv .cb-nom { color: #fca5a5; }
.cb-points { color: #fde68a; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.cb-chrono { flex: none; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.cb-chrono.urgent { background: rgba(239, 68, 68, 0.3); color: #fecaca; }

.cb-plateaux { flex: 1 1 auto; min-height: 0; display: flex; gap: 10px; padding: 0 6px; }
.cb-plateaux .cb-zone { flex: 1 1 0; padding-left: 0; padding-right: 0; }
.cb-zone-adv { flex: 1 1 0; min-width: 0; min-height: 0; display: flex; align-items: flex-start; justify-content: center; padding: 6px 0; }
.cb-zone-adv canvas { display: block; border-radius: 8px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1); }

.cb-annonce {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 3;
  margin: 0; padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 0.95rem; white-space: nowrap;
  pointer-events: none; max-width: 94vw; overflow: hidden; text-overflow: ellipsis;
}
.cb-annonce[hidden] { display: none; }
.cb-annonce.recu { background: rgba(220, 38, 38, 0.95); color: #fff; }
.cb-annonce.envoye { background: rgba(34, 197, 94, 0.95); color: #052e16; }

.cb-decompte .cb-carte { background: none; border: 0; }
.cb-affiche { font-size: 1.2rem; font-weight: 800; color: #fff; }
.cb-affiche small { color: #a8a29e; font-weight: 600; margin: 0 6px; }
.cb-chiffre { font-size: 6rem; font-weight: 900; color: #fbbf24; line-height: 1; margin: 6px 0; }

/* Écran étroit : le plateau adverse devient une vignette dans la barre du haut. */
@media (max-width: 820px) {
  .cb-hud-duel { flex-wrap: wrap; row-gap: 2px; padding-right: 92px; min-height: 110px; align-content: center; position: relative; }
  .cb-hud-duel .cb-camp { flex: 1 1 100%; justify-content: flex-start; }
  .cb-hud-duel .cb-camp.adv { flex-direction: row-reverse; justify-content: flex-end; }
  .cb-hud-duel .cb-chrono { order: 3; }
  .cb-hud-duel .cb-outils { order: 4; margin-left: auto; }
  .cb-plateaux { display: block; position: static; padding: 0; }
  .cb-plateaux .cb-zone { height: 100%; padding: 6px 6px max(6px, env(safe-area-inset-bottom)); }
  .cb-zone-adv { position: absolute; top: max(4px, env(safe-area-inset-top)); right: 6px; width: 84px; height: 100px; padding: 0; z-index: 2; }
  .cb-duel { position: relative; }
  .cb-duel .cb-plateaux { flex: 1 1 auto; min-height: 0; }
  .cb-annonce { top: 118px; }
}

@media (max-width: 520px) {
  .cb-hud { gap: 6px; font-size: 0.85rem; }
  .cb-score-lib { display: none; }
  .cb-outils button { width: 44px; height: 44px; }
  .cb-vie { width: 13px; }
  .cb-liste-niveaux { grid-template-columns: 1fr; }
}
@media (max-height: 460px) {
  .cb-carte { padding: 12px 16px; }
  .cb-carte h2 { font-size: 1.15rem; margin-bottom: 4px; }
  .cb-btn { min-height: 40px; padding: 6px 14px; font-size: 0.92rem; }
  .cb-chiffre { font-size: 3.5rem; }
}
