* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #123a2c; font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif; color: #2b2d42; -webkit-user-select: none; user-select: none; }
.hidden { display: none !important; }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 30%, #2f8a63 0%, #1b5a42 55%, #0f3427 100%); }
#hud { flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
#score { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; color: #fff; }
.team { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 2px 10px; border-radius: 14px; background: rgba(255,255,255,.16); line-height: 1.05; }
.team small { font-size: 12px; font-weight: 700; opacity: .85; }
.team b { font-size: clamp(20px, 5.5vmin, 28px); }
.team.us { background: rgba(255,210,63,.3); }
.goal { font-size: 13px; font-weight: 700; opacity: .8; }
#contract { flex: none; display: flex; align-items: center; gap: 4px; background: #fff; border-radius: 18px; padding: 3px 10px; font-weight: 800; font-size: 20px; min-height: 40px; box-shadow: 0 2px 6px rgba(0,0,0,.3); white-space: nowrap; }
.suit.red { color: #d6283a; } .suit.black { color: #23263d; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #fff; font-size: 24px; cursor: pointer; flex: none; box-shadow: 0 3px 0 rgba(0,0,0,.25); display: grid; place-items: center; padding: 0; }
.round:active { transform: translateY(2px); box-shadow: none; }

#stage { position: relative; flex: 1 1 auto; min-height: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
@media (orientation: portrait) { #c { top: 36px; height: calc(100% - 36px); } } /* bande réservée à la pastille de messages */
#bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 6; }
.bubble { position: absolute; transform: translate(-50%, -50%); background: #fff; border-radius: 18px; padding: 5px 12px; font-weight: 900; font-size: clamp(15px, 4vmin, 22px); box-shadow: 0 3px 10px rgba(0,0,0,.35); white-space: nowrap; animation: pop .25s; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.4); } }
#toast { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); background: rgba(20,24,40,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: clamp(.85rem, 3.4vmin, .95rem); line-height: 1.25; box-shadow: 0 2px 8px rgba(0,0,0,.25); opacity: 0; transition: opacity .18s; pointer-events: none; max-width: 90vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; z-index: 7; }
#toast.show { opacity: 1; }
#live { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); background: rgba(255,255,255,.9); border-radius: 16px; padding: 3px 12px; font-weight: 800; font-size: 14px; pointer-events: none; white-space: nowrap; z-index: 4; }

#side { flex: none; height: clamp(210px, 42dvh, 330px); display: flex; flex-direction: column; background: rgba(8, 36, 26, .55); border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); min-height: 0; }
#status { flex: none; text-align: center; color: #fff; font-weight: 800; font-size: clamp(15px, 4vmin, 21px); padding: 6px 10px 2px; line-height: 1.15; min-height: 30px; }
#advice { flex: none; text-align: center; color: #3b2a00; background: #ffe58a; font-weight: 800; font-size: 15px; margin: 2px 10px; padding: 3px 10px; border-radius: 14px; }
#bid { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 4px 8px; }
#hand { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 10px 6px 8px; overflow: hidden; }
.hrow { display: flex; justify-content: center; gap: 4px; }
.hrow + .hrow { margin-top: calc(var(--card-w, 70px) * -1.5 + var(--row-top, 60px)); }

.btn { min-height: 52px; padding: 8px 20px; border-radius: 28px; border: 0; background: #ffd23f; color: #2b2d42; font: 800 clamp(17px, 4.4vmin, 24px) "Trebuchet MS", Arial, sans-serif; cursor: pointer; box-shadow: 0 4px 0 #c99200; }
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn:disabled { opacity: .45; }
.btn.ghost { background: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.btn.big { min-height: 64px; padding: 10px 34px; font-size: clamp(22px, 6vmin, 32px); background: #4cd07d; box-shadow: 0 5px 0 #249455; color: #fff; }
.btn.bid { min-height: 56px; }
.btn.bid .suit { font-size: 1.3em; line-height: 1; vertical-align: -2px; background: #fff; border-radius: 50%; padding: 0 5px; }
.btn.advised { outline: 4px solid #fff36b; outline-offset: 1px; }

.card { flex: none; padding: 0; border: 0; background: none; width: var(--card-w, 70px); aspect-ratio: 2 / 3; border-radius: 8px; cursor: pointer; filter: drop-shadow(0 3px 3px rgba(0,0,0,.35)); transition: transform .15s, opacity .2s; }
.card img { width: 100%; height: 100%; display: block; pointer-events: none; }
.card.playable { transform: translateY(-8px); filter: drop-shadow(0 0 7px #fff36b) drop-shadow(0 0 3px #fff36b); }
.card.dim { filter: brightness(.62) saturate(.5) drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.card.advised { transform: translateY(-14px); filter: drop-shadow(0 0 9px #ffd23f) drop-shadow(0 0 4px #ffd23f); }
.card.shake { animation: shake .35s; }
.card.gone { visibility: hidden; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(10, 40, 30, .93); z-index: 30; overflow-y: auto; padding: 8px; }
.hero { display: block; width: 100%; max-height: 20dvh; object-fit: cover; border-radius: 22px; margin: 0 0 8px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.hero.hidden { display: none; }
#home { place-items: start center; }
#home .panel { max-height: calc(100dvh - 16px); overflow-y: auto; padding-bottom: 18px; }
#home .row { margin-top: 12px; }
#home .row .btn, #home .row .round { min-height: 64px; }
#home .row .round { min-width: 64px; }
#pass { background: #123a2c; z-index: 35; }
#pass .btn { min-height: 64px; }
#deal { z-index: 32; background: rgba(10, 40, 30, .8); }
#seat-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.seat { display: flex; align-items: center; gap: 6px; }
.seat .role { flex: none; width: 62px; font-size: 11px; font-weight: 800; opacity: .7; text-align: left; }
.seat input { flex: 1 1 auto; min-width: 0; height: 52px; border: 4px solid #d8d6ef; border-radius: 16px; padding: 0 10px; font: 700 18px "Trebuchet MS", Arial, sans-serif; color: #2b2d42; background: #fff; }
.seat .chips { flex: none; flex-wrap: nowrap; gap: 4px; }
.seat .chip { min-width: 56px; min-height: 52px; padding: 2px 5px; border-width: 3px; }
.seat .chip b { font-size: 13px; }
.seat .chip:disabled { opacity: .5; cursor: default; }
#end { background: rgba(10, 40, 30, .82); }
.panel { background: #fff; border-radius: 30px; padding: 18px 22px; text-align: center; width: min(520px, 100%); max-height: 100dvh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.panel h1 { margin: 0; font-size: clamp(38px, 11vmin, 64px); color: #1f9d6b; letter-spacing: 1px; text-shadow: 3px 3px 0 #ffd23f; }
.panel h2 { margin: 4px 0 8px; font-size: clamp(26px, 7vmin, 40px); }
.panel h3 { margin: 8px 0 4px; font-size: 16px; opacity: .75; }
.sub { margin: 2px 0 8px; font-weight: 700; font-size: clamp(15px, 4vmin, 20px); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { min-width: 80px; min-height: 56px; padding: 6px 12px; border-radius: 18px; border: 4px solid #d8d6ef; background: #f6f5ff; cursor: pointer; font: 700 15px "Trebuchet MS", Arial, sans-serif; color: #2b2d42; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.chip b { font-size: 20px; }
.chip small { font-size: 13px; opacity: .8; }
.chip.sel { border-color: #4cd07d; background: #e5fbee; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.big-emoji { font-size: clamp(50px, 14vmin, 90px); line-height: 1; }
#deal-table { width: 100%; border-collapse: collapse; margin: 4px 0; font-weight: 800; font-size: clamp(16px, 4.2vmin, 21px); }
#deal-table th { font-size: 14px; opacity: .7; padding: 3px 6px; }
#deal-table td { padding: 5px 8px; border-top: 1px solid #ecebf7; }
#deal-table td:first-child { text-align: left; font-weight: 700; opacity: .85; }
#deal-table tr.sum td { background: #fff6cf; border-top: 2px solid #ffd23f; }

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
#confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-height: 500px) and (orientation: landscape) {
  .hero { display: none; }
  .seat input { height: 48px; }
  .seat .chip { min-height: 48px; }
  .seat .role { width: 70px; font-size: 12px; }
  #home { place-items: center; padding: 4px; }
  #home .panel { width: min(700px, 100%); max-height: 100dvh; padding: 6px 12px; display: grid; grid-template-columns: 1fr 1.35fr; column-gap: 12px; align-content: start; }
  #home h1 { grid-column: 1; grid-row: 1; }
  #home .sub { grid-column: 1; grid-row: 2; }
  #grp-palier { grid-column: 1; grid-row: 3; }
  #grp-diff { grid-column: 1; grid-row: 4; }
  #grp-places { grid-column: 2; grid-row: 1 / 5; }
  #home .row { grid-column: 1 / 3; grid-row: 5; margin-top: 4px; }
  #home .group h3 { margin: 2px 0; }
  #seat-list { gap: 4px; }
  #home .seat input, #home .seat .chip { height: 48px; min-height: 48px; }
  #app { display: grid; grid-template-columns: 1fr minmax(0, 48vw); grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
  #hud { grid-column: 1 / 3; padding: 3px 8px; gap: 6px; }
  .team { flex-direction: row; gap: 6px; padding: 1px 10px; }
  #side { grid-column: 2; grid-row: 2; height: auto; border-radius: 22px 0 0 0; min-height: 0; overflow: hidden; }
  #stage { grid-column: 1; grid-row: 2; }
  #status { padding: 4px 8px 0; font-size: 15px; min-height: 22px; }
  #advice { font-size: 13px; padding: 1px 8px; }
  #bid { gap: 6px; padding: 2px 6px; }
  .btn { min-height: 48px; padding: 6px 14px; font-size: 16px; }
  .btn.bid { min-height: 50px; }
  #hand { padding: 8px 4px 4px; }
  .panel { padding: 8px 14px; border-radius: 22px; width: min(640px, 100%); }
  .panel h1 { font-size: 34px; }
  .panel h2 { font-size: 26px; margin: 2px 0 4px; }
  .panel h3 { margin: 3px 0 2px; font-size: 13px; }
  .sub { margin: 0 0 3px; font-size: 14px; }
  .chip { min-height: 48px; min-width: 70px; padding: 3px 8px; border-width: 3px; }
  .chip b { font-size: 17px; }
  .chip small { font-size: 11px; }
  .row { margin-top: 6px; }
  .btn.big { min-height: 52px; font-size: 22px; }
  .big-emoji { font-size: 40px; }
  #deal-table td { padding: 2px 8px; }
}
