/* Tailles à l'échelle 1 (interface.md § 2, § 8) ; main.js applique un facteur entier par transform.
   Habillage : plaques de métal sombre à rivets et boutons ocre bombés (direction-artistique.md § 9).
   Contrastes calculés dans tests/rendu-ui.test.js à partir des variables ci-dessous : les modifier avec lui. */
:root {
  color-scheme: dark;
  --fond: #1c120e; --texte: #f4ead8; --erreur: #ff4a3a;
  --jaune: #ffd24a; --rouge-clair: #ff9a8a; --sable: #e0b88a;
  --plaque-haut: #41382f; --plaque-bas: #272019; --plaque-bord: #7a6449; --rivet: #a8916b;
  --ocre-haut: #dca877; --ocre-bas: #bd7a45; --ocre-bord: #5a3220; --ocre-texte: #24100a; --ocre-ombre: #2a140a; --ocre-selection: #fff3d6;
  --off-fond: #4a3224; --off-texte: #f4ead8; --off-opacite: 0.75;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--fond); color: var(--texte); font: 14px/1.15 var(--sans); overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#cadre { position: relative; width: 100%; height: 100%; overflow: hidden; }
[hidden] { display: none !important; }
.mono, .cout { font-family: var(--mono); }

/* Plaque : métal sombre en dégradé, bordure ocre foncé (en ombre interne : elle ne change aucune taille), quatre rivets, relief interne. */
.plaque {
  background:
    radial-gradient(circle at 6px 6px, #d8c49c 0, var(--rivet) 1px, #5a4630 2px, transparent 2.6px),
    radial-gradient(circle at calc(100% - 6px) 6px, #d8c49c 0, var(--rivet) 1px, #5a4630 2px, transparent 2.6px),
    radial-gradient(circle at 6px calc(100% - 6px), #d8c49c 0, var(--rivet) 1px, #5a4630 2px, transparent 2.6px),
    radial-gradient(circle at calc(100% - 6px) calc(100% - 6px), #d8c49c 0, var(--rivet) 1px, #5a4630 2px, transparent 2.6px),
    linear-gradient(var(--plaque-haut), var(--plaque-bas));
  box-shadow: inset 0 0 0 2px var(--plaque-bord), inset 0 3px 0 rgba(255, 235, 200, 0.14), inset 0 -4px 8px rgba(0, 0, 0, 0.45);
}

#zone { position: absolute; left: 50%; top: 50%; display: flex; transform-origin: 0 0; }
#carte { position: relative; flex: none; }
#toile { display: block; touch-action: none; image-rendering: auto; }
#colonne { flex: none; width: 120px; display: flex; flex-direction: column; touch-action: none; }

#infos { position: relative; height: 48px; padding: 0 8px; }
#infos .ligne { height: 24px; display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; }
#infos b { color: var(--jaune); }
#pv b { color: var(--rouge-clair); }
#vague { letter-spacing: -0.6px; white-space: nowrap; } /* « Vague 10 / 10 » tient dans les 104 px utiles */
#deltas { position: absolute; inset: 0; pointer-events: none; }
.delta { position: absolute; right: calc(100% + 6px); font-family: var(--mono); font-size: 14px; font-weight: 700; text-shadow: 0 0 3px #000, 0 0 3px #000; animation: monte 1.5s ease-out forwards; }
.delta.argent { top: 4px; } .delta.pv { top: 26px; }
@keyframes monte { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(6px); } }
/* Éclat rouge : cadre en ombre interne et fond léger (≤ 0,35) placés sous le texte, qui reste lisible. */
#infos { isolation: isolate; }
#infos.flash::after { content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(160, 42, 26, 0.35); box-shadow: inset 0 0 0 3px var(--erreur); pointer-events: none; animation: flash 0.5s; }
@keyframes flash { 0%, 100% { opacity: 0; } 40% { opacity: 1; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#argent.clignote { animation: clignote 0.5s 2; }
@keyframes clignote { 50% { color: var(--erreur); } }

#commandes { display: flex; height: 48px; }

/* Bouton ocre bombé : dégradé, bordure brun sombre, ombre de 2 px sous le bord (à l'intérieur : les boutons sont jointifs), enfoncement de 2 px. */
.bouton { height: 48px; min-width: 48px; border: 2px solid var(--ocre-bord); background: linear-gradient(var(--ocre-haut), var(--ocre-bas)); color: var(--ocre-texte); box-shadow: inset 0 1px 0 rgba(255, 235, 200, 0.55), inset 0 -2px 0 var(--ocre-ombre); font: 600 16px/1.1 var(--sans); touch-action: manipulation; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 0 2px; }
#commandes .bouton { width: 60px; padding: 0; white-space: nowrap; }
#pause[aria-pressed="true"] { font-size: 14px; }
.bouton.large { width: 120px; }
.bouton:active { transform: translateY(2px); box-shadow: none; }
.bouton[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--ocre-selection), inset 0 -2px 0 var(--ocre-ombre); }
/* Désactivé : fond sombre, texte clair, opacité réduite (contraste vérifié par test), bordure en pointillés. */
.bouton[aria-disabled="true"] { background: var(--off-fond); color: var(--off-texte); opacity: var(--off-opacite); border-style: dashed; box-shadow: none; }
.bouton[aria-disabled="true"]:active { transform: none; }
.bouton:focus-visible { outline: 3px solid #fff; outline-offset: -3px; box-shadow: inset 0 0 0 5px var(--ocre-bord); }
#lancer { line-height: 1.05; }
#lancer small { font-size: 14px; font-weight: 400; }
/* Une ligne par libellé, 14 px (plancher du projet), dans les 112 px utiles : la hauteur reste 48 px. */
#lancer-texte, #lancer-attente { display: block; width: 100%; overflow: hidden; white-space: nowrap; text-align: center; }
#lancer-texte { font-size: 14px; }
.secoue { animation: secoue 0.3s; }
@keyframes secoue { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

#panneau { height: 192px; display: flex; flex-direction: column; }
#panneau .aide { height: 144px; padding: 8px 8px; }
#panneau .fiche { height: 96px; padding: 0 8px; line-height: 16px; overflow: hidden; }
#panneau .fiche > * { display: block; overflow: hidden; white-space: nowrap; }
#panneau .fiche strong { font-weight: 700; }
#panneau .hauteur { height: 48px; padding: 0 8px; line-height: 48px; overflow: hidden; white-space: nowrap; font-size: 14px; }
.grille { display: grid; grid-template-columns: 60px 60px; }
.grille .bouton { width: 60px; }
.bouton.type { font-size: 14px; }
.bouton.type .icone { width: 26px; height: 26px; flex: none; }
.bouton .cout { font-weight: 700; color: inherit; }
.bouton.texte { font-size: 14px; padding: 0; white-space: nowrap; }
.bouton.texte .nom { display: block; width: 100%; overflow: hidden; text-align: center; font-weight: 400; }

#bandeau { position: absolute; left: 12%; right: 12%; height: 32px; display: flex; align-items: center; justify-content: center; background: rgba(28,18,14,0.88); border: 1px solid var(--erreur); font-weight: 700; pointer-events: none; opacity: 0; }
#bandeau.visible { opacity: 1; }

#fin { position: absolute; inset: 0; background: rgba(28,18,14,0.86); display: flex; align-items: center; justify-content: center; text-align: center; animation: apparait 0.35s ease-out; }
.cartouche { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 32px 20px; max-width: 100%; }
#fin h2 { font-size: 28px; line-height: 1.1; letter-spacing: 0.08em; text-transform: uppercase; }
#fin h2:focus { outline: none; }
#fin[data-issue="victoire"] h2 { color: var(--jaune); }
#fin[data-issue="defaite"] h2 { color: var(--rouge-clair); }
#fin-detail { font-size: 16px; color: var(--sable); }
#bilan { display: grid; grid-template-columns: auto auto; gap: 2px 24px; margin: 4px 0 8px; font-family: var(--mono); font-size: 16px; text-align: left; }
#bilan dt { color: var(--sable); }
#bilan dd { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.rangee-boutons { display: flex; gap: 8px; }
.rangee-boutons .bouton { width: 140px; }
@keyframes apparait { from { opacity: 0; } to { opacity: 1; } }

.ecran { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--fond); text-align: center; padding: 16px; font-size: 18px; }
#inadapte { position: fixed; z-index: 10; }
#reessayer { width: 200px; }

/* Écran de début : désert rouge (univers.md), titre dans une plaque à rivets pour garder le contraste. */
#debut { background: linear-gradient(to bottom, #3a1c16 0%, #a4542e 62%, #c9885a 62%, #a8663f 63.5%, #8a4f2e 100%); animation: apparait 0.5s ease-out; }
.carte-titre { width: min(520px, 100%); max-width: 520px; padding: 18px 28px 22px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.carte-titre h1 { font-size: clamp(36px, min(13vh, 9vw), 72px); line-height: 1.05; font-weight: 800; letter-spacing: 0.1em; white-space: nowrap; }
.sous-titre { font-size: 16px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--sable); }
.accroche { font-size: 16px; line-height: 1.3; margin-bottom: 8px; text-wrap: balance; }
.bouton.large-titre { width: 200px; height: 48px; font-size: 18px; }

@media (prefers-reduced-motion: reduce) {
  .delta, #infos.flash::after, #argent.clignote, .secoue { animation: none; }
  .delta { opacity: 1; }
  #infos.flash::after { opacity: 1; }
  #argent.clignote { color: var(--erreur); }
  .secoue { outline: 3px solid var(--erreur); }
  #fin, #debut { animation: none; }
}
