/* ════════════════════════════════════════════════════════════
   LA TAVERNE — identité : encre de seiche, laiton, parchemin.
   Gravure au trait, chiffres « corsaires », table cerclée de laiton.
   ════════════════════════════════════════════════════════════ */
:root {
  --ink: #0d1a1f;
  --ink-2: #12242b;
  --ink-3: #1a323b;
  --ink-4: #24434d;
  --line: rgba(242, 230, 201, 0.12);
  --line-2: rgba(242, 230, 201, 0.22);
  --parch: #f2e6c9;
  --parch-2: #e4d2a8;
  --parch-ink: #2b2118;
  --muted: #b4c1bc;
  --brass: #d6a84e;
  --brass-2: #f3cd7a;
  --brass-dk: #8d6a2a;
  --rouge: #c0463a;
  --rouge-ink: #ff9a8a; /* rouge lisible sur fond sombre (≥ 7:1) */
  --rouge-parch: #a8352a; /* rouge lisible sur parchemin (≥ 5:1) */
  --parch-label: #6a5638; /* libellés sur parchemin (≥ 5,5:1) */
  --ecume: #8fc3b9;
  --focus: #fff1c4; /* anneau de focus : crème clair, distinct du laiton de la sélection */
  --ok: #7cc28f;

  --s-green: #2f7d4f;
  --s-yellow: #c4902a;
  --s-purple: #6c4699;
  --s-black: #1b1b1d;
  /* encres de couleur lisibles sur parchemin (≥ 4,5:1) pour les chiffres et pictogrammes */
  --ink-green: #1f6338;
  --ink-yellow: #7a500a;
  --ink-purple: #5b3787;

  --f-display: 'Pirata One', 'Luminari', fantasy, serif;
  --f-body: 'Alegreya', Georgia, serif;
  --f-label: 'Alegreya Sans SC', 'Alegreya', sans-serif;

  --r: 12px;
  --cw: 68px; /* largeur carte */
  --ch: calc(var(--cw) * 1.48);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 700px) and (min-height: 700px) { :root { --cw: 88px; } }
@media (min-width: 1100px) and (min-height: 800px) { :root { --cw: 100px; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--parch);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body::before { /* lueur de lanterne + grain */
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(214, 168, 78, 0.16), transparent 60%),
    radial-gradient(90% 60% at 50% 110%, rgba(63, 143, 134, 0.18), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .9 0 0 0 0 .8 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
svg.ic { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.ticket :focus-visible, .toast :focus-visible { outline-color: var(--parch-ink); }
.card:focus-visible { outline-offset: 4px; border-radius: calc(var(--cw) * 0.1); }
.skip-link { position: absolute; left: 8px; top: -80px; z-index: 100; padding: 10px 16px; border-radius: 10px; background: var(--parch); color: var(--parch-ink); font-family: var(--f-label); font-weight: 800; text-decoration: none; }
.skip-link:focus { top: 8px; }
.sr-only { position: fixed; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd {
  font-family: var(--f-label); font-size: 0.72em; font-weight: 700;
  padding: 0.05em 0.45em; border-radius: 5px; border: 1px solid var(--line-2);
  border-bottom-width: 3px; background: rgba(255, 255, 255, 0.04); color: var(--parch-2);
}
@media (hover: none) { .kbd-only { display: none !important; } }

/* ───────── Boutons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 48px; padding: 0.6em 1.3em; border-radius: 999px;
  border: 1.5px solid var(--line-2); background: var(--ink-3);
  font-family: var(--f-label); font-weight: 700; font-size: 1rem; letter-spacing: 0.04em;
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, opacity 0.2s;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--brass); }
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-brass {
  background: linear-gradient(180deg, var(--brass-2), var(--brass) 55%, var(--brass-dk));
  color: #2a1c08; border-color: #f7dc9b;
  box-shadow: 0 2px 0 #6b4f1c, 0 8px 22px rgba(214, 168, 78, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-brass:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-icon { min-height: 44px; width: 44px; padding: 0; border-radius: 50%; }
.btn-sm { min-height: 44px; padding: 0.3em 0.9em; font-size: 0.9rem; }
.btn .ic { width: 1.25em; height: 1.25em; }

/* ───────── Accueil ───────── */
.home { min-height: 100dvh; display: grid; place-items: center; padding: 28px 18px calc(28px + var(--safe-b)); }
.home-inner { width: min(500px, 100%); }
.brand { text-align: center; margin-bottom: 26px; }
svg.brand-crest { width: 92px; height: 92px; color: var(--brass); margin: 0 auto 6px; display: block; filter: drop-shadow(0 6px 16px rgba(214, 168, 78, 0.35)); }
.brand h1 {
  font-family: var(--f-display); font-weight: 400; margin: 0;
  font-size: clamp(3rem, 14vw, 4.6rem); line-height: 0.9; letter-spacing: 0.02em;
  background: linear-gradient(180deg, var(--brass-2), var(--brass) 60%, #a37a33);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .sub {
  font-family: var(--f-label); letter-spacing: 0.32em; font-size: 0.85rem; color: var(--ecume);
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 6px;
}
.brand .sub::before, .brand .sub::after { content: ''; height: 1px; width: 38px; background: currentColor; opacity: 0.5; }
.panel {
  background: linear-gradient(180deg, rgba(26, 50, 59, 0.9), rgba(18, 36, 43, 0.95));
  border: 1px solid var(--line-2); border-radius: 18px; padding: 22px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.panel + .panel { margin-top: 14px; }
.panel h2 { font-family: var(--f-label); font-size: 0.95rem; letter-spacing: 0.18em; color: var(--brass); margin: 0 0 14px; font-weight: 800; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-family: var(--f-label); font-size: 0.85rem; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 50px; padding: 0 16px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.28); border: 1.5px solid var(--line-2); color: var(--parch);
  font: 600 1.1rem var(--f-body);
}
.input:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 4px rgba(214, 168, 78, 0.18); }
.input::placeholder { color: #8a9a95; opacity: 1; }
.input.code { text-transform: uppercase; letter-spacing: 0.4em; font-family: var(--f-label); font-weight: 800; text-align: center; font-size: 1.4rem; }
.emblems { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 520px) { .home .emblems { grid-template-columns: repeat(8, 1fr); gap: 6px; } }
.emblem-opt {
  min-height: 48px; aspect-ratio: 1.15; border-radius: 12px; transition: border-color 0.2s, background 0.2s, transform 0.15s var(--ease); border: 1.5px solid var(--line); background: rgba(0, 0, 0, 0.2);
  display: grid; place-items: center; color: var(--parch-2); padding: 0;
}
.emblem-opt .ic { width: 58%; height: 58%; stroke-width: 3.2; }
.emblem-opt:active { transform: scale(0.94); }
@media (hover: hover) { .emblem-opt:hover { border-color: var(--brass-dk); color: var(--brass-2); } }
.emblem-opt[aria-checked='true'] { border-color: var(--brass); color: var(--brass-2); background: rgba(214, 168, 78, 0.12); }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; }
.or { text-align: center; font-family: var(--f-label); color: var(--muted); letter-spacing: 0.2em; font-size: 0.8rem; margin: 14px 0; }
.foot-note { text-align: center; color: var(--muted); font-size: 0.9rem; margin-top: 18px; font-style: italic; }

@media (max-height: 520px) and (orientation: landscape) { /* accueil en deux colonnes : emblème à gauche, formulaire à droite */
  .home { padding-top: 12px; padding-bottom: 12px; }
  .home-inner { width: min(900px, 100%); display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 4px 28px; align-items: center; }
  .brand { margin: 0; } svg.brand-crest { width: 64px; height: 64px; }
  .brand h1 { font-size: 3.2rem; }
  .foot-note { grid-column: 1; margin: 0; text-align: center; }
  .home .panel { grid-column: 2; grid-row: 1 / span 2; padding: 16px 18px; }
  .home .emblems { grid-template-columns: repeat(8, 1fr); gap: 5px; }
  .home .emblem-opt { min-height: 40px; }
  .home .panel .or { margin: 8px 0; } .field { margin-bottom: 10px; }
}

/* ───────── Salon d'attente ───────── */
.lobby { min-height: 100dvh; padding: 18px 16px calc(110px + var(--safe-b)); max-width: 980px; margin: 0 auto; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.wordmark { font-family: var(--f-display); font-size: 1.7rem; color: var(--brass); line-height: 1; letter-spacing: 0.02em; display: flex; align-items: center; gap: 8px; }
.wordmark .ic { width: 1.1em; height: 1.1em; }
.ticket {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  background: var(--parch); color: var(--parch-ink); border-radius: 16px; padding: 18px 20px;
  box-shadow: var(--shadow);
  background-image: radial-gradient(circle at 0 50%, var(--ink) 10px, transparent 11px), radial-gradient(circle at 100% 50%, var(--ink) 10px, transparent 11px);
}
.ticket .lbl { font-family: var(--f-label); font-size: 0.8rem; letter-spacing: 0.2em; color: var(--parch-label); }
.ticket .code-big { font-family: var(--f-display); font-size: clamp(2.6rem, 12vw, 3.6rem); letter-spacing: 0.12em; line-height: 1; color: var(--rouge-parch); }
.ticket .actions { display: flex; gap: 8px; }
.ticket .btn { background: var(--parch-ink); color: var(--parch); border-color: transparent; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 14px; }
@media (min-width: 820px) { .lobby-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
.crew { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.crew li {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line);
  animation: rise 0.35s var(--ease) both;
}
.crew .who { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.crew .nm { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.crew .tag { font-family: var(--f-label); font-weight: 800; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brass); }
.crew .tag.me { color: var(--ecume); } .crew .tag.off { color: var(--muted); font-style: italic; }
.crew .btn-icon { width: 44px; min-height: 44px; flex: none; }
.crew .empty { color: var(--muted); border-style: dashed; justify-content: center; font-style: italic; min-height: 52px; }
.seat-no { font-family: var(--f-display); color: var(--muted); width: 1.2em; text-align: center; font-size: 1.2rem; }
.avatar {
  --c: var(--brass);
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, color-mix(in oklab, var(--c) 55%, white 10%), color-mix(in oklab, var(--c) 70%, black 45%));
  border: 2px solid color-mix(in oklab, var(--c) 60%, white 30%); color: #fff8e6;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}
.avatar .ic { width: 62%; height: 62%; stroke-width: 4; }
.opt-group { display: grid; gap: 8px; margin-bottom: 16px; }
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (min-width: 560px) and (max-width: 819px), (min-width: 1000px) { .seg { grid-template-columns: repeat(4, 1fr); } }
.seg button, .toggle {
  border: 1.5px solid var(--line-2); background: rgba(0, 0, 0, 0.2); border-radius: 12px;
  padding: 10px 6px; text-align: center; min-height: 54px;
}
.seg button b, .toggle b { display: block; font-family: var(--f-label); font-weight: 800; letter-spacing: 0.04em; }
.seg button small, .toggle small { color: var(--muted); font-size: 0.78rem; }
.seg button[aria-pressed='true'], .toggle[aria-pressed='true'] { border-color: var(--brass); background: rgba(214, 168, 78, 0.13); color: var(--brass-2); }
.seg button:disabled, .toggle:disabled { cursor: default; }
.toggles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.toggle { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.toggle .ic { width: 28px; height: 28px; }
.start-bar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(180deg, transparent, rgba(13, 26, 31, 0.95) 30%);
  display: flex; justify-content: center; gap: 10px; z-index: 5;
}
.start-bar .btn-brass { min-width: min(360px, 100%); min-height: 56px; font-size: 1.1rem; }
.cheat { font-size: 0.95rem; color: var(--parch-2); }
.cheat ol { margin: 0; padding-left: 1.2em; }
.cheat li { margin: 0.3em 0; }
.cheat .mini-cards { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; vertical-align: middle; margin: 4px 0; }
.card.mini .c-art { inset: 30% 12% 14%; }
.card.mini:not(.k-num) .c-v { display: none; }

/* ───────── Écran de jeu ───────── */
.game {
  height: 100dvh; display: grid; overflow: hidden;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: 'top' 'rail' 'table' 'dock' 'hand';
}
@media (min-width: 1100px) and (min-height: 521px) {
  .game { grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: 'top top' 'rail side' 'table side' 'dock side' 'hand side'; }
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  padding-top: max(6px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), transparent);
}
.topbar .wordmark { font-size: 1.35rem; }
.round-info { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 14px; font-family: var(--f-label); font-weight: 700; letter-spacing: 0.06em; font-size: 0.92rem; color: var(--parch-2); }
.round-info b { color: var(--brass-2); font-family: var(--f-display); font-size: 1.3rem; font-weight: 400; letter-spacing: 0; vertical-align: -1px; }
.round-info > span { white-space: nowrap; }
.top-actions { display: flex; gap: 6px; }
.top-actions .btn-icon { border-color: var(--line); background: transparent; }
@media (max-width: 520px) { .topbar .wordmark span { display: none; } .round-info { gap: 10px; font-size: 0.82rem; } }
@media (max-width: 400px) {
  .topbar { padding-left: 8px; padding-right: 8px; }
  .topbar .wordmark { display: none; }
  .round-info { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.15; }
  .top-actions { gap: 2px; }
}

/* Équipage (bande des joueurs) : une grille qui s'adapte au nombre de pirates, jamais de défilement caché */
.rail {
  list-style: none; margin: 0;
  grid-area: rail; position: relative; z-index: 4; display: grid; gap: 6px; padding: 8px 10px 6px;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); width: 100%; max-width: 940px; margin: 0 auto;
}
.chip {
  position: relative; container-type: inline-size; min-width: 0; max-width: 200px; width: 100%; justify-self: center; border-radius: 13px; border: 1.5px solid var(--line);
  background: rgba(18, 36, 43, 0.85); transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s var(--ease), background 0.25s;
}
.chip .cb { /* compact : [avatar][pari/plis … score] puis le nom sur toute la largeur */
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: 'av meta' 'nm nm';
  column-gap: 6px; row-gap: 2px; align-items: center; padding: 5px 6px 5px 5px; min-height: 48px;
}
.chip .avatar { grid-area: av; width: 26px; height: 26px; border-width: 1.5px; }
.chip .nm { grid-area: nm; font-weight: 700; font-size: 0.8rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .meta { grid-area: meta; min-width: 0; display: flex; gap: 4px; align-items: center; justify-content: space-between; font-family: var(--f-label); font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.chip .meta .pips, .chip .meta .bid-long { display: none; }
.chip .score { color: var(--brass-2); font-weight: 800; }
@container (max-width: 99px) { /* micro (8 joueurs sur 360 px) : avatar + nom en haut, pari et score dessous */
  .chip .cb { grid-template-areas: 'av nm' 'meta meta'; padding: 4px 5px; min-height: 0; row-gap: 3px; column-gap: 5px; }
  .chip .avatar { width: 22px; height: 22px; }
  .chip .nm { font-size: 0.74rem; }
}
@container (min-width: 118px) { /* assez large : avatar à gauche, nom puis pari */
  .chip .cb { grid-template-areas: 'av nm' 'av meta'; column-gap: 8px; row-gap: 0; padding: 6px 9px 6px 6px; min-height: 50px; }
  .chip .avatar { width: 36px; height: 36px; border-width: 2px; }
  .chip .nm { font-size: 0.95rem; }
  .chip .meta { justify-content: flex-start; gap: 8px; font-size: 0.8rem; }
  .chip .meta .pips, .chip .meta .bid-long { display: inline-flex; }
  .chip .meta .score { margin-left: auto; }
}
.chip.turn { border-color: var(--brass); background: rgba(52, 62, 52, 0.95); box-shadow: 0 0 0 2px rgba(214, 168, 78, 0.35), 0 0 22px rgba(214, 168, 78, 0.28); transform: translateY(-1px); }
.chip.turn::after {
  content: ''; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; margin-left: -5px;
  background: var(--brass); transform: rotate(45deg); border-radius: 2px;
}
.chip.turn .nm { color: var(--brass-2); }
.chip.me { background: rgba(36, 67, 77, 0.92); }
.chip.me.turn { background: rgba(60, 66, 50, 0.95); }
.chip.off .cb { opacity: 0.62; }
.chip.off { border-style: dashed; }
.chip.off .meta .score { order: 3; }
@container (min-width: 118px) { .chip.off .meta::before { content: 'absent'; font-style: italic; color: var(--muted); } .chip.off .meta > * { display: none !important; } .chip.off .meta .score { display: inline !important; } }
.chip .host-mark { position: absolute; top: -8px; left: -4px; width: 20px; height: 20px; color: var(--brass-2); background: var(--ink); border-radius: 50%; padding: 2px; z-index: 1; }
.pips { display: inline-flex; gap: 3px; align-items: center; }
.pip { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--parch-2); opacity: 0.7; }
.pip.on { background: var(--brass-2); border-color: var(--brass-2); opacity: 1; }
.pip.over { background: var(--rouge); border-color: var(--rouge); opacity: 1; }
.bidtag { font-weight: 800; color: var(--parch); }
.bidtag.wait { color: var(--muted); font-style: italic; font-weight: 500; }
.bidtag.done { color: var(--ok); }
.bidtag.over { color: var(--rouge-ink); }
.emote-bubble {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--parch); color: var(--parch-ink); padding: 6px 12px; border-radius: 12px;
  font-weight: 700; font-size: 0.9rem; white-space: nowrap; box-shadow: var(--shadow);
  animation: pop 2.6s var(--ease) forwards; pointer-events: none;
}
.emote-bubble::before { content: ''; position: absolute; top: -6px; left: 50%; margin-left: -6px; border: 6px solid transparent; border-top: 0; border-bottom-color: var(--parch); }

/* Table */
.table-wrap { grid-area: table; position: relative; display: grid; place-items: center; padding: 8px 10px; min-height: 0; min-width: 0; }
.table {
  position: relative; container-type: size; width: min(100%, 980px); height: 100%; max-height: 640px; min-height: 0;
  border-radius: 50% / 46%;
  background:
    radial-gradient(60% 60% at 50% 45%, rgba(63, 143, 134, 0.35), transparent 70%),
    radial-gradient(ellipse at center, #1d4a4a 0%, #143436 55%, #0e2527 100%);
  box-shadow:
    inset 0 0 0 6px #2a1d10, inset 0 0 0 8px var(--brass-dk), inset 0 0 0 9px var(--brass), inset 0 0 0 11px #2a1d10,
    inset 0 20px 60px rgba(0, 0, 0, 0.55), 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
}
.table.art { background-size: cover; background-position: center; }
.table::before { /* rose des vents en filigrane */
  content: ''; position: absolute; width: 58%; aspect-ratio: 1; max-height: 90%; opacity: 0.08;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none' stroke='%23f3cd7a' stroke-width='1.4'%3E%3Cpath d='M32 2l5 25 25 5-25 5-5 25-5-25-25-5 25-5z'/%3E%3Ccircle cx='32' cy='32' r='20'/%3E%3Ccircle cx='32' cy='32' r='28'/%3E%3Cpath d='M12 12l10 10M52 12L42 22M12 52l10-10M52 52L42 42'/%3E%3C/svg%3E") center/contain no-repeat;
}
/* Le pli : les cartes se serrent selon le nombre de joueurs pour toujours tenir dans l'ovale */
.trick {
  --gap: 8px; --per: var(--n, 1); --rows: 1;
  --tcw: min(calc(var(--cw) * 1.3), calc((var(--wf, 72cqw) - (var(--per) - 1) * var(--gap)) / var(--per)), calc((var(--bud, 70cqh) - var(--rows) * var(--lab, 30px)) / (1.48 * var(--rows))));
  position: relative; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 6px var(--gap); padding: 0 8px; z-index: 1;
  max-width: calc(var(--per) * (var(--tcw) + 6px) + (var(--per) - 1) * var(--gap) + 16px);
}
.trick.many { --per: var(--per2); --rows: 2; --wf: 66cqw; }
.table:has(.result-banner) .trick, .table:has(.power-note) .trick { --bud: 52cqh; margin-bottom: 40px; } /* de la place pour le bandeau du pli */
.trick .card { --cw: max(var(--tcw), 24px); }
.trick .slot { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; width: calc(var(--tcw) + 6px); }
.trick .slot .who {
  font-family: var(--f-label); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; line-height: 1.05; text-align: center; width: 100%;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; color: var(--parch);
}
.trick .slot .who i { display: block; height: 3px; border-radius: 2px; background: var(--c); margin: 0 auto 2px; width: 70%; }
.trick .slot.win .card { box-shadow: 0 0 0 3px var(--brass-2), 0 0 30px rgba(243, 205, 122, 0.6); transform: translateY(-6px) scale(1.05); z-index: 2; }
.trick .slot.win .who { color: var(--brass-2); }
.trick .slot.lose .card { filter: saturate(0.6) brightness(0.75); }
.trick.destroyed .card { animation: sink 1.6s var(--ease) forwards; }
.table-msg { text-align: center; color: var(--parch-2); font-style: italic; z-index: 1; padding: 0 22px; max-width: 100%; text-wrap: balance; }
.table-msg .big { font-family: var(--f-display); font-style: normal; font-size: clamp(1.6rem, 7cqw, 2.4rem); color: var(--brass-2); display: block; line-height: 1.1; margin-bottom: 4px; }
.table-msg .who-turn { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line-2); font-style: normal; font-weight: 700; color: var(--parch); }
.table-msg .who-turn .avatar { width: 26px; height: 26px; }
.lead-chip {
  position: absolute; top: 1px; left: 50%; transform: translateX(-50%); z-index: 6; white-space: nowrap;
  font-family: var(--f-label); font-size: 0.78rem; letter-spacing: 0.1em; font-weight: 800; color: #fff8e6;
  display: flex; align-items: center; gap: 6px; padding: 3px 12px 3px 4px; border-radius: 999px;
  background: color-mix(in oklab, var(--sc) 62%, #0d1a1f); border: 1.5px solid color-mix(in oklab, var(--sc) 55%, #f2e6c9);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.lead-chip .dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in oklab, var(--sc) 70%, #f2e6c9 20%); color: #fff; }
.lead-chip .dot .ic { width: 14px; height: 14px; stroke-width: 4.5; }
.result-banner {
  position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); z-index: 3; width: max-content;
  background: var(--parch); color: var(--parch-ink); border-radius: 12px; padding: 7px 16px; text-align: center;
  box-shadow: var(--shadow); animation: rise-c 0.4s var(--ease) both; max-width: 86%;
}
.result-banner b { font-family: var(--f-display); font-weight: 400; font-size: 1.3rem; line-height: 1.1; color: var(--rouge-parch); }
.result-banner small { display: block; font-size: 0.85rem; line-height: 1.2; }
@media (max-width: 520px) { .result-banner { padding: 5px 12px; } .result-banner b { font-size: 1.1rem; } .result-banner small { font-size: 0.78rem; } }

/* Dock d'action */
.dock { grid-area: dock; padding: 6px 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bid-head, .play-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 14px; max-width: 100%; }
.bid-head .status { flex: 1 1 auto; text-align: left; }
.bid-head .btn { flex: none; min-height: 44px; padding: 0.4em 1.1em; }
.kbd-hint { color: var(--muted); font-size: 0.85rem; }
.status { text-align: center; font-size: 1rem; color: var(--parch-2); min-height: 1.5em; }
.status strong { color: var(--brass-2); font-family: var(--f-display); font-weight: 400; font-size: 1.35rem; letter-spacing: 0.02em; }
.status .dots i { display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: currentColor; margin-left: 3px; animation: blink 1.2s infinite both; }
.status .dots i:nth-child(2) { animation-delay: 0.2s; } .status .dots i:nth-child(3) { animation-delay: 0.4s; }
.status.mine strong::before { content: ''; display: inline-block; width: 9px; height: 9px; margin-right: 9px; border-radius: 50%; background: var(--brass-2); vertical-align: 2px; animation: ping 1.6s ease-out infinite; }
.mystats { display: flex; gap: 14px; font-family: var(--f-label); font-size: 0.85rem; color: var(--muted); letter-spacing: 0.05em; }
.mystats b { color: var(--parch); }
.bids { display: grid; grid-template-columns: repeat(var(--cols, 6), 52px); justify-content: center; gap: 8px; max-width: 100%; }
@media (min-width: 700px) { .bids { grid-template-columns: repeat(var(--cols-d, 11), 52px); } }
.bid-btn {
  width: 100%; height: 48px; border-radius: 26px; border: 2px solid var(--line-2);
  background: radial-gradient(circle at 35% 30%, #2d4f59, #15292f);
  font-family: var(--f-display); font-size: 1.6rem; line-height: 1; color: var(--parch);
  box-shadow: 0 3px 0 #08100f; transition: transform 0.15s var(--ease), border-color 0.2s;
  touch-action: manipulation;
}
.bid-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #08100f; }
.bid-btn[aria-pressed='true'] {
  background: radial-gradient(circle at 35% 30%, var(--brass-2), var(--brass) 55%, var(--brass-dk));
  color: #2a1c08; border-color: #f7dc9b; transform: translateY(-3px);
}
.dock-actions { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }

/* Main */
.hand-wrap {
  grid-area: hand; position: relative; padding: 18px 10px calc(10px + var(--safe-b)); min-width: 0;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.35));
}
.hand-wrap.myturn { background: radial-gradient(70% 90% at 50% 0%, rgba(214, 168, 78, 0.2), transparent 75%), linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.35)); }
.hand-wrap.myturn::before { content: ''; position: absolute; left: 12%; right: 12%; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--brass), transparent); }
.hand { --hcw: var(--cw); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hand-row { display: flex; justify-content: center; align-items: flex-end; max-width: 100%; }
.hand .card { --cw: var(--hcw); margin-left: var(--ov, 6px); }
.hand .card:first-child { margin-left: 0; }
.hand .card.grp { margin-left: calc(var(--ov, 6px) + 6px); }
.hand-row .card:first-child { margin-left: 0; }
.hand[data-mode='fan'] .hand-row { min-height: calc(var(--cw) * 1.48 + 6px); }
.hand[data-mode='grid'] { --ratio: 1.36; gap: 7px; }
.hand .card.illegal { filter: grayscale(0.55) brightness(0.7); transform: translateY(6px); }
.hand[data-mode='grid'] .card.illegal, .hand[data-mode='row'] .card.illegal { transform: none; }
.hand .card.sel { transform: translateY(-18px); z-index: 5; box-shadow: 0 0 0 3px var(--brass-2), 0 16px 30px rgba(0, 0, 0, 0.6); }
.hand[data-mode='grid'] .card.sel { transform: scale(1.07); box-shadow: 0 0 0 3px var(--brass-2), 0 8px 18px rgba(0, 0, 0, 0.6); }
.hand[data-mode='row'] .card.sel { transform: translateY(-10px); }
.hand.myturn .card.legal:not(.sel):hover { transform: translateY(-8px); }
.hand[data-mode='grid'].myturn .card.legal:not(.sel):hover { transform: none; }
.hand.deal .card { animation: deal 0.5s var(--ease) both; animation-delay: calc(var(--i) * 60ms); }
.hand-wrap:has(.hand[data-mode='grid']) { padding-top: 10px; }
.hand-empty { color: var(--muted); font-style: italic; text-align: center; }

/* ───────── Paysage téléphone (≈ 844×390) : tout tient sans défiler ───────── */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --cw: 52px; }
  .game {
    grid-template-columns: 196px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: 'rail top' 'rail table' 'rail dock' 'rail hand';
  }
  .side { display: none !important; }
  .topbar { padding: 3px 10px; padding-top: max(3px, env(safe-area-inset-top)); gap: 8px; }
  .topbar .wordmark { display: none; }
  .round-info { flex-direction: row; align-items: center; gap: 14px; justify-content: center; font-size: 0.85rem; }
  .rail { display: flex; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 6px 4px 6px max(8px, env(safe-area-inset-left)); overflow-y: auto; scrollbar-width: thin; max-width: none; margin: 0; }
  .chip { flex: none; max-width: none; }
  .chip .cb { min-height: 38px; padding: 3px 7px 3px 5px; }
  .chip .avatar { width: 28px; height: 28px; }
  .chip.turn::after { display: none; }
  .table-wrap { padding: 4px 8px; }
  .table { max-height: none; min-height: 0; }
  .trick.many { --per: var(--n); --rows: 1; }
  .table-msg .big { font-size: 1.5rem; }
  .lead-chip { top: -2px; font-size: 0.7rem; padding: 2px 10px 2px 3px; }
  .lead-chip .dot { width: 16px; height: 16px; }
  .lead-chip .dot .ic { width: 11px; height: 11px; }
  .result-banner { bottom: 5%; padding: 3px 12px; }
  .result-banner b { font-size: 1rem; } .result-banner small { font-size: 0.72rem; }
  .table-msg { padding: 0 10%; font-size: 0.92rem; line-height: 1.25; }
  .table-msg .who-turn { margin-top: 4px; }
  .dock { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; padding: 2px 10px; gap: 2px 14px; }
  .dock .bids { order: -1; flex: 1 1 100%; }
  .status { font-size: 0.92rem; min-height: 0; }
  .status strong { font-size: 1.15rem; }
  .mystats { display: none; }
  .bids, .bids { grid-template-columns: repeat(var(--cols-d, 11), 40px); gap: 5px; }
  .bid-btn { height: 40px; font-size: 1.25rem; box-shadow: 0 2px 0 #08100f; border-radius: 20px; }
  .kbd-hint { display: none; }
  .dock .btn { min-height: 40px; padding-top: 0.3em; padding-bottom: 0.3em; }
  .dock-actions { flex-wrap: nowrap; }
  .hand-wrap { padding: 12px 10px 4px; }
  .hand .card.sel { transform: translateY(-12px); }
  .kbd-only { display: none !important; }
}
@media (max-width: 400px) { .rail { padding: 6px 6px 4px; gap: 5px; } }
@media (max-width: 359px) {
}
@container (max-height: 175px) { .table-msg { font-size: 0.8rem; line-height: 1.2; padding: 0 12%; } .table-msg .big { font-size: 1.3rem; } }
@container (max-height: 120px) { .table-msg > :not(.big) { display: none; } .table-msg .big { margin: 0; } }
@media (max-height: 700px) and (orientation: portrait) { .mystats { display: none; } }
/* ───────── Cartes ───────── */
.card {
  --sc: var(--s-black);
  position: relative; flex: none; width: var(--cw); height: calc(var(--cw) * var(--ratio, 1.48)); padding: 0;
  border-radius: calc(var(--cw) * 0.1); border: none;
  background: var(--parch);
  color: var(--sc-ink, var(--sc));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  transition: transform 0.18s var(--ease), filter 0.2s, box-shadow 0.2s;
  display: block; overflow: hidden; text-align: left;
  font-family: var(--f-display);
}
.card::before { /* filet intérieur */
  content: ''; position: absolute; inset: calc(var(--cw) * 0.05); border-radius: calc(var(--cw) * 0.06);
  border: 1.5px solid currentColor; opacity: 0.55; pointer-events: none;
}
.card .c-corner { position: absolute; top: 4%; left: 8%; display: flex; align-items: center; gap: calc(var(--cw) * 0.05); line-height: 1; }
.card .c-corner .c-v { position: static; font-size: calc(var(--cw) * 0.36); line-height: 1; }
.card .c-v.br { position: absolute; top: auto; left: auto; bottom: 4%; right: 9%; transform: rotate(180deg); font-size: calc(var(--cw) * 0.36); line-height: 1; }
.card .c-art { position: absolute; inset: 22% 14% 24%; display: grid; place-items: center; }
.card .c-art .ic { width: 100%; height: 100%; stroke-width: 3; }
.card .c-art img { position: absolute; inset: -30% -16%; width: 132%; height: 160%; object-fit: cover; }
.card .c-name {
  position: absolute; bottom: 7%; left: 0; right: 0; text-align: center;
  font-family: var(--f-label); font-weight: 800; font-size: max(9px, calc(var(--cw) * 0.14)); letter-spacing: 0.03em; line-height: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 10%;
}
.card .c-s { position: static; width: calc(var(--cw) * 0.22); height: calc(var(--cw) * 0.22); flex: none; }
.card .c-s .ic { width: 100%; height: 100%; stroke-width: 4.5; }
.card.mini .c-s { display: none; }
.card .c-key {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 5px; display: grid; place-items: center;
  font-family: var(--f-label); font-weight: 800; font-size: 11px; line-height: 1; color: #f6ecd2; background: rgba(24, 16, 8, 0.78);
}
@media (hover: none) { .card .c-key { display: none; } }
.card.k-num .c-name { display: none; }
.card.k-num .c-art { inset: 30% 24% 22% 26%; }
.card.s-green { --sc: var(--s-green); --sc-ink: var(--ink-green); }
.card.s-yellow { --sc: var(--s-yellow); --sc-ink: var(--ink-yellow); }
.card.s-purple { --sc: var(--s-purple); --sc-ink: var(--ink-purple); }
.card.s-black { --sc: var(--s-black); background: linear-gradient(160deg, #3b3a38, #19191a); color: #efe6d2; }
.card.s-black::after { content: ''; position: absolute; inset: 0; border-top: 5px solid var(--rouge); pointer-events: none; }
.card.k-num:not(.s-black) { background: linear-gradient(160deg, #f8eed6, var(--parch-2)); }
.card.k-num:not(.s-black)::after { content: ''; position: absolute; inset: 0; border-top: 5px solid var(--sc); pointer-events: none; }
/* Spéciales */
.card.k-escape { background: linear-gradient(160deg, #e9eef0, #b9c6cc); color: #34505b; }
.card.k-pirate { background: linear-gradient(160deg, #b8483a, #7c231c); color: #ffe8d0; }
.card.k-tigress { background: linear-gradient(135deg, #e48a2e 0 50%, #e9eef0 50% 100%); color: #3a1f0b; }
.card.k-skullking { background: radial-gradient(circle at 50% 40%, #3b2b12, #0e0b07 75%); color: var(--brass-2); }
.card.k-skullking::before { opacity: 0.9; border-width: 2px; }
.card.k-mermaid { background: linear-gradient(160deg, #23857c, #0f4d50); color: #e6fff9; }
.card.k-kraken { background: linear-gradient(160deg, #4b2e5c, #150c1d); color: #e3c7ff; }
.card.k-whale { background: linear-gradient(160deg, #f6fbff, #c3d5e2); color: #2b4b63; }
.card.k-loot { background: linear-gradient(160deg, #f1d27a, #a4782a); color: #3b2508; }
.card.has-art .c-art .ic { display: none; }
.card.mini { --cw: 34px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); cursor: default; }
.card.mini .c-v.br, .card.mini .c-name { display: none; }
.card.mini .c-v { font-size: 13px; }
.card.mini::after { border-top-width: 3px !important; }
.card.enter { animation: toss 0.38s var(--ease) both; }
.card.back {
  background: repeating-linear-gradient(45deg, #2a1d10 0 6px, #34261a 6px 12px); color: var(--brass);
}

/* ───────── Feuilles & modales ───────── */
.side { grid-area: side; display: none; border-left: 1px solid var(--line); background: rgba(0, 0, 0, 0.18); min-height: 0; flex-direction: column; }
@media (min-width: 1100px) { .side { display: flex; } }
.side h3 { font-family: var(--f-label); letter-spacing: 0.18em; color: var(--brass); font-size: 0.85rem; margin: 16px 16px 8px; }
.journal { list-style: none; margin: 0; padding: 0 16px 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; }
.journal li { padding: 6px 10px; border-left: 2px solid var(--line-2); color: var(--parch-2); animation: rise 0.3s var(--ease) both; }
.journal li.j-trick { border-color: var(--ecume); }
.journal li.j-bid { border-color: var(--brass); }
.journal li.j-round { border-color: var(--rouge); color: var(--parch); font-weight: 600; }
.journal time { font-family: var(--f-label); font-size: 0.72rem; color: var(--muted); margin-right: 6px; }
.side .emotes { padding: 10px 16px 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; }

.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center;
  background: rgba(5, 10, 12, 0.72); animation: fade 0.2s ease both;
}
@media (min-width: 700px) { .overlay { place-items: center; } }
.sheet {
  width: min(720px, 100%); max-height: 90dvh; display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, var(--ink-3), var(--ink-2)); border: 1px solid var(--line-2);
  border-radius: 20px 20px 0 0; padding: 18px 18px 0; box-shadow: var(--shadow);
  animation: slide-up 0.32s var(--ease) both;
}
@media (min-width: 700px) { .sheet { border-radius: 20px; max-height: 88dvh; } }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 2rem; color: var(--brass-2); line-height: 1; }
.sheet .btn-icon { border-color: var(--line); background: transparent; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px 16px; position: relative; }
.sheet-body:focus-visible, .scroll-x:focus-visible { outline-offset: -3px; }
.sheet-foot { flex: none; padding: 12px 0 calc(14px + var(--safe-b)); border-top: 1px solid var(--line-2); background: var(--ink-2); }
.sheet-foot .ready-row .btn { min-height: 48px; }
.scroll-x { overflow-x: auto; border-radius: 10px; }
table.scores { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.95rem; }
table.scores th, table.scores td { padding: 6px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; min-width: 68px; }
table.scores thead th { font-family: var(--f-label); font-weight: 800; letter-spacing: 0.03em; color: var(--parch-2); vertical-align: bottom; padding-top: 4px; }
table.scores thead th .avatar { width: 28px; height: 28px; margin: 0 auto 3px; }
table.scores .hn { display: block; max-width: 74px; overflow: hidden; text-overflow: ellipsis; font-size: 0.78rem; margin: 0 auto; }
table.scores tbody th, table.scores thead td:first-child, table.scores .total th { font-family: var(--f-label); color: var(--muted); text-align: left; position: sticky; left: 0; background: var(--ink-3); min-width: 56px; z-index: 1; }
table.scores tbody th small { opacity: 0.8; }
table.scores td .d { display: block; font-size: 0.78rem; font-family: var(--f-label); }
table.scores .pos { color: var(--ok); }
table.scores .neg { color: var(--rouge-ink); }
table.scores .total th, table.scores .total td { font-family: var(--f-display); font-size: 1.35rem; color: var(--brass-2); background: var(--ink-2); border-bottom: 2px solid var(--brass-dk); padding: 4px 8px; }
table.scores .total th { font-size: 0.95rem; font-family: var(--f-label); letter-spacing: 0.1em; text-transform: uppercase; }
table.scores .total td.best { color: #2a1c08; background: linear-gradient(180deg, var(--brass-2), var(--brass)); }
table.scores .none { color: var(--muted); font-style: italic; padding: 18px; white-space: normal; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.results li {
  display: grid; grid-template-columns: 1.4em auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 9px 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line);
  animation: rise 0.4s var(--ease) both; animation-delay: calc(var(--i) * 60ms);
}
.results li:first-child { border-color: var(--brass-dk); background: rgba(214, 168, 78, 0.1); }
.results .rank { font-family: var(--f-display); font-size: 1.5rem; color: var(--muted); text-align: center; }
.results li:first-child .rank { color: var(--brass-2); }
.results .who { display: grid; min-width: 0; }
.results .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .nm em { font-weight: 400; color: var(--ecume); font-size: 0.85em; }
.results .det { font-size: 0.85rem; color: var(--muted); }
.results .delta { font-family: var(--f-display); font-size: 1.6rem; text-align: right; line-height: 1; }
.results .delta small { display: block; font-family: var(--f-label); font-size: 0.78rem; color: var(--parch-2); }
.results .made { color: var(--ok); }
.results .miss { color: var(--rouge-ink); }
.results .half { color: var(--brass-2); }
.ready-row { display: flex; gap: 8px 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.sheet-foot .ready-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.sheet-foot .ready-row > .btn-brass { grid-column: 1 / -1; }
.sheet-foot .ready-row > .hint { grid-column: 1 / -1; }
.ready-row .hint { width: 100%; text-align: center; color: var(--muted); font-size: 0.88rem; }
/* Fin de partie : le couronnement */
.sheet.end .sheet-body { padding-top: 0; }
.sheet.end::before { /* rayons de projecteur derrière le vainqueur */
  content: ''; position: absolute; left: 50%; top: 40px; width: 560px; height: 560px; margin-left: -280px; pointer-events: none; opacity: 0.55;
  background: repeating-conic-gradient(from 0deg, rgba(243, 205, 122, 0.16) 0 8deg, transparent 8deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 68%); mask: radial-gradient(circle, #000 0, transparent 68%);
  animation: spin 60s linear infinite;
}
.sheet.end { position: relative; }
.sheet.end > * { position: relative; }
.champion { text-align: center; padding: 4px 0 2px; }
.champion .crown-big { display: block; width: 58px; height: 58px; margin: 0 auto -10px; color: var(--brass-2); position: relative; z-index: 1; filter: drop-shadow(0 4px 12px rgba(243, 205, 122, 0.5)); animation: crown-drop 0.9s var(--ease) 0.35s both; }
.champion .avatar { width: 84px; height: 84px; margin: 0 auto; border-width: 3px; box-shadow: 0 0 0 4px rgba(243, 205, 122, 0.35), 0 10px 30px rgba(0, 0, 0, 0.5); animation: slam 0.6s var(--ease) 0.15s both; }
.champ-name { margin: 10px 0 0; font-family: var(--f-display); font-size: clamp(2rem, 9vw, 2.9rem); line-height: 1; color: var(--brass-2); overflow-wrap: anywhere; text-wrap: balance; }
.champ-line { margin: 6px auto 0; color: var(--parch-2); max-width: 30em; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 8px; margin: 14px 0 12px; }
.podium .step { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1 1 0; min-width: 0; max-width: 170px; animation: rise 0.6s var(--ease) both; }
.podium .step .avatar { width: 46px; height: 46px; }
.podium .block {
  width: 100%; border-radius: 10px 10px 0 0; display: grid; place-items: center; margin-top: 2px;
  background: linear-gradient(180deg, var(--brass-2), var(--brass-dk)); color: #2a1c08; font-family: var(--f-display); font-size: 2rem;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.podium .p1 .block { height: 96px; }
.podium .p2 .block { height: 70px; background: linear-gradient(180deg, #e6ecee, #8fa0a6); }
.podium .p3 .block { height: 52px; background: linear-gradient(180deg, #e0a56a, #8a5527); }
.podium .p1 { order: 2; } .podium .p2 { order: 1; } .podium .p3 { order: 3; }
.podium .nm { font-weight: 800; text-align: center; font-size: 0.92rem; line-height: 1.1; max-width: 100%; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.podium .pts { font-family: var(--f-label); color: var(--brass-2); font-weight: 800; font-size: 0.88rem; }
.rest { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.rest li { display: grid; grid-template-columns: 1.6em auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line); }
.rest .rank { font-family: var(--f-display); color: var(--muted); font-size: 1.2rem; text-align: center; }
.rest .avatar { width: 30px; height: 30px; }
.rest .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rest b { font-family: var(--f-display); font-weight: 400; font-size: 1.3rem; color: var(--parch-2); }
.confetti-box { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 3; }
.confetti { position: absolute; top: -14px; left: var(--x); width: 8px; height: 14px; background: var(--c); border-radius: 2px; opacity: 0; animation: confetti var(--t) ease-in var(--d) 1 both; animation-delay: calc(var(--d) + var(--el, 0ms)); }
.confetti.coin { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(42, 28, 8, 0.35); }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice button {
  border: 2px solid var(--line-2); border-radius: 16px; background: rgba(0, 0, 0, 0.25); padding: 16px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 150px;
}
.choice button:hover, .choice button:focus-visible { border-color: var(--brass); }
.choice button b { font-family: var(--f-display); font-weight: 400; font-size: 1.6rem; color: var(--brass-2); }
.choice button small { color: var(--muted); }
.choice .ic { width: 48px; height: 48px; }
.emote-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.emote-grid .btn { justify-content: flex-start; border-radius: 12px; text-align: left; line-height: 1.15; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; font-size: 0.95rem; }
.help-grid dt { text-align: right; }
.help-grid dd { margin: 0; color: var(--parch-2); }
.rules-h { font-family: var(--f-label); color: var(--brass); letter-spacing: 0.15em; font-size: 0.85rem; margin: 18px 0 8px; }
.hier { display: grid; gap: 8px; }
.hier > div { display: flex; align-items: center; gap: 10px; font-size: 0.93rem; color: var(--parch-2); }
.reveal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; pointer-events: none;
  background: radial-gradient(circle, rgba(13, 26, 31, 0.75), rgba(13, 26, 31, 0.92));
  animation: fade 0.25s ease both, fade 0.4s ease 1.9s reverse forwards;
}
.reveal .inner { text-align: center; max-width: 100%; }
.reveal h2 { font-family: var(--f-display); font-weight: 400; font-size: clamp(3rem, 14vw, 5.5rem); color: var(--brass-2); margin: 0; animation: slam 0.5s var(--ease) both; line-height: 1; }
.reveal .bids-reveal { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 18px; padding: 0 16px; }
.reveal .bids-reveal div { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 74px; animation: flip 0.5s var(--ease) both; animation-delay: calc(0.35s + var(--i) * 90ms); }
.reveal .bids-reveal b { font-family: var(--f-display); font-size: 2.6rem; font-weight: 400; line-height: 1; }
.reveal .bids-reveal span { font-family: var(--f-label); font-size: 0.85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-height: 520px) and (orientation: landscape) {
  .reveal .bids-reveal { gap: 8px; margin-top: 8px; } .reveal h2 { font-size: 3rem; } .reveal .bids-reveal b { font-size: 1.8rem; } .reveal .bids-reveal div { width: 64px; }
  .sheet { max-height: 96dvh; width: min(860px, 100%); border-radius: 16px; padding-top: 10px; } .overlay { place-items: center; }
  .sheet-head { margin-bottom: 6px; } .sheet-head h2 { font-size: 1.6rem; }
  .results { grid-template-columns: 1fr 1fr; gap: 6px; } .results li { padding: 5px 10px; }
  .podium { margin: 6px 0; } .champion .avatar { width: 56px; height: 56px; } .champion .crown-big { width: 40px; height: 40px; }
  .sheet-foot { padding: 8px 0 8px; } .sheet-foot .ready-row .btn { min-height: 44px; }
  .sheet-foot .hint { display: none; }
  .sheet-foot .ready-row { display: flex; flex-wrap: nowrap; } .sheet-foot .ready-row > .btn-brass { flex: 1 1 auto; }
}

#toasts { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(420px, calc(100% - 24px)); pointer-events: none; }
.toast { background: var(--parch); color: var(--parch-ink); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; animation: rise 0.3s var(--ease) both; text-align: center; }
.toast.err { background: #f6d2c9; border-left: 5px solid var(--rouge); }
.conn {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top)); background: #8a2a22; color: #fff; text-align: center;
  font-family: var(--f-label); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.04em; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #ffd9d3; animation: blink 1.2s infinite both; flex: none; }
body.offline #toasts { top: 52px; }


/* ───────── Animations ───────── */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes rise-c { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(243, 205, 122, 0.6); } 80%, 100% { box-shadow: 0 0 0 9px rgba(243, 205, 122, 0); } }
@keyframes fade { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes crown-drop { from { transform: translateY(-50px) rotate(-14deg); opacity: 0; } 60% { transform: translateY(4px) rotate(3deg); } }
@keyframes confetti { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: 0; transform: translate(var(--sw), 105dvh) rotate(var(--rot)); } }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes deal { from { opacity: 0; transform: translateY(-120px) rotate(-12deg) scale(0.7); } }
@keyframes toss { from { opacity: 0; transform: translateY(60px) rotate(8deg) scale(0.8); } }
@keyframes sink { 40% { transform: rotate(-6deg); } to { transform: translateY(30px) rotate(14deg) scale(0.6); opacity: 0.1; filter: blur(2px) hue-rotate(60deg); } }
@keyframes pop { 0% { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(0.8); } 10%, 85% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } 100% { opacity: 0; transform: translateX(-50%) translateY(-6px); } }
@keyframes slam { from { transform: scale(2.2) rotate(-6deg); opacity: 0; } }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(214, 168, 78, 0.0), 0 0 30px rgba(214, 168, 78, 0.45); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  /* les animations « forwards » qui finissent invisibles doivent rester lisibles quand elles sont figées */
  .reveal { animation: none; }
  .emote-bubble { animation: none; opacity: 1; transform: translateX(-50%); }
  .trick.destroyed .card { animation: none; opacity: 0.35; }
  .status .dots i { opacity: 0.7; }
  .confetti { display: none; }
}

/* Petits écrans en hauteur (portrait) : on compacte */
@media (max-height: 700px) and (orientation: portrait) {
  :root { --cw: 58px; }
  .bid-btn { height: 44px; font-size: 1.4rem; }
  .bids { grid-template-columns: repeat(var(--cols, 6), 48px); gap: 6px 8px; }
  .hand-wrap { padding-top: 14px; }
  .dock { gap: 6px; }
}


/* ───────── Règles avancées : pouvoirs des pirates, Rascal, boulet de canon ───────── */
.ic.inl { width: 1em; height: 1em; vertical-align: -0.15em; }
.chip-ic { display: inline-flex; align-items: center; gap: 2px; color: var(--brass-2); font-weight: 800; }
.chip-ic .ic { width: 1.05em; height: 1.05em; }
.chip-ic.wager { color: var(--ecume); }
.chip .meta .wv { display: none; } /* chip étroite : l'icône suffit, le montant est dans l'infobulle et le texte pour lecteur d'écran */
@container (min-width: 118px) { .chip .meta .wv { display: inline; } }
.chip .meta { overflow: hidden; }
.bidtag.adj { color: var(--ecume); text-decoration: underline dotted; text-underline-offset: 3px; }

.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(100%, 520px); }
.shot {
  display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; min-height: 48px;
  border: 1.5px solid var(--line-2); background: rgba(0, 0, 0, 0.22); border-radius: 12px; touch-action: manipulation;
}
.shot .ic { width: 26px; height: 26px; color: var(--ecume); }
.shot b { display: block; font-family: var(--f-label); font-weight: 800; letter-spacing: 0.04em; line-height: 1.1; }
.shot small { display: block; color: var(--muted); font-size: 0.72rem; line-height: 1.15; }
.shot kbd { margin-left: auto; }
.shot[aria-pressed='true'] { border-color: var(--brass); background: rgba(214, 168, 78, 0.14); color: var(--brass-2); }
.shot[aria-pressed='true'] .ic { color: var(--brass-2); }
@media (max-width: 420px) { .shot small { display: none; } .shot { padding: 6px 8px; } }

.power-note {
  position: relative; z-index: 3; margin-top: 8px; display: flex; align-items: center; gap: 8px; max-width: 92%;
  padding: 7px 14px; border-radius: 999px; background: rgba(13, 26, 31, 0.85); border: 1.5px solid var(--brass);
  color: var(--brass-2); font-family: var(--f-label); font-weight: 700; letter-spacing: 0.03em; animation: rise 0.35s var(--ease) both;
}
.power-note .ic { width: 1.4em; height: 1.4em; }
.seen-btn { margin-left: 4px; }
.sheet-head h2 .ic { width: 0.8em; height: 0.8em; vertical-align: -0.08em; margin-right: 4px; }
.power-intro { display: flex; gap: 12px; align-items: center; margin: 0 0 14px; color: var(--parch-2); }
.power-intro .ic { width: 38px; height: 38px; color: var(--brass-2); }
.power-hint { margin: 14px 0 0; }
.choice.c3 { grid-template-columns: repeat(3, 1fr); }
.choice.c3 button { min-height: 130px; position: relative; }
.choice.c3 button b { font-size: 2.6rem; line-height: 1; }
.choice.c3 button:disabled { opacity: 0.35; cursor: not-allowed; }
.choice.players { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.choice.players button { min-height: 104px; position: relative; }
.choice.players button b { font-size: 1.15rem; font-family: var(--f-label); font-weight: 800; letter-spacing: 0.03em; color: var(--parch); }
.choice button kbd { position: absolute; top: 8px; right: 10px; }

.seen-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.card.sm { --cw: 54px; cursor: default; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.card.sm .c-v { font-size: 20px; }
.card.sm .c-name { font-size: 7.5px; }
@media (min-width: 700px) { .card.sm { --cw: 62px; } }
.seen-grid.bendt .card.sm { cursor: pointer; }
.bd-wrap { position: relative; }
.bd-wrap .card.discard { filter: grayscale(0.8) brightness(0.5); transform: translateY(6px) rotate(-3deg); }
.bd-wrap.out::after {
  content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  color: #ff8a7a; font-size: 2.2rem; font-weight: 800; text-shadow: 0 2px 6px #000;
}
.bd-wrap .card[aria-pressed='false']:hover { transform: translateY(-4px); }
.fresh-tag {
  position: absolute; top: -7px; left: -5px; z-index: 2; width: 20px; height: 20px; border-radius: 50%; font-style: normal;
  display: grid; place-items: center; background: var(--brass-2); color: #2a1c08; font-size: 12px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
table.scores td s { opacity: 0.55; }
table.scores td .x { display: inline-flex; align-items: center; gap: 1px; margin-left: 4px; font-size: 0.72rem; color: var(--ecume); font-family: var(--f-label); }
table.scores td .x .ic { width: 1em; height: 1em; }
.hier-sub { display: block !important; font-size: 0.85rem; color: var(--muted); font-style: italic; margin-top: 6px; }
.hier-power { padding-left: 4px; }
.hier-power .ic { width: 22px; height: 22px; color: var(--brass-2); }
.reveal .bids-reveal .shot-tag { font-style: normal; font-family: var(--f-label); font-size: 0.72rem; color: var(--brass-2); display: inline-flex; align-items: center; gap: 3px; }
.reveal .bids-reveal .shot-tag .ic { width: 1.1em; height: 1.1em; }

/* 320 px : six boutons de pari par rangée tiennent à 44 px */
@media (max-width: 359px) and (orientation: portrait) { .bids { gap: 6px; grid-template-columns: repeat(var(--cols, 6), 44px); } .bid-btn { height: 44px; font-size: 1.35rem; } }
/* Petit portrait (≤ 700 px de haut) : pendant les paris la table n'a rien à montrer que la topbar ne dise déjà → on lui reprend la place */
@media (max-height: 700px) and (orientation: portrait) {
  .game[data-phase='bidding'] { grid-template-rows: auto auto 0 minmax(0, 1fr) auto; }
  .game[data-phase='bidding'] .table-wrap { visibility: hidden; padding: 0; }
  .game[data-phase='bidding'] .dock { align-self: center; }
}

/* Table basse (petit portrait, 7-8 pirates) : on remplace les noms par l'emblème coloré sous chaque carte, pour que les cartes restent grandes */
.trick .slot .who .wa { display: none; }
.trick .slot .who .wa .avatar { width: 18px; height: 18px; border-width: 1.5px; margin: 0 auto; }
@container (max-height: 235px) {
  .trick { --gap: 5px; --bud: 90cqh; --lab: 22px; }
  .trick .slot .who .wn { display: none; }
  .trick .slot .who .wa { display: block; }
  .trick .slot .who i { display: none; }
  .trick .slot { gap: 2px; }
  .result-banner { bottom: 3%; padding: 3px 10px; } .result-banner b { font-size: 1rem; } .result-banner small { font-size: 0.7rem; }
}

.tk-reason { display: none; }
.table-wrap:has(.lead-chip) { padding-top: 24px; }
.lead-chip { top: 2px; }
@container (max-height: 235px) { .result-banner { display: none; } }
@media (max-height: 760px) and (orientation: portrait) { .tk-reason { display: block; font-size: 0.78rem; color: var(--parch-2); line-height: 1.2; } }
@media (max-height: 520px) and (orientation: landscape) { .table-wrap:has(.lead-chip) { padding-top: 16px; } }

@media (max-height: 520px) and (orientation: landscape) {
  .dock .bid-head, .dock .play-row { flex: 1 1 100%; justify-content: center; flex-wrap: nowrap; }
  .dock .bid-head .status { flex: 0 1 auto; text-align: right; }
  .dock .bids { width: 100%; flex: 1 1 100%; }
  .dock .bid-head .btn { min-height: 40px; }
}

/* Portrait téléphone : table en rectangle arrondi (l'ovale rognait les coins d'un pli sur deux rangées) */
@media (max-width: 600px) and (orientation: portrait) {
  .table { border-radius: 34px; }
  .table::before { width: 46%; }
}
