:root {
  --c0: #e5484d; --c1: #2f7de1; --c2: #f5b50a; --c3: #2fa84f;
  --ink: #26324f; --gold: #ffd23f;
  --cw: clamp(48px, 11.5vw, 82px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: #1d2b6b; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }

#app { height: 100dvh; display: flex; flex-direction: column; background: linear-gradient(180deg, #2b1f6b 0%, #1b6f9a 100%); color: #fff; }
#top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; min-height: 54px; }
#obj { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
#lvl { font-size: clamp(14px, 3.8vw, 20px); color: var(--gold); }
#objtxt { font-size: clamp(13px, 3.6vw, 18px); font-weight: 700; }
#topbtns { display: flex; gap: 6px; flex: none; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #fff; font-size: 22px; box-shadow: 0 3px 0 #0003; }

#stage { position: relative; flex: 1 1 0; min-height: 110px; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#chips { position: absolute; top: 4px; left: 4px; right: 4px; display: flex; flex-wrap: wrap; gap: 4px; pointer-events: none; }
.chip { background: #ffffffe6; color: var(--ink); border-radius: 14px; padding: 2px 8px; font-size: clamp(11px, 3vw, 14px); font-weight: 700; white-space: nowrap; }
.chip.active { background: var(--gold); }
#msg { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); max-width: 94%; width: max-content; background: #fff; color: var(--ink); border-radius: 18px; padding: 6px 14px; font-weight: 800; font-size: clamp(14px, 3.8vw, 20px); text-align: center; pointer-events: none; box-shadow: 0 3px 0 #0003; }
#msg.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-50%) translateX(-6px); } 75% { transform: translateX(-50%) translateX(6px); } }

#groups { flex: none; display: flex; gap: 8px; padding: 4px 6px; overflow-x: auto; overflow-y: hidden; min-height: 84px; align-items: stretch; background: #0003; -webkit-overflow-scrolling: touch; }
#groups .empty { align-self: center; font-size: 13px; opacity: .8; }
.group { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 64px; padding: 3px 8px; border-radius: 12px; border: 2px solid transparent; background: #ffffff26; color: #fff; font-size: 14px; font-weight: 800; text-align: left; }
.group.target { border-color: var(--gold); background: #ffd23f55; }
.group.swap { border-style: dashed; }
.group .cards { display: flex; --cw: 34px; padding-right: 2px; }
.group .cards .card + .card { margin-left: -7px; }
.group .cards.many .card + .card { margin-left: -11px; }
.group .card.joker .lbl { font-size: 12px; bottom: 3px; }
.card.flash { animation: flash .5s 2; z-index: 2; }
@keyframes flash { 50% { transform: scale(1.3); box-shadow: 0 0 0 4px var(--gold); } }

#side { flex: none; display: flex; flex-direction: column; }
#actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px; }
.act { min-height: 54px; border: 0; border-radius: 16px; background: #fff; color: var(--ink); font-size: 22px; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; box-shadow: 0 4px 0 #0003; padding: 2px; }
.act span { font-size: clamp(11px, 3vw, 14px); }
.act.go { background: #46d07a; }
.act:disabled { opacity: .4; box-shadow: none; }
.act.pulse:not(:disabled) { animation: pulse 1s infinite; }
#topcard { display: block; line-height: 0; }
#topcard .card { --cw: 24px; cursor: inherit; }
@keyframes pulse { 50% { transform: scale(1.07); box-shadow: 0 0 0 5px #ffd23f; } }

#handwrap { padding: 0 6px 6px; }
#tools { display: flex; gap: 6px; justify-content: center; padding-bottom: 4px; }
.tool { min-height: 48px; min-width: 56px; padding: 0 12px; border: 0; border-radius: 14px; background: #ffffff33; color: #fff; font-weight: 800; font-size: 16px; }
.tool.on { background: var(--gold); color: var(--ink); }
.tool:disabled { opacity: .4; }
#hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-height: 34dvh; overflow-y: auto; padding: 12px 2px 4px; }

/* cartes */
.card { display: block; width: var(--cw); height: calc(var(--cw) * 1.4); position: relative; flex: none; border: 0; padding: 0; border-radius: calc(var(--cw) * .14); color: #fff; font-weight: 800; box-shadow: 0 3px 0 #0004; transition: transform .12s; }
.c0 { background: var(--c0); } .c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); }
.joker { background: conic-gradient(from 30deg, #e5484d, #f5b50a, #2fa84f, #2f7de1, #e5484d); }
.pass { background: #26324f; }
.card .mid { position: absolute; inset: 16% 12%; background: #fff; border-radius: calc(var(--cw) * .22); display: grid; place-items: center; font-size: calc(var(--cw) * .56); line-height: 1; color: var(--ink); }
.c0 .mid { color: #a62a31; } .c1 .mid { color: #1b55a8; } .c2 .mid { color: #a06f00; } .c3 .mid { color: #1a7133; }
.card .mid.u { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 3px; }
.card .corner { position: absolute; top: 3%; left: 8%; font-size: calc(var(--cw) * .2); }
.card .pip { position: absolute; bottom: 3%; right: 8%; font-size: calc(var(--cw) * .2); }
.joker .mid, .pass .mid { inset: 10% 12% 32% 12%; color: #7a3fd1; }
.pass .mid { color: #26324f; }
.card .lbl { position: absolute; left: 0; right: 0; bottom: 6%; text-align: center; font-size: calc(var(--cw) * .15); text-shadow: 0 1px 2px #0008; }
.mini .corner, .mini .pip { display: none; }
.mini .mid { inset: 8%; font-size: calc(var(--cw) * .6); }
.mini.joker .mid, .mini.pass .mid { inset: 8% 8% 40% 8%; font-size: calc(var(--cw) * .4); }
.mini .lbl { font-size: calc(var(--cw) * .32); bottom: 4%; }
#hand .card:active { transform: scale(.96); }
.card.sel { transform: translateY(-12px); outline: 4px solid var(--gold); z-index: 2; }
.card.keep { box-shadow: 0 0 0 3px #46f0a8, 0 3px 0 #0004; }
.card.ready { animation: glow 1s infinite; }
.card.dim { opacity: .55; }
.card.suggest { outline: 3px dashed #fff; }
.card.new { animation: pop .35s; }
@keyframes glow { 50% { box-shadow: 0 0 0 6px #46f0a8, 0 0 18px 6px #46f0a8aa; } }
@keyframes pop { 0% { transform: scale(.5) translateY(-30px); } 100% { transform: none; } }

/* écrans */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #14204aaa; overflow-y: auto; padding: 8px; }
.panel { width: min(94vw, 520px); max-height: 100dvh; overflow-y: auto; background: #fff; color: var(--ink); border-radius: 26px; padding: 16px 18px; text-align: center; box-shadow: 0 8px 0 #0004; }
.panel h1 { margin: 0; font-size: clamp(30px, 8vw, 46px); color: #5b3fd1; }
.panel h2 { margin: 4px 0; font-size: clamp(22px, 6vw, 30px); }
.sub { margin: 2px 0 8px; font-weight: 700; }
.big-emoji { font-size: clamp(40px, 12vw, 64px); }
.opt { margin: 8px 0; }
.opt > span { display: block; font-weight: 800; margin-bottom: 4px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.seg button { min-width: 48px; min-height: 48px; padding: 0 14px; border-radius: 14px; border: 3px solid #d7dcf5; background: #fff; font-weight: 800; font-size: 17px; color: var(--ink); }
.seg button.on { border-color: #5b3fd1; background: #ece7ff; }
.btn { min-height: 56px; min-width: 150px; padding: 0 22px; border: 0; border-radius: 28px; background: #46d07a; color: #fff; font-size: 22px; font-weight: 800; box-shadow: 0 5px 0 #2b9a55; margin-top: 8px; }
.btn.alt { background: #8a7bd8; box-shadow: 0 5px 0 #5b3fd1; }
.row { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.rules { text-align: left; padding-left: 0; list-style: none; font-size: clamp(14px, 3.8vw, 17px); font-weight: 600; }
.rules li { margin: 6px 0; }
.plist { list-style: none; padding: 0; margin: 6px 0; text-align: left; font-weight: 700; }
.plist li { padding: 6px 10px; border-radius: 12px; background: #f1f3fb; margin: 4px 0; display: flex; justify-content: space-between; gap: 8px; }
.plist li.me { background: #ffefb3; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
#confetti i { position: absolute; top: -20px; width: 10px; height: 14px; animation: fall 2.6s linear forwards; }
@keyframes fall { to { transform: translateY(110dvh) rotate(720deg); } }

/* téléphone en paysage */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --cw: 48px; }
  #app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 46%); grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-areas: "top top" "stage side" "goal side" "groups side"; }
  #top { grid-area: top; min-height: 40px; padding: 2px 8px; flex-direction: row; }
  #obj { flex-direction: row; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  #lvl, #objtxt { font-size: 14px; }
  #chips { display: none; }
  #msg { font-size: 14px; padding: 4px 10px; }
  #stage { grid-area: stage; min-height: 0; min-width: 0; }
  #groups { grid-area: groups; min-width: 0; max-width: 100%; min-height: 84px; max-height: 96px; }
  #hero { display: none; }
  #goal { grid-area: goal; min-height: 54px; max-height: 60px; }
  #goal .gslots { --cw: 22px; }
  #goal .glegend { font-size: 10px; }
  #side { grid-area: side; min-height: 0; overflow-y: auto; }
  #actions { grid-template-columns: 1fr 1fr 1fr; gap: 4px; padding: 4px; }
  .act { flex-direction: row; gap: 6px; min-height: 48px; font-size: 20px; }
  .act span { font-size: 14px; }
  #tools { padding-bottom: 2px; }
  .tool { min-height: 48px; }
  #hand { max-height: none; overflow-y: visible; padding-top: 12px; gap: 4px; }
  .round { width: 48px; height: 48px; font-size: 18px; }
  .panel { padding: 8px 14px; }
  .opt { margin: 4px 0; }
  .btn { min-height: 48px; margin-top: 4px; }
  .big-emoji { font-size: 34px; }
  .panel h1 { font-size: 26px; }
  .sub { display: none; }
  .opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .opt > span { margin: 0; width: 120px; text-align: left; }
  .seg button { min-height: 48px; padding: 0 10px; font-size: 15px; }
}
/* téléphone en portrait étroit */
@media (max-width: 420px) and (orientation: portrait) {
  #hand { gap: 4px; }
}

#hero { margin: 0 0 6px; }
#hero img { display: block; width: 100%; max-height: 16vh; object-fit: cover; object-position: 50% 0; border-radius: 18px; }
@media (max-height: 740px) { #hero { display: none; } }

/* bandeau objectif */
#objtxt { opacity: .75; font-size: clamp(11px, 3vw, 14px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#goal { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 60px; max-height: 72px; padding: 3px 8px; margin: 0; border: 0; border-radius: 0; background: #ffffff1f; color: #fff; font: inherit; font-weight: 800; font-size: 14px; overflow-x: auto; overflow-y: hidden; }
#goal.laid { background: #46d07a55; }
#goal.done { background: #46d07a66; animation: glowbar 1s infinite; }
@keyframes glowbar { 50% { box-shadow: inset 0 0 0 3px #46f0a8, 0 0 14px #46f0a8aa; } }
#goal .gok { font-size: 26px; }
.goalgroups { display: flex; gap: 14px; align-items: center; justify-content: center; }
.ggroup { display: flex; flex-direction: column; align-items: center; gap: 1px; flex: none; }
.glegend { font-size: 11px; font-weight: 800; white-space: nowrap; color: #ffe9a8; }
.gslots { display: flex; --cw: 26px; }
.gslots .card + .card { margin-left: -5px; }
.gslots .ghost { opacity: .38; box-shadow: none; outline: 2px dashed #ffffffaa; outline-offset: -2px; }
.goalgroups.big { flex-direction: column; gap: 14px; }
.goalgroups.big .gslots { --cw: 40px; flex-wrap: wrap; justify-content: center; gap: 2px; }
.goalgroups.big .gslots .card + .card { margin-left: 0; }
.goalgroups.big .glegend { font-size: 16px; color: var(--ink); white-space: normal; text-align: center; }
#goalcard h2 { margin: 0 0 8px; }
#goalcard .row { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; }
#goalcard .btn { min-height: 64px; }
@media (max-height: 500px) and (orientation: landscape) {
  #goal { grid-area: goal; min-height: 52px; max-height: 58px; padding: 2px 6px; }
  #goal .gslots { --cw: 22px; }
  #goal .glegend { font-size: 10px; }
  .goalgroups.big .gslots { --cw: 30px; }
  .goalgroups.big { flex-direction: row; flex-wrap: wrap; }
}

/* bandeau objectif : grand tant que rien n'est posé, compact ensuite */
#goal { --gcw: 30px; max-height: none; min-height: 60px; }
#goal .gslots { --cw: var(--gcw); }
#goal .glegend { font-size: 12px; }
#goal.grow { --gcw: clamp(40px, min(7.5vh, 12vw), 56px); padding: 8px; align-items: center; }
#goal.grow .glegend { font-size: 14px; }
#goal.grow .goalgroups { width: 100%; flex-wrap: wrap; gap: 8px; }
#goal .ggroup { background: #ffffff33; border-radius: 14px; padding: 4px 8px 6px; gap: 3px; }
#goal.grow .ggroup { flex: 1 1 auto; }
#goal .gok { font-size: 34px; }
.gslots .ghost { opacity: .55; outline: 3px dashed #fff; outline-offset: -3px; }
.goalgroups.big .gslots .ghost { opacity: .8; }
.gslots .real { position: relative; outline: 2px solid #fff; }
.gslots .real::after { content: '✓'; position: absolute; top: -5px; right: -3px; z-index: 3; width: 16px; height: 16px; border-radius: 50%; background: #2fa84f; color: #fff; font-size: 11px; line-height: 16px; text-align: center; }
.gslots .joker.mini .mid { inset: 8% 8% 38% 8%; font-size: calc(var(--cw) * .55); }
.gslots .joker.mini .lbl { font-size: calc(var(--cw) * .25); }
.goalgroups.big .gslots { --cw: 56px; }
@media (max-height: 500px) and (orientation: landscape) {
  #goal { --gcw: 24px; min-height: 52px; max-height: none; }
  #goal.grow { --gcw: clamp(30px, 11vh, 40px); }
  #goal .glegend { font-size: 11px; }
  #goal.grow .glegend { font-size: 14px; }
  .goalgroups.big .gslots { --cw: 40px; }
}

/* avatars */
.av { display: inline-flex; align-items: center; justify-content: center; width: 1.5em; height: 1.5em; border-radius: 50%; overflow: hidden; vertical-align: middle; background: #ffffffcc; flex: none; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av.emo { font-size: 1em; }
.bigav { width: 1.4em; height: 1.4em; }
.chip .av, .glabel .av { width: 22px; height: 22px; }
.avatars { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.avbtn { width: 64px; height: 64px; padding: 0; border-radius: 50%; border: 4px solid #d7dcf5; background: #fff; font-size: 34px; overflow: hidden; }
.avbtn .av { width: 100%; height: 100%; background: none; }
.avbtn.on { border-color: #5b3fd1; box-shadow: 0 0 0 3px #ece7ff; }

/* accueil compact */
.seg .botsbtn { gap: 2px; }
.botsbtn .av { width: 26px; height: 26px; font-size: 20px; }
.botsbtn { display: inline-flex; align-items: center; justify-content: center; }
.avatars { flex-wrap: nowrap; gap: 4px; }
.avbtn { flex: 0 1 64px; width: auto; height: auto; aspect-ratio: 1; min-width: 48px; border-width: 3px; font-size: 28px; }
#btn-play { position: sticky; bottom: 0; z-index: 2; }
@media (max-width: 420px) and (orientation: portrait) {
  #setup .panel { padding: 8px 8px 0; }
  #setup .panel h1 { font-size: 28px; }
  #setup .sub { display: none; }
  #setup .opt { margin: 4px 0; }
  #setup .opt > span { font-size: 14px; margin-bottom: 2px; }
  #setup .seg { gap: 4px; }
  #setup .seg button { min-height: 48px; padding: 0 8px; font-size: 15px; }
  #btn-play { margin: 6px auto 8px; }
}

/* défausses personnelles */
#discards { display: flex; gap: 6px; padding: 4px 6px 0; overflow-x: auto; flex: none; }
.dis { flex: 0 0 auto; min-width: 64px; height: 56px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px; border: 3px solid #ffffff55; border-radius: 14px; background: #ffffff26; color: #fff; }
.dis:disabled { opacity: .6; }
.dis:not(:disabled) { border-color: var(--gold); background: #ffd23f33; }
.dis .dis-av .av { width: 22px; height: 22px; }
.dis .card { --cw: 28px; }
.dis-empty { width: 28px; height: 39px; border: 2px dashed #ffffff88; border-radius: 5px; }
.dis.pulse:not(:disabled) { animation: pulse 1s infinite; }

/* défausses : rangée pleine largeur au-dessus des boutons (grand écran et paysage) */
#discards { order: -1; grid-column: 1 / -1; }

/* portrait étroit : tout doit tenir, table >= 140 px */
@media (max-width: 500px) and (orientation: portrait) {
  #top { min-height: 44px; padding: 2px 8px; }
  #lvl { font-size: 14px; }
  #objtxt { display: none; }
  #stage { min-height: 140px; }
  #chips { flex-wrap: nowrap; overflow: hidden; gap: 3px; }
  .chip { font-size: 12px; padding: 2px 6px; flex: none; }
  .chip .cn { display: none; }
  #msg { font-size: 13px; padding: 3px 10px; bottom: 2px; }
  #goal { --gcw: 34px; min-height: 0; padding: 4px 6px; }
  #goal.grow { --gcw: 34px; padding: 4px 6px; }
  #goal.grow .goalgroups { flex-wrap: nowrap; gap: 6px; }
  #goal.grow .ggroup { flex: 1 1 0; min-width: 0; }
  .goalgroups { gap: 6px; }
  .ggroup { padding: 3px 6px 4px; }
  .glegend, #goal.grow .glegend { font-size: 12px; white-space: normal; text-align: center; line-height: 1.1; }
  #goal .gok { font-size: 24px; }
  #groups { min-height: 72px; padding: 3px 6px; }
  .group .cards { --cw: 30px; }
  .group { min-height: 64px; padding: 2px 6px; }
  #actions { display: flex; gap: 4px; padding: 4px 6px; align-items: stretch; }
  #discards { order: 0; flex: 1 1 0; min-width: 0; padding: 0; gap: 4px; align-items: stretch; }
  .act { flex: 0 0 56px; min-height: 52px; font-size: 20px; }
  .act span { font-size: 11px; }
  .dis { min-width: 56px; height: 52px; padding: 0 6px; gap: 3px; border-width: 2px; }
  .dis .card { --cw: 26px; }
  .dis-empty { width: 26px; height: 36px; }
  #handwrap { padding: 0 6px 4px; }
  #tools { padding-bottom: 2px; gap: 6px; }
  .tool { min-height: 48px; }
  #hand { flex-wrap: nowrap; gap: 0; max-height: none; overflow: visible; justify-content: center; padding: 12px 2px 2px; }
  #hand .card { --cw: var(--hcw, 40px); }
  #hand .card + .card { margin-left: calc(var(--hcw, 40px) * -0.16); }
}

/* paysage bas : les 4 défausses tiennent dans le panneau latéral */
@media (max-height: 500px) and (orientation: landscape) {
  #discards { gap: 4px; padding: 2px 4px 0; }
  .dis { flex: 1 1 0; min-width: 0; padding: 0 4px; gap: 2px; height: 50px; }
}

/* ===== paysage (toute fenêtre plus large que haute) : plateau à gauche, panneau à droite ===== */
@media (orientation: landscape) {
  #app { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 42%, 560px); grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-areas: "top top" "stage side" "goal side" "groups side"; }
  #top { grid-area: top; min-height: 44px; padding: 2px 8px; flex-direction: row; }
  #obj { flex-direction: row; align-items: baseline; gap: 8px; }
  #lvl { font-size: 15px; }
  #objtxt { display: none; }
  .round { width: 44px; height: 44px; font-size: 18px; }
  #stage { grid-area: stage; min-height: 0; min-width: 0; }
  #chips { display: flex; flex-wrap: nowrap; overflow: hidden; gap: 3px; }
  .chip { font-size: 12px; padding: 2px 6px; flex: none; }
  .chip .cn { display: none; }
  #msg { font-size: clamp(12px, 2.2vh, 15px); padding: 3px 10px; bottom: 3px; max-width: 80%; }
  #goal { grid-area: goal; --gcw: clamp(24px, 4.4vh, 38px); min-height: 0; max-height: none; padding: 4px 6px; }
  #goal.grow { --gcw: clamp(26px, 5vh, 40px); padding: 4px 6px; }
  #goal.grow .goalgroups { flex-wrap: nowrap; gap: 6px; }
  #goal.grow .ggroup { flex: 1 1 0; min-width: 0; }
  .goalgroups { gap: 6px; }
  .ggroup { padding: 3px 6px 4px; }
  .glegend, #goal.grow .glegend { font-size: clamp(10px, 1.8vh, 13px); white-space: normal; text-align: center; line-height: 1.1; }
  #goal .gok { font-size: 24px; }
  #groups { grid-area: groups; min-width: 0; max-width: 100%; min-height: 0; max-height: none; padding: 3px 6px; }
  .group { min-height: 64px; padding: 2px 6px; }
  .group .cards { --cw: clamp(28px, 5.2vh, 36px); }
  #side { grid-area: side; min-height: 0; overflow-y: auto; }
  #actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; padding: 4px; }
  #discards { order: -1; grid-column: 1 / -1; gap: 4px; padding: 2px 0 0; }
  .dis { flex: 1 1 0; min-width: 0; padding: 0 4px; gap: 2px; height: clamp(50px, 7vh, 62px); }
  .act { flex-direction: row; gap: 6px; min-height: clamp(48px, 7vh, 60px); font-size: 20px; }
  .act span { font-size: 14px; }
  #handwrap { padding: 0 6px 4px; }
  #tools { padding-bottom: 2px; }
  .tool { min-height: 48px; }
  #hand { flex-wrap: wrap; gap: 4px 0; max-height: none; overflow: visible; justify-content: center; padding: 14px 2px 2px; }
  #hand .card { --cw: var(--hcw, 48px); }
  #hand .card:not(:first-child) { margin-left: calc(var(--hcw, 48px) * -0.16); }
  #hero { display: none; }
}
@media (orientation: landscape) and (min-width: 1000px) { .chip .cn { display: inline; } }
/* portrait étroit : bandeau <= 80 px, boutons du header plus petits */
@media (max-width: 500px) and (orientation: portrait) {
  .round { width: 44px; height: 44px; font-size: 18px; }
  #goal { max-height: 80px; overflow: hidden; }
  .glegend, #goal.grow .glegend { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #msg { max-width: 80%; }
}

/* jeu à plusieurs sur le même appareil */
.seats { display: grid; gap: 4px; margin: 4px 0; }
.seat { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.seat .avbtn { flex: none; width: 52px; height: 52px; min-width: 52px; aspect-ratio: auto; }
.seat input { min-width: 0; height: 52px; padding: 0 12px; font: inherit; font-weight: 700; border: 3px solid #d7dcf5; border-radius: 16px; color: var(--ink); }
.seat .kind { min-width: 112px; min-height: 52px; padding: 0 10px; border: 3px solid #d7dcf5; border-radius: 16px; background: #fff; font: inherit; font-weight: 800; color: var(--ink); }
.seat .kind.human { border-color: #5b3fd1; background: #ece7ff; }
.seat .kind:disabled { opacity: 1; }
#gate { z-index: 40; background: #14204a; }
#gate .big-emoji .av { width: 1.6em; height: 1.6em; }
.gate-name { font-size: clamp(30px, 9vw, 44px); font-weight: 900; color: #5b3fd1; margin: 4px 0 10px; overflow-wrap: anywhere; }
#btn-ready { min-height: 72px; min-width: 220px; font-size: 24px; }
#app.cloak #handwrap, #app.cloak #goal, #app.cloak #discards { visibility: hidden; }
@media (max-width: 420px) and (orientation: portrait) {
  .seat .kind { min-width: 96px; font-size: 14px; padding: 0 6px; }
}
@media (max-height: 420px) and (orientation: landscape) {
  .seat, .seats { gap: 3px; }
  .seat { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .seat .avbtn { width: 48px; height: 48px; min-width: 48px; }
  .seat input, .seat .kind { height: 48px; min-height: 48px; }
}

/* messages : pastille translucide en haut du plateau, sous les pastilles des joueurs (2026-10-18) */
#msg { top: calc(var(--chips-h, 0px) + 6px); bottom: auto !important; max-width: min(90vw, calc(100% - 12px)) !important; background: rgba(20, 24, 40, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: #fff; font-weight: 700; font-size: clamp(13px, 3.6vw, 15px) !important; padding: 6px 14px !important; border-radius: 999px; box-shadow: 0 2px 8px #0003; z-index: 5; transition: opacity .18s; }
#msg.off { opacity: 0; }

/* barre d'actions en deux lignes, partout (portrait, paysage, panneau latéral) :
   ligne 1 = Pioche + 4 défausses ; ligne 2 = Poser, Jeter, tri, aide. Jamais de défilement horizontal. */
#actions { display: flex; flex-wrap: nowrap; align-items: stretch; gap: 4px; padding: 4px 6px; }
#actions > .act { flex: 0 0 64px; min-width: 0; min-height: 52px; padding: 0 2px; font-size: 20px; }
#actions > .act span { font-size: 11px; white-space: nowrap; }
#discards { order: 0; grid-column: auto; flex: 1 1 0; min-width: 0; padding: 0; gap: 4px; overflow: visible; align-items: stretch; }
.dis { flex: 1 1 0; min-width: 0; height: 52px; padding: 0 2px; gap: 2px; border-width: 2px; }
.dis .dis-av .av { width: 20px; height: 20px; }
.dis .card { --cw: 26px; }
.dis-empty { width: 26px; height: 36px; }
#tools { display: flex; flex-wrap: nowrap; justify-content: center; align-items: stretch; gap: 4px; padding: 0 0 2px; }
#tools > * { flex: 0 1 auto; min-width: 0; min-height: 48px; }
#tools .tool { min-width: 44px; padding: 0 8px; font-size: 15px; white-space: nowrap; }
#tools .act { flex-direction: row; gap: 4px; padding: 0 12px; border-radius: 14px; font-size: 18px; }
#tools .act span { font-size: 14px; white-space: nowrap; }
@media (orientation: landscape) {
  #actions > .act, .dis { min-height: clamp(50px, 7vh, 62px); height: clamp(50px, 7vh, 62px); }
  #actions > .act { height: auto; }
}
@media (max-width: 380px) {
  #tools { gap: 3px; }
  #tools .act { padding: 0 8px; }
  #tools .tool { padding: 0 6px; min-width: 40px; font-size: 14px; }
}

/* paysage bas (ex. 667x375) : panneau latéral étroit, tout sur 2 lignes sans débordement */
@media (orientation: landscape) and (max-height: 500px) {
  #actions { gap: 3px; padding: 4px; }
  #actions > .act { flex: 0 0 64px; padding: 0 1px; }
  #actions > .act span { font-size: 11px; line-height: 1.05; white-space: normal; text-align: center; overflow-wrap: anywhere; }
  #tools { gap: 3px; }
  #tools .tool { min-width: 40px; padding: 0 5px; font-size: 13px; }
  #tools .act { flex-direction: column; gap: 0; padding: 0 6px; font-size: 16px; }
  #tools .act span { font-size: 12px; line-height: 1; }
  #hand { flex-wrap: nowrap; gap: 0; justify-content: center; }
  #hand .card:not(:first-child) { margin-left: calc(var(--hcw, 30px) * -0.16); }
}
