/* ==========================================================================
   Calculateur de bûcheronnage · Clan Crinière d'Or
   Thème forêt et bois, contours épais façon dessin animé.
   Couleurs du blason : or, rouge, noir.
   ========================================================================== */

:root {
  --encre: #2b1a0e;
  --encre-douce: #5b4330;
  --parchemin: #fdf4de;
  --parchemin-2: #f6e6c2;
  --parchemin-3: #ead3a2;
  --creme: #fffaf0;
  --bois-fonce: #6b3f1d;
  --bois: #8f5a2c;
  --bois-clair: #b97c45;
  --or: #e3bd55;
  --or-clair: #f5da84;
  --or-fonce: #b8902c;
  --rouge: #a12b2f;
  --noir-clan: #15120a;
  --sapin-fonce: #1d4630;
  --sapin: #2f6b45;
  --mousse: #86bf6a;
  --positif: #2a6e2d;
  --negatif: #b3261e;
  --fond-hausse: #d3eabf;
  --fond-baisse: #f7d2c8;

  --trait: 3px solid var(--encre);
  --ombre: 0 5px 0 var(--encre);
  --ombre-haute: 0 8px 0 var(--encre);
  --rayon: 20px;

  --police: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --police-titre: "Arial Black", "Segoe UI Black", "Arial Rounded MT Bold", "Helvetica Neue", sans-serif;

  --texture-bois:
    repeating-linear-gradient(176deg, transparent 0 9px, rgba(255, 255, 255, 0.07) 9px 11px, transparent 11px 21px, rgba(0, 0, 0, 0.1) 21px 23px),
    linear-gradient(180deg, #a86d38, #8a5428);
  --contour-texte:
    2px 2px 0 var(--encre), -2px 2px 0 var(--encre), 2px -2px 0 var(--encre), -2px -2px 0 var(--encre),
    0 3px 0 var(--encre), 0 -3px 0 var(--encre), 3px 0 0 var(--encre), -3px 0 0 var(--encre),
    0 6px 0 var(--encre);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: #9dd6d6;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--police);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--encre);
  /* Pas de fond ici : il passerait devant le décor (position fixed, z-index -1). */
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--bois-fonce);
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--rouge);
}

:focus-visible {
  outline: 4px solid var(--or);
  outline-offset: 2px;
  border-radius: 6px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icone {
  width: 1.5em;
  height: 1.5em;
  flex: none;
  vertical-align: middle;
}

.positif {
  color: var(--positif);
}

.negatif {
  color: var(--negatif);
}

/* --------------------------------------------------------------------------
   Décor de fond
   -------------------------------------------------------------------------- */

.decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(180deg, #8fd0d3 0%, #bfe5d9 42%, #f4ebc6 78%, #f4ebc6 100%);
}

.decor-ciel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 42vh;
}

.decor-foret {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: min(46vh, 430px);
}

.nuage {
  animation: derive 38s ease-in-out infinite alternate;
}

.nuage-2 {
  animation-duration: 52s;
  animation-delay: -12s;
}

.nuage-3 {
  animation-duration: 44s;
  animation-delay: -24s;
}

@keyframes derive {
  from {
    transform: translateX(-50px);
  }
  to {
    transform: translateX(60px);
  }
}

/* --------------------------------------------------------------------------
   Mise en page
   -------------------------------------------------------------------------- */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 16px 32vh;
}

.grille-calc {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.grille-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 0 28px;
  align-items: start;
}

.panneau:not([hidden]) {
  animation: apparition 0.28s ease-out;
}

@keyframes apparition {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   En-tête : panneau de bois et blason
   -------------------------------------------------------------------------- */

.entete {
  display: flex;
  justify-content: center;
  margin: 18px 0 26px;
}

.panneau-titre {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 100%;
  padding: 14px 30px 16px 18px;
  background:
    radial-gradient(circle at 16px 16px, #c9a26b 0 3.5px, var(--encre) 3.5px 5.5px, transparent 6px),
    radial-gradient(circle at calc(100% - 16px) 16px, #c9a26b 0 3.5px, var(--encre) 3.5px 5.5px, transparent 6px),
    radial-gradient(circle at 16px calc(100% - 16px), #c9a26b 0 3.5px, var(--encre) 3.5px 5.5px, transparent 6px),
    radial-gradient(circle at calc(100% - 16px) calc(100% - 16px), #c9a26b 0 3.5px, var(--encre) 3.5px 5.5px, transparent 6px),
    var(--texture-bois);
  border: 4px solid var(--encre);
  border-radius: 26px;
  box-shadow: var(--ombre-haute);
  transform: rotate(-0.6deg);
}

.blason {
  flex: none;
  width: 118px;
  height: auto;
  margin: -34px 0 -40px;
  filter: drop-shadow(0 6px 0 rgba(43, 26, 14, 0.85));
  transform: rotate(-3deg);
  transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.6, 1);
}

.panneau-titre:hover .blason {
  transform: rotate(2deg) scale(1.04);
}

.titres {
  min-width: 0;
}

.ruban {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 14px;
  font: 900 0.8rem/1.3 var(--police-titre);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--or-clair);
  background: var(--rouge);
  border: 3px solid var(--encre);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--encre);
  transform: rotate(-2deg);
}

h1 {
  margin: 0;
  font: 900 clamp(1.45rem, 4.4vw, 2.6rem)/1.08 var(--police-titre);
  letter-spacing: 0.01em;
  color: var(--or-clair);
  text-shadow: var(--contour-texte);
}

.devise {
  margin: 10px 0 0;
  font-weight: 700;
  font-style: italic;
  color: var(--parchemin);
  text-shadow: 0 2px 0 rgba(43, 26, 14, 0.8);
}

/* --------------------------------------------------------------------------
   Onglets : planches de bois
   -------------------------------------------------------------------------- */

.onglets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 40px;
}

.onglet {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 12px;
  font: 900 1rem/1.1 var(--police-titre);
  color: var(--parchemin);
  text-shadow: 0 2px 0 rgba(43, 26, 14, 0.85);
  background: var(--texture-bois);
  border: var(--trait);
  border-radius: 16px;
  box-shadow: var(--ombre);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.onglet .icone {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 2px 0 rgba(43, 26, 14, 0.5));
}

.onglet:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--encre);
}

.onglet[aria-selected="true"] {
  color: var(--encre);
  text-shadow: none;
  background: linear-gradient(180deg, var(--or-clair), var(--or));
  transform: translateY(-4px) rotate(-1deg);
  box-shadow: 0 9px 0 var(--encre);
}

/* --------------------------------------------------------------------------
   Cartes en parchemin et planches de titre
   -------------------------------------------------------------------------- */

.carte {
  position: relative;
  min-width: 0;
  margin: 0 0 40px;
  padding: 38px 20px 20px;
  background: var(--parchemin);
  border: var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre-haute);
}

.planche {
  position: absolute;
  top: -22px;
  left: 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 36px);
  margin: 0;
  padding: 6px 16px 6px 10px;
  font: 900 1.05rem/1.2 var(--police-titre);
  color: var(--parchemin);
  text-shadow: 0 2px 0 rgba(43, 26, 14, 0.85);
  background: var(--texture-bois);
  border: var(--trait);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--encre);
  transform: rotate(-1.5deg);
}

.planche .icone {
  width: 28px;
  height: 28px;
}

.planche-rouge {
  background: var(--rouge);
}

.carte-entree {
  position: sticky;
  top: 16px;
}

.titre-groupe {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0 10px;
  font: 900 0.95rem/1.2 var(--police-titre);
  color: var(--bois-fonce);
}

.titre-groupe:first-child {
  margin-top: 0;
}

.titre-groupe .icone {
  width: 26px;
  height: 26px;
}

.vide {
  margin: 0;
  padding: 18px;
  text-align: center;
  color: var(--encre-douce);
  background: var(--parchemin-2);
  border: 2px dashed var(--parchemin-3);
  border-radius: 14px;
}

.aide {
  margin: 0;
  font-size: 0.88rem;
  color: var(--encre-douce);
}

/* --------------------------------------------------------------------------
   Formulaires
   -------------------------------------------------------------------------- */

.champ {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 18px;
  min-width: 0;
}

.etiquette {
  font-weight: 800;
}

.ligne-champs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0 14px;
}

/* Champs longs (nom, liste d'articles) : l'un sous l'autre sur téléphone */
.ligne-champs-large {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

input[type="text"],
input[type="date"],
select {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  font-size: 1rem;
  background: var(--creme);
  border: var(--trait);
  border-radius: 12px;
  box-shadow: inset 0 3px 0 rgba(43, 26, 14, 0.1);
}

select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--encre) 50%),
    linear-gradient(135deg, var(--encre) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input[aria-invalid="true"] {
  border-color: var(--negatif);
  background-color: #fdecea;
}

.erreur-champ {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--negatif);
}

.erreur-champ:empty {
  display: none;
}

.erreurs-form {
  margin: 0 0 14px;
  padding: 10px 14px 10px 30px;
  font-weight: 700;
  color: #7d1a14;
  background: #fde2dc;
  border: 2px solid var(--negatif);
  border-radius: 12px;
}

.erreurs-form:empty {
  display: none;
}

/* Compteur de quantité */
.compteur {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  gap: 10px;
}

.compteur input {
  min-height: 58px;
  text-align: center;
  font: 900 1.7rem/1 var(--police-titre);
}

.btn-rond {
  font: 900 1.7rem/1 var(--police-titre);
  background: linear-gradient(180deg, var(--or-clair), var(--or));
  border: var(--trait);
  border-radius: 14px;
  box-shadow: var(--ombre);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.btn-rond:hover {
  filter: brightness(1.05);
}

.btn-rond:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--encre);
}

/* Bascule (deux choix collés) */
.bascule {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  overflow: hidden;
  background: var(--parchemin-2);
  border: var(--trait);
  border-radius: 14px;
  box-shadow: var(--ombre);
}

.bascule label {
  position: relative;
  display: block;
}

.bascule input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.bascule label > span {
  display: block;
  padding: 10px 8px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
}

.bascule label + label > span {
  border-left: var(--trait);
}

.bascule input:checked + span {
  background: linear-gradient(180deg, var(--or-clair), var(--or));
}

.bascule input:focus-visible + span {
  outline: 4px solid var(--sapin);
  outline-offset: -6px;
}

.bascule-type input[value="depense"]:checked + span {
  background: var(--fond-baisse);
}

.bascule-type input[value="recette"]:checked + span {
  background: var(--fond-hausse);
}

/* Prix utilisés */
.prix-utilises ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 0;
  list-style: none;
}

.jeton {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  font-size: 0.9rem;
  background: var(--parchemin-2);
  border: 2px solid var(--encre);
  border-radius: 999px;
}

.jeton .icone {
  width: 24px;
  height: 24px;
}

/* --------------------------------------------------------------------------
   Boutons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  font: 900 1rem/1.15 var(--police-titre);
  color: var(--encre);
  text-decoration: none;
  background: var(--or);
  border: var(--trait);
  border-radius: 14px;
  box-shadow: var(--ombre);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, filter 0.1s;
}

.btn .icone {
  width: 24px;
  height: 24px;
}

.btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 6px 0 var(--encre);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--encre);
}

.btn-or {
  background: linear-gradient(180deg, var(--or-clair), var(--or));
}

.btn-bois {
  color: var(--parchemin);
  text-shadow: 0 2px 0 rgba(43, 26, 14, 0.85);
  background: var(--texture-bois);
}

.btn-rouge {
  color: var(--parchemin);
  background: var(--rouge);
}

.btn-large {
  width: 100%;
}

.btn-supprimer {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-weight: 900;
  color: var(--parchemin);
  background: var(--rouge);
  border: 2px solid var(--encre);
  border-radius: 50%;
  box-shadow: 0 3px 0 var(--encre);
  cursor: pointer;
}

.btn-supprimer:hover {
  filter: brightness(1.15);
}

.btn-supprimer:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--encre);
}

/* --------------------------------------------------------------------------
   Résultats
   -------------------------------------------------------------------------- */

.resultats {
  min-width: 0;
}

/* Verdict : bandeau aux couleurs du blason, diagonale noir / rouge, chiffres d'or */
.verdict-banniere {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  margin: 0 0 34px;
  padding: 18px 20px;
  color: var(--or-clair);
  background: linear-gradient(118deg, var(--noir-clan) 0 62%, var(--rouge) 62% 100%);
  border: 4px solid var(--encre);
  border-radius: var(--rayon);
  box-shadow: var(--ombre-haute);
}

.verdict-fabrication {
  background: linear-gradient(118deg, var(--rouge) 0 62%, var(--noir-clan) 62% 100%);
}

.verdict-egalite,
.verdict-neutre {
  color: var(--encre);
  background: linear-gradient(180deg, var(--or-clair), var(--or));
}

.verdict-medaille {
  display: grid;
  place-items: center;
  flex: none;
  width: 64px;
  height: 64px;
  background: radial-gradient(circle at 35% 30%, var(--or-clair), var(--or) 60%, var(--or-fonce));
  border: 3px solid var(--encre);
  border-radius: 50%;
  box-shadow: 0 4px 0 var(--encre);
}

.verdict-medaille .icone {
  width: 38px;
  height: 38px;
}

.verdict-texte {
  flex: 1 1 180px;
  min-width: 0;
}

.verdict-titre {
  margin: 0;
  font: 900 clamp(1.35rem, 3.6vw, 2rem)/1.1 var(--police-titre);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
}

.verdict-sous {
  margin: 4px 0 0;
  font-weight: 700;
  color: var(--parchemin-2);
}

.verdict-egalite .verdict-titre,
.verdict-neutre .verdict-titre {
  text-shadow: none;
}

.verdict-egalite .verdict-sous,
.verdict-neutre .verdict-sous {
  color: var(--encre-douce);
}

.verdict-gain {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 8px 16px;
  font: 900 clamp(1.4rem, 3.4vw, 1.8rem)/1 var(--police-titre);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--encre);
  background: linear-gradient(180deg, var(--or-clair), var(--or));
  border: 3px solid var(--encre);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--encre);
  transform: rotate(2deg);
}

.verdict-gain small {
  margin-top: 3px;
  font: 800 0.78rem/1 var(--police);
}

/* Deux fiches : une par façon d'avoir une hache */
.fiches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 26px 18px;
  margin: 0 0 40px;
}

.fiche {
  position: relative;
  min-width: 0;
  background: var(--parchemin);
  border: var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre-haute);
}

.fiche.gagnante {
  outline: 4px solid var(--or);
  outline-offset: 3px;
}

.fiche-tete {
  padding: 16px 18px 14px;
  color: var(--or-clair);
  background: linear-gradient(118deg, var(--noir-clan) 0 58%, var(--rouge) 58% 100%);
  border-bottom: var(--trait);
  border-radius: calc(var(--rayon) - 3px) calc(var(--rayon) - 3px) 0 0;
}

.fiche-fabrication .fiche-tete {
  background: linear-gradient(118deg, var(--rouge) 0 58%, var(--noir-clan) 58% 100%);
}

.fiche-titre {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font: 900 1.05rem/1.2 var(--police-titre);
  color: var(--parchemin);
}

.fiche-titre .icone {
  width: 30px;
  height: 30px;
}

.fiche-montant {
  margin: 8px 0 0;
  font: 900 clamp(2rem, 4.6vw, 2.6rem)/1.05 var(--police-titre);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.65);
}

.fiche-montant.negatif {
  color: #ffb3a7;
}

.fiche-legende {
  margin: 2px 0 0;
  font-weight: 700;
  color: var(--parchemin-2);
}

.fiche > .alerte {
  margin: 14px 14px 0;
}

.fiche > .vide {
  margin: 14px;
}

.fiche-lignes {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
  list-style: none;
}

.ligne {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 8px;
  background: var(--creme);
  border: 2px solid var(--parchemin-3);
  border-radius: 14px;
}

.ligne .icone {
  width: 46px;
  height: 46px;
}

.ligne-texte {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.ligne-principal {
  font-weight: 700;
}

.ligne-valeur {
  font: 900 1.35rem/1.1 var(--police-titre);
  font-variant-numeric: tabular-nums;
}

.ligne-sous {
  font-size: 0.86rem;
  color: var(--encre-douce);
}

/* Pastille dorée qui déborde du coin haut droit, au-dessus du libellé */
.badge-gagnant {
  position: absolute;
  top: -15px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px 3px 7px;
  font: 900 0.72rem/1.2 var(--police-titre);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--encre);
  background: linear-gradient(180deg, var(--or-clair), var(--or));
  border: 3px solid var(--encre);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--encre);
  transform: rotate(3deg);
}

.badge-gagnant .icone {
  width: 16px;
  height: 16px;
}

.alerte {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 14px;
  font-weight: 800;
  color: #7d1a14;
  background: #fde2dc;
  border: var(--trait);
  border-radius: 12px;
}

.alerte .icone {
  width: 30px;
  height: 30px;
}

/* Détail du calcul */
.carte-detail > summary {
  list-style: none;
  cursor: pointer;
}

.carte-detail > summary::-webkit-details-marker {
  display: none;
}

.resume-detail {
  display: inline-block;
  font-weight: 800;
  color: var(--bois-fonce);
}

.carte-detail[open] > summary {
  margin-bottom: 16px;
}

.carte-detail .si-ouvert,
.carte-detail[open] .si-ferme {
  display: none;
}

.carte-detail[open] .si-ouvert {
  display: inline;
}

/* Un bloc par sujet (la coupe, le charbon, l'argent…), chacun avec un tableau à trois colonnes. */
.calcul-blocs {
  display: grid;
  gap: 14px;
}

.calcul-bloc {
  padding: 12px 16px 4px;
  background: var(--creme);
  border: 2px solid var(--parchemin-3);
  border-radius: 14px;
}

.calcul-titre {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  font: 900 1rem/1.2 var(--police-titre);
  color: var(--bois-fonce);
}

.calcul-titre .icone {
  width: 28px;
  height: 28px;
}

.calcul-precision {
  padding: 2px 9px;
  font: 700 0.76rem/1.3 var(--police);
  color: var(--encre-douce);
  background: var(--parchemin-2);
  border-radius: 999px;
}

.calcul-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 -4px;
  font: 900 1.1rem/1.2 var(--police-titre);
}

.calcul-mode .icone {
  width: 32px;
  height: 32px;
}

.calcul {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.calcul th,
.calcul td {
  padding: 9px 0;
  text-align: left;
  vertical-align: baseline;
  border-top: 1px dashed var(--parchemin-3);
}

.calcul tr:first-child > * {
  border-top: 0;
}

.calcul th {
  width: 38%;
  padding-right: 14px;
  font-weight: 700;
}

.calcul .calcul-formule {
  padding-right: 14px;
  font-size: 0.92rem;
  color: var(--encre-douce);
}

.calcul .calcul-valeur {
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.calcul-signe {
  display: inline-block;
  min-width: 1em;
  margin-right: 4px;
  font-weight: 900;
  text-align: center;
}

/* Résultat d'un compte : sous un trait, en gras */
.calcul .calcul-total > * {
  font-size: 1.06rem;
  font-weight: 900;
  border-top: 2px solid var(--encre);
}

/* Carte d'erreur */
.carte-alerte {
  background: #fdeee9;
}

.liste-erreurs {
  margin: 0 0 12px;
  padding-left: 22px;
  font-weight: 700;
  color: #7d1a14;
}

/* --------------------------------------------------------------------------
   Prix
   -------------------------------------------------------------------------- */

.cours-grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr));
  gap: 14px;
}

.cours {
  display: grid;
  justify-items: start;
  align-content: start;
  gap: 6px;
  padding: 12px;
  background: var(--creme);
  border: var(--trait);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--encre);
}

.icone-grande {
  width: 42px;
  height: 42px;
}

.cours-nom {
  font-weight: 800;
}

/* Le prix se modifie directement dans la carte */
.cours-saisie {
  position: relative;
  display: block;
  width: 100%;
}

.cours .cours-champ {
  padding-right: 42px;
  font: 900 1.3rem/1 var(--police-titre);
  font-variant-numeric: tabular-nums;
  background-color: var(--parchemin);
}

.cours-unite {
  position: absolute;
  top: 50%;
  right: 12px;
  font-weight: 800;
  color: var(--encre-douce);
  transform: translateY(-50%);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Listes (historique des prix, écritures du journal)
   -------------------------------------------------------------------------- */

.rangees {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rangee {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 10px;
  background: var(--creme);
  border: 2px solid var(--parchemin-3);
  border-radius: 14px;
}

.rangee > .icone {
  width: 36px;
  height: 36px;
}

.rangee-texte {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.rangee-titre {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.rangee-sous {
  font-size: 0.84rem;
  color: var(--encre-douce);
  overflow-wrap: anywhere;
}

.rangee-montant {
  flex: none;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rangee .btn-supprimer {
  flex: none;
}

.ecriture-depense {
  border-left: 6px solid var(--negatif);
}

.ecriture-depense .rangee-montant {
  color: var(--negatif);
}

.ecriture-recette {
  border-left: 6px solid var(--positif);
}

.ecriture-recette .rangee-montant {
  color: var(--positif);
}

/* --------------------------------------------------------------------------
   Journal : bilan
   -------------------------------------------------------------------------- */

.champ-filtre {
  max-width: 320px;
}

.bilan-tuiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.bilan-tuile {
  padding: 10px 8px;
  text-align: center;
  border: var(--trait);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--encre);
}

.bilan-tuile span {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
}

.bilan-tuile strong {
  display: block;
  font: 900 clamp(0.95rem, 2.2vw, 1.2rem)/1.2 var(--police-titre);
  font-variant-numeric: tabular-nums;
}

.bt-depenses {
  background: var(--fond-baisse);
}

.bt-recettes {
  background: var(--fond-hausse);
}

.bt-solde {
  background: linear-gradient(180deg, var(--or-clair), var(--or));
}

.bt-solde-negatif {
  background: #f2a99b;
}

.joueurs {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.joueur {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--creme);
  border: 2px solid var(--parchemin-3);
  border-radius: 12px;
}

.joueur-nom {
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.joueur-solde {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.joueur-choisi {
  background: var(--parchemin-2);
  border-color: var(--encre);
}

.total-apercu {
  margin: 0 0 14px;
  padding: 8px 12px;
  font-size: 1.05rem;
  background: var(--parchemin-2);
  border-radius: 10px;
}

/* --------------------------------------------------------------------------
   Paramètres
   -------------------------------------------------------------------------- */

.champ-param input {
  max-width: 220px;
  font-weight: 800;
}

.reperes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.repere {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 10px;
  background: var(--creme);
  border: 2px solid var(--parchemin-3);
  border-radius: 12px;
}

.repere .icone {
  flex: none;
  width: 38px;
  height: 38px;
}

.repere-texte {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.repere-libelle {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--encre-douce);
}

.repere-valeur {
  font: 900 1.15rem/1.15 var(--police-titre);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Pied de page, notification, dialogue
   -------------------------------------------------------------------------- */

.pied {
  margin-top: 10px;
  text-align: center;
  font-weight: 800;
  color: var(--parchemin);
  text-shadow: 0 2px 0 var(--encre), 0 -1px 0 var(--encre), 1px 0 0 var(--encre), -1px 0 0 var(--encre);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 50;
  max-width: min(92vw, 520px);
  padding: 12px 18px;
  font-weight: 800;
  color: var(--parchemin);
  text-shadow: 0 1px 0 var(--encre);
  background: var(--texture-bois);
  border: var(--trait);
  border-radius: 14px;
  box-shadow: var(--ombre);
  visibility: hidden;
  transform: translate(-50%, 160%);
  transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.6, 1), visibility 0.3s;
}

.toast.visible {
  visibility: visible;
  transform: translate(-50%, 0);
}

.toast-succes {
  background: var(--sapin);
}

.toast-erreur {
  background: var(--rouge);
}

.dialogue {
  max-width: min(92vw, 460px);
  padding: 0;
  color: var(--encre);
  background: var(--parchemin);
  border: 4px solid var(--encre);
  border-radius: 20px;
  box-shadow: 0 8px 0 var(--encre);
}

.dialogue::backdrop {
  background: rgba(21, 18, 10, 0.6);
}

.dialogue form {
  padding: 22px;
}

.dialogue h2 {
  margin: 0 0 10px;
  font: 900 1.25rem/1.2 var(--police-titre);
}

.dialogue p {
  margin: 0;
}

.dialogue-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* --------------------------------------------------------------------------
   Écrans étroits
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .grille-calc {
    grid-template-columns: minmax(0, 1fr);
  }

  .carte-entree {
    position: relative;
    top: auto;
  }
}

@media (max-width: 680px) {
  .page {
    padding-top: 18px;
  }

  .panneau-titre {
    gap: 12px;
    padding: 12px 16px 12px 12px;
  }

  .blason {
    width: 78px;
    margin: -22px 0 -26px;
  }

  .ruban {
    font-size: 0.68rem;
    padding: 2px 10px;
  }

  .devise {
    display: none;
  }

  .onglets {
    gap: 8px;
  }

  .onglet {
    flex-direction: column;
    gap: 4px;
    min-height: 64px;
    padding: 8px 4px;
    font-size: 0.74rem;
  }

  .onglet .icone {
    width: 28px;
    height: 28px;
  }

  .carte {
    padding: 36px 14px 16px;
  }
}

/* Détail du calcul sur téléphone : libellé et résultat sur une ligne, le calcul en dessous. */
@media (max-width: 560px) {
  .calcul-bloc {
    padding: 10px 12px 4px;
  }

  .calcul,
  .calcul tbody {
    display: block;
  }

  .calcul tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 1px;
    padding: 8px 0;
    border-top: 1px dashed var(--parchemin-3);
  }

  .calcul tr:first-child {
    border-top: 0;
  }

  .calcul th,
  .calcul td {
    width: auto;
    padding: 0;
    border-top: 0;
  }

  .calcul th {
    grid-column: 1;
    grid-row: 1;
  }

  .calcul .calcul-valeur {
    grid-column: 2;
    grid-row: 1;
  }

  .calcul .calcul-formule {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 0;
    font-size: 0.84rem;
  }

  .calcul .calcul-formule:empty {
    display: none;
  }

  .calcul .calcul-total {
    border-top: 2px solid var(--encre);
  }

  .calcul .calcul-total > * {
    border-top: 0;
  }
}

@media (max-width: 460px) {
  .bilan-tuiles {
    grid-template-columns: minmax(0, 1fr);
  }

  .bilan-tuile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
  }

  .compteur {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
  }
}

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