/* Charte « Mer Égée » de ConjuGrec */
:root {
  --nuit: #1a3b6e;
  --bleu: #2856a8;
  --ciel: #e4ebf8;
  --or: #c8a03a;
  --creme: #f8f3e8;
  --pierre: #5a6886;
  --vert: #1f6b43;
  --vert-pale: #d5ebdd;
  --ambre: #7a5208;
  --ambre-pale: #f6e7c1;
  --ombre: 0 2px 16px rgb(26 59 110 / .1);
  --texte: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 18px/1.6 var(--texte); color: var(--nuit); background: var(--creme); }
a { color: var(--bleu); font-weight: 600; }
:focus-visible { outline: 3px solid var(--or); outline-offset: 2px; }
.cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* En-tête */
header { color: var(--creme); background: var(--nuit); border-bottom: 3px solid var(--or); }
.dedans { display: flex; align-items: center; gap: 16px; max-width: 1100px; margin: 0 auto; padding: 14px 16px; }
header img { border-radius: 14px; background: #fff; box-shadow: 0 0 0 2px var(--or); }
.dedans > div { min-width: 0; }
h1 { margin: 0; font-size: 1.9rem; line-height: 1.1; font-weight: 700; }
.latin { margin-left: .4em; font: 700 .5em/1 Cinzel, Georgia, serif; letter-spacing: .08em; color: #e4c878; white-space: nowrap; }
header p { margin: 2px 0 0; font-size: .9rem; line-height: 1.3; color: #d5deee; }
#numero { margin-left: auto; padding: 4px 14px; font-weight: 700; white-space: nowrap; color: var(--nuit); background: var(--or); border-radius: 99px; }
#numero:empty { display: none; }

/* Mise en page */
main { display: grid; grid-template: "jeu infos" auto "jeu mots" 1fr / minmax(0, 1fr) 260px; gap: 14px 20px;
  align-items: start; max-width: 1100px; margin: 0 auto; padding: 16px; }
#jeu { grid-area: jeu; min-width: 0; }
#infos { grid-area: infos; display: grid; gap: 4px; padding: 14px 18px; font-size: .95rem; background: #fff; border-radius: 16px; box-shadow: var(--ombre); }
#mots { grid-area: mots; padding: 14px 18px; background: #fff; border-radius: 16px; box-shadow: var(--ombre); }
#mots h3 { margin: 0 0 6px; font-size: 1rem; }

/* Barre fixe */
#barre { position: sticky; top: 0; z-index: 2; padding: 8px 0 6px; background: var(--creme); }
#saisie { display: flex; background: #fff; border: 2px solid var(--nuit); border-radius: 14px; overflow: hidden; }
#saisie:focus-within { border-color: var(--or); box-shadow: 0 0 0 3px rgb(200 160 58 / .3); }
#mot { flex: 1; min-width: 0; padding: 11px 14px; font: inherit; color: inherit; background: none; border: 0; outline: 0; }
#mot::placeholder { color: var(--pierre); }
button { padding: 10px 18px; font: 600 1em/1.3 var(--texte); color: var(--creme); background: var(--nuit); border: 0; border-radius: 12px; cursor: pointer; }
button:hover { background: var(--bleu); }
button:disabled { background: var(--pierre); cursor: default; }
#saisie button { border-radius: 0; }
button.discret { padding: 8px 4px; color: var(--bleu); background: none; }
button.discret:hover { text-decoration: underline; }
/* Le message occupe toujours une ligne, pour que le texte ne bouge pas */
#message { height: 34px; margin: 6px 0 0; line-height: 34px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#message.trouve, #message.proche, #message.rate, #message.deja, #message.inconnu { width: fit-content; max-width: 100%; padding: 0 14px;
  font-weight: 600; color: var(--pierre); background: var(--ciel); border-radius: 99px; }
#message.trouve { color: var(--vert); background: var(--vert-pale); }
#message.proche { color: var(--ambre); background: var(--ambre-pale); }
#ligne { display: flex; justify-content: space-between; align-items: center; min-height: 32px; font-size: .95rem; }
#score { font-weight: 700; }
#ouvrirMots { display: none; }

/* Article */
#titre { margin: 4px 0 12px; padding: 16px 20px; font-size: 1.6rem; line-height: 1.5; background: #fff; border-radius: 16px;
  border-top: 3px solid var(--or); box-shadow: var(--ombre); overflow-wrap: anywhere; }
#texte { padding: 18px 20px; line-height: 2; background: #fff; border-radius: 16px; box-shadow: var(--ombre); overflow-wrap: anywhere; }
.mot { border-radius: 7px; }
.ferme { position: relative; display: inline-block; height: 1.2em; min-width: .7em; vertical-align: -.22em; line-height: 1.2em; cursor: help;
  background: #d3ddf0; user-select: none; }
.ferme:not(.voisin) { width: calc(var(--n) * .56em); max-width: 100%; }
.voisin { vertical-align: baseline; padding: 0 .3em; min-width: calc(var(--n) * .56em); text-align: center; font-style: italic; color: var(--ambre);
  background: color-mix(in srgb, #efc765 var(--force), #fdf6e3); }
.ferme.montre::after { content: attr(data-n); position: absolute; inset: 0; min-width: 1.6em; font: 700 .75em/1.6em var(--texte);
  text-align: center; color: var(--creme); background: var(--nuit); border-radius: inherit; }
.nouveau { padding: 0 .2em; color: var(--vert); background: var(--vert-pale); animation: eclore .5s ease-out; }
.devoile { color: var(--pierre); }
@keyframes eclore { from { opacity: 0; transform: scale(.85); } }

/* Fin de partie */
#perime { padding: 12px 18px; background: var(--ambre-pale); border-radius: 16px; }
#victoire { margin: 4px 0 12px; padding: 16px 20px; color: var(--creme); background: var(--nuit); border-radius: 16px; border-top: 3px solid var(--or); }
#victoire p { margin: 0 0 8px; }
#victoire a { color: #f0d48a; }
#victoire button { margin: 0 6px 8px 0; color: var(--nuit); background: var(--or); }
#victoire button:hover { background: #ddb956; }
#bravo { font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

#fin { width: min(92vw, 420px); padding: 24px 20px 18px; text-align: center; color: var(--nuit); background: var(--creme);
  border: 0; border-top: 5px solid var(--or); border-radius: 18px; }
#fin[open] { animation: monter .35s ease-out; }
#fin::backdrop { background: rgb(18 40 76 / .72); }
#fin h2 { margin: 8px 0 0; font-size: 1.4rem; }
#fin p { margin: 0 0 8px; }
#fin p:empty { display: none; }
#finReponse { font-size: 1.35rem; font-weight: 700; color: var(--bleu); }
#compteurs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; font-size: .85rem; line-height: 1.3; }
#compteurs div { padding: 8px 4px; border-radius: 12px; color: var(--nuit); background: var(--ciel); }
#compteurs .trouve { color: var(--vert); background: var(--vert-pale); }
#compteurs .proche { color: var(--ambre); background: var(--ambre-pale); }
#compteurs b { display: block; font-size: 1.5rem; }
#fin .rang { font-weight: 700; }
#finMessage { color: var(--vert); font-weight: 600; }
#fin .actions { display: grid; }
#voirTexte { color: var(--nuit); background: none; box-shadow: inset 0 0 0 2px var(--nuit); }
#voirTexte:hover { background: var(--ciel); }
#question { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--or); font-size: .95rem; }
#question a { display: inline-block; padding: 8px; }
#fermerFin { position: absolute; top: 6px; right: 8px; padding: 6px 12px; }
@keyframes monter { from { opacity: 0; transform: translateY(24px); } }

/* Icônes d'une couleur : elles prennent celle du texte */
.icone { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -.28em; background: currentColor; -webkit-mask: var(--svg) center / contain no-repeat; mask: var(--svg) center / contain no-repeat; }
.i-partager { --svg: url("icones/partager.svg"); }
.i-traduire { --svg: url("icones/traduire.svg"); }
.i-fermer { --svg: url("icones/fermer.svg?v=2"); width: 1.5em; height: 1.5em; }
.i-trouve { --svg: url("icones/trouve.svg"); }
.i-absent { --svg: url("icones/absent.svg?v=2"); }
.i-instagram { --svg: url("icones/instagram.svg"); margin-right: .25em; }
.i-facebook { --svg: url("icones/facebook.svg"); margin-right: .25em; }
#compteurs .icone { display: block; margin: 0 auto; width: 26px; height: 26px; }
#compteurs .i-absent { width: 40px; }
#compteurs img { display: block; margin: 0 auto; }
#ouvrirMots img, footer img { vertical-align: middle; }
footer img { border-radius: 10px; }
footer p { margin: 4px 0 0; }
footer .credits { margin-top: 12px; font-size: .8rem; }
.credits a { font-weight: 400; color: inherit; }

/* Essais */
#essais { max-height: 60vh; margin: 0; padding-left: 2em; overflow: auto; }
#essais .trouve, .legende .trouve { color: var(--vert); font-weight: 600; }
#essais .proche, .legende .proche { color: var(--ambre); font-weight: 600; }
#essais .rate { color: var(--pierre); }
.legende { margin: 10px 0 0; font-size: .85rem; line-height: 1.4; color: var(--pierre); }
#repartition { width: 100%; margin: 10px 0 0; font-size: .85rem; border-spacing: 0 3px; }
#repartition caption { text-align: left; font-weight: 600; }
#repartition td:nth-child(2) { width: 55%; }
#repartition i { display: block; height: .8em; border-radius: 4px; background: var(--or); }
footer { max-width: 1100px; margin: 8px auto 0; padding: 14px 16px 24px; font-size: .9rem; text-align: center; color: var(--pierre); }

@media (max-width: 760px) {
  .dedans { gap: 12px; padding: 10px 12px; }
  header img { width: 46px; height: 46px; }
  h1 { font-size: 1.35rem; }
  .latin { display: block; margin: 3px 0 0; font-size: .58em; }
  header p { font-size: .78rem; }
  main { grid-template: "infos" auto "jeu" auto / minmax(0, 1fr); gap: 2px; padding: 8px 12px; }
  #infos { display: flex; flex-wrap: wrap; gap: 0 12px; padding: 4px 2px; font-size: .85rem; background: none; box-shadow: none; }
  #saisie button { padding: 10px 14px; }
  #titre, #texte { padding: 14px 16px; }
  #titre { font-size: 1.35rem; }
  #ouvrirMots { display: block; min-height: 40px; }
  #mots { display: none; }
  #mots.ouvert { display: block; position: fixed; z-index: 3; inset: var(--haut, 120px) 12px auto; overflow: auto;
    max-height: calc(100dvh - var(--haut, 120px) - 12px); border-top: 3px solid var(--or); box-shadow: 0 10px 30px rgb(18 40 76 / .4); }
  #essais { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
