/* ==========================================================================
   Skull King en ligne — sur le pont d'un navire : planches, table ovale, carte au trésor,
   parchemin pour les fenêtres, doublons d'or pour les boutons. Polices : Pirata One (titres),
   IM Fell English (textes d'ambiance), Nunito (chiffres et petites indications).
   ========================================================================== */
/* Les chiffres de Pirata One (le 0 ressemble à un 8) et ceux d'IM Fell (le 0 ressemble à un o) sont peu lisibles :
   dans ces deux polices, les chiffres viennent d'un Nunito figé (gras pour les titres). */
@font-face { font-family: "SK Title"; src: url("fonts/pirata-one.woff2") format("woff2"); font-display: swap; unicode-range: U+0000-002F, U+003A-FFFF; }
@font-face { font-family: "SK Title"; src: url("fonts/digits-bold.woff2") format("woff2"); font-display: swap; unicode-range: U+0030-0039; }
@font-face { font-family: "SK Fell"; src: url("fonts/im-fell.woff2") format("woff2"); font-display: swap; unicode-range: U+0000-002F, U+003A-FFFF; }
@font-face { font-family: "SK Fell"; src: url("fonts/digits.woff2") format("woff2"); font-display: swap; unicode-range: U+0030-0039; }
@font-face { font-family: "Nunito"; src: url("fonts/nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }

:root {
  --night: #0b1218;
  --sea: #123240;
  --wood: #4a2c18;
  --wood-dark: #2a170c;
  --parch: #f1e2bf;
  --parch-2: #dcc28f;
  --ink: #2a1a0c;
  --ink-soft: #6b4a2a;
  --gold: #e0a83c;
  --gold-light: #ffd98a;
  --gold-deep: #8f5f17;
  --blood: #a8261c;
  --teal: #2c8c87;
  --muted: #d9c7a0;
  --title: "SK Title", "Georgia", serif;
  --fell: "SK Fell", "Georgia", serif;
  --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --card-ratio: 1.458;      /* hauteur / largeur des cartes */
  --hand-w: clamp(76px, 12.5vh, 140px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  color: var(--parch); font: 600 15px/1.4 var(--body); overflow: hidden;
  background:
    radial-gradient(70vw 55vh at 50% 42%, #ffcf7a22, transparent 70%),
    radial-gradient(140vw 110vh at 50% 50%, transparent 45%, #000000d9 100%),
    url("img/deck.jpg") center / cover;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }
a { color: inherit; }

/* ---------- Boutons : doublons et cartons de parchemin ---------- */
button { cursor: pointer; font-family: var(--title); font-size: 19px; letter-spacing: .02em; color: var(--ink);
  padding: 7px 18px 6px; border-radius: 10px; border: 0; border-bottom: 4px solid #9c7f4c;
  background: linear-gradient(var(--parch), var(--parch-2)); box-shadow: 0 6px 14px #0008; transition: translate .08s, filter .12s; }
button:hover { filter: brightness(1.07); }
button:active { translate: 0 3px; border-bottom-width: 1px; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.gold { background: linear-gradient(var(--gold-light), var(--gold)); border-bottom-color: var(--gold-deep); }
button.big { width: 100%; font-size: 22px; padding: 10px 18px 8px; }
button.big small { display: block; font: 700 12px var(--body); color: var(--ink-soft); letter-spacing: 0; }
button.link { background: none; border: 0; box-shadow: none; padding: 0; color: var(--ink-soft); font: 600 14px var(--body); text-decoration: underline; letter-spacing: 0; }
input, select { background: #fff8e8; color: var(--ink); border: 2px solid #b8955c; border-radius: 10px; padding: 9px 12px; font-weight: 700; }
input:focus, select:focus { outline: none; border-color: var(--blood); }

/* Parchemin (fenêtres) */
.sheet { color: var(--ink); background:
    radial-gradient(120% 90% at 50% 40%, #f7ebcf 40%, #e3c88f 80%, #c49c5c 100%);
  border-radius: 6px 10px 8px 12px; padding: 26px 30px 22px;
  box-shadow: inset 0 0 40px #8a5a1e66, inset 0 0 6px #6b3f12, 0 30px 70px #000c; }
.sheet h2, .sheet h3 { color: var(--blood); }
.hint { color: var(--ink-soft); font-size: 14px; }
.sheet.scroll { max-height: 92dvh; overflow: auto; }

/* ---------- Accueil ---------- */
.screen { position: relative; height: 100%; }
#lobby, #waiting { display: grid; place-items: center; padding: max(3vh, 96px) 16px 3vh; overflow: auto; }
#waiting { padding-top: 3vh; }
#lobby .sheet { width: min(470px, 94vw); text-align: center; position: relative; }
.lobbyCards { position: relative; height: 140px; margin: -92px auto 6px; width: 220px; }
.lobbyCards img { position: absolute; top: 0; width: 82px; border-radius: 7px; box-shadow: 0 10px 22px #000b; }
.lobbyCards img:nth-child(1) { left: 14px; rotate: -14deg; top: 14px; }
.lobbyCards img:nth-child(2) { left: 69px; z-index: 2; width: 88px; }
.lobbyCards img:nth-child(3) { left: 126px; rotate: 14deg; top: 14px; }
h1 { margin: 6px 0 0; font: 400 clamp(52px, 8vw, 70px)/1 var(--title); color: var(--blood); text-shadow: 0 2px 0 #f9e9c4, 0 4px 10px #6b3f1288; }
h2 { margin: 0; font: 400 34px var(--title); }
.sub { color: var(--ink-soft); margin: 8px 0 18px; font: 400 17px/1.35 var(--fell); }
.field { display: block; text-align: left; margin: 12px 0 0; color: var(--blood); font: 400 18px var(--title); }
.field input, .field select { width: 100%; margin-top: 4px; font-size: 16px; }
.seg { display: flex; gap: 6px; margin-top: 5px; }
.seg button { flex: 1; font-size: 20px; padding: 6px 0 5px; background: #fff8e8; border-bottom-color: #b8955c; box-shadow: none; }
.seg button[aria-checked="true"] { background: linear-gradient(var(--gold-light), var(--gold)); border-bottom-color: var(--gold-deep); }
#create { margin-top: 16px; }
#tutoBtn { margin-top: 10px; background: linear-gradient(#e7f2ef, #b9d6cf); border-bottom-color: #5e8f87; }
.or { margin: 14px 0 8px; color: var(--ink-soft); font: 400 15px var(--fell); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
#code { text-transform: uppercase; text-align: center; letter-spacing: 6px; font: 400 22px var(--title); }
.links { display: flex; justify-content: center; gap: 18px; margin: 16px 0 0; font-size: 14px; color: var(--ink-soft); flex-wrap: wrap; }
.hubLink { position: fixed; top: 14px; left: 14px; z-index: 20; display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px 7px 12px;
  border-radius: 999px; text-decoration: none; font-weight: 800; font-size: 14px; color: var(--ink);
  background: linear-gradient(var(--parch), var(--parch-2)); box-shadow: 0 3px 0 #9c7f4c, 0 10px 20px #0009; }
.hubLink svg { width: 18px; height: 18px; }

/* ---------- Salle d'attente ---------- */
#waiting .sheet { width: min(560px, 94vw); text-align: center; max-height: 94dvh; overflow: auto; }
.code { font: 400 64px var(--title); letter-spacing: 14px; color: var(--blood); margin: 0 0 12px; }
#seats { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; text-align: left; }
#seats li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; background: #fff8e8aa; border: 1px solid #c9a76b; }
#seats li .num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 400 15px var(--title); color: var(--ink); background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 60%, var(--gold-deep)); flex: none; }
#seats li.empty { color: var(--ink-soft); border-style: dashed; }
#seats li .tag { margin-left: auto; font-size: 12px; color: var(--ink-soft); }
#seats li button { margin-left: auto; font-size: 13px; padding: 2px 10px 1px; border-bottom-width: 2px; }
#settings { text-align: left; margin: 4px 0 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid #c9a76b; background: #fff8e866; }
#settings h3 { margin: 0 0 4px; font: 400 22px var(--title); }
#settings select { width: 100%; }
#settings select:disabled, #settings input:disabled { opacity: .75; }
#settings .hint { margin: 4px 0 6px; font-size: 13px; }
.toggles { display: grid; gap: 6px; margin: 10px 0 4px; }
.toggle { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 6px 10px; border-radius: 10px; background: #fff8e8aa; border: 1px solid #d8bd88; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--blood); grid-row: span 2; }
.toggle span { font: 400 18px var(--title); color: var(--ink); }
.toggle small { color: var(--ink-soft); font-size: 12.5px; }

/* ---------- Table ---------- */
#game { display: grid; grid-template-rows: 1fr auto auto; height: 100dvh; padding: 0 1.4vw; }
#tableWrap { min-height: 0; display: grid; place-items: center; padding: 8vh 0 1vh; perspective: 1700px; }
#tableBox { position: relative; aspect-ratio: 1.6; height: min(100%, calc((100vw - 18vw) / 1.6)); max-width: 100%; container-type: size; }
#heldLayer { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
#table { position: absolute; inset: 0; z-index: 1; background: url("img/table.webp") center / 100% 100% no-repeat;
  transform: rotateX(9deg); transform-origin: 50% 85%; filter: drop-shadow(0 26px 40px #000c); container-type: size; }
#table.dropping { filter: drop-shadow(0 0 1.4cqw #6fd3c9) drop-shadow(0 26px 40px #000c); }
#seatLayer, #trickArea { position: absolute; inset: 0; }
.seat { position: absolute; inset: 0; pointer-events: none; }
.seat > * { pointer-events: auto; }

/* Cartes */
.card { position: relative; display: block; aspect-ratio: 1 / var(--card-ratio); border-radius: 5.5% / 3.8%;
  background: #f3e6c8 center / cover no-repeat; box-shadow: 0 .4em 1em #000b, 0 0 0 1px #00000033;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.card.back { background-image: url("img/back.svg"); }
.card.zoomable { cursor: zoom-in; }

/* Plaque d'un pirate autour de la table */
.plate { position: absolute; translate: -50% -50%; z-index: 3; min-width: 12cqw; padding: .5cqw .9cqw .5cqw .5cqw; border-radius: 1.4cqw;
  display: grid; grid-template-columns: auto 1fr auto; column-gap: .7cqw; align-items: center; color: var(--ink);
  background: linear-gradient(var(--parch), var(--parch-2)); box-shadow: 0 .5cqw 1.2cqw #000b; font-size: 1.15cqw; white-space: nowrap; }
.plate .coin { grid-row: span 2; width: 3.4cqw; height: 3.4cqw; border-radius: 50%; display: grid; place-items: center;
  font: 400 1.9cqw var(--title); color: var(--ink); background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 0 0 .2cqw #5c3a0c, inset 0 0 0 .25cqw #ffe7a355; }
.plate .who { font: 400 1.7cqw/1.05 var(--title); max-width: 12cqw; overflow: hidden; text-overflow: ellipsis; }
.plate .stats { display: flex; gap: .5cqw; align-items: center; font: 800 1.05cqw var(--body); color: var(--ink-soft); }
.plate .bid { padding: .1cqw .6cqw; border-radius: 99px; background: var(--ink); color: var(--gold-light); }
.plate .bid.hidden { background: #6b4a2a; color: #e8d3a8; }
.plate .bid.done { background: var(--teal); color: #fff; }
.plate .tricks { display: inline-flex; gap: .25cqw; }
.plate .tricks i { width: .9cqw; height: 1.3cqw; border-radius: .15cqw; background: url("img/back.svg") center / cover; box-shadow: 0 0 0 .06cqw #0006; }
.plate .score { grid-column: 3; grid-row: 1 / span 2; align-self: center; padding-left: .3cqw; font: 400 2cqw var(--title); color: var(--blood); }
.plate .who { grid-column: 2; grid-row: 1; } .plate .stats { grid-column: 2; grid-row: 2; }
.plate.me { background: linear-gradient(#fff2c9, var(--gold)); }
.plate.turn { box-shadow: 0 0 0 .3cqw var(--gold-light), 0 0 2.4cqw #ffc94d, 0 .5cqw 1.2cqw #000b; }
.plate.off .who { opacity: .55; }
.plate.ghost { background: linear-gradient(#d9e4e2, #9fb3b0); }
.plate.ghost .coin { background: radial-gradient(circle at 35% 30%, #f4fbfa, #9fb3b0 60%, #4c605d); }
.plate.target { cursor: pointer; outline: .35cqw solid var(--teal); }

/* Cartes tenues par les autres joueurs : debout derrière le bord de la table */
.oppHand { position: absolute; display: flex; align-items: flex-end; transform: translate(-50%, -100%) rotate(var(--r, 0deg)); transform-origin: 50% 100%; }
.oppHand i { width: 4.6cqw; aspect-ratio: 1 / var(--card-ratio); margin-left: -3cqw; border-radius: .35cqw; background: url("img/back.svg") center / cover;
  box-shadow: -.25cqw 0 .6cqw #000a; rotate: calc(var(--o) * 3.2deg); transform-origin: 50% 170%; translate: 0 calc(var(--o) * var(--o) * .1cqw); }
.oppHand i:first-child { margin-left: 0; }

/* Plis remportés par chacun (petites piles) */
.wonPile { position: absolute; translate: -50% -50%; width: 3.2cqw; aspect-ratio: 1 / var(--card-ratio); pointer-events: none; }
.wonPile i { position: absolute; inset: 0; border-radius: .3cqw; background: url("img/back.svg") center / cover; box-shadow: 0 .2cqw .4cqw #000a; }

/* Le pli en cours, au centre */
.tcard { position: absolute; translate: -50% -50%; width: 8.4cqw; z-index: 2; }
.tcard .who { position: absolute; left: 50%; bottom: -1.9cqw; translate: -50% 0; white-space: nowrap; padding: .1cqw .7cqw; border-radius: 99px;
  font: 800 1cqw var(--body); background: #2a1a0ccc; color: var(--parch); }
.tcard.lead::after { content: "ouvre"; position: absolute; left: 50%; top: -1.6cqw; translate: -50% 0; font: 800 .9cqw var(--body); color: var(--gold-light); }
.tcard .tig { position: absolute; left: 50%; top: 42%; translate: -50% 0; padding: .1cqw .6cqw; border-radius: 99px; font: 800 1cqw var(--body);
  background: var(--blood); color: #fff; }
.tcard.leading .card { box-shadow: 0 0 0 .3cqw var(--gold-light), 0 0 2.4cqw #ffc94d; }
.tcard.winner .card { box-shadow: 0 0 0 .35cqw var(--gold-light), 0 0 3.2cqw #ffd36b; }
.tcard.lost .card { filter: brightness(.6) saturate(.7); }
.liveTag { position: absolute; left: 50%; top: -1.8cqw; translate: -50% 0; white-space: nowrap; padding: .15cqw .7cqw; border-radius: 99px;
  font: 800 .95cqw var(--body); background: linear-gradient(var(--gold-light), var(--gold)); color: var(--ink); z-index: 3; }

/* Chronomètre et flèche */
#clock { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 7cqw; aspect-ratio: 1; z-index: 1; pointer-events: none; }
#clockFace { position: absolute; inset: 0; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(circle at 40% 32%, #f7ebcf, #d4b47a 70%, #a17840); box-shadow: 0 0 0 .3cqw #5c3a0c, 0 .6cqw 1.6cqw #000a; }
#clockTime { font: 400 2.4cqw/1 var(--title); color: var(--ink); }
#clockWho { display: block; max-width: 6cqw; margin-top: .15cqw; font: 800 .8cqw var(--body); color: var(--blood); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#clock.urgent #clockTime { color: var(--blood); animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { scale: 1.15; } }
#clockArrow { position: absolute; left: 50%; top: 50%; width: 0; height: 0; rotate: var(--a, 0rad); transition: rotate .45s cubic-bezier(.3,1.4,.5,1); }
#clockArrow::after { content: ""; position: absolute; left: 4cqw; top: -1.2cqw; border-left: 2.2cqw solid var(--blood); border-top: 1.2cqw solid transparent;
  border-bottom: 1.2cqw solid transparent; filter: drop-shadow(0 0 .4cqw #000a); }
#clock.bidding #clockArrow { display: none; }

/* Fenêtre d'action (mise, Tigresse, pouvoirs) au centre de la table */
#actionBox { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 6; width: min(42cqw, 560px); padding: 1.4cqw 1.8cqw 1.6cqw; text-align: center;
  color: var(--ink); background: radial-gradient(120% 90% at 50% 40%, #f7ebcf 40%, #e3c88f 85%, #c49c5c);
  border-radius: 1cqw; box-shadow: inset 0 0 2cqw #8a5a1e66, 0 0 0 .3cqw #5c3a0c, 0 2cqw 5cqw #000d; }
#actionBox h3 { margin: 0; font: 400 clamp(22px, 2.8cqw, 36px) var(--title); color: var(--blood); }
#actionBox p { margin: .4cqw 0 1cqw; font: 400 clamp(14px, 1.45cqw, 19px)/1.3 var(--fell); }
#actionButtons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#actionButtons button { font-size: clamp(16px, 1.7cqw, 22px); }
#actionButtons button.bidBtn { width: clamp(44px, 4.6cqw, 62px); height: clamp(44px, 4.6cqw, 62px); padding: 0; border-radius: 50%; border: 0;
  font: 400 clamp(20px, 2.4cqw, 32px) var(--title); background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 0 0 .2cqw #5c3a0c, 0 .4cqw .8cqw #0008; }
#actionButtons button.bidBtn:disabled { filter: grayscale(.8) brightness(.8); }
#actionDrop { padding: 1.4cqw 1cqw; border: .2cqw dashed #8f5f17; border-radius: .9cqw; color: var(--ink-soft); font: 700 clamp(13px, 1.2cqw, 16px) var(--body); }
#actionBox.dropping #actionDrop { border-color: var(--teal); background: #2c8c8722; color: var(--ink); }
#actionCards { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-bottom: .8cqw; max-height: 24cqh; overflow: auto; }
#actionCards .card { width: clamp(34px, 3.6cqw, 52px); }
#actionBox:not([hidden]) ~ #clock { opacity: .2; }

/* Bannière (Yo-ho-ho, fin de manche…) */
#banner { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 20; padding: 1.4cqw 3.4cqw 1.2cqw; text-align: center; color: var(--ink);
  background: radial-gradient(120% 90% at 50% 40%, #f7ebcf 40%, #e3c88f 85%, #c49c5c); border-radius: 1cqw; box-shadow: 0 0 0 .3cqw #5c3a0c, 0 2cqw 5cqw #000d; }
#banner h3 { margin: 0; font: 400 4.4cqw/1 var(--title); color: var(--blood); }
#banner p { margin: .6cqw 0 0; font: 400 1.6cqw var(--fell); white-space: pre-line; }

/* Consigne */
#status { text-align: center; padding: 4px 0 0; position: relative; z-index: 5; }
#prompt { display: inline-block; margin: 0 0 6px; padding: 8px 22px 6px; border-radius: 4px; font: 400 clamp(16px, 2.3vh, 21px)/1.25 var(--fell); color: var(--ink);
  background: linear-gradient(#fbf1d8, #e6d0a0); box-shadow: 0 3px 0 #b39461, 0 12px 22px #000b; rotate: -.6deg; max-width: min(860px, 94vw); }
#prompt:empty { display: none; }
#prompt.wait { color: #6b5a44; background: linear-gradient(#ece2c9, #d8c5a0); }
#prompt.win { font: 400 28px var(--title); color: var(--blood); box-shadow: 0 0 0 3px var(--gold), 0 0 30px var(--gold); }
#choices { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#lastEvent { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
#lastEvent:empty { display: none; }
#suitBadge { display: inline-block; margin-bottom: 6px; padding: 4px 12px; border-radius: 99px; font: 800 13px var(--body); background: var(--ink); color: var(--gold-light); box-shadow: 0 4px 10px #0008; }

/* Main en éventail */
#handWrap { display: flex; justify-content: center; padding: 6px 0 calc(12px + env(safe-area-inset-bottom)); position: relative; z-index: 4; }
.hand { display: flex; justify-content: center; align-items: flex-end; min-height: calc(var(--hand-w) * var(--card-ratio) * .7); }
.hand .card { width: var(--hand-w); margin: 0 calc(var(--hand-w) * var(--ov, -.08)); transform: rotate(var(--rot, 0deg)) translateY(var(--drop, 0px));
  transform-origin: 50% 120%; transition: transform .15s; }
.hand .card:hover { transform: translateY(-22%) scale(1.14); z-index: 3; }
.hand .card.playable { box-shadow: 0 0 0 2px var(--gold-light), 0 0 16px #ffc94daa, 0 .5em 1.2em #000b; }
.hand .card.draggable { cursor: grab; touch-action: none; }
.hand .card.dim { filter: brightness(.5) saturate(.6); }
.hand .card.dragSource { opacity: .25; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }
.dragGhost { z-index: 85; scale: 1.08; rotate: -3deg; box-shadow: 0 0 0 3px var(--gold-light), 0 24px 40px #000c; }
.flying { position: fixed; z-index: 60; pointer-events: none; }
.floatText { position: fixed; z-index: 70; pointer-events: none; font: 400 30px var(--title); color: var(--gold-light); text-shadow: 0 2px 0 #5c3a0c, 0 0 14px #000; }

/* Bandeau de gauche */
#drawerBtn { position: absolute; top: 8px; left: 1.2vw; z-index: 30; height: 44px; padding: 0 16px 0 12px; border-radius: 22px; display: flex; align-items: center; gap: 8px; font-size: 19px; }
#drawerBtn svg { width: 22px; height: 22px; }
#drawer { position: fixed; z-index: 76; left: 0; top: 0; bottom: 0; width: min(340px, 86vw); padding: 18px 18px 22px; overflow: auto; display: flex; flex-direction: column; gap: 10px;
  color: var(--ink); background: radial-gradient(120% 90% at 50% 30%, #f7ebcf 40%, #e0c48a 90%); box-shadow: inset -10px 0 30px #8a5a1e55, 20px 0 50px #000c;
  translate: -105% 0; transition: translate .3s cubic-bezier(.3,.8,.3,1); }
#drawer.open { translate: 0 0; }
#drawer header { display: flex; align-items: center; justify-content: space-between; }
#drawer h2 { font-size: 32px; color: var(--blood); }
#drawer h3 { margin: 4px 0 0; font: 400 22px var(--title); color: var(--blood); }
#drawerClose { width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 22px; line-height: 1; }
#scoreList { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#scoreList li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 7px 10px; border-radius: 10px; background: #fff8e8aa; border: 1px solid #d8bd88; }
#scoreList li b { font: 400 19px var(--title); }
#scoreList li .pts { font: 400 22px var(--title); color: var(--blood); grid-row: span 2; align-self: center; }
#scoreList li small { color: var(--ink-soft); font-size: 12.5px; }
#scoreList li.me { border-color: var(--gold-deep); background: #ffe9b0aa; }
#drawer #optionsInfo { margin-top: auto; }
@media (prefers-reduced-motion: reduce) { #drawer { transition: none; } }

/* Menu */
#menuBtn { position: absolute; top: 8px; right: 1.2vw; z-index: 30; width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
#menuBtn svg { width: 24px; height: 24px; transition: rotate .4s; }
#menuBtn[aria-expanded="true"] svg { rotate: 90deg; }
#tools { position: absolute; top: 60px; right: 1.2vw; z-index: 30; display: flex; flex-direction: column; gap: 2px; min-width: 240px; padding: 10px; border-radius: 12px;
  background: linear-gradient(#fbf1d8, #e6d0a0); box-shadow: 0 3px 0 #b39461, 0 18px 34px #000c; }
#tools button, #tools a { text-align: left; font: 400 19px var(--title); color: var(--ink); text-decoration: none; padding: 6px 10px 5px; border-radius: 8px; background: none; border: 0; box-shadow: none; }
#tools button:hover, #tools a:hover { background: #fff8e6; }
#tools button:last-child { color: var(--blood); }
#logPanel { position: absolute; z-index: 25; top: 60px; right: 1.2vw; width: 360px; max-height: 60vh; display: flex; flex-direction: column; padding: 12px 14px; border-radius: 12px; color: var(--ink);
  background: linear-gradient(#fbf1d8, #e6d0a0); box-shadow: 0 3px 0 #b39461, 0 18px 34px #000c; }
#logPanel h3 { margin: 0 0 6px; font: 400 22px var(--title); color: var(--blood); }
#log { margin: 0; padding: 0; list-style: none; overflow: auto; font: 400 14px/1.35 var(--fell); }
#log li { padding: 3px 0; border-bottom: 1px solid #d8c69e; }

/* Fenêtres par-dessus la table */
.overlay { position: fixed; inset: 0; z-index: 72; display: grid; place-items: center; background: #050a0ecc; padding: 16px; }
.overlay .sheet { width: min(900px, 96vw); }
.overlay h3 { margin: 0 0 10px; font: 400 34px var(--title); color: var(--blood); text-align: center; }
#sheetClose, #trickClose { display: block; margin: 16px auto 0; }

/* Carnet de bord */
.roundTable { width: 100%; border-collapse: collapse; font-size: 14px; }
.roundTable th { font: 400 17px var(--title); color: var(--ink-soft); text-align: left; padding: 4px 8px; border-bottom: 2px solid #b8955c; }
.roundTable td { padding: 7px 8px; border-bottom: 1px solid #d8c69e; vertical-align: top; }
.roundTable td.name { font: 400 19px var(--title); white-space: nowrap; }
.roundTable td.num { font: 400 20px var(--title); text-align: center; white-space: nowrap; }
.roundTable td.pos { color: #22713b; } .roundTable td.neg { color: var(--blood); }
.roundTable .detail { font: 400 14px/1.3 var(--fell); color: var(--ink); }
.roundTable .bonusLine { display: block; color: #22713b; font-size: 13px; }
.roundTable tr.best td.name::after { content: " ☠"; color: var(--blood); }
.fullTable { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.fullTable th, .fullTable td { padding: 4px 6px; border: 1px solid #d8c69e; text-align: center; }
.fullTable th { font: 400 16px var(--title); }
.fullTable td small { display: block; color: var(--ink-soft); font-size: 11px; }
.howto { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: #fff8e8aa; border: 1px dashed #b8955c; font: 400 15px/1.4 var(--fell); }
.howto b { font-family: var(--body); }

#sheetBody details { margin-top: 12px; }
#sheetBody summary { cursor: pointer; font: 400 20px var(--title); color: var(--blood); }
#sheet .sub { text-align: center; font-size: 20px; }

/* Dernier pli */
#trickCards { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.trickCell { margin: 0; width: clamp(90px, 11vw, 124px); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.trickCell .card { width: 100%; }
.trickCell.won .card { box-shadow: 0 0 0 3px var(--gold), 0 0 22px var(--gold); }
.trickCell figcaption { font: 400 17px var(--title); text-align: center; }
.trickCell .mark { display: block; font: 700 12px var(--body); color: var(--ink-soft); }

/* Aide de jeu */
#helpBody { width: min(860px, 96vw); }
#helpBody h3 { text-align: left; font-size: 28px; margin: 14px 0 6px; }
#helpBody h3:first-child { margin-top: 0; text-align: center; font-size: 36px; }
.helpGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.helpItem { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; padding: 8px; border-radius: 10px; background: #fff8e888; border: 1px solid #d8bd88; }
.helpItem .card { width: 64px; }
.helpItem b { font: 400 19px var(--title); display: block; }
.helpItem p { margin: 2px 0 0; font: 400 14px/1.3 var(--fell); }
#helpBody ol, #helpBody ul { font: 400 16px/1.4 var(--fell); padding-left: 20px; }
#helpBody .example { padding: 8px 12px; border-left: 4px solid var(--gold); background: #fff8e8aa; font: 400 15px/1.35 var(--fell); margin: 6px 0; }

/* Aperçu agrandi et carte en grand */
#peek { position: fixed; z-index: 70; pointer-events: none; height: min(56vh, 480px); aspect-ratio: 1 / var(--card-ratio); border-radius: 3%;
  background: center / cover no-repeat; box-shadow: 0 0 0 4px #2a170c, 0 24px 70px #000e; }
#viewer { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #050a0eee; cursor: zoom-out; padding: 3vh; }
#viewImg { height: min(80vh, 140vw); border-radius: 3%; box-shadow: 0 0 0 4px #2a170c, 0 30px 80px #000; }
#viewText { margin: 0; max-width: 560px; text-align: center; font: 400 18px/1.4 var(--fell); color: var(--parch); }
#toast { position: fixed; bottom: 18px; left: 50%; translate: -50% 0; z-index: 90; padding: 9px 20px; border-radius: 10px; background: var(--blood); color: #fff; font: 400 18px var(--title); box-shadow: 0 10px 24px #000a; }
#soundPanel { position: fixed; z-index: 75; left: 50%; top: 50%; translate: -50% -50%; display: grid; gap: 12px; min-width: 260px; }
#soundPanel h3 { margin: 0; font: 400 28px var(--title); }
#soundPanel label { display: flex; align-items: center; gap: 10px; }
#soundPanel input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--blood); }
#soundPanel .vol input { flex: 1; accent-color: var(--blood); }

/* Tutoriel : tout est assombri sauf l'élément expliqué */
#tutoMask { position: fixed; inset: 0; z-index: 77; pointer-events: none; }
#tutoHole { position: fixed; border-radius: 14px; box-shadow: 0 0 0 200vmax #050a0ed9, 0 0 0 4px var(--gold-light), 0 0 30px 6px #ffd36b;
  transition: left .35s ease, top .35s ease, width .35s ease, height .35s ease; }
#tutoHole.none { box-shadow: 0 0 0 200vmax #050a0ed9; }
#tutoBlock { position: fixed; inset: 0; z-index: 78; }
#tutoBubble { position: fixed; z-index: 79; width: min(440px, 92vw); padding: 16px 18px 14px; color: var(--ink); border-radius: 10px;
  background: radial-gradient(120% 90% at 50% 40%, #f7ebcf 40%, #e3c88f 85%, #c49c5c); box-shadow: inset 0 0 20px #8a5a1e66, 0 0 0 3px #5c3a0c, 0 20px 50px #000d;
  transition: left .35s ease, top .35s ease; }
#tutoBubble h3 { margin: 0 0 6px; font: 400 28px/1.05 var(--title); color: var(--blood); }
#tutoStep { margin: 0; font: 800 12px var(--body); color: var(--ink-soft); }
#tutoText { font: 400 17px/1.4 var(--fell); }
#tutoText p { margin: 0 0 8px; }
#tutoText .cards { display: flex; gap: 6px; margin: 4px 0 8px; }
#tutoText .cards .card { width: 58px; }
#tutoBubble .row { margin-top: 8px; }
#tutoBubble.action #tutoNext { display: none; }
#tutoBubble .doit { display: block; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--gold-light); font: 800 14px var(--body); }

/* ---------- Grand écran : la consigne passe à droite de la main ---------- */
@media (min-width: 1100px) {
  #game { grid-template-rows: 1fr auto; }
  #status { position: absolute; right: 1.6vw; bottom: calc(18px + env(safe-area-inset-bottom)); width: clamp(220px, calc((100vw - var(--hand-w) * 7) / 2 - 3vw), 380px); padding: 0; }
  #prompt { display: block; max-width: none; rotate: -1deg; }
}

/* ---------- Téléphone (portrait) : les pirates en grille, le pli en ligne ---------- */
#rotate { display: none; }
@media (max-width: 760px) {
  :root { --hand-w: clamp(56px, 16vw, 80px); }
  #game { padding-top: 58px; grid-template-rows: 1fr auto auto; }
  #drawerBtn { left: 8px; }
  #tableWrap { place-items: stretch; padding: 0; perspective: none; overflow-y: auto; }
  #tableBox { height: auto; width: 100%; aspect-ratio: auto; container-type: normal; }
  #heldLayer { display: none; }
  #table { position: relative; inset: auto; transform: none; filter: none; border-radius: 16px; padding: 10px 8px; container-type: inline-size;
    background: radial-gradient(120% 90% at 50% 40%, #8a5a2e, #4a2c18 75%); box-shadow: inset 0 0 0 3px #2a170c, inset 0 0 0 5px var(--gold-deep), 0 14px 30px #000c; }
  #seatLayer { position: static; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
  .seat { position: static; inset: auto; }
  .plate { position: static; translate: none; min-width: 0; width: 100%; padding: 5px 7px; border-radius: 10px; font-size: 11px; column-gap: 6px; }
  .plate .coin { width: 26px; height: 26px; font-size: 15px; }
  .plate .who { font-size: 15px; max-width: 100%; }
  .plate .stats { font-size: 10.5px; gap: 4px; flex-wrap: wrap; }
  .plate .score { font-size: 16px; }
  .plate .tricks i { width: 6px; height: 9px; }
  .wonPile { display: none; }
  #trickArea { position: static; display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 8px; min-height: 120px; margin-top: 12px; padding: 12px 6px 18px;
    border-radius: 12px; background: radial-gradient(#f1e2bf, #d8bd88); box-shadow: inset 0 0 18px #8a5a1e88; }
  .tcard { position: relative; left: auto !important; top: auto !important; translate: none; rotate: none !important; width: 19vw; max-width: 88px; }
  .tcard .who { font-size: 10px; bottom: -15px; }
  .tcard .tig { font-size: 10px; }
  .liveTag { font-size: 10px; top: -14px; }
  .tcard.lead::after { display: none; }
  #clock { position: relative; left: auto; top: auto; translate: none; width: 62px; margin: 10px auto 0; }
  #clockArrow { display: none; }
  #clockTime { font-size: 22px; } #clockWho { font-size: 9px; max-width: 54px; }
  #actionBox { position: fixed; left: 50%; top: 46%; width: min(94vw, 400px); padding: 14px; border-radius: 12px; z-index: 40; }
  #actionBox h3 { font-size: 28px; } #actionBox p { font-size: 15px; }
  #actionButtons button.bidBtn { width: 46px; height: 46px; font-size: 24px; }
  #actionCards .card { width: 40px; }
  #banner { position: fixed; padding: 14px 24px; border-radius: 12px; }
  #banner h3 { font-size: 40px; } #banner p { font-size: 15px; }
  #prompt { font-size: 15px; padding: 6px 12px 5px; }
  #lastEvent { display: none; }
  .roundTable { font-size: 12px; } .roundTable td.name { font-size: 16px; }
  /* le calcul passe sous chaque ligne */
  .roundTable tr { display: grid; grid-template-columns: 1fr 36px 36px 52px 46px; align-items: center; border-bottom: 1px solid #d8c69e; }
  .roundTable th:nth-child(4) { display: none; }
  .roundTable td { border: 0; padding: 4px; }
  .roundTable td.detail { grid-column: 1 / -1; grid-row: 2; padding-top: 0; }
  .overlay { padding: 8px; } .overlay .sheet { padding: 18px 14px 16px; } .overlay h3 { font-size: 28px; }
}
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  body:has(#game:not([hidden])) #rotate { position: fixed; inset: 0; z-index: 99; display: grid; place-content: center; justify-items: center; gap: 14px;
    background: #0b1218f2; text-align: center; font: 400 26px var(--title); padding: 20px; }
  #rotate .phoneIcon { width: 46px; height: 76px; border: 4px solid var(--gold); border-radius: 10px; }
}
@media (hover: none) { .hand .card:hover { transform: rotate(var(--rot, 0deg)) translateY(var(--drop, 0px)); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
