/* Ambiance « tapis de bar » de l'app iOS : feutre vert, laiton, crème. */
:root {
  --felt-light: #175c40;
  --felt-dark: #051f14;
  --brass: #f2bd57;
  --brass-dark: #b8802e;
  --cream: #faf2de;
  --muted: rgba(250, 242, 222, 0.62);
  --faint: rgba(250, 242, 222, 0.38);
  --danger: #ed4d4a;
  --fire: #ff8c26;
  --card: rgba(0, 0, 0, 0.28);
  --card-stroke: rgba(255, 255, 255, 0.07);
  --pip: #1d1a16;
  --pip-red: #c8252a;
  --radius: 22px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-weight: 500;
  color: var(--cream);
  background: var(--felt-dark) radial-gradient(ellipse 120% 80% at 50% 30%, var(--felt-light), var(--felt-dark)) fixed;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brass); }

.wrap {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

h1, h2, h3 { margin: 0; line-height: 1.1; }

.label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
}

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.center { text-align: center; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--card-stroke);
  border-radius: var(--radius);
  padding: 16px;
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }

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

.btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  font: 800 21px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.btn-primary {
  color: rgba(0, 0, 0, 0.82);
  background: linear-gradient(var(--brass), #c99a45);
  box-shadow: 0 6px 18px rgba(242, 189, 87, 0.35);
}

.btn-secondary {
  color: var(--cream);
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(250, 242, 222, 0.35);
}

.btn-small { min-height: 44px; font-size: 16px; border-radius: 14px; width: auto; }

.icon-btn {
  appearance: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--card-stroke);
  background: var(--card);
  color: var(--cream);
  font-size: 20px;
  cursor: pointer;
}

/* --- Dés ----------------------------------------------------------------------------------- */

.dice-row { display: flex; justify-content: center; gap: 18px; padding: 8px 0; }

.die {
  --size: 88px;
  appearance: none;
  position: relative;
  width: var(--size);
  height: var(--size);
  padding: calc(var(--size) * 0.14);
  border: 0;
  border-radius: calc(var(--size) * 0.2);
  background: linear-gradient(145deg, #fffaf0, #e9dfc6);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 8px 18px rgba(0, 0, 0, 0.45);
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  touch-action: manipulation;
}

button.die { cursor: pointer; }
button.die:disabled { cursor: default; }

.die .pip {
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--pip);
  box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.35);
}

.die.red .pip { background: var(--pip-red); }

.die .p1 { grid-area: 1 / 1; } .die .p2 { grid-area: 1 / 2; } .die .p3 { grid-area: 1 / 3; }
.die .p4 { grid-area: 2 / 1; } .die .p5 { grid-area: 2 / 2; } .die .p6 { grid-area: 2 / 3; }
.die .p7 { grid-area: 3 / 1; } .die .p8 { grid-area: 3 / 2; } .die .p9 { grid-area: 3 / 3; }

.die.blank { background: rgba(250, 242, 222, 0.12); box-shadow: inset 0 0 0 2px rgba(250, 242, 222, 0.2); }

.die.held {
  transform: translateY(-8px);
  box-shadow: 0 0 0 4px var(--brass), 0 12px 22px rgba(0, 0, 0, 0.5);
}

.die.held::after {
  content: "GARDÉ";
  position: absolute;
  left: 50%;
  bottom: -30px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--brass);
}

.die.rolling { animation: tumble 0.55s cubic-bezier(0.3, 0.7, 0.4, 1); }

@keyframes tumble {
  0% { transform: translateY(-40px) rotate(-200deg) scale(0.8); }
  60% { transform: translateY(6px) rotate(15deg) scale(1.04); }
  80% { transform: translateY(-4px) rotate(-6deg); }
  100% { transform: none; }
}

.mini-dice { display: inline-flex; gap: 5px; vertical-align: middle; }
.mini-dice .die { --size: 26px; padding: 4px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
.mini-dice .die .pip { box-shadow: none; }

@media (max-width: 360px) {
  .die { --size: 76px; }
  .dice-row { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .die.rolling { animation: none; }
  .btn, .die { transition: none; }
}

/* --- Accueil ------------------------------------------------------------------------------- */

.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: clamp(40px, 12vw, 60px); font-weight: 900; letter-spacing: -0.02em; }
.hero h1 span { color: var(--brass); }
.hero p { margin: 12px auto 0; max-width: 30em; font-size: 18px; line-height: 1.45; color: var(--muted); }
.hero .dice-row { margin: 22px 0 10px; }

.home-actions { display: flex; flex-direction: column; gap: 12px; margin: 22px 0 8px; }

/* --- Contenu éditorial (accueil + règles) --------------------------------------------------- */

.prose { line-height: 1.55; font-size: 17px; }
.prose h2 { font-size: 26px; font-weight: 900; margin: 34px 0 12px; }
.prose h3 { font-size: 19px; font-weight: 800; margin: 22px 0 8px; }
.prose p, .prose li { color: rgba(250, 242, 222, 0.88); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 6px 0; }

.hands { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.hands li { display: flex; align-items: center; gap: 14px; margin: 0; }
.hands strong { display: block; font-size: 18px; }
.hands .fire { color: var(--fire); }
.hands small { color: var(--muted); font-size: 14px; }

.faq details { border-top: 1px solid var(--card-stroke); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 800; font-size: 17px; }
.faq details p { margin: 10px 0 0; }

.site-footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--card-stroke); font-size: 14px; color: var(--faint); text-align: center; }
.site-footer a { color: var(--muted); }

.topnav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.topnav a.brand { font-weight: 900; font-size: 20px; text-decoration: none; color: var(--cream); }

/* --- Écran de jeu -------------------------------------------------------------------------- */

.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.bar .label { flex: 1; }

.players { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-stroke);
  font-size: 14px;
  font-weight: 700;
}
.chip.current { border-color: var(--brass); color: var(--brass); }
.chip.out { opacity: 0.4; text-decoration: line-through; }
.legs { letter-spacing: 1px; font-size: 12px; color: var(--brass); }
.legs .lost { color: var(--faint); }

.turn-name { font-size: clamp(34px, 10vw, 46px); font-weight: 900; text-align: center; margin: 18px 0 4px; overflow-wrap: anywhere; }
.turn-info { text-align: center; color: var(--muted); font-size: 16px; min-height: 22px; }

.combo { text-align: center; min-height: 64px; margin: 26px 0 6px; }
.combo .title { font-size: 34px; font-weight: 900; }
.combo .title.fire { color: var(--fire); text-shadow: 0 0 24px rgba(255, 140, 38, 0.6); }
.combo .title.bad { color: var(--danger); }
.combo .sub { color: var(--muted); font-size: 15px; margin-top: 4px; }

.hint { text-align: center; color: var(--faint); font-size: 14px; min-height: 20px; margin: 4px 0 14px; }

.actions { display: flex; flex-direction: column; gap: 12px; }

.played { margin-top: 18px; }
.played li, .results li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--card-stroke); }
.played ul, .results ul { list-style: none; margin: 8px 0 0; padding: 0; }
.played .who, .results .who { flex: 1; font-weight: 700; overflow-wrap: anywhere; }
.results li.loser .who, .results li.loser .what { color: var(--danger); }
.results .rank { width: 24px; color: var(--faint); font-weight: 800; }
.what { font-weight: 800; }

/* --- Passage du téléphone, résultats ------------------------------------------------------ */

.handoff { min-height: 70dvh; display: flex; flex-direction: column; justify-content: center; gap: 22px; text-align: center; }
.handoff .big { font-size: clamp(34px, 11vw, 50px); font-weight: 900; overflow-wrap: anywhere; }
.handoff .big span { color: var(--brass); }

.banner { text-align: center; padding: 18px; }
.banner .big { font-size: 30px; font-weight: 900; }
.banner.loss .big { color: var(--danger); }
.banner .penalty { margin-top: 10px; font-size: 20px; font-weight: 800; color: var(--brass); }
.banner .dare { margin-top: 6px; font-size: 18px; color: var(--cream); }
.banner .line { margin-top: 8px; color: var(--muted); font-style: italic; }

.podium { text-align: center; padding: 10px 0 4px; }
.podium .trophy { font-size: 56px; }
.podium .big { font-size: 36px; font-weight: 900; color: var(--brass); overflow-wrap: anywhere; }

.stats { width: 100%; border-collapse: collapse; font-size: 15px; }
.stats th, .stats td { padding: 8px 4px; border-top: 1px solid var(--card-stroke); text-align: center; }
.stats th { color: var(--brass); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.stats td:nth-child(2), .stats th:nth-child(2) { text-align: left; }

/* --- Réglages ----------------------------------------------------------------------------- */

.field { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; padding: 10px 0; border-top: 1px solid var(--card-stroke); }
.field:first-child { border-top: 0; }
.field .name { font-weight: 700; }
.field small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; margin-top: 2px; }

.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { appearance: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(250, 242, 222, 0.3); background: rgba(0, 0, 0, 0.25); color: var(--cream); font: 800 22px/1 var(--font); cursor: pointer; }
.stepper output { min-width: 22px; text-align: center; font-weight: 900; font-size: 20px; }

.seg { display: inline-flex; background: rgba(0, 0, 0, 0.3); border-radius: 12px; padding: 3px; gap: 3px; margin-left: auto; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: 700 14px/1 var(--font); padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--brass); color: rgba(0, 0, 0, 0.85); }

.switch { appearance: none; width: 52px; height: 32px; border-radius: 16px; background: rgba(250, 242, 222, 0.2); position: relative; cursor: pointer; flex: none; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--cream); transition: transform 0.2s; }
.switch:checked { background: var(--brass); }
.switch:checked::after { transform: translateX(20px); }

.player-input { display: flex; gap: 8px; }
.player-input input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(250, 242, 222, 0.25);
  background: rgba(0, 0, 0, 0.3);
  color: var(--cream);
  font: 700 18px var(--font);
}
.player-input input::placeholder { color: var(--faint); }
.player-input input:focus { outline: 2px solid var(--brass); outline-offset: 1px; }

details.settings summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.settings summary::-webkit-details-marker { display: none; }
details.settings summary::after { content: "＋"; color: var(--brass); font-weight: 900; }
details.settings[open] summary::after { content: "－"; }
details.settings[open] summary { margin-bottom: 8px; }

.error { color: var(--danger); font-weight: 700; text-align: center; min-height: 20px; }
.note { font-size: 13px; color: var(--muted); }

.fire-flash { animation: flash 0.9s ease; }
@keyframes flash { 0%, 100% { box-shadow: none; } 30% { box-shadow: inset 0 0 120px rgba(255, 140, 38, 0.55); } }

/* --- Menu en cours de partie --------------------------------------------------------------- */

dialog {
  width: min(92vw, 420px);
  padding: 18px;
  border: 1px solid var(--card-stroke);
  border-radius: var(--radius);
  background: #0b2a1d;
  color: var(--cream);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

/* --- Mode jetons : pot, jetons, phases -------------------------------------------------------- */

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 2px solid rgba(250, 242, 222, 0.22);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--cream);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.mode strong { font-size: 18px; font-weight: 900; }
.mode small { font-size: 13px; line-height: 1.3; color: var(--muted); font-weight: 500; }
.mode[aria-pressed="true"] { border-color: var(--brass); background: rgba(242, 189, 87, 0.14); }
.mode[aria-pressed="true"] strong { color: var(--brass); }

.coin {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border-radius: 50%;
  vertical-align: -0.1em;
  background: radial-gradient(circle at 35% 30%, #ffe3a1, var(--brass) 55%, var(--brass-dark));
  box-shadow: inset 0 0 0 0.12em rgba(0, 0, 0, 0.18);
}
.tokens { display: inline-flex; align-items: center; gap: 4px; color: var(--brass); font-weight: 800; font-size: 13px; }
.chip.safe { opacity: 0.6; }
.chip.safe .tokens { color: #7fdc9c; }

.stage { margin-top: 14px; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--card-stroke); }
.stage .pot { font-size: 14px; font-weight: 700; color: var(--muted); }
.stage .pot strong { color: var(--brass); font-size: 17px; }
.stage.decharge { border-color: rgba(237, 77, 74, 0.5); }
.stage.decharge .label { color: var(--danger); }
.stage small { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.35; font-weight: 500; }
.meter { height: 8px; margin-top: 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--brass-dark), var(--brass)); transition: width 0.4s ease; }

.token-list { list-style: none; margin: 8px 0 0; padding: 0; }
.token-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--card-stroke); }
.token-list .who { flex: 1; font-weight: 700; overflow-wrap: anywhere; }
.token-list .count { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; color: var(--brass); }
.token-list .count.safe { color: #7fdc9c; font-size: 14px; }
.token-list li.loser .who { color: var(--danger); }
.token-list .pot-row .who { color: var(--muted); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; }

.results li.winner .who, .results li.winner .what { color: #7fdc9c; }
.banner .note-line { margin-top: 8px; font-weight: 700; }
.banner .phase-change { margin-top: 14px; padding: 12px; border-radius: 14px; background: rgba(237, 77, 74, 0.14); border: 1px solid rgba(237, 77, 74, 0.4); font-weight: 900; font-size: 18px; }
.banner .phase-change small { display: block; margin-top: 6px; font-size: 14px; font-weight: 500; color: var(--muted); line-height: 1.4; }

/* --- Installer sur l'écran d'accueil ----------------------------------------------------------- */

dialog { max-height: 92dvh; overflow-y: auto; }
.install h3 { font-size: 20px; font-weight: 900; margin: 4px 0 8px; }
.install .steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; line-height: 1.45; }
.install .steps li { padding-left: 4px; }
.install .note { margin: 10px 0 0; }
.share-icon { vertical-align: -5px; color: var(--brass); }
.callout { padding: 12px; border-radius: 14px; background: rgba(237, 77, 74, 0.14); border: 1px solid rgba(237, 77, 74, 0.4); font-size: 15px; line-height: 1.4; }

.banner .handline { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 0; white-space: nowrap; font-size: 18px; }

/* --- Tableau des valeurs en jetons (page des règles) ------------------------------------------- */

.values { width: 100%; border-collapse: collapse; font-size: 16px; margin: 8px 0; }
.values th, .values td { padding: 10px 6px; border-top: 1px solid var(--card-stroke); text-align: left; vertical-align: middle; }
.values th { color: var(--brass); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; border-top: 0; }
.values td:nth-child(2), .values td:last-child, .values th:nth-child(2), .values th:last-child { width: 1%; white-space: nowrap; }
.values td:last-child, .values th:last-child { text-align: right; }
.values td:last-child { color: var(--brass); font-size: 18px; }
.values .mini-dice { flex-wrap: nowrap; }
