/* Sous-préfoku — le sudoku des préfectures. Charte omniaamplecti (papier / or). */
:root {
  --ink: #1a1814;
  --paper: #f2f5fa;
  --paper-dark: #e6ecf6;
  --gold: #b89a5a;
  --muted: #7a7060;
  --brand: #1d3a5f;
  --nav-h: 72px;
  --line: rgba(184, 154, 90, 0.28);
  --ok: #4f8a5b;
  --ko: #b5544b;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: 'Montserrat', sans-serif; font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

/* ── EN-TÊTE ── */
.entete { max-width: 900px; margin: 0 auto; padding: calc(var(--nav-h) + 2.5rem) 1.5rem 1rem; text-align: center; }
.eyebrow { font-size: 0.66rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--gold); margin: 0 0 0.7rem; }
.entete h1 { font-family: 'Cormorant Garamond', serif; font-weight: 600; font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1; margin: 0; letter-spacing: 0.01em; color: var(--brand); }
.entete h1 em { font-style: italic; color: var(--brand); }
.accroche { max-width: 560px; margin: 0.9rem auto 0; font-size: 0.92rem; line-height: 1.6; color: var(--muted); }
.meta { margin: 1rem 0 0; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.meta b { color: var(--ink); }
.filet { width: 56px; height: 1px; background: var(--gold); margin: 1.3rem auto 0; }

/* ── BARRE D'ÉTAT ── */
.bar { max-width: 620px; margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center; gap: 1.2rem; padding: 0 1rem; flex-wrap: wrap; }
.bar .pill { font-size: 0.8rem; letter-spacing: 0.06em; color: var(--muted); display: inline-flex; align-items: center; }
.bar .pill b { color: var(--ink); font-weight: 600; font-size: 1.05rem; }
.lives { display: inline-flex; gap: 0.28rem; margin-left: 0.5rem; }
.lives .life { font-size: 1rem; line-height: 1; color: #c0392b; }
.lives .life.lost { color: var(--muted); opacity: 0.5; }
.giveup {
  font-family: 'Montserrat', sans-serif; font-size: 0.68rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 4px; padding: 0.4rem 0.9rem; cursor: pointer;
  transition: color .2s, border-color .2s;
}
.giveup:hover { color: var(--ko); border-color: var(--ko); }
.giveup[hidden] { display: none; }

/* ── GRILLE ── */
.grid-wrap { max-width: 620px; margin: 0 auto; padding: 0 0.6rem; }
.grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr 1fr;
  grid-auto-rows: minmax(88px, auto);
  gap: 5px;
  width: 100%;
}
.cell {
  border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 0.45rem; overflow: hidden;
  min-width: 0; word-break: break-word;
}
.cell.corner {
  background: var(--ink); color: var(--paper); gap: 0.25rem;
}
.corner-logo { font-family: 'Cormorant Garamond', serif; font-weight: 600; font-size: 1.02rem; letter-spacing: 0.06em; color: var(--gold); }
.corner-sub { font-size: 0.52rem; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(243,246,241,0.7); }
.cell.head {
  background: var(--paper-dark); border: 1px solid var(--line);
  font-size: 0.74rem; font-weight: 500; line-height: 1.25; color: var(--ink);
  hyphens: auto;
}
.cell.head span { display: block; }
.cell.head-row { text-align: left; align-items: flex-start; justify-content: center; }

/* Cases jouables */
.cell.play {
  background: var(--paper); border: 1.5px solid var(--line); cursor: pointer;
  font-family: 'Montserrat', sans-serif; color: var(--ink); transition: border-color .2s, background .2s, box-shadow .2s;
}
.cell.play:hover:not(:disabled) { border-color: var(--gold); box-shadow: 0 4px 14px rgba(26,24,20,0.08); }
.cell.play .cell-plus { font-size: 1.8rem; font-weight: 300; color: var(--gold); }
.cell.play.filled { background: #eef4ec; border-color: var(--ok); cursor: default; }
.cell.play.filled .ans-title { font-family: 'Cormorant Garamond', serif; font-size: 1.02rem; font-weight: 600; line-height: 1.1; }
.cell.play.filled .ans-sub { font-size: 0.66rem; color: var(--muted); margin-top: 0.2rem; }
.cell.play.filled .ans-pop { font-size: 0.6rem; color: var(--gold); margin-top: 0.1rem; letter-spacing: 0.03em; }
.cell.play.missed { background: var(--paper-dark); border-color: var(--line); color: var(--muted); cursor: default; }
.cell.play.missed .cell-plus { color: var(--ko); font-size: 1.1rem; }
/* Réponse révélée (case non trouvée) : ton neutre, distinct des cases gagnées. */
.cell.play.revealed { background: var(--paper-dark); border-color: var(--line); border-style: dashed; cursor: default; }
.cell.play.revealed .rev-tag {
  font-size: 0.5rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.15rem;
}
.cell.play.revealed .ans-title { font-family: 'Cormorant Garamond', serif; font-size: 0.94rem; font-weight: 600; line-height: 1.1; color: var(--muted); }
.cell.play.revealed .ans-sub { font-size: 0.6rem; color: var(--muted); margin-top: 0.15rem; }
/* Réponse la plus proposée par les joueurs : accent doré. */
.cell.play.revealed.comm-answer { border-color: var(--gold); border-style: solid; }
.cell.play.revealed.comm-answer .rev-tag { color: var(--gold); }
.cell.play.revealed.comm-answer .ans-title { color: var(--ink); }

/* ── RÉSULTAT ── */
.result { max-width: 460px; margin: 1.6rem auto 0; padding: 1.5rem; text-align: center;
  background: var(--paper-dark); border: 1px solid var(--line); border-radius: 8px; }
.result h2 { font-family: 'Cormorant Garamond', serif; font-weight: 600; font-size: 1.8rem; margin: 0 0 0.4rem; }
.result .score { font-size: 1rem; margin: 0.2rem 0; }
.result .score b { font-size: 1.4rem; color: var(--gold); }
.result .streak { font-size: 0.78rem; color: var(--muted); margin: 0.3rem 0 0; }
.result .reveal-note { font-size: 0.74rem; color: var(--muted); font-style: italic; margin: 0.4rem 0 0; }

/* ── PARTAGE ── */
.share-row { max-width: 460px; margin: 1rem auto 0; display: flex; justify-content: center; gap: 0.6rem; flex-wrap: wrap; }
.share-row[hidden] { display: none; }
.share-btn {
  font-family: 'Montserrat', sans-serif; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--paper); background: var(--ink); border: none; border-radius: 4px; padding: 0.7rem 1.3rem; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; transition: background .2s, opacity .2s;
}
.share-btn:hover { background: var(--gold); }
.share-tw { background: #1d9bf0; }
.share-tw:hover { background: #0c7abf; }
.share-bsky { background: #1185fe; }
.share-bsky:hover { background: #0a6ed6; }

/* ── STATISTIQUES DU JOUR ── */
.community { margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.community h3 { font-family: 'Cormorant Garamond', serif; font-weight: 600; font-size: 1.25rem; margin: 0 0 0.4rem; color: var(--brand); }
.community .comm-count { font-size: 0.9rem; margin: 0.2rem 0 0.9rem; }
.community .comm-count b { color: var(--gold); font-weight: 600; }
.community .comm-legend { font-size: 0.72rem; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 0.55rem; text-transform: uppercase; }
.comm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; max-width: 240px; margin: 0 auto; }
.comm-cell {
  position: relative; aspect-ratio: 1 / 1; border-radius: 5px; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.comm-cell::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--p, 0%);
  background: rgba(79, 138, 91, 0.32); transition: height .4s ease;
}
.comm-cell .cc-pct { position: relative; font-size: 0.82rem; font-weight: 600; color: var(--ink); }

/* ── MODALE (saisie libre) ── */
.modal { position: fixed; inset: 0; z-index: 500; background: rgba(26,24,20,0.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 1rem 1rem; }
.modal[hidden] { display: none; }
.modal-box { background: var(--paper); border-radius: 10px; width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem 0.6rem; }
.modal-crit { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.82rem; }
.modal-crit .mc-row, .modal-crit .mc-col { background: var(--paper-dark); border: 1px solid var(--line); border-radius: 4px; padding: 0.3rem 0.6rem; font-weight: 500; }
.modal-crit .mc-plus { color: var(--gold); font-weight: 600; }
#modal-close { background: none; border: none; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 0.3rem; }
#modal-close:hover { color: var(--ink); }
.modal-search { padding: 0.8rem 1.2rem 1.1rem; border-top: 1px solid var(--line); }
#guess-form { display: flex; gap: 0.5rem; }
#guess { flex: 1; font-family: 'Montserrat', sans-serif; font-size: 0.95rem; padding: 0.65rem 0.75rem;
  border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); }
#guess:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184,154,90,0.15); }
.guess-btn {
  font-family: 'Montserrat', sans-serif; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--paper); background: var(--brand); border: none; border-radius: 5px; padding: 0 1.1rem; cursor: pointer;
  transition: background .2s;
}
.guess-btn:hover { background: #16304e; }
.guess-feedback { margin: 0.7rem 0 0; font-size: 0.82rem; color: var(--muted); min-height: 1em; }
.guess-feedback.gf-info { color: var(--ko); }
.guess-hint { margin: 0.55rem 0 0; font-size: 0.72rem; color: var(--muted); font-style: italic; }

/* ── FLASH ── */
.flash { position: fixed; left: 50%; bottom: 12%; transform: translate(-50%, 20px); opacity: 0;
  padding: 0.7rem 1.4rem; border-radius: 6px; font-size: 0.85rem; font-weight: 500; z-index: 600;
  transition: opacity .25s, transform .25s; color: #fff; }
.flash.show { opacity: 1; transform: translate(-50%, 0); }
.flash-ok { background: var(--ok); }
.flash-ko { background: var(--ko); }

/* ── AIDE ── */
.help { max-width: 620px; margin: 2.2rem auto 0; padding: 0 1.2rem; }
.help details { border-top: 1px solid var(--line); padding: 0.9rem 0; }
.help summary { cursor: pointer; font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.help summary:hover { color: var(--gold); }
.help p, .help ul { font-size: 0.85rem; line-height: 1.65; color: var(--ink); }
.help ul { padding-left: 1.2rem; }

/* ── PIED ── */
.pied { text-align: center; padding: 2.5rem 1rem; margin-top: 3rem; font-size: 0.75rem;
  letter-spacing: 0.05em; color: var(--muted); border-top: 1px solid var(--line); }
.pied a { color: var(--muted); text-decoration: none; transition: color .2s; }
.pied a:hover { color: var(--gold); }
.pied .sep { margin: 0 0.5rem; color: var(--gold); }

@media (max-width: 560px) {
  .grid-wrap { padding: 0 0.4rem; }
  .grid { grid-template-columns: 0.95fr 1fr 1fr 1fr; gap: 4px; grid-auto-rows: minmax(74px, auto); }
  .cell { padding: 0.28rem; border-radius: 5px; }
  .cell.head { font-size: 0.56rem; line-height: 1.18; }
  .cell.play .cell-plus { font-size: 1.3rem; }
  .cell.play.filled .ans-title { font-size: 0.74rem; }
  .cell.play.filled .ans-sub { font-size: 0.54rem; }
  .cell.play.filled .ans-pop { font-size: 0.5rem; }
  .corner-logo { font-size: 0.74rem; letter-spacing: 0.03em; }
  .corner-sub { display: none; }
}
@media (max-width: 380px) {
  .grid { gap: 3px; grid-auto-rows: minmax(66px, auto); }
  .cell.head { font-size: 0.5rem; }
  .cell.play.filled .ans-title { font-size: 0.66rem; }
  .corner-logo { font-size: 0.64rem; }
}
