/* La Grande Grille : un atlas qu'on découvre. Le monde est une feuille de papier ; la grille y est
   imprimée (cases blanches, définitions bleu pâle), l'inexploré reste vierge. L'interface est sur
   le même papier : filets d'encre, titres en serif, étiquettes en capitales condensées. La force
   d'une contrée s'écrit partout de la même façon : quatre petites cases, 1 à 4 noircies. */
:root {
  --paper: #f4f1ea;
  --paper-2: #ebe6da; /* creux, survol */
  --card: #fbf9f4; /* fiches et fenêtres, un ton au-dessus du papier */
  --ink: #1d1b18;
  --ink-2: #48433b;
  --muted: #7d7668;
  --rule: #dcd5c6;
  --line-grid: #a7acb3;
  --clue: #e8f3fb;
  --accent: #1a7dc0;
  --ok: #3d7a4f;
  --gold: #c99a00;
  --danger: #a8321f;
  --font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "Roboto Condensed", "Arial Narrow", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --r: 3px;
  --shadow-lg: 0 18px 40px rgba(29, 27, 24, 0.18), 0 2px 6px rgba(29, 27, 24, 0.08);
  --safe-t: env(safe-area-inset-top);
  --safe-r: env(safe-area-inset-right);
  --safe-b: env(safe-area-inset-bottom);
  --safe-l: env(safe-area-inset-left);
  /* Papier vierge : une croix à chaque coin de case, comme le brouillard de la grille. */
  --croix: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M0 4V0h4M40 0h4v4M44 40v4h-4M4 44H0v-4' fill='none' stroke='%231d1b18' stroke-opacity='.16'/%3E%3C/svg%3E");
}

/* --- Socle ---------------------------------------------------------------------------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
@supports (height: 100dvh) { body { height: 100dvh; } } /* hauteur réelle (barre d'adresse mobile) */
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.inl { width: 15px; height: 15px; vertical-align: -3px; }
kbd { display: inline-block; min-width: 1.7em; padding: 0 5px; border: 1px solid var(--ink-2); border-bottom-width: 2px; border-radius: 2px; background: var(--card); font: 500 12px/1.5 var(--font); text-align: center; color: var(--ink); }

/* Étiquette : capitales condensées espacées (titres de sections, légendes). */
.side-sec h2, .mc-stats h3, .sp-body h3, .clue-meta, .bl-head, .welcome label {
  font-family: var(--cond); font-weight: 700; font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}

/* Force : quatre petites cases, autant de noircies que la force. */
.pips { display: inline-flex; gap: 2px; vertical-align: 0.05em; color: inherit; }
.pips i { width: 0.5em; height: 0.5em; min-width: 6px; min-height: 6px; border: 1.25px solid currentColor; }
.pips[data-f="1"] i:nth-child(-n+1), .pips[data-f="2"] i:nth-child(-n+2),
.pips[data-f="3"] i:nth-child(-n+3), .pips[data-f="4"] i { background: currentColor; }

/* Boutons. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border: 1px solid var(--ink); border-radius: var(--r);
  background: var(--ink); color: var(--paper); font: 500 15px/1 var(--font); letter-spacing: 0.01em; white-space: nowrap;
}
.btn:hover { background: #3a362f; border-color: #3a362f; }
.btn-lg { height: 48px; width: 100%; font-size: 16px; }
.btn-ghost { background: transparent; border-color: var(--rule); color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-2); border-color: var(--rule); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: var(--r); background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.link { padding: 0; border: 0; background: none; color: var(--ink); font-weight: 500; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--ink); }
.link::after { content: " →"; }

/* Panneau : fiches, fenêtres, carte de contrée. */
.panel { background: var(--card); border: 1px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow-lg); color: var(--ink); }
.panel-head { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--rule); }
.panel-head b { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font: 600 19px/1.2 var(--serif); }
.panel-head b .pips { font-size: 14px; }
.panel-head b > i, .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ph-icon { color: var(--ink-2); }
.panel-body { padding: 16px 18px 18px; }

/* Barre d'avancement : un filet qui se remplit. */
.progress { display: flex; align-items: center; gap: 10px; color: var(--muted); font: 400 13px var(--cond); font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 3px; background: var(--rule); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.4s; }

/* --- En-tête ------------------------------------------------------------------------------- */
.top {
  position: relative; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  min-height: 64px; padding: 10px 18px;
  background: var(--paper); border-bottom: 1px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 12px; flex: none; font: 700 22px/1 var(--serif); letter-spacing: -0.01em; white-space: nowrap; }
/* Une case de définition miniature, avec sa flèche. */
.brand-mark { position: relative; width: 24px; height: 24px; margin-right: 4px; background: var(--clue); border: 1px solid var(--line-grid); }
.brand-mark::after { content: ""; position: absolute; left: calc(100% + 2px); top: 50%; border: 5px solid transparent; border-left: 6px solid var(--ink); border-right: 0; transform: translateY(-50%); }

/* Bandeau de la définition en cours : une grande case de définition, posée sur le papier. */
.clue {
  --ct: var(--accent);
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 4px;
  height: 44px; padding: 0 4px;
  background: var(--clue); border: 1px solid var(--line-grid);
}
.clue-btn {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: var(--r); background: transparent; color: var(--ink-2);
  touch-action: manipulation;
}
.clue-btn:hover { background: rgba(255, 255, 255, 0.75); color: var(--ink); }
.clue-dir { flex: none; position: relative; width: 26px; height: 26px; margin: 0 8px 0 4px; background: var(--ct); }
.clue-dir::after { content: ""; position: absolute; left: 50%; top: 50%; border: 6px solid transparent; transform: translate(-30%, -50%); border-left: 8px solid #fff; border-right: 0; }
.clue-dir[data-dir="v"]::after { border: 6px solid transparent; border-top: 8px solid #fff; border-bottom: 0; transform: translate(-50%, -30%); }
.clue-main { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 14px; }
.clue-text { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 20px/1.2 var(--serif); }
.clue-meta { flex: 0 1000 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0.1em; } /* cède la place à la définition */
.clue-meta b { color: #8a6a00; }
.clue.nosel .clue-dir { display: none; }
.clue.nosel .clue-text { color: var(--muted); font-weight: 400; font-style: italic; padding-left: 10px; }
.clue.nosel #clPrev, .clue.nosel #clDir { display: none; }
.clue.solved { background: #eaf3ea; }
.clue.solved .clue-text { color: var(--ink-2); }
.clue.repere { box-shadow: inset 4px 0 0 var(--gold); }

/* Contrée en cours : famille, force, avancement. */
.ct {
  flex: none; width: 220px;
  display: flex; flex-direction: column; gap: 6px;
  padding: 4px 10px; border: 0; border-left: 1px solid var(--rule); border-radius: 0; background: transparent; text-align: left;
}
.ct:hover { background: var(--paper-2); }
.ct-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ct-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ct-name { min-width: 0; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; font: 600 17px/1.15 var(--serif); }
.ct-name .pips { font-size: 13px; }
.ct-bar { flex: 1; height: 3px; background: var(--rule); overflow: hidden; }
.ct-bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.4s; }
.ct-count { flex: none; color: var(--muted); font: 400 12.5px/1 var(--cond); font-variant-numeric: tabular-nums; }
.ct.fini .ct-bar i { background: var(--gold); }

/* Joueurs en ligne : ouvre le panneau latéral quand il n'est pas affiché en permanence. */
.online {
  flex: none; display: flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 12px; border: 1px solid var(--ink); border-radius: var(--r); background: transparent;
  font: 500 15px/1 var(--cond); font-variant-numeric: tabular-nums;
}
.online:hover { background: var(--paper-2); }

.debug { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.debug b { padding: 2px 6px; background: var(--danger); color: #fff; font: 700 11px var(--cond); text-transform: uppercase; letter-spacing: 0.08em; }
.debug label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.debug button { padding: 3px 8px; border: 1px solid var(--danger); border-radius: var(--r); background: transparent; color: var(--danger); font-size: 12px; }
.debug button:hover { background: var(--danger); color: #fff; }
.debug-load { color: var(--ink-2); font-style: italic; }

/* --- Grille ------------------------------------------------------------------------------- */
.layout { position: relative; flex: 1; min-height: 0; display: flex; }
#stage { position: relative; flex: 1; min-width: 0; background: var(--paper) var(--croix); }
#grid { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: default; }
#grid.panning { cursor: grabbing; }
#mobileInput { position: absolute; left: -100px; top: 0; width: 1px; height: 1px; opacity: 0; }

.status { position: absolute; top: 0; left: 0; right: 0; z-index: 6; padding: 8px 16px; background: var(--ink); color: var(--paper); font-size: 13px; text-align: center; border-bottom: 2px solid var(--danger); }

/* Outils : une colonne de groupes de touches, à l'encre. */
.tools { position: absolute; right: 14px; bottom: 14px; z-index: 3; display: flex; flex-direction: column; gap: 10px; }
.tgroup { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--ink); border-radius: var(--r); box-shadow: 2px 2px 0 rgba(29, 27, 24, 0.12); overflow: hidden; }
.tgroup button { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; background: transparent; color: var(--ink); touch-action: manipulation; }
.tgroup button + button { border-top: 1px solid var(--rule); }
.tgroup button:hover { background: var(--paper-2); }
.tgroup button.on { background: var(--ink); color: var(--paper); }
#lockBtn .if-on, #lockBtn.on .if-off { display: none; }
#lockBtn.on .if-on { display: block; }

/* Messages : un bandeau d'encre. */
.toasts { position: absolute; left: 50%; bottom: 18px; z-index: 7; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { max-width: min(460px, calc(100vw - 32px)); padding: 10px 16px; border-radius: var(--r); background: var(--ink); color: var(--paper); font-size: 14px; box-shadow: var(--shadow-lg); animation: toast 3.2s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(6px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
/* Bilan de fin de contrée. */
.toast.bilan { width: min(360px, calc(100vw - 32px)); padding: 16px 18px; background: var(--card); color: var(--ink); border: 1px solid var(--ink); border-top: 5px solid var(--bl, var(--ink)); text-align: left; animation-duration: 7.2s; }
.toast.bilan .bl-title { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; font: 600 22px/1.2 var(--serif); }
.toast.bilan .bl-title .pips { font-size: 15px; }
.toast.bilan .st-tiles { margin-bottom: 10px; }
.toast.bilan .st-chips { margin: 0; }

/* Fiche d'une contrée (repère) et porte. */
.repere-card { position: absolute; z-index: 4; width: 270px; overflow: hidden; font-size: 14px; }
.rc-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: #fff; }
.rc-head canvas { width: 48px; height: 48px; flex: none; }
.rc-head b { display: flex; align-items: center; gap: 8px; font: 600 19px/1.2 var(--serif); }
.rc-head b .pips { font-size: 13px; }
.rc-head span { display: block; font-size: 12.5px; opacity: 0.9; }
.rc-body { padding: 14px 16px 16px; }
.rc-body p { margin: 12px 0 14px; line-height: 1.45; color: var(--ink-2); }
.rc-body .btn { width: 100%; }
.repere-card.fini .bar i { background: var(--gold); }

.porte-card { position: absolute; z-index: 4; width: 340px; max-width: calc(100% - 16px); font-size: 14px; }
.pc-enigme { margin: 0 0 14px; font: italic 400 17px/1.4 var(--serif); }
.pc-lettres { display: flex; flex-wrap: wrap; margin-bottom: 10px; }
.pc-lettres span { display: flex; align-items: center; justify-content: center; width: 28px; height: 32px; margin: 0 -1px -1px 0; border: 1px solid var(--line-grid); background: #fff; font: 600 17px var(--font); }
.pc-lettres span.vide { color: transparent; background: var(--paper-2); }
.pc-aide { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; }
.pc-form { display: flex; gap: 8px; }
.pc-form input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border: 1px solid var(--ink-2); border-radius: var(--r); background: #fff; text-transform: uppercase; letter-spacing: 0.08em; }
.porte-card.faux input { border-color: var(--danger); animation: secoue 0.35s; }
@keyframes secoue { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* --- Carte du monde : une page d'atlas ------------------------------------------------------ */
.worldmap { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; background: var(--paper); }
.map-head { display: flex; align-items: center; gap: 8px 24px; flex-wrap: wrap; min-height: 56px; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--ink); }
.map-head > b { font: 600 21px/1.2 var(--serif); }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; color: var(--ink-2); font: 400 13px var(--cond); }
.map-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend > span > i { display: inline-block; width: 16px; height: 11px; border: 1px solid rgba(29, 27, 24, 0.25); }
.map-legend .lg-atteinte { background: #87b7d5; }
.map-legend .lg-finie { background: #1a7dc0; }
.map-legend .lg-noire { background: #2f3846; }
.map-legend .pips { font-size: 12px; color: var(--ink); }
.map-hint { margin-left: auto; color: var(--muted); font: italic 400 14px var(--serif); }
.map-stage { position: relative; flex: 1; min-height: 0; }
.map-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.map-tools { top: 14px; bottom: auto; }
.map-card { position: absolute; left: 14px; bottom: 14px; width: min(420px, calc(100% - 28px)); max-height: calc(100% - 28px); display: flex; flex-direction: column; overflow: hidden; }
.map-card .panel-body { overflow-y: auto; }
.map-card .mc-stats:empty { display: none; }
.map-card .btn { width: 100%; margin-top: 16px; }

/* --- Panneau latéral : joueurs, classement, monde ------------------------------------------ */
.side { flex: none; width: 300px; display: flex; flex-direction: column; background: var(--paper); border-left: 1px solid var(--ink); }
.side-head { display: none; }
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.side-sec { padding: 18px 18px 16px; border-bottom: 1px solid var(--rule); }
.side-sec h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.side-sec h2 small { font-weight: 400; letter-spacing: 0.04em; text-transform: none; font-size: 12.5px; }
.side-sec ul, .side-sec ol { margin: 0; padding: 0; list-style: none; }
/* Joueurs en ligne. */
.pl { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 6px; margin: 0 -6px; border-radius: var(--r); }
.pl .dot { width: 10px; height: 10px; }
.pl-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pl-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14.5px; }
.pl-text b em { color: var(--muted); font-style: normal; font-weight: 400; }
.pl-text small { display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; color: var(--muted); font: 400 12.5px var(--cond); }
.pl-text small .pips { font-size: 10px; }
.pl-act { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 9px; border: 1px solid var(--ink-2); border-radius: var(--r); background: transparent; color: var(--ink); font: 500 13px var(--cond); }
.pl-act svg { width: 14px; height: 14px; }
.pl-act:hover { background: var(--ink); color: var(--paper); }
.pl:hover { background: var(--paper-2); }
/* Classement. */
.rank { display: grid; grid-template-columns: 24px 10px 1fr auto; align-items: center; gap: 8px; min-height: 34px; padding: 0 6px; margin: 0 -6px; border-radius: var(--r); cursor: pointer; font-size: 14.5px; }
.rank + .rank { border-top: 1px dotted var(--rule); }
.rank:hover { background: var(--paper-2); }
.rank-n { color: var(--muted); text-align: right; font: italic 400 15px var(--serif); font-variant-numeric: tabular-nums; }
.rank .dot { width: 8px; height: 8px; }
.rank-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank b { font: 500 15px var(--cond); font-variant-numeric: tabular-nums; }
.rank-me { background: var(--clue); }
.rank-me:hover { background: #dcecf8; }
.rank-me .rank-name { font-weight: 500; }
.rank-gap { margin-top: 8px; border-top: 1px dashed var(--muted) !important; }
.side-sec .link { margin-top: 12px; font-size: 14px; }
/* Le monde. */
.world { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-size: 14.5px; }
.world dt { color: var(--ink-2); }
.world dd { margin: 0; font: 600 17px/1.2 var(--serif); font-variant-numeric: tabular-nums lining-nums; text-align: right; }

.scrim { display: none; }

/* --- Fenêtres ------------------------------------------------------------------------------ */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(29, 27, 24, 0.42); }
.sp-box { width: min(540px, 100%); max-height: min(780px, 100%); display: flex; flex-direction: column; }
.sp-body { flex: 1; min-height: 0; overflow-y: auto; font-size: 14.5px; line-height: 1.45; }
.sp-body h3:first-child { margin-top: 0; }
.mc-stats h3, .sp-body h3 { margin: 22px 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--ink); }

/* Accueil : choix du pseudo, sur le papier vierge de la grille. */
.welcome { background: var(--paper) var(--croix); padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); }
.welcome-box { width: min(480px, 100%); max-height: 100%; overflow-y: auto; padding: 32px; box-shadow: 6px 6px 0 rgba(29, 27, 24, 0.1); }
.welcome h1 { margin: 22px 0 26px; font: 700 40px/1.05 var(--serif); letter-spacing: -0.015em; }
.welcome label { display: block; margin-bottom: 8px; }
.welcome input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--ink); border-radius: var(--r); background: #fff; font-size: 18px; }
.welcome input:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.welcome .btn-lg { margin-top: 12px; }
.welcome-err { margin: 10px 0 0; color: var(--danger); font-size: 14.5px; line-height: 1.4; }
.welcome-code { margin-top: 14px; }
.welcome-code input { font-family: var(--cond); letter-spacing: 0.08em; text-transform: uppercase; }
.welcome-note { margin: 12px 0 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.45; }
.welcome-note b { font: 700 15px var(--cond); letter-spacing: 0.08em; color: var(--ink); white-space: nowrap; user-select: all; }
.welcome-foot { margin: 22px 0 0; font-size: 13px; }
.welcome-foot a { color: var(--muted); text-underline-offset: 3px; }
.side-about { display: block; margin: 18px 0 8px; color: var(--muted); font-size: 12.5px; text-underline-offset: 3px; }
.welcome .btn-ghost { margin-top: 8px; }
/* Mini-grille du titre : les mêmes cases que le jeu. */
/* Image d'accueil : la grille posée à plat, qui file jusqu'à l'horizon. */
.welcome-art { display: block; width: 100%; height: auto; }
.help { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 26px 0 0; padding-top: 18px; border-top: 1px solid var(--ink); font-size: 13.5px; }
.help dt { font: 500 13.5px var(--cond); white-space: nowrap; }
.help dd { margin: 0; color: var(--ink-2); }

/* --- Statistiques -------------------------------------------------------------------------- */
/* Chiffres clés : de grands chiffres en serif, séparés par des filets. */
.st-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); margin: 0 0 14px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.st-tile { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 10px 12px 10px 0; }
.st-tile + .st-tile { padding-left: 12px; border-left: 1px solid var(--rule); }
.st-tile b { font: 600 26px/1.1 var(--serif); font-variant-numeric: tabular-nums lining-nums; }
.st-tile b small { color: var(--muted); font-weight: 400; font-size: 16px; }
.st-tile span { margin-top: 2px; color: var(--muted); font: 400 12.5px var(--cond); }
.st-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px dotted var(--rule); }
.st-row:first-of-type { border-top: 0; }
.st-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 6px; }
.st-main { flex: 1; min-width: 0; }
.st-line { display: flex; align-items: baseline; gap: 10px; }
.st-line > span { flex: 1; min-width: 0; color: var(--ink); }
.st-line > span .pips { font-size: 11px; margin-left: 4px; color: var(--ink-2); }
.st-line > b { flex: none; white-space: nowrap; font: 500 14.5px var(--cond); }
.st-sub { margin-top: 1px; color: var(--muted); font-size: 12.5px; }
.st-mot { font: 600 13px var(--font); letter-spacing: 0.14em; color: var(--ink); }
.st-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.st-chip, .st-tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid var(--rule); border-radius: 2px; font-size: 13px; color: var(--ink-2); background: var(--card); }
.st-chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.st-chip b { color: var(--ink); font-weight: 500; }
.st-chip.moi { background: var(--clue); border-color: #c8dff0; }
.st-tag { margin: 0 4px 6px 0; font-size: 12.5px; }
.st-tag.fini { border-color: var(--ok); color: var(--ok); font-weight: 500; }
.st-bar { height: 3px; margin: 6px 0 8px; background: var(--rule); overflow: hidden; }
.st-bar i { display: block; height: 100%; }
.st-vide { margin: 0; color: var(--muted); font: italic 400 15px var(--serif); }
.sp-jour { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.sp-jour span:first-child { width: 3.4em; flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.sp-jour i { height: 9px; flex: none; background: var(--ink); }
.sp-jour span:last-child { color: var(--ink-2); }

/* --- Largeurs ------------------------------------------------------------------------------ */
/* Sous 1100 px, le panneau latéral devient un tiroir ouvert par le bouton des joueurs. */
@media (max-width: 1099px) {
  .side {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 45;
    width: min(340px, 88vw); padding-top: var(--safe-t); padding-right: var(--safe-r);
    box-shadow: var(--shadow-lg);
    transform: translateX(105%); transition: transform 0.2s ease; visibility: hidden;
  }
  .side-open .side { transform: none; visibility: visible; }
  .side-head { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 0 10px 0 18px; border-bottom: 1px solid var(--ink); }
  .side-head b { flex: 1; font: 600 21px/1 var(--serif); }
  .side-open .scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(29, 27, 24, 0.32); }
}
@media (min-width: 1100px) {
  .online { display: none; }
}
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px; }
  .brand { display: none; }
  .clue { order: 3; flex-basis: 100%; }
  .ct { flex: 1; width: auto; border-left: 0; }
  .clue-meta { display: none; }
  .map-hint { display: none; }
}

/* --- Écrans tactiles ------------------------------------------------------------------------ */
/* En-tête fin (contrée, joueurs) ; bandeau de définition et clavier du jeu en bas, sous les pouces. */
#dock { display: none; }
.help-touch { display: none; }
.touch .help-touch { display: grid; }
.touch .help-mouse { display: none; }
.touch { -webkit-tap-highlight-color: transparent; }
.touch #grid { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.touch .top { flex-wrap: nowrap; gap: 8px; min-height: 0; padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l)); }
.touch .brand { display: none; }
.touch .ct { flex: 1; width: auto; padding: 2px 4px; border-left: 0; }
.touch .online { height: 38px; }
.touch .debug { flex-wrap: wrap; white-space: normal; }
.touch .tools { right: calc(8px + var(--safe-r)); bottom: 8px; gap: 8px; }
.touch .map-tools { top: 8px; bottom: auto; }
.touch .toasts { top: 10px; bottom: auto; }
.touch .status { font-size: 12.5px; }
/* Au téléphone, la carte prend tout l'écran (par-dessus le clavier du jeu). */
.touch .worldmap { position: fixed; inset: 0; z-index: 50; }
.touch .map-head { justify-content: space-between; padding-top: calc(8px + var(--safe-t)); padding-right: calc(10px + var(--safe-r)); padding-left: calc(16px + var(--safe-l)); }
.touch .map-head .icon-btn { width: 44px; height: 44px; }
.touch .map-head .icon-btn svg { width: 24px; height: 24px; }
.touch .map-hint { display: none; }
.touch .map-legend { order: 3; flex-basis: 100%; gap: 4px 12px; font-size: 12.5px; }
.touch .map-card { bottom: calc(12px + var(--safe-b)); }
.touch .pl-act { height: 34px; padding: 0 11px; font-size: 14px; }
.touch .rank { min-height: 40px; }

.touch #dock {
  display: block; z-index: 2;
  padding: 8px calc(6px + var(--safe-r)) calc(6px + var(--safe-b)) calc(6px + var(--safe-l));
  background: var(--paper-2); border-top: 1px solid var(--ink);
  -webkit-user-select: none; user-select: none;
}
/* Hauteur fixe : passer d'une définition à l'autre ne redimensionne jamais la grille au-dessus
   (sinon elle se décale et clignote). Définition sur 2 lignes au plus, infos sur une seule. */
.touch .clue { height: 72px; gap: 2px; padding: 0 2px; }
.touch .clue-main { flex-direction: column; align-items: stretch; gap: 3px; }
.touch .clue-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; white-space: normal; font-size: 18px; line-height: 1.15; }
.touch .clue-meta { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.touch .clue-dir { width: 24px; height: 24px; margin: 0 4px 0 0; }
.touch .clue-btn { width: 40px; height: 56px; background: rgba(255, 255, 255, 0.6); }
.touch .clue-btn:active { background: #c9d9e8; }
.touch .clue.nosel .clue-text { padding-left: 6px; }

#kb { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.kb-row { display: flex; justify-content: center; gap: 5px; }
#kb button {
  flex: 1 1 0; max-width: 46px; height: 46px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #c9c1b0; border-radius: var(--r); background: #fff; color: var(--ink);
  font: 600 20px system-ui, -apple-system, sans-serif; box-shadow: 0 1px 0 #c9c1b0; touch-action: manipulation;
}
#kb button.down { background: var(--ink); color: var(--paper); border-color: var(--ink); transform: translateY(1px); box-shadow: none; }
#kb .kb-wide { flex: 1.7 1 0; max-width: 78px; background: var(--paper); }
#kb .kb-wide svg { width: 24px; height: 24px; }
/* Numéros des définitions affichés : pavé de chiffres à la place des lettres. */
#kb .kb-digits { display: none; }
.hinting #kb .kb-letters { display: none; }
.hinting #kb .kb-digits { display: flex; }
#kb .kb-digits button { max-width: 64px; }
