:root {
  color-scheme: dark;
  --bg: #17142a;
  --surface: #242039;
  --surface-2: #2c2643;
  --line: #ffffff18;
  --text: #fcfaff;
  --muted: #b7b0ca;
  --lime: #dbfa77;
  --lime-dark: #92a945;
  --lime-ink: #273210;
  --purple: #c7a8ff;
  --purple-ink: #302041;
  --danger: #ff8a8a;
  font-family: ui-rounded, 'Trebuchet MS', 'Segoe UI', Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100svh;
  color: var(--text);
  background:
    radial-gradient(ellipse at 15% 0, #38265280, transparent 55%),
    radial-gradient(ellipse at 95% 80%, #233b4260, transparent 50%),
    var(--bg);
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, summary:focus-visible { outline: 3px solid white; outline-offset: 4px; }
img { max-width: 100%; }

/* Logo du studio au lancement */
.splash { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 32px; background: radial-gradient(ellipse 70% 38% at 50% 50%, #3a3560, #241f3d 55%, var(--bg) 100%); }
/* Pas de filtre sur le logo : animé, il coûterait trop cher aux téléphones modestes. La lueur vient du fond. */
.splash img { width: min(74vw, 420px); height: auto; opacity: 0; will-change: transform, opacity; }
/* « go » est posé par le script à la première image réellement affichée : dans l'application,
   le décompte ne démarre donc pas pendant que l'écran de démarrage d'Android masque la page. */
.splash.go { animation: splash-out .45s ease 1.6s forwards; }
.splash.go img { animation: splash-logo .7s cubic-bezier(.2, 1.3, .4, 1) both; }
.splash.skip { animation: splash-out .2s ease forwards; }
@keyframes splash-logo { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }

/* En-tête */
.top { max-width: 880px; margin: auto; padding: 22px 24px; display: flex; justify-content: space-between; align-items: center; }
.brand { font-size: 34px; letter-spacing: -2px; font-weight: 1000; transform: rotate(-4deg); }
.brand span { color: var(--lime); }
.mode-badge { font-size: 13px; font-weight: bold; background: #ffffff08; border: 1px solid var(--line); padding: 8px 13px; border-radius: 30px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.icon-button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: #ffffff08; font-size: 17px; line-height: 1; display: grid; place-items: center; transition: background .15s, opacity .15s; }
.icon-button:hover { background: #ffffff16; }
.icon-button.off { opacity: .4; text-decoration: line-through; }
.mode-badge::before { content: ''; display: inline-block; width: 7px; height: 7px; background: var(--lime); border-radius: 50%; margin-right: 8px; vertical-align: 1px; }

main { max-width: 800px; margin: auto; padding: 0 24px 32px; }
.banner { margin: 0 0 16px; padding: 12px 16px; border-radius: 14px; border: 1px solid #ffc77566; background: #ffc77515; color: #ffe5b0; font-size: 14px; }

/* Accueil */
.lobby { max-width: 560px; margin: 30px auto; text-align: center; padding: 34px 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; }
.lobby-hands { display: flex; justify-content: center; align-items: center; gap: 18px; margin-bottom: 18px; }
.lobby-hands img { width: 72px; height: 72px; image-rendering: pixelated; filter: drop-shadow(0 6px 0 #0d0a1a); }
.lobby-hands img.left { transform: scaleX(-1); }
.lobby-hands img.foe { transform: rotate(180deg); }
.lobby-hands span { font-weight: 1000; color: var(--purple); font-size: 18px; letter-spacing: 1px; }
.lobby h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: -.5px; }
.lobby p { font-size: 16px; line-height: 1.6; color: var(--muted); margin: 0 0 22px; }
.lobby-actions .action, .waiting .action { display: block; width: 100%; margin: 12px 0; }
.spinner { width: 32px; height: 32px; border: 3px solid #ffffff20; border-top-color: var(--lime); border-radius: 50%; animation: spin 1s linear infinite; margin: 8px auto 18px; }
summary { font-size: 14px; color: var(--muted); cursor: pointer; }

/* Statistiques locales */
.stats { display: flex; justify-content: center; gap: 10px; margin: 6px 0 4px; flex-wrap: wrap; }
.stat { min-width: 76px; padding: 10px 8px; border-radius: 16px; background: #ffffff08; border: 1px solid var(--line); }
.stat strong { display: block; font-size: 22px; line-height: 1.1; }
.stat span { display: block; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.stat.highlight { border-color: #dbfa7788; background: #dbfa7712; }
.stat.highlight strong { color: var(--lime); }
.result-stats { font-size: 14px; color: var(--muted); margin: -10px 0 22px; }
.link-button { background: none; border: 0; padding: 0; color: var(--purple); text-decoration: underline; font-size: inherit; cursor: pointer; }

/* Bouton discret et fiche « How to play » */
.action.ghost { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 14px; background: transparent; border: 1px dashed #ffffff30; color: var(--muted); font-weight: bold; }
.action.ghost:hover:not(:disabled) { color: var(--text); border-color: #ffffff55; background: #ffffff08; }
.help-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--purple); color: var(--purple-ink); font-size: 15px; font-weight: 1000; }
.sheet { width: min(520px, calc(100% - 24px)); padding: 26px 22px 20px; text-align: left; overflow-y: auto; overscroll-behavior: contain; }
.sheet:focus { outline: none; }
/* La fiche d'aide garde la même hauteur quel que soit l'onglet : changer d'onglet ne la redimensionne pas. */
#help-dialog { height: min(760px, calc(100svh - 40px)); }
#help-dialog[open] { display: flex; flex-direction: column; }
#help-dialog > * { flex-shrink: 0; }
#help-dialog .sheet-close { margin-top: auto; }
.sheet h2 { text-align: center; }
.sheet .help-lead { text-align: center; margin: 8px 0 18px; font-size: 15px; }
.sheet-grip { display: none; width: 44px; height: 5px; border-radius: 3px; background: #ffffff33; margin: -8px auto 14px; }
.help-steps { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.help-steps li { display: grid; grid-template-columns: 196px 1fr; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 18px; background: #ffffff08; border: 1px solid var(--line); counter-increment: step; }
.help-steps h3 { margin: 0 0 3px; font-size: 16px; color: var(--text); }
.help-steps h3::before { content: counter(step) '. '; color: var(--lime); }
.help-steps p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.help-visual { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 54px; position: relative; width: fit-content; margin: 0 auto; }
.help-visual img { width: 40px; height: 40px; image-rendering: pixelated; filter: drop-shadow(0 3px 0 #0d0a1a88); }
.help-visual img.left { transform: scaleX(-1); }
.help-visual img.out { opacity: .35; filter: grayscale(.8); }
.help-visual span { color: var(--muted); font-weight: bold; font-size: 15px; }
.help-visual .ko { position: absolute; right: -30px; top: -6px; padding: 3px 7px; border-radius: 9px; background: var(--lime); color: var(--lime-ink); font-size: 12px; transform: rotate(9deg); }
.clock-chip { padding: 8px 14px; border-radius: 20px; background: #ff8a8a22; border: 1px solid #ff8a8a88; color: var(--danger); font-size: 18px; }
.sheet-close { position: sticky; bottom: 0; display: block; width: 100%; z-index: 1; background: #3a3352; box-shadow: 0 -14px 18px 6px #28213c, 0 46px 0 24px #28213c; }
/* Fond opaque : la liste défile dessous sans transparaître. */
.action.sheet-close.outline { background: #3a3352; }
.action.sheet-close.outline:hover:not(:disabled) { background: #453d60; }
.sheet-close.primary { background: var(--lime); box-shadow: 0 4px 0 var(--lime-dark), 0 -14px 18px 6px #28213c, 0 46px 0 24px #28213c; }
/* Onglets de la fiche d'aide */
.tabs { display: flex; gap: 6px; margin: 14px 0 4px; padding: 5px; border-radius: 16px; background: #00000033; border: 1px solid var(--line); }
.tabs [role="tab"] { flex: 1; min-height: 40px; padding: 8px 12px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-weight: bold; font-size: 15px; transition: background .15s, color .15s; }
.tabs [role="tab"][aria-selected="true"] { background: var(--lime); color: var(--lime-ink); box-shadow: 0 3px 0 var(--lime-dark); }

/* Fins de partie : trois cartes, une couleur par issue */
.outcomes { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.outcomes li { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 12px 14px; border-radius: 18px; background: #ffffff08; border: 1px solid var(--line); text-align: left; }
.outcomes b { grid-row: 1 / 3; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; font-size: 22px; }
.outcomes h4 { margin: 0; font-size: 15px; }
.outcomes p { margin: 2px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.outcomes .win { border-color: #dbfa7755; }
.outcomes .win b { background: #dbfa7722; }
.outcomes .win h4 { color: var(--lime); }
.outcomes .lose { border-color: #ff8f8f55; }
.outcomes .lose b { background: #ff8f8f1f; }
.outcomes .lose h4 { color: #ffa4a4; }
.outcomes .draw { border-color: #c7a8ff55; }
.outcomes .draw b { background: #c7a8ff22; }
.outcomes .draw h4 { color: var(--purple); }

.help-foot { text-align: center; font-size: 12px !important; margin: 14px 0 0 !important; }
.help-foot a { color: var(--purple); }

/* Plateau */
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 3px 14px; flex-wrap: wrap; }
h1 { font-size: 20px; letter-spacing: -.5px; margin: 0; }
.game-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; font-weight: bold; }
.presence { color: var(--lime); }
.presence.offline { color: var(--muted); }
.clock { padding: 6px 11px; border-radius: 20px; background: #ffffff10; border: 1px solid var(--line); letter-spacing: .5px; min-width: 110px; text-align: center; }
.clock.urgent { background: #ff8a8a22; border-color: #ff8a8a88; color: var(--danger); animation: blink 1s steps(2) infinite; }

.table { border-radius: 28px; border: 1px solid #ffffff1c; background: linear-gradient(145deg, var(--surface-2), #211e33); box-shadow: 0 20px 70px #0b071d66; overflow: hidden; position: relative; }
.player { padding: 20px 32px 24px; }
.player.me { background: linear-gradient(0deg, #c7ef7309, transparent); }
/* À qui le tour : camp actif encadré et étiquette en pastille ; mes mains grisées = coup en cours d'envoi. */
.player { transition: box-shadow .25s, background .25s; }
.player.foe { border-radius: 27px 27px 0 0; }
.player.me { border-radius: 0 0 27px 27px; }
.player.me.turn { box-shadow: inset 0 0 0 2px #dbfa77cc; background: linear-gradient(0deg, #c7ef7326, transparent 75%); }
.player.foe.turn { box-shadow: inset 0 0 0 2px #b79cf0cc; background: linear-gradient(180deg, #b79cf026, transparent 75%); }
.player.turn .sub-label { display: inline-flex; align-items: center; justify-content: center; height: 20px; min-height: 0; line-height: 1; margin-top: 3px; padding: 0 10px; border-radius: 20px; font-weight: bold; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; }
.player.me.turn .sub-label { background: var(--lime); color: var(--lime-ink); }
.player.foe.turn .sub-label { background: var(--purple); color: var(--purple-ink); animation: blink 1.4s ease-in-out infinite; }
/* Hauteur réservée : la pastille n'entraîne aucun saut du plateau. */
.player .sub-label { min-height: 23px; }
.player.me .hand { transition: filter .25s, opacity .25s; }
.player.me.locked .hand { filter: grayscale(.9) brightness(.8); opacity: .55; }
.player-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.identity { display: flex; gap: 10px; align-items: center; }
.identity strong { display: block; font-size: 16px; }
.sub-label { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; min-height: 1em; }
.avatar { display: grid; place-items: center; flex-shrink: 0; width: 38px; height: 38px; background: var(--purple); color: var(--purple-ink); border-radius: 13px; font-size: 11px; font-weight: 1000; transform: rotate(-6deg); }
.me .avatar { background: var(--lime); color: var(--lime-ink); transform: rotate(5deg); }
.lives { display: flex; gap: 5px; }
.lives i { width: 10px; height: 10px; border-radius: 50%; background: #ffffff12; border: 1px solid #ffffff20; }
.me .lives .alive { background: var(--lime); }
.foe .lives .alive { background: var(--purple); }

.hands { display: flex; justify-content: center; gap: 24px; }
.foe .hands { flex-direction: row-reverse; } /* l'adversaire nous fait face */
.hand {
  position: relative; width: 180px; min-width: 0; border: 2px solid #ffffff14; background: #17142650; border-radius: 23px;
  padding: 12px 15px 10px; box-shadow: 0 6px 0 #141124; transition: transform .18s, border-color .18s, background .18s; isolation: isolate;
  user-select: none; -webkit-user-select: none;
}
.me .hand:not(:disabled) { touch-action: none; cursor: grab; }
.me .hand:not(:disabled):active { cursor: grabbing; }
.me .hand.dead:not(:disabled) { cursor: pointer; }
.me .hand.dead:not(:disabled):hover { transform: none; border-color: #dbfa7799; background: #dbfa770a; }
.hand-top { display: block; font-size: 11px; font-weight: bold; letter-spacing: 1.4px; color: var(--muted); }
.hand img { display: block; width: 106px; height: 106px; object-fit: contain; image-rendering: pixelated; margin: 2px auto 0; filter: drop-shadow(0 7px 0 #120b2228); pointer-events: none; }
/* Vue de dessus. Le sprite de base sert de main droite (pouce à droite) ; la main gauche est son miroir.
   L'adversaire est en face : ses mains sont les miennes tournées de 180°. */
.me .hand.left img { transform: scaleX(-1); }
.foe .hand.left img { transform: rotate(180deg) scaleX(-1); }
.foe .hand.right img { transform: rotate(180deg); }
.hand-bottom { display: flex; justify-content: center; align-items: baseline; gap: 6px; }
.hand-bottom strong { font-size: 26px; line-height: 1.15; }
.hand-bottom > span { font-size: 12px; color: var(--muted); }
.me .hand:not(:disabled):hover { transform: translateY(-5px) rotate(-2deg); background: #dbfa7710; border-color: #dbfa7777; }
.me .hand.right:not(:disabled):hover { transform: translateY(-5px) rotate(2deg); }
.hand.selected { border-color: var(--lime); background: #dbfa7717; transform: translateY(-5px); box-shadow: 0 6px 0 #8ca434, 0 0 30px #dbfa7710; }
.hand.selected .hand-top { color: var(--lime); }
.hand.target { border-color: var(--purple); background: #c7a8ff0c; }
.hand.target:hover { transform: translateY(3px); background: #c7a8ff25; box-shadow: 0 3px 0 #141124; }
.hand.transfer-target { border-color: #dbfa7799; border-style: dashed; }
.hand.drop-ready { outline: 4px solid white; outline-offset: 5px; transform: scale(1.05) !important; }
.hand.dead { box-shadow: none; border-style: dashed; background: transparent; }
.hand.dead img { opacity: .3; filter: grayscale(.8); }
.hand.dead .hand-bottom { opacity: .55; }
.preview { position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%); white-space: nowrap; background: var(--purple); color: var(--purple-ink); padding: 6px 13px; border-radius: 20px; font-size: 14px; font-weight: bold; box-shadow: 0 3px 0 #120e23; z-index: 2; }
.preview.ko { background: var(--lime); color: var(--lime-ink); }
.pop { position: absolute; right: -9px; top: 36px; padding: 7px 10px; background: var(--lime); color: var(--lime-ink); border-radius: 12px; font-weight: 1000; font-size: 22px; transform: rotate(9deg); pointer-events: none; animation: pop .65s both; z-index: 3; }
.hand.hit { animation: hit .45s ease-out; }
.drag-ghost { position: fixed; width: 90px; height: 90px; object-fit: contain; image-rendering: pixelated; transform: translate(-50%, -80%) rotate(-10deg); pointer-events: none; z-index: 1000; filter: drop-shadow(0 7px 8px #0008); }
.drag-ghost.left { transform: translate(-50%, -80%) rotate(-10deg) scaleX(-1); }
body.dragging { cursor: grabbing; }

.duel-line { display: flex; gap: 16px; align-items: center; padding: 8px 32px; min-height: 47px; }
.duel-line > span { height: 1px; flex: 1; background: #ffffff13; }
.recap { font-size: 12px; font-weight: bold; letter-spacing: .8px; color: var(--muted); text-align: center; }
.recap b { color: var(--text); }
.recap.fresh { color: var(--purple); animation: appear .25s ease-out; }

/* Répartition */
#transfer-dialog { padding: 28px 22px 20px; }
#transfer-dialog:focus { outline: none; }
#transfer-dialog p { margin: 10px 0 18px; font-size: 15px; }
.transfer-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 8px; }
.split-choice { display: flex; align-items: center; gap: 8px; background: #dbfa770d; border: 1px solid #dbfa7744; border-radius: 18px; padding: 12px 16px; box-shadow: 0 4px 0 #100e1d; transition: transform .15s, background .15s; }
.split-choice:hover { background: #dbfa7722; border-color: var(--lime); transform: translateY(-2px); }
.split-choice > span:not(.plus) { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.split-choice img { width: 58px; height: 58px; image-rendering: pixelated; }
.split-choice img.left { transform: scaleX(-1); }
.split-choice b { font-size: 18px; }
.plus { color: var(--muted); font-size: 14px; }

/* Consigne et actions */
.instruction { display: flex; gap: 12px; align-items: center; padding: 16px 22px; min-height: 62px; background: var(--lime); color: var(--lime-ink); font-size: 16px; font-weight: bold; border-radius: 17px; margin: 16px 0 0; box-shadow: 0 4px 0 var(--lime-dark); }
.instruction b { display: grid; place-items: center; font-size: 24px; min-width: 28px; }
body.thinking .instruction { background: var(--purple); color: var(--purple-ink); box-shadow: 0 4px 0 #8671aa; }
body.thinking #status-icon { animation: think 1s ease-in-out infinite; }
/* Coup en cours d'envoi : sablier remplacé par un indicateur qui tourne, plateau figé. */
body.sending .instruction b { font-size: 0; width: 22px; height: 22px; min-width: 22px; border-radius: 50%; border: 3px solid #0000002e; border-top-color: currentColor; animation: spin .8s linear infinite; }
body.sending .table { pointer-events: none; }
body.won .table { border-color: #dbfa7777; }
body.won #status-icon { animation: celebrate 1s ease-in-out 3; }
.controls { display: flex; justify-content: center; align-items: stretch; gap: 10px; padding: 16px 0 0; }
.action { border: 1px solid #ffffff20; border-radius: 14px; min-height: 46px; padding: 11px 23px; background: #ffffff08; font-size: 15px; font-weight: bold; transition: background .15s, transform .15s; }
.action:hover:not(:disabled) { background: #ffffff16; transform: translateY(-2px); }
.action:disabled { opacity: .35; }
.action.secondary { border-color: transparent; background: transparent; color: var(--muted); font-weight: normal; }
/* Action secondaire mais bien visible : annuler, revenir en arrière. */
.action.outline { background: #ffffff0d; border: 1.5px solid #ffffff55; color: var(--text); font-weight: bold; }
.action.outline:hover:not(:disabled) { background: #ffffff1c; border-color: #ffffff88; }
/* Historique : bouton avec compteur, puis fiche avec un coup par ligne. */
.action.history { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 180px; height: 48px; min-height: 0; padding: 0 16px; line-height: 1; background: #ffffff0a; border: 1.5px solid #ffffff40; color: var(--text); }
.action.history b { min-width: 24px; padding: 2px 7px; border-radius: 12px; background: var(--purple); color: var(--purple-ink); font-size: 13px; line-height: 1.4; }
.history-icon { width: 16px; height: 12px; border-top: 2px solid currentColor; border-bottom: 2px solid currentColor; position: relative; opacity: .85; }
.history-icon::after { content: ''; position: absolute; left: 0; right: 0; top: 3px; border-top: 2px solid currentColor; }
.history { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.history li { display: grid; grid-template-columns: 30px 38px 1fr; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 14px; background: #ffffff08; border: 1px solid var(--line); }
.history li:first-child { border-color: #ffffff38; background: #ffffff12; }
.history .num { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.history .kind { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; font-size: 17px; background: var(--purple); color: var(--purple-ink); }
.history li.mine .kind { background: var(--lime); color: var(--lime-ink); }
.history .who { display: block; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.history .what { display: block; font-size: 15px; color: var(--text); line-height: 1.35; }
.history .what b { color: var(--lime); }
.history li:not(.mine) .what b { color: var(--purple); }
.history-empty { text-align: center; color: var(--muted); font-size: 15px; padding: 18px 0 22px; }

/* Action à conséquence (abandon) : visible, mais jamais le bouton mis en avant. */
.action.danger-outline { background: #ff8a8a12; border: 1.5px solid #ff8a8a99; color: #ffc9c9; font-weight: bold; }
.action.danger-outline:hover:not(:disabled) { background: #ff8a8a26; color: #fff; }

/* Quitter ou abandonner : lisible sans concurrencer le plateau. */
.action.leave { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 180px; height: 48px; min-height: 0; padding: 0 16px; line-height: 1; background: #ffffff0a; border: 1.5px solid #ffffff40; color: var(--text); }
.action.leave.danger { border-color: #ff8a8a99; color: #ffc9c9; background: #ff8a8a12; }
.action.leave.danger::before { content: '⚑'; font-size: 15px; line-height: 1; }
.action.leave.danger:hover:not(:disabled) { background: #ff8a8a26; color: #fff; }

/* Annuler la recherche : on doit le repérer d'un coup d'œil. */
.action.cancel { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 54px; font-size: 17px; font-weight: bold; background: #ff8a8a1f; border: 2px solid #ff8a8a; color: #ffd0d0; box-shadow: 0 4px 0 #7a3b4a; }
.action.cancel span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #ff8a8a; color: #3a1220; font-size: 14px; }
.action.cancel:hover:not(:disabled) { background: #ff8a8a33; color: #fff; }
.waiting-note { font-size: 14px !important; margin: 18px 0 0 !important; }
.action.primary { background: var(--lime); color: var(--lime-ink); border: 0; box-shadow: 0 4px 0 var(--lime-dark); }
.action.primary:hover:not(:disabled) { background: #e6ff8f; }
footer { text-align: center; padding: 0 20px 24px; color: #aaa1bd; font-size: 12px; }

/* Boîtes de dialogue */
dialog { width: min(420px, calc(100% - 32px)); max-height: calc(100svh - 40px); padding: 32px 25px; border: 1px solid #dbfa7766; border-radius: 25px; background: #28213c; color: var(--text); text-align: center; box-shadow: 0 24px 90px #0009; }
dialog::backdrop { background: #100b20bb; backdrop-filter: blur(5px); }
dialog h2 { font-size: 27px; line-height: 1.2; margin: 0; }
dialog p { font-size: 16px; color: var(--muted); line-height: 1.6; margin: 16px 0 24px; }
dialog .action { display: block; width: 100%; margin-top: 12px; }
dialog[open] { animation: appear .2s ease-out; }
.result-symbol { font-size: 48px; margin-bottom: 12px; }

@keyframes hit { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-7px) rotate(-3deg); } 65% { transform: translateX(7px) rotate(3deg); } }
@keyframes pop { 0% { opacity: 0; scale: .4; } 40% { opacity: 1; scale: 1.2; } 100% { opacity: 1; scale: 1; } }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes think { 50% { opacity: .3; } }
@keyframes celebrate { 50% { transform: rotate(25deg) scale(1.3); } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .5; } }


/* Application native : zones sûres (encoche, barre de gestes) et pas de sélection de texte. */
body.native { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
body.native .top { padding-top: 12px; }

@media (max-width: 520px) {
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 26px 26px 0 0; border-bottom: 0; max-height: 88svh; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  #help-dialog { height: 88svh; }
  .sheet[open] { animation: sheet-up .25s ease-out; }
  .sheet-grip { display: block; }
  .help-steps li { grid-template-columns: 1fr; gap: 8px; text-align: center; padding: 12px; }
  .top { padding: 10px 16px; }
  .mode-badge { display: none; }
  .brand { font-size: 26px; }
  .icon-button { width: 34px; height: 34px; font-size: 15px; }
  main { padding: 0 12px 16px; }
  .lobby { margin-top: 12px; padding: 26px 18px; }
  .lobby h1 { font-size: 24px; }
  /* Cinq tuiles : trois résultats en haut, les deux séries en dessous, sans tuile orpheline. */
  .stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 16px; }
  .stat { min-width: 0; grid-column: span 2; }
  .stat:nth-child(n+4) { grid-column: span 3; }

  /* Écran de partie : en-tête, plateau, consigne et bouton visibles d'un seul coup d'œil. */
  .game-head { margin: 0 2px 8px; flex-wrap: nowrap; }
  .game-head h1 { font-size: 16px; white-space: nowrap; }
  .game-meta { gap: 8px; font-size: 11px; }
  .clock { min-width: 0; padding: 5px 10px; }
  .table { border-radius: 20px; }
  .player.foe { border-radius: 19px 19px 0 0; }
  .player.me { border-radius: 0 0 19px 19px; }
  .player { padding: 10px 12px 12px; }
  .player-label { margin-bottom: 8px; }
  .identity { gap: 8px; }
  .identity strong { font-size: 14px; }
  .sub-label { font-size: 11px; margin-top: 1px; }
  .avatar { width: 30px; height: 30px; border-radius: 10px; font-size: 10px; }
  .hands { gap: 12px; }
  .hand { width: 50%; max-width: 200px; padding: 7px 6px 6px; border-radius: 17px; border-width: 2px; box-shadow: 0 4px 0 #141124; }
  .hand-top { font-size: 10px; letter-spacing: 1.2px; }
  /* La taille des mains suit la hauteur libre : ~515 px sont pris par le reste de l'écran. */
  .hand img { width: auto; height: clamp(50px, calc((100svh - 516px) / 2), min(168px, 36vw)); aspect-ratio: 1; margin-top: 0; }
  .hand-bottom strong { font-size: 20px; }
  .hand-bottom > span { font-size: 11px; }
  .preview { bottom: -12px; padding: 4px 10px; font-size: 12px; }
  .pop { top: 22px; right: -4px; font-size: 17px; padding: 5px 8px; }
  .duel-line { padding: 4px 12px; gap: 8px; min-height: 30px; }
  .recap { font-size: 11px; letter-spacing: .2px; }
  .instruction { font-size: 14px; padding: 10px 14px; min-height: 50px; margin-top: 10px; border-radius: 15px; gap: 10px; }
  .instruction b { font-size: 20px; min-width: 22px; }
  .controls { padding-top: 12px; }
  .action.history, .action.leave { flex: 1; min-width: 0; height: 46px; }
    .action { padding: 11px 16px; }
  footer { padding-bottom: 14px; }

  /* La page occupe toute la hauteur : accueil centré, plateau étiré, boutons d'action près du pouce. */
  body { display: flex; flex-direction: column; }
  .top { width: 100%; }
  main { flex: 1; width: 100%; display: flex; flex-direction: column; }
  .lobby { margin: auto; width: 100%; }
  .game { flex: 1; display: flex; flex-direction: column; }
  .table { flex: 1; display: flex; flex-direction: column; }
  .table > .player { flex: 1; display: flex; flex-direction: column; justify-content: center; }
}
/* Pendant une partie sur petit écran, le pied de page n'apporte rien : on gagne sa hauteur. */
@media (max-width: 520px) { body:has(#game:not([hidden])) footer { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
