/* =====================================================================
   Bingo photo – styles (direction artistique terracotta)
   ===================================================================== */
:root {
  --umber: #3D1C12;      /* fond principal joueur, en-têtes */
  --umber-2: #4A2317;    /* cases vides */
  --umber-3: #5C2D1E;    /* pistes, chips */
  --star: #6E3825;
  --sand: #FBEFE6;       /* cases à trouver */
  --paper: #FFFBF8;      /* panneaux organisateurs */
  --page: #F6ECE4;       /* fond organisateurs */
  --clay: #E07A52;       /* accent */
  --terra: #A84A2C;      /* boutons principaux */
  --terra-dark: #7D3A22;
  --brick: #A3301A;      /* refus, danger */
  --brick-soft: #FBE1D6;
  --on-dark: #E9CDBD;    /* texte secondaire sur fond sombre */
  --muted: #6B4A3D;      /* texte secondaire sur fond clair */
  --line: #E3CBBB;
  --line-2: #EEDFD4;
  --display: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif;
  --text: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--text); }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 3px solid var(--clay); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { flex: none; }

/* ---------------------------------------------------------------------
   Boutons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 2px solid transparent;
  font-weight: 700; font-size: 15px; text-decoration: none; line-height: 1.15;
}
.btn--primary { background: var(--terra); color: #fff; }
.btn--primary:hover { background: var(--terra-dark); }
.btn--outline { background: var(--paper); color: var(--terra); border-color: var(--terra); }
.btn--soft { background: #F1E0D4; color: var(--umber); }
.btn--danger { background: var(--brick); color: #fff; }
.btn--small { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn--ghost-danger { background: transparent; color: #F6C2AA; border-color: #F2A585; min-height: 44px; font-size: 14px; }
.btn--ghost-danger:hover { background: var(--umber-3); }

/* ---------------------------------------------------------------------
   Toast
   --------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%);
  z-index: 50; max-width: min(520px, calc(100vw - 32px));
  background: var(--umber); color: #fff; padding: 12px 16px; border-radius: 14px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(30, 12, 6, .3);
}
.toast--error { background: var(--brick); }

/* =====================================================================
   PAGE JOUEUR
   ===================================================================== */
body.player {
  background: var(--umber); color: #fff;
  min-height: 100vh; min-height: 100dvh;
}
body.player.in-game { height: 100vh; height: 100dvh; overflow: hidden; }
.boot { margin: 0; padding: 40px; text-align: center; color: var(--on-dark); }

/* ---- Accueil ---- */
.landing {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 24px 44px;
  padding: calc(24px + var(--safe-t)) calc(24px + var(--safe-r)) calc(24px + var(--safe-b)) calc(24px + var(--safe-l));
}
.landing__intro { flex: 1 1 320px; max-width: 440px; display: flex; flex-direction: column; gap: 14px; }
.landing__event { margin: 0; color: var(--clay); font-weight: 700; font-size: 14px; }
.landing__title { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(40px, 7vw, 60px); line-height: 1; color: var(--sand); }
.landing__text { margin: 0; color: var(--on-dark); font-size: 15px; line-height: 1.45; max-width: 380px; }
.steps { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 18px; color: var(--on-dark); font-size: 13px; }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps span { display: inline-flex; width: 24px; height: 24px; border-radius: 12px; background: var(--clay); color: var(--umber); font-weight: 700; align-items: center; justify-content: center; }
.landing__card {
  flex: 0 1 340px; background: var(--sand); color: var(--umber);
  border-radius: 18px; padding: 24px; display: flex; flex-direction: column; gap: 12px;
}
.landing__card label { font-weight: 700; font-size: 14px; }
.landing__card input {
  height: 48px; border: 2px solid var(--line); border-radius: 12px; padding: 0 14px;
  font-size: 16px; background: #fff; color: var(--umber);
}
.landing__card input:focus { border-color: var(--terra); outline: none; }
.landing__note { margin: 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.form-error { margin: 0; font-size: 13px; line-height: 1.4; color: var(--brick); font-weight: 700; }

/* ---- Jeu ---- */
.game {
  display: flex; height: 100%;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}
.rail {
  flex: 0 0 clamp(124px, 17vw, 200px);
  padding: 14px 10px 14px 16px;
  display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden;
}
.rail__logo { margin: 0; font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1; color: var(--clay); }
.rail__logo span { color: var(--sand); }
.rail__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rail__label { font-size: 11px; color: var(--on-dark); }
.rail__pseudo { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail__score { display: flex; flex-direction: column; gap: 5px; }
.rail__big { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 800; line-height: 1.1; }
.rail__big small { font-family: var(--text); font-size: 12px; font-weight: 400; color: var(--on-dark); }
.rail__line { margin: 0; font-size: 12px; color: var(--on-dark); }
.rail__alert {
  align-self: flex-start; margin: 2px 0 0; display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 10px; background: var(--sand); color: var(--brick);
  font-size: 11px; font-weight: 700;
}
.rail__done { margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--clay); color: var(--umber); font-weight: 700; font-size: 13px; line-height: 1.25; }
.rail__hint { margin: auto 0 0; font-size: 11px; line-height: 1.4; color: var(--on-dark); }

.bar { height: 6px; border-radius: 3px; background: var(--umber-3); overflow: hidden; }
.bar__fill { height: 100%; width: 0; background: var(--clay); border-radius: 3px; transition: width .4s ease; }

.grid {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(4px, .8vw, 8px);
  padding: 10px 10px 10px 0;
}

.cell {
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  border-radius: 10px; border: none; padding: 0; text-align: left;
  font-size: clamp(10px, min(1.5vw, 3.1vh), 16px); line-height: 1.22;
  hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere;
}
.cell--empty { background: var(--umber-2); color: var(--star); display: flex; align-items: center; justify-content: center; }
.cell--todo {
  background: var(--sand); color: var(--umber); padding: 8px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 4px;
}
.cell--todo .cell__text { font-weight: 700; }
.cell__cam {
  align-self: flex-end; display: inline-flex; width: 26px; height: 26px; border-radius: 13px;
  background: var(--clay); color: var(--umber); align-items: center; justify-content: center;
}
.cell--refused {
  background: var(--sand); color: var(--umber); border: 2px solid var(--brick); padding: 6px 7px;
  display: flex; flex-direction: column; gap: 4px;
}
.cell--refused .cell__text { font-weight: 700; font-size: .92em; flex: 1 1 auto; overflow: hidden; }
.cell__link { font-size: .85em; font-weight: 700; color: var(--brick); text-decoration: underline; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
  padding: 2px 7px; border-radius: 9px; font-size: 10px; font-weight: 700; line-height: 1.4;
}
.chip--refused { background: var(--brick); color: #fff; }
.chip--pending { position: absolute; top: 6px; left: 6px; background: var(--umber); color: #fff; }
.cell--photo { background: var(--umber-3); color: #fff; }
.cell__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cell--photo.is-pending .cell__img { filter: grayscale(1) brightness(.9); opacity: .6; }
.cell--photo.is-valid { box-shadow: inset 0 0 0 2px var(--clay); }
.cell__badge {
  position: absolute; top: 5px; right: 5px; display: inline-flex; width: 24px; height: 24px; border-radius: 12px;
  background: var(--clay); color: var(--umber); align-items: center; justify-content: center;
}
.cell__caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 5px 7px;
  background: rgba(45, 20, 12, .85); font-size: .82em; line-height: 1.2; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cell__progress {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(45, 20, 12, .82); color: #fff; font-size: 11px; font-weight: 700; text-align: center;
}
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .3); border-top-color: var(--clay); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .bar__fill { transition: none; } }

/* ---- Portrait : demander de tourner le téléphone ---- */
.rotate { display: none; }
@media (orientation: portrait) and (max-width: 900px) {
  body.in-game .game { display: none; }
  body.in-game .rotate {
    position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px; padding: 40px; text-align: center; color: var(--sand);
  }
  .rotate svg { color: var(--clay); }
  .rotate__title { margin: 0; font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1.1; }
  .rotate__text { margin: 0; font-size: 16px; color: var(--on-dark); }
}

/* ---- Fenêtre d'une case ---- */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(30, 12, 6, .72);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.sheet {
  width: min(420px, 100%); max-height: calc(100dvh - 24px); overflow: auto;
  background: var(--paper); color: var(--umber); border-radius: 18px; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.sheet__kicker { margin: 0; font-size: 12px; color: var(--muted); font-weight: 700; }
.sheet__title { margin: 0 0 2px; font-family: var(--display); font-size: 19px; line-height: 1.2; }
.sheet__msg { margin: 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.sheet__refused { background: var(--brick-soft); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; font-size: 13px; line-height: 1.4; }
.sheet__refused strong { color: var(--brick); }
.sheet__actions { display: flex; gap: 8px; }
.sheet__actions .btn { flex: 1 1 0; padding: 0 10px; font-size: 14px; }

/* =====================================================================
   PAGES ORGANISATEURS
   ===================================================================== */
body.orga { background: var(--page); color: var(--umber); min-height: 100vh; min-height: 100dvh; }
a { color: var(--terra); }
.hint { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.alert { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--brick-soft); color: var(--brick); font-size: 14px; font-weight: 700; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }

/* ---- Connexion ---- */
.login {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background: var(--umber);
}
.login__title { margin: 0; font-family: var(--display); font-weight: 800; font-size: 40px; color: var(--sand); }
.login__sub { margin: 0 0 16px; color: var(--on-dark); font-size: 14px; text-align: center; }
.login__card { width: min(380px, 100%); background: var(--paper); border-radius: 18px; padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.login__card label { font-weight: 700; font-size: 14px; }
.login__card input, .adm textarea, .adm input[type="text"], .val textarea {
  width: 100%; min-height: 46px; border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px;
  font-size: 16px; background: #fff; color: var(--umber);
}
.login__card input:focus, .adm textarea:focus, .adm input:focus, .val textarea:focus { border-color: var(--terra); outline: none; }
.login__card .btn { margin-top: 6px; }

/* ---- Validation (téléphone, portrait) ---- */
.val { min-height: 100vh; min-height: 100dvh; height: 100dvh; display: flex; flex-direction: column; }
.val__head { background: var(--umber); color: var(--sand); padding: calc(14px + var(--safe-t)) calc(18px + var(--safe-r)) 14px calc(18px + var(--safe-l)); display: flex; flex-direction: column; gap: 8px; }
.val__row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.val__row p { margin: 0; }
.val__title { font-family: var(--display); font-weight: 800; font-size: 22px; }
.val__title span { color: var(--clay); margin-right: 4px; }
.val__meta { font-size: 13px; color: var(--on-dark); align-items: baseline; }
.val__meta strong { font-family: var(--display); font-size: 24px; color: var(--sand); }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.who { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 12px; border-radius: 18px; background: var(--umber-3); font-size: 13px; font-weight: 700; cursor: pointer; }
.menu__panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 190px; background: var(--paper); border-radius: 12px; box-shadow: 0 10px 30px rgba(30, 12, 6, .25); padding: 6px; display: flex; flex-direction: column; }
.menu__panel a { padding: 12px; border-radius: 8px; color: var(--umber); text-decoration: none; font-weight: 700; font-size: 15px; }
.menu__panel a:hover { background: var(--line-2); }

.val__photo { flex: 1 1 auto; min-height: 0; padding: 14px 14px 0; display: flex; flex-direction: column; gap: 12px; }
.val__frame { position: relative; flex: 1 1 auto; min-height: 0; border: none; padding: 0; border-radius: 16px; overflow: hidden; background: var(--umber-2); }
.val__frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.val__zoom { position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 14px; background: rgba(45, 20, 12, .85); color: #fff; font-size: 12px; font-weight: 700; }
.val__info { display: flex; flex-direction: column; gap: 4px; padding-left: calc(var(--safe-l)); }
.val__by { margin: 0; display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.val__by span { font-size: 13px; color: var(--muted); }
.val__phrase { margin: 0; font-family: var(--display); font-size: 20px; line-height: 1.2; font-weight: 600; }
.val__empty { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px; text-align: center; color: var(--muted); }
.val__empty svg { color: #C65D3B; }
.val__empty h1 { margin: 0; font-family: var(--display); font-size: 24px; color: var(--umber); }
.val__empty p { margin: 0; font-size: 15px; line-height: 1.45; }

.val__actions { display: flex; gap: 10px; padding: 14px calc(14px + var(--safe-r)) calc(18px + var(--safe-b)) calc(14px + var(--safe-l)); }
.btn--big { min-height: 60px; border-radius: 16px; font-size: 17px; }
.val__actions .btn--refuse { flex: 1 1 0; background: var(--paper); color: var(--brick); border-color: #D9BFAE; }
.val__actions .btn--primary { flex: 1.4 1 0; }
.val__refuse { margin-top: 12px; background: var(--paper); border-radius: 20px 20px 0 0; padding: 14px calc(14px + var(--safe-r)) calc(18px + var(--safe-b)) calc(14px + var(--safe-l)); display: flex; flex-direction: column; gap: 8px; max-height: 60dvh; overflow: auto; }
.val__refuse-title { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.val__reasons { display: flex; flex-direction: column; gap: 8px; }
.btn--reason { justify-content: flex-start; text-align: left; min-height: 50px; padding: 8px 16px; border-color: var(--line); background: #fff; color: var(--umber); font-size: 15px; }
.val__other { display: flex; flex-direction: column; gap: 8px; }
.toast--val { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: calc(100vw - 32px); top: calc(12px + var(--safe-t)); bottom: auto; padding: 8px 8px 8px 16px; }
.toast--val button { min-height: 40px; padding: 0 14px; border: none; border-radius: 10px; background: var(--umber-3); color: #F6C2AA; font-weight: 700; }
.zoom { position: fixed; inset: 0; z-index: 60; background: #1E0C06; display: flex; align-items: center; justify-content: center; }
.zoom img { max-width: 100%; max-height: 100%; object-fit: contain; }
.zoom__close { position: absolute; top: calc(12px + var(--safe-t)); right: calc(12px + var(--safe-r)); width: 48px; height: 48px; border-radius: 24px; border: none; background: rgba(255, 255, 255, .15); color: #fff; display: flex; align-items: center; justify-content: center; }

/* ---- Administration ---- */
.adm-wrap { max-width: 1180px; margin: 0 auto; padding-left: calc(20px + var(--safe-l)); padding-right: calc(20px + var(--safe-r)); }
.adm-head { background: var(--umber); color: var(--sand); padding-top: var(--safe-t); }
.adm-head__in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 20px; padding-bottom: 20px; }
.adm-head__title { margin: 0; font-family: var(--display); font-weight: 800; font-size: 26px; }
.adm-head__title span { color: var(--clay); margin-right: 6px; }
.adm-head__sub { margin: 2px 0 0; font-size: 13px; color: var(--on-dark); }
.adm-head__sub a { color: #F6C2AA; }
.adm { display: flex; flex-direction: column; gap: 32px; padding-top: 24px; padding-bottom: calc(40px + var(--safe-b)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { background: var(--paper); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat__label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat__value { font-family: var(--display); font-size: 34px; font-weight: 800; line-height: 1.1; }
.stat--cta { background: var(--terra); color: #fff; text-decoration: none; }
.stat--cta .stat__label { color: #FBE1D6; }
.stat--cta:hover { background: var(--terra-dark); }
.stat__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 14px; }
.adm-section { display: flex; flex-direction: column; gap: 14px; }
.adm-section__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.adm-section__head h2 { margin: 0; font-family: var(--display); font-size: 22px; }
.adm-section__head p { margin: 0; font-size: 14px; color: var(--muted); }
.panel { background: var(--paper); border-radius: 14px; }
.empty { margin: 0; padding: 22px; color: var(--muted); }
.adm-add { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.adm-add__row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { flex: 1 1 320px; display: flex; flex-direction: column; gap: 6px; }
.field label, .adm-import label { font-size: 13px; font-weight: 700; }
.adm-import summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--terra); min-height: 32px; display: flex; align-items: center; }
.adm-import form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; align-items: flex-start; }
.adm-import textarea { resize: vertical; }
.phrases { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.phrase { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 16px; border-top: 1px solid var(--line-2); }
.phrase:first-child { border-top: none; }
.phrase--empty { color: var(--muted); padding: 20px 16px; }
.phrase__num { flex: 0 0 28px; font-size: 13px; font-weight: 700; color: #9A6A55; }
.phrase__text { flex: 1 1 300px; min-width: 0; font-size: 15px; line-height: 1.35; }
.phrase__used { font-size: 12px; color: var(--muted); white-space: nowrap; }
.phrase__input { flex: 1 1 300px; min-width: 0; }
.phrase__actions { display: flex; gap: 6px; }
.icon-btn { width: 44px; height: 44px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--umber); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { border-color: var(--terra); }
.icon-btn--danger { color: var(--brick); }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 700; padding: 14px 18px; }
td { padding: 10px 18px; border-top: 1px solid var(--line-2); }
.col-progress { width: 32%; }
.progress { display: flex; align-items: center; gap: 10px; }
.progress .bar { flex: 1 1 auto; height: 8px; border-radius: 4px; }
.bar--light { background: var(--line-2); }
.bar--light .bar__fill { background: #C65D3B; }
.progress__num { font-weight: 700; min-width: 34px; text-align: right; }
.modal { width: min(460px, 100%); background: var(--paper); color: var(--umber); border-radius: 18px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.modal h2 { margin: 0; font-family: var(--display); font-size: 22px; }
.modal p { margin: 0; font-size: 15px; line-height: 1.45; }
.modal__quote { font-weight: 700; }
.modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 6px; }
