/* Plein écran 3D ; interface en panneaux « verre de nuage » ancrés aux bords :
   menus en colonne à gauche, salon à droite, HUD aux coins, cartes centrées.
   Un seul monde visuel (journée ensoleillée), donc un seul thème clair assumé. */
:root {
  --sky: #2b86cf;
  --sky-deep: #1b5f96;
  --sky-pale: #d9eefb;
  --ink: #1e3850;
  --ink-soft: #4d6780;
  --cloud: rgba(255, 255, 255, 0.82);
  --cloud-lite: rgba(255, 255, 255, 0.74);
  --cloud-solid: #ffffff;
  --stone: #f1e9d6;
  --stone-dark: #d9cdb2;
  --sage: #3f8f45;
  --coral: #d8513a;
  --gold: #f2be45;
  --gold-deep: #b98512;
  --turq: #2fb3ae;
  --lavender: #8a74d6;
  --shadow: 0 14px 40px -14px rgba(30, 56, 80, 0.42);
  --font-display: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Nunito', ui-rounded, 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

html, body { height: 100%; margin: 0; overflow: hidden; background: #d6ecf8; color: var(--ink); }
body { font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#ui {
  position: absolute; inset: 0; pointer-events: none;
  font-size: calc(16px * var(--ui-scale, 1));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(14px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  line-height: 1.4;
}
#ui *, #ui *::before, #ui *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.screen { position: absolute; inset: 0; padding: inherit; pointer-events: none; }

/* ---------------------------------------------------------------- surfaces */
.panel {
  pointer-events: auto;
  background: var(--cloud);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  border-radius: 1.5em;
  box-shadow: var(--shadow);
  padding: 1.25em;
}
.panel-lite {
  pointer-events: auto;
  background: var(--cloud-lite);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 1em;
  box-shadow: 0 8px 24px -14px rgba(30, 56, 80, 0.45);
  padding: 0.55em 0.9em;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; color: var(--ink); }
h2 { font-size: 1.75em; font-weight: 700; line-height: 1.1; }
p { margin: 0; }
.eyebrow, .section-title, .field-label {
  font-family: var(--font-body); font-weight: 900; font-size: 0.74em;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-soft);
}
.section-title { margin: 0.2em 0 0; }
.note { font-size: 0.86em; color: var(--ink-soft); font-weight: 700; }
.note-warn { color: var(--coral); }
.tag { display: inline-block; font-size: 0.72em; font-weight: 800; padding: 0.1em 0.6em; border-radius: 999px; background: rgba(255, 255, 255, 0.7); color: var(--sky-deep); vertical-align: middle; }

/* ---------------------------------------------------------------- boutons */
.btn {
  pointer-events: auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6em;
  min-height: 3em; padding: 0 1.15em;
  font: 800 1em/1.1 var(--font-body); color: var(--ink);
  background: var(--cloud-solid);
  border: 2px solid rgba(30, 56, 80, 0.08);
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(30, 56, 80, 0.14);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn svg { width: 1.25em; height: 1.25em; flex: none; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 rgba(30, 56, 80, 0.14); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(30, 56, 80, 0.14); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: 0 3px 0 rgba(30, 56, 80, 0.1); }
.btn-primary { background: var(--sky); color: #fff; border-color: transparent; box-shadow: 0 4px 0 var(--sky-deep); }
.btn-primary:hover { background: #3593dc; box-shadow: 0 6px 0 var(--sky-deep); }
.btn-primary:active { box-shadow: 0 1px 0 var(--sky-deep); }
.btn-ghost { background: rgba(255, 255, 255, 0.45); box-shadow: none; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.85); box-shadow: none; }
.btn-small { min-height: 2.4em; font-size: 0.9em; padding: 0 0.95em; }
.btn-big { min-height: 4em; justify-content: flex-start; border-radius: 1.2em; padding: 0.55em 1.1em; text-align: left; width: 100%; }
.btn-big .btn-text { display: flex; flex-direction: column; gap: 0.15em; }
.btn-big strong { font-family: var(--font-display); font-weight: 600; font-size: 1.22em; }
.btn-big small { font-weight: 700; font-size: 0.82em; opacity: 0.82; }
.btn-icon { display: grid; place-items: center; width: 2.4em; height: 2.4em; border-radius: 0.8em; background: rgba(255, 255, 255, 0.22); }
.btn:not(.btn-primary) .btn-icon { background: var(--sky-pale); color: var(--sky-deep); }
.icon-btn {
  pointer-events: auto; display: grid; place-items: center; width: 2.25em; height: 2.25em; padding: 0;
  border-radius: 50%; border: none; background: rgba(30, 56, 80, 0.07); color: var(--ink); cursor: pointer;
}
.icon-btn svg { width: 1.1em; height: 1.1em; }
.icon-btn:hover { background: rgba(30, 56, 80, 0.14); }
#ui :focus-visible { outline: 3px solid var(--sky-deep); outline-offset: 2px; }

.text-input {
  width: 100%; height: 3em; padding: 0 0.9em;
  font: 800 1.05em var(--font-body); color: var(--ink);
  background: #fff; border: 2px solid var(--stone-dark); border-radius: 0.9em;
}
.text-input:focus { border-color: var(--sky); outline: none; }
kbd {
  display: inline-grid; place-items: center; min-width: 2em; height: 2em; padding: 0 0.5em;
  font: 900 0.82em var(--font-body); color: var(--ink);
  background: #fff; border: 1.5px solid var(--stone-dark); border-bottom-width: 3.5px; border-radius: 0.5em;
}

/* ---------------------------------------------------------------- menu */
.screen-menu { display: flex; align-items: center; }
.menu-wrap { display: flex; flex-direction: column; gap: 1.1em; width: min(27em, 100%); max-height: 100%; overflow: auto; padding: 0.4em; }
.brand { display: grid; gap: 0.35em; color: #fff; }
.brand-mark { display: grid; place-items: center; width: 3em; height: 3em; border-radius: 1em; background: rgba(255, 255, 255, 0.9); color: var(--sky); box-shadow: var(--shadow); }
.brand-mark svg { width: 1.9em; height: 1.9em; }
.brand h1 {
  color: #fff; font-weight: 700; font-size: clamp(2.6em, 6vw, 3.9em); line-height: 0.98; letter-spacing: -0.01em;
  text-shadow: 0 3px 0 rgba(27, 95, 150, 0.45), 0 14px 40px rgba(27, 95, 150, 0.45);
}
.brand p { font-weight: 800; font-size: 1.08em; text-shadow: 0 2px 10px rgba(27, 95, 150, 0.55); }
.menu-panel { display: flex; flex-direction: column; gap: 0.75em; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 0.6em; }
.code-input { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; }
.menu-secondary { display: flex; gap: 0.6em; flex-wrap: wrap; }
.menu-secondary .btn { flex: 1 1 8em; }
.menu-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.5em; flex-wrap: wrap; }
.rupies { display: inline-flex; align-items: center; gap: 0.35em; font-weight: 800; color: var(--ink); }
.rupies svg { width: 1.15em; height: 1.15em; color: var(--gold-deep); }
.menu-foot .rupies { background: #fff6da; padding: 0.35em 0.9em; border-radius: 999px; }

/* ---------------------------------------------------------------- salon */
.lobby-panel {
  position: absolute; top: max(14px, env(safe-area-inset-top, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  width: min(23em, calc(100% - 32px)); max-height: calc(100% - 28px); overflow: auto;
  display: flex; flex-direction: column; gap: 0.8em;
}
.lobby-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6em; flex-wrap: wrap; }
.lobby-head > div { display: grid; }
.room-code { font-family: var(--font-display); font-weight: 700; font-size: 2.1em; letter-spacing: 0.14em; color: var(--sky-deep); line-height: 1; }
.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4em; }
.player-row {
  display: grid; grid-template-columns: 2.1em minmax(0, 1fr) auto auto; align-items: center; gap: 0.55em;
  padding: 0.35em 0.45em; border-radius: 0.9em; background: rgba(255, 255, 255, 0.6);
}
.player-row.is-off { opacity: 0.55; }
.pname { font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pname em { font-style: normal; color: var(--ink-soft); font-weight: 700; }
.swatch {
  display: inline-grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: 50%; flex: none;
  background: var(--c); color: #fff; font-size: 0.95em; font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}
.badges { display: flex; gap: 0.3em; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  display: inline-flex; align-items: center; gap: 0.25em; padding: 0.15em 0.55em; border-radius: 999px;
  font-size: 0.74em; font-weight: 900; background: var(--stone); color: var(--ink-soft); white-space: nowrap;
}
.badge svg { width: 1.1em; height: 1.1em; }
.badge-host { background: #fff3cf; color: var(--gold-deep); }
.badge-ok { background: #e3f3df; color: var(--sage); }
.badge-off { background: #fde4de; color: var(--coral); }
.add-bot { align-self: flex-start; }
.rounds-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; }
.segmented { display: inline-flex; background: rgba(30, 56, 80, 0.07); border-radius: 999px; padding: 0.2em; gap: 0.2em; }
.seg {
  pointer-events: auto; min-width: 2.6em; height: 2.2em; border: none; border-radius: 999px; background: transparent;
  font: 900 0.95em var(--font-body); color: var(--ink-soft); cursor: pointer; font-variant-numeric: tabular-nums;
}
.seg.on { background: #fff; color: var(--sky-deep); box-shadow: 0 2px 0 rgba(30, 56, 80, 0.12); }
.seg:disabled { cursor: default; }
.start-btn { width: 100%; }
.lobby-hint { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); bottom: max(14px, env(safe-area-inset-bottom, 0px)); max-width: min(28em, calc(100% - 32px)); font-weight: 700; font-size: 0.9em; }

/* ---------------------------------------------------------------- présentation */
.screen-intro { display: grid; place-items: center; }
.intro-card { width: min(39em, 100%); display: flex; flex-direction: column; gap: 0.85em; padding: 1.5em; animation: card-in 0.45s cubic-bezier(.2, .9, .3, 1.2); }
.intro-title { display: flex; gap: 1em; align-items: center; }
.intro-title h2 { font-size: 2.3em; }
.mg-icon { display: grid; place-items: center; width: 4em; height: 4em; border-radius: 1.2em; color: #fff; flex: none; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12); }
.mg-icon svg { width: 58%; height: 58%; }
.mg-icon.small { width: 2.1em; height: 2.1em; border-radius: 0.7em; }
.cat-parcours { background: var(--turq); }
.cat-skill { background: var(--gold); color: #5a3f00; }
.cat-strategie { background: #e46f8e; }
.cat-logique { background: var(--lavender); }
.cat-chance { background: var(--sky); }
.chips { display: flex; flex-wrap: wrap; gap: 0.35em; margin-top: 0.45em; }
.chip { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.2em 0.7em; border-radius: 999px; background: var(--ink); color: #fff; font-size: 0.8em; font-weight: 800; }
.chip svg { width: 1em; height: 1em; }
.chip-soft { background: var(--stone); color: var(--ink); }
.objective { font-size: 1.3em; font-weight: 900; line-height: 1.25; color: var(--ink); }
.rules { margin: 0; padding-left: 1.2em; display: grid; gap: 0.2em; font-weight: 700; color: var(--ink-soft); }
.team-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6em; font-weight: 800; }
.team-chip { display: inline-flex; padding: 0.25em 0.8em; border-radius: 999px; background: var(--c); color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 1.1em; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25); }
.controls-row { display: flex; flex-wrap: wrap; gap: 0.9em; font-weight: 800; font-size: 0.92em; }
.ctrl { display: inline-flex; align-items: center; gap: 0.45em; }
.countdown { min-height: 1.1em; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 4.2em; line-height: 1; color: var(--sky); }
.countdown.pop { animation: pop 0.5s ease-out; }
.countdown:empty { display: none; }

/* ---------------------------------------------------------------- HUD */
.hud-top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 0.8em; }
.hud-objective { justify-self: start; display: flex; gap: 0.6em; align-items: center; font-weight: 800; max-width: 22em; }
.hud-timer {
  pointer-events: none; justify-self: center; min-width: 5.2em; text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: 2.1em; line-height: 1;
  padding: 0.25em 0.6em; border-radius: 999px; background: rgba(255, 255, 255, 0.86); color: var(--ink);
  box-shadow: var(--shadow); font-variant-numeric: tabular-nums;
}
.hud-timer.urgent { color: var(--coral); animation: pulse 1s ease-in-out infinite; }
.hud-score { justify-self: end; display: grid; justify-items: end; min-width: 8em; }
.score-label { font-size: 0.72em; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.score-value { font-family: var(--font-display); font-weight: 700; font-size: 1.9em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.score-value.bump { animation: pop 0.35s ease-out; }
.score-sub { font-size: 0.82em; font-weight: 800; color: var(--ink-soft); }
.hud-bars { display: grid; gap: 0.35em; width: min(26em, 100%); margin: 0.6em auto 0; }
.tbar { display: grid; grid-template-columns: minmax(6em, auto) 1fr 2.4em; align-items: center; gap: 0.5em; padding: 0.3em 0.7em; border-radius: 999px; background: var(--cloud-lite); font-weight: 800; font-size: 0.9em; }
.tbar.mine { outline: 2.5px solid var(--c); }
.tbar.coop { grid-template-columns: auto 1fr; }
.tbar-track { height: 0.65em; border-radius: 999px; background: rgba(30, 56, 80, 0.1); overflow: hidden; }
.tbar-fill { display: block; height: 100%; width: var(--w); background: var(--c); border-radius: inherit; transition: width 0.3s ease; }
.tbar b { text-align: right; font-variant-numeric: tabular-nums; }
.hud-hint {
  position: absolute; left: 50%; bottom: max(5.2em, calc(env(safe-area-inset-bottom, 0px) + 4.8em)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.6em; padding: 0.5em 1.1em; border-radius: 999px; background: rgba(255, 255, 255, 0.9);
  font-family: var(--font-display); font-weight: 600; font-size: 1.35em; box-shadow: var(--shadow); white-space: nowrap; max-width: calc(100% - 32px);
}
.hud-hint img { width: 1.9em; height: 1.9em; }
.hud-hint.urgent { color: var(--coral); }
.hud-help { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(14px, env(safe-area-inset-bottom, 0px)); font-size: 0.78em; font-weight: 800; color: #fff; text-shadow: 0 1px 4px rgba(27, 95, 150, 0.8); }
.prompt {
  position: absolute; left: 50%; bottom: max(1.2em, calc(env(safe-area-inset-bottom, 0px) + 1em)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.6em; padding: 0.5em 1em 0.5em 0.6em; border-radius: 999px;
  background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); font-weight: 900;
}

/* ---------------------------------------------------------------- messages */
.toasts { z-index: 40; position: absolute; top: 6.2em; left: 50%; transform: translateX(-50%); display: grid; gap: 0.4em; justify-items: center; width: min(30em, calc(100% - 32px)); }
.toast { padding: 0.5em 1em; border-radius: 999px; background: rgba(255, 255, 255, 0.92); font-weight: 800; box-shadow: var(--shadow); animation: toast-in 0.25s ease-out; transition: opacity 0.4s, transform 0.4s; text-align: center; }
.toast.good { color: var(--sage); }
.toast.warn { color: var(--coral); }
.toast.out { opacity: 0; transform: translateY(-6px); }
.banner {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2.6em, 7vw, 4.6em); color: #fff; white-space: nowrap;
  text-shadow: 0 4px 0 var(--sky-deep), 0 12px 40px rgba(27, 95, 150, 0.55);
}
.banner.show { animation: banner 0.5s cubic-bezier(.2, .9, .3, 1.3); }
.banner.good { text-shadow: 0 4px 0 var(--gold-deep), 0 12px 40px rgba(185, 133, 18, 0.5); }
.banner.end { text-shadow: 0 4px 0 #a33b28, 0 12px 40px rgba(160, 60, 40, 0.45); }
.popups { position: absolute; inset: 0; overflow: hidden; }
.popup { position: absolute; left: 0; top: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.6em; color: #fff; text-shadow: 0 2px 0 var(--sky-deep), 0 4px 14px rgba(27, 95, 150, 0.5); white-space: nowrap; will-change: transform; }
.popup.gold { color: #fff4cc; text-shadow: 0 2px 0 var(--gold-deep), 0 4px 14px rgba(185, 133, 18, 0.5); }
.popup.good { color: #effbea; text-shadow: 0 2px 0 var(--sage), 0 4px 14px rgba(63, 143, 69, 0.5); }

/* ---------------------------------------------------------------- résultats */
.screen-results { display: grid; place-items: center; }
.results-card { width: min(56em, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 1em; animation: card-in 0.4s ease-out; }
.results-head { display: flex; gap: 1em; align-items: center; }
.headline { font-weight: 900; color: var(--sky-deep); margin-top: 0.2em; }
.results-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.4em; }
.res-list, .std-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4em; }
.res-row { display: grid; grid-template-columns: 2em minmax(0, 1fr) auto 3.4em; align-items: center; gap: 0.6em; padding: 0.45em 0.6em; border-radius: 0.9em; background: rgba(255, 255, 255, 0.6); font-weight: 800; animation: row-in 0.35s ease-out both; }
.res-row:nth-child(2) { animation-delay: 0.05s; } .res-row:nth-child(3) { animation-delay: 0.1s; } .res-row:nth-child(4) { animation-delay: 0.15s; } .res-row:nth-child(5) { animation-delay: 0.2s; } .res-row:nth-child(6) { animation-delay: 0.25s; }
.res-row.me, .std-row.me { background: #e2f1fc; }
.res-row.is-off { opacity: 0.55; }
.res-name { display: flex; align-items: center; gap: 0.5em; min-width: 0; flex-wrap: wrap; }
.res-name small { width: 100%; color: var(--ink-soft); font-weight: 700; }
.team-row .res-name b { color: var(--ink); font-family: var(--font-display); font-weight: 600; font-size: 1.1em; }
.team-row { box-shadow: inset 0 0 0 2px var(--c); }
.members { display: flex; flex-wrap: wrap; gap: 0.4em; width: 100%; font-size: 0.9em; }
.member { display: inline-flex; align-items: center; gap: 0.3em; }
.member .swatch { width: 1.5em; height: 1.5em; font-size: 0.8em; }
.member.me { text-decoration: underline; text-underline-offset: 3px; }
.res-val { color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.res-pts { text-align: right; font-family: var(--font-display); font-weight: 700; color: var(--sage); font-size: 1.15em; font-variant-numeric: tabular-nums; }
.rank { display: grid; place-items: center; width: 1.8em; height: 1.8em; border-radius: 50%; background: var(--stone); font-weight: 900; font-size: 0.95em; font-variant-numeric: tabular-nums; }
.rank-1 { background: var(--gold); color: #5a3f00; }
.rank-2 { background: #d5dee7; }
.rank-3 { background: #e9b48d; color: #5c2f12; }
.standings { display: grid; gap: 0.5em; align-content: start; }
.std-row { display: grid; grid-template-columns: 1.8em 1.9em minmax(0, 7em) 1fr 2.6em; align-items: center; gap: 0.5em; padding: 0.3em 0.5em; border-radius: 0.8em; font-weight: 800; }
.std-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.std-track { height: 0.7em; border-radius: 999px; background: rgba(30, 56, 80, 0.1); overflow: hidden; }
.std-fill { display: block; height: 100%; width: var(--to); background: var(--c); border-radius: inherit; animation: grow 1s 0.3s ease-out both; }
.std-row b { text-align: right; font-variant-numeric: tabular-nums; }
.results-foot { text-align: center; font-weight: 800; color: var(--ink-soft); }

/* ---------------------------------------------------------------- podium */
.screen-final { display: flex; align-items: center; }
.final-card { width: min(31em, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 0.9em; animation: card-in 0.5s ease-out; }
.winner { display: flex; gap: 0.5em; align-items: center; font-size: 1.7em; }
.winner svg { width: 1.4em; height: 1.4em; color: var(--gold-deep); flex: none; }
.table-wrap { overflow-x: auto; }
.final-table { width: 100%; border-collapse: collapse; font-weight: 800; font-size: 0.95em; }
.final-table th { text-align: left; font-size: 0.72em; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); padding: 0 0.4em 0.3em; }
.final-table td { padding: 0.35em 0.4em; border-top: 1px solid rgba(30, 56, 80, 0.08); }
.final-table tr.me td { background: #e2f1fc; }
.final-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.final-table .best { color: var(--ink-soft); font-size: 0.9em; }
.fin-name { display: flex; align-items: center; gap: 0.5em; }
.rupies-earned { display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; padding: 0.6em 0.9em; border-radius: 1em; background: #fff6da; font-weight: 800; }
.rupies-earned svg { width: 1.4em; height: 1.4em; color: var(--gold-deep); }
.rupies-earned b { font-family: var(--font-display); font-weight: 700; font-size: 1.25em; color: var(--gold-deep); }
.final-actions { display: flex; flex-wrap: wrap; gap: 0.6em; }
.seed { font-size: 0.75em; color: var(--ink-soft); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- fenêtres */
.modal-layer {
  z-index: 20; position: absolute; inset: 0; pointer-events: auto; display: grid; place-items: center;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px;
  background: rgba(30, 56, 80, 0.22);
}
.modal { width: min(36em, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 0.85em; background: rgba(255, 255, 255, 0.94); animation: card-in 0.3s ease-out; }
.modal > *, .menu-panel > *, .lobby-panel > *, .intro-card > *, .final-card > *, .results-card > * { flex-shrink: 0; }
.modal-customize { justify-self: start; }
@media (max-width: 760px) { .modal-customize { justify-self: center; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6em; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.6em; flex-wrap: wrap; margin-top: 0.3em; }
.stack { display: grid; gap: 0.6em; }
.tabs { display: flex; gap: 0.3em; background: rgba(30, 56, 80, 0.07); padding: 0.25em; border-radius: 999px; align-self: flex-start; flex-wrap: wrap; }
.tab { pointer-events: auto; border: none; background: transparent; padding: 0.5em 1em; border-radius: 999px; font: 900 0.9em var(--font-body); color: var(--ink-soft); cursor: pointer; }
.tab.on { background: #fff; color: var(--sky-deep); box-shadow: 0 2px 0 rgba(30, 56, 80, 0.1); }
.settings-body { display: grid; gap: 0.8em; }
.toggle { display: flex; align-items: center; gap: 0.7em; font-weight: 800; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track { position: relative; width: 2.8em; height: 1.6em; border-radius: 999px; background: var(--stone-dark); flex: none; transition: background 0.15s; }
.toggle .track::after { content: ''; position: absolute; top: 0.2em; left: 0.2em; width: 1.2em; height: 1.2em; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.15s; }
.toggle input:checked + .track { background: var(--sky); }
.toggle input:checked + .track::after { transform: translateX(1.2em); }
.toggle input:focus-visible + .track { outline: 3px solid var(--sky-deep); outline-offset: 2px; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 0.3em 0.8em; font-weight: 800; }
.slider input, .slider select { grid-column: 1 / -1; width: 100%; accent-color: var(--sky); }
.slider select { height: 2.6em; border-radius: 0.8em; border: 2px solid var(--stone-dark); font: 800 0.95em var(--font-body); padding: 0 0.6em; background: #fff; color: var(--ink); }
.slider output { font-variant-numeric: tabular-nums; color: var(--sky-deep); }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(12em, 1fr)); gap: 0.4em 1em; }
.key-row { display: flex; justify-content: space-between; align-items: center; gap: 0.6em; font-weight: 800; }
.keycap { pointer-events: auto; min-width: 4.4em; height: 2.3em; border-radius: 0.6em; border: 1.5px solid var(--stone-dark); border-bottom-width: 4px; background: #fff; font: 900 0.9em var(--font-body); color: var(--ink); cursor: pointer; }
.keycap.listening { border-color: var(--sky); color: var(--sky-deep); }
.color-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5em; }
.color-pick {
  pointer-events: auto; display: grid; justify-items: center; gap: 0.3em; padding: 0.5em 0.2em; border-radius: 1em;
  border: 2px solid transparent; background: rgba(255, 255, 255, 0.7); font: 800 0.8em var(--font-body); color: var(--ink); cursor: pointer;
}
.color-pick::before { content: ''; width: 2.2em; height: 2.2em; border-radius: 50%; background: var(--c); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15); }
.color-pick.on { border-color: var(--sky); background: #fff; }
.hat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8em, 1fr)); gap: 0.5em; }
.hat-pick {
  pointer-events: auto; display: grid; gap: 0.2em; padding: 0.7em; border-radius: 1em; border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.7); font: 800 0.9em var(--font-body); color: var(--ink); cursor: pointer; text-align: left;
}
.hat-pick small { display: inline-flex; align-items: center; gap: 0.2em; color: var(--gold-deep); }
.hat-pick small svg { width: 1em; height: 1em; }
.hat-pick.on { border-color: var(--sky); background: #fff; }
.hat-pick:disabled { opacity: 0.55; cursor: not-allowed; }
.merchant-line { font-style: italic; font-weight: 700; color: var(--ink-soft); }
.rupies.big { font-size: 1.15em; }
.shop-list, .board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45em; }
.shop-item { display: flex; justify-content: space-between; align-items: center; gap: 0.6em; padding: 0.5em 0.7em; border-radius: 1em; background: rgba(255, 255, 255, 0.7); }
.shop-name { display: flex; align-items: center; gap: 0.5em; font-weight: 800; flex-wrap: wrap; }
.shop-name svg { width: 1.3em; height: 1.3em; color: var(--sky-deep); }
.shop-name small { display: inline-flex; align-items: center; gap: 0.2em; color: var(--ink-soft); font-weight: 800; }
.shop-name small svg { width: 1em; height: 1em; color: var(--gold-deep); }
.board-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.8em; padding: 0.7em; border-radius: 1em; background: rgba(255, 255, 255, 0.7); align-items: start; }
.board-item b { font-family: var(--font-display); font-weight: 600; font-size: 1.15em; }
.board-item p { font-weight: 700; margin-top: 0.35em; }
.board-item small { color: var(--ink-soft); font-weight: 700; }
.board-item .mg-icon { width: 3em; height: 3em; }
.fatal { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(30em, calc(100% - 32px)); display: grid; gap: 0.6em; }
.debug { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); font: 700 11px ui-monospace, monospace; color: #fff; background: rgba(30, 56, 80, 0.55); padding: 2px 8px; border-radius: 6px; }

/* ---------------------------------------------------------------- contraste élevé */
#ui.hc .panel, #ui.hc .panel-lite, #ui.hc .toast, #ui.hc .hud-hint, #ui.hc .prompt, #ui.hc .hud-timer, #ui.hc .modal {
  background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; border: 2.5px solid var(--ink);
}
#ui.hc .note, #ui.hc .eyebrow, #ui.hc .section-title, #ui.hc .score-label, #ui.hc .rules, #ui.hc .res-val { color: var(--ink); }
#ui.hc .btn { border: 2.5px solid var(--ink); }
#ui.hc .chip-soft, #ui.hc .badge { border: 1.5px solid var(--ink); }
#ui.hc .hud-help, #ui.hc .brand, #ui.hc .brand h1, #ui.hc .brand p { color: var(--ink); text-shadow: none; }
#ui.hc .brand { background: #fff; padding: 0.8em; border-radius: 1em; border: 2.5px solid var(--ink); }
#ui.hc .banner, #ui.hc .popup { color: var(--ink); text-shadow: 0 0 6px #fff, 0 0 2px #fff; }

/* ---------------------------------------------------------------- animations */
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes row-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1.45); opacity: 0.3; } 60% { transform: scale(0.95); opacity: 1; } 100% { transform: scale(1); } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes banner { 0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; } 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { width: var(--from); } to { width: var(--to); } }
#ui.reduce-motion *, #ui.reduce-motion *::before, #ui.reduce-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  #ui *, #ui *::before, #ui *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------- petits écrans */
@media (max-width: 760px) {
  #ui { font-size: calc(14.5px * var(--ui-scale, 1)); }
  .results-grid { grid-template-columns: 1fr; }
  .lobby-panel { top: auto; bottom: max(14px, env(safe-area-inset-bottom, 0px)); max-height: 58%; width: calc(100% - 32px); right: max(16px, env(safe-area-inset-right, 0px)); }
  .lobby-hint { display: none; }
  .hud-top { grid-template-columns: 1fr auto; }
  .hud-objective { grid-column: 1 / -1; order: 3; max-width: none; }
  .hud-timer { justify-self: start; font-size: 1.7em; }
  .screen-menu { align-items: flex-start; }
  .color-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hud-hint { font-size: 1.1em; white-space: normal; }
}

/* ================================================================ COLLECTION
   Fiches d'objets façon « carte de collection » : vignette claire, bandeau
   d'encre sombre où le nom prend la couleur de sa rareté (lisible pour les
   quatre teintes), rareté répétée en texte. */
.modal-collection { width: min(70em, 100%); height: min(46em, 100%); max-height: 100%; padding: 1.1em; gap: 0.7em; overflow: hidden; }
.col-head { display: flex; align-items: center; gap: 0.8em; }
.col-head h2 { flex: 1; }
.col-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(13em, 0.8fr) minmax(0, 2.2fr); gap: 1em; }
.col-preview {
  margin: 0; position: relative; min-height: 0; border-radius: 1.2em; overflow: hidden;
  background: radial-gradient(120% 80% at 50% 25%, #ffffff 0%, #dcefff 55%, #bfe0f6 100%);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.9);
}
.col-preview canvas { width: 100%; height: 100%; display: block; cursor: grab; outline: none; }
.col-preview canvas:active { cursor: grabbing; }
.col-preview canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--sky-deep); }
.col-preview figcaption { position: absolute; left: 0.7em; right: 0.7em; bottom: 0.7em; text-align: center; font-weight: 800; font-size: 0.82em; color: var(--ink-soft); background: rgba(255, 255, 255, 0.8); border-radius: 999px; padding: 0.3em 0.8em; }
.col-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 0.6em; }
.col-tabs { align-self: stretch; }
.col-tabs .tab { flex: 1; }
.col-content { flex: 1; min-height: 0; overflow: auto; padding-right: 0.2em; display: flex; flex-direction: column; gap: 0.8em; }
.col-section { display: flex; flex-direction: column; gap: 0.45em; }
.name-row { display: grid; grid-template-columns: 1fr auto; gap: 0.5em; }
.color-row { display: flex; flex-wrap: wrap; gap: 0.45em; }
.color-dot { pointer-events: auto; width: 2.2em; height: 2.2em; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 1.5px rgba(30, 56, 80, 0.15), inset 0 -3px 0 rgba(0, 0, 0, 0.15); cursor: pointer; }
.color-dot.on { box-shadow: 0 0 0 3px var(--sky-deep); }

.name-tag { display: flex; flex-direction: column; gap: 0.05em; background: var(--ink); padding: 0.35em 0.6em 0.4em; text-align: left; min-width: 0; }
.name-tag b { color: var(--rc); font-weight: 900; font-size: 0.86em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.name-tag small { display: inline-flex; align-items: center; gap: 0.35em; color: #e8eef4; font-size: 0.66em; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.rdot { display: inline-block; width: 0.65em; height: 0.65em; border-radius: 50%; background: var(--rc); box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.5); }
.name-tag.big { border-radius: 0.7em; padding: 0.45em 0.8em; }
.name-tag.big b { font-family: var(--font-display); font-weight: 600; font-size: 1.25em; -webkit-line-clamp: 3; }
.name-tag.inline { border-radius: 0.6em; display: inline-flex; padding: 0.25em 0.6em; }
.name-tag.inline b { -webkit-line-clamp: 1; }

.col-toolbar { display: flex; flex-direction: column; gap: 0.5em; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0.35em; }
.chip-btn { pointer-events: auto; border: 1.5px solid rgba(30, 56, 80, 0.12); background: #fff; border-radius: 999px; padding: 0.35em 0.85em; font: 800 0.85em var(--font-body); color: var(--ink-soft); cursor: pointer; }
.chip-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.select-row { display: flex; flex-wrap: wrap; gap: 0.6em; align-items: center; }
.select-row label { display: inline-flex; align-items: center; gap: 0.4em; font-weight: 800; font-size: 0.85em; color: var(--ink-soft); }
.select-row select { height: 2.4em; border-radius: 0.8em; border: 2px solid var(--stone-dark); background: #fff; font: 800 0.95em var(--font-body); color: var(--ink); padding: 0 0.5em; }
.count { font-weight: 800; font-size: 0.82em; color: var(--ink-soft); }

.col-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(14em, 17em); gap: 0.9em; align-items: start; }
.col-split:has(> .item-grid:only-child) { grid-template-columns: 1fr; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.2em, 1fr)); gap: 0.6em; min-width: 0; }
.item-tile {
  pointer-events: auto; position: relative; display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left;
  border-radius: 1em; border: 2px solid transparent; background: linear-gradient(180deg, #ffffff 0%, #eef6fc 100%);
  box-shadow: inset 0 3px 0 var(--rc), 0 4px 12px -8px rgba(30, 56, 80, 0.5); cursor: pointer; font: inherit; color: inherit;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.item-tile:hover { transform: translateY(-2px); }
.item-tile.on { border-color: var(--sky-deep); }
.item-tile img { width: 100%; height: auto; aspect-ratio: 1; max-width: 100%; object-fit: contain; padding: 0.3em; }
.item-tile .name-tag { flex: 1; }
.tile-badge { position: absolute; top: 0.45em; left: 0.45em; display: inline-flex; align-items: center; gap: 0.2em; padding: 0.15em 0.5em; border-radius: 999px; background: var(--sage); color: #fff; font-size: 0.68em; font-weight: 900; }
.tile-badge svg { width: 1.1em; height: 1.1em; }
.tile-badge.soft { background: #fff; color: var(--sage); box-shadow: 0 0 0 1.5px #cfe6c8; }
.tile-badge.static { position: static; }
.tile-price { position: absolute; top: 0.45em; right: 0.45em; display: inline-flex; align-items: center; gap: 0.2em; padding: 0.15em 0.55em; border-radius: 999px; background: rgba(255, 255, 255, 0.92); font-weight: 900; font-size: 0.78em; font-variant-numeric: tabular-nums; }
.tile-price svg, .detail-price svg, .sell-value svg { width: 1em; height: 1em; color: var(--gold-deep); }

.item-detail { position: sticky; top: 0; display: flex; flex-direction: column; gap: 0.6em; padding: 0.8em; border-radius: 1.1em; background: #fff; box-shadow: inset 0 3px 0 var(--rc), 0 6px 18px -12px rgba(30, 56, 80, 0.6); }
.detail-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.6em; align-items: center; }
.detail-top img { width: 5.5em; height: 5.5em; max-width: 100%; border-radius: 0.8em; background: #eef6fc; }
.detail-cat { display: block; margin-top: 0.3em; font-size: 0.78em; font-weight: 800; color: var(--ink-soft); }
.detail-desc { font-weight: 700; color: var(--ink); font-size: 0.92em; }
.detail-meta { font-size: 0.8em; font-weight: 700; color: var(--ink-soft); }
.detail-price { font-weight: 800; display: flex; flex-wrap: wrap; gap: 0.3em; align-items: center; }
.detail-price b { display: inline-flex; align-items: center; gap: 0.2em; font-variant-numeric: tabular-nums; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.5em; }
.confirm-sell { display: flex; flex-direction: column; gap: 0.5em; padding: 0.7em; border-radius: 0.9em; background: #fff6da; border: 1.5px solid #f2d27a; font-weight: 800; }

.slot-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5em; }
.slot-tile { position: relative; }
.slot-main {
  pointer-events: auto; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 0.2em; padding: 0.5em 0.3em 0.6em;
  border-radius: 1em; border: 2px dashed rgba(30, 56, 80, 0.18); background: rgba(255, 255, 255, 0.6); cursor: pointer; font: inherit; color: var(--ink); min-height: 7.4em;
}
.slot-tile.filled .slot-main { border-style: solid; border-color: transparent; background: #fff; box-shadow: inset 0 3px 0 var(--rc); }
.slot-main img { width: 4em; height: 4em; max-width: 100%; }
.slot-label { font-size: 0.68em; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.slot-name { font-size: 0.75em; font-weight: 800; text-align: center; line-height: 1.15; }
.slot-empty { flex: 1; display: grid; place-items: center; color: var(--ink-soft); font-weight: 800; }
.slot-empty svg { width: 1.6em; height: 1.6em; }
.slot-x { pointer-events: auto; position: absolute; top: 0.25em; right: 0.25em; width: 1.7em; height: 1.7em; display: grid; place-items: center; border: none; border-radius: 50%; background: rgba(30, 56, 80, 0.08); color: var(--ink); cursor: pointer; }
.slot-x svg { width: 0.9em; height: 0.9em; }
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5em; }
.stat { display: flex; flex-direction: column; align-items: center; padding: 0.55em 0.3em; border-radius: 0.9em; background: #fff; }
.stat b { font-family: var(--font-display); font-weight: 700; font-size: 1.5em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.72em; font-weight: 800; color: var(--ink-soft); text-align: center; }
.hist-list, .sell-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35em; }
.hist-list li { display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; padding: 0.3em 0.5em; border-radius: 0.8em; background: rgba(255, 255, 255, 0.7); }
.hist-list img { border-radius: 0.5em; background: #eef6fc; }
.hist-meta { font-size: 0.8em; font-weight: 700; color: var(--ink-soft); }
.hist-list .empty, .empty-state { font-weight: 700; color: var(--ink-soft); padding: 0.8em; text-align: center; background: rgba(255, 255, 255, 0.6); border-radius: 0.9em; }
.crate-banner { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.7em; padding: 0.7em 0.9em; border-radius: 1em; background: linear-gradient(90deg, #fff6da, #ffffff); border: 1.5px solid #f2d27a; }
.crate-banner div { display: flex; flex-direction: column; }
.crate-banner small { color: var(--ink-soft); font-weight: 700; }
.crate-ico { display: grid; place-items: center; width: 2.6em; height: 2.6em; border-radius: 0.8em; background: var(--gold); color: #5a3f00; }
.crate-ico svg { width: 1.5em; height: 1.5em; }
.shop-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5em; align-items: center; }
.rotation { display: inline-flex; align-items: center; gap: 0.35em; font-weight: 800; font-size: 0.86em; color: var(--sky-deep); background: #e7f3fc; padding: 0.3em 0.8em; border-radius: 999px; }
.rotation svg { width: 1.1em; height: 1.1em; }
.price-table { display: flex; flex-wrap: wrap; gap: 0.4em; font-weight: 800; font-size: 0.82em; }
.price-table span { display: inline-flex; align-items: center; gap: 0.35em; padding: 0.25em 0.7em; border-radius: 999px; background: var(--ink); color: #fff; }
.sell-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 0.6em; padding: 0.4em 0.6em; border-radius: 0.9em; background: #fff; box-shadow: inset 3px 0 0 var(--rc); }
.sell-row img { border-radius: 0.6em; background: #eef6fc; }
.sell-info { display: flex; flex-wrap: wrap; gap: 0.4em; align-items: center; min-width: 0; }
.sell-value { display: inline-flex; align-items: center; gap: 0.2em; font-variant-numeric: tabular-nums; }
.sell-confirm-wrap { grid-column: 1 / -1; }
.menu-secondary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5em; }
.menu-secondary .btn { min-height: 2.6em; font-size: 0.92em; justify-content: flex-start; }
.crate-chip { pointer-events: auto; align-self: stretch; }
.lobby-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.5em; flex-wrap: wrap; }
.rupies-earned .btn { margin-left: auto; }

/* ================================================================ CAISSE */
.crate-layer {
  position: absolute; inset: 0; pointer-events: auto; z-index: 30; display: grid; place-items: center;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px;
  background: radial-gradient(circle at 50% 42%, rgba(255, 246, 214, 0.35), rgba(30, 56, 80, 0.62) 70%);
  animation: fade-in 0.3s ease-out;
}
.crate-card {
  width: min(30em, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 0.5em;
  padding: 1.2em; border-radius: 1.6em; background: #ffffff; box-shadow: var(--shadow); text-align: center;
}
.crate-stage { position: relative; width: min(24em, 100%); aspect-ratio: 1; max-width: 100%; }
.crate-canvas { position: absolute; inset: 24%; width: 52%; height: 52%; cursor: pointer; }
.crate-ring { --spin: 0deg; position: absolute; inset: 0; transform: rotate(var(--spin)); opacity: 0; transition: opacity 0.4s; }
.crate-ring.on { opacity: 1; }
.ring-item {
  position: absolute; left: 50%; top: 50%; width: 3.2em; height: 3.2em; margin: -1.6em 0 0 -1.6em; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 3px var(--rc), 0 4px 10px -4px rgba(30, 56, 80, 0.5);
  transform: rotate(var(--a)) translateY(-9.9em) rotate(calc(-1 * var(--a) - var(--spin)));
  transition: box-shadow 0.3s;
}
.ring-item img { width: 100%; height: 100%; border-radius: 50%; }
.crate-ring.done .ring-item:not(.win) { opacity: 0.35; }
.ring-item.win { box-shadow: 0 0 0 4px var(--rc), 0 0 22px 6px var(--rc); }
.crate-marker { position: absolute; left: 50%; top: -0.2em; width: 0; height: 0; transform: translateX(-50%); border-left: 0.7em solid transparent; border-right: 0.7em solid transparent; border-top: 1em solid var(--gold-deep); filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2)); }
.crate-burst { position: absolute; inset: 20%; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, var(--rc, #fff3c4) 0%, transparent 65%); opacity: 0; transform: scale(0.4); }
.crate-burst.on { animation: burst 0.9s ease-out forwards; }
.crate-foot { display: flex; flex-direction: column; align-items: center; gap: 0.6em; width: 100%; }
.crate-prompt { font-weight: 800; color: var(--ink-soft); }
.reveal { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.8em; text-align: left; width: 100%; padding: 0.6em; border-radius: 1.1em; background: #fff; box-shadow: inset 0 3px 0 var(--rc), 0 0 0 1.5px rgba(30, 56, 80, 0.08); animation: card-in 0.4s ease-out; }
.reveal img { width: 6.5em; height: 6.5em; max-width: 100%; border-radius: 0.9em; background: #eef6fc; }
.reveal-text { display: flex; flex-direction: column; gap: 0.3em; min-width: 0; }
.dup-note { display: inline-flex; align-items: center; gap: 0.3em; font-weight: 800; color: var(--gold-deep); }
.dup-note svg { width: 1.1em; height: 1.1em; }
.reveal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5em; }
@keyframes burst { 0% { opacity: 0; transform: scale(0.4); } 30% { opacity: 1; } 100% { opacity: 0.55; transform: scale(1.6); } }
@keyframes fade-in { from { opacity: 0; } }

@media (max-width: 760px) {
  .modal-collection { height: 100%; }
  .col-body { grid-template-columns: 1fr; grid-template-rows: 30% minmax(0, 1fr); }
  .col-split { grid-template-columns: 1fr; }
  .item-detail { position: static; order: -1; }
  .slot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(6.8em, 1fr)); }
  .ring-item { width: 2.6em; height: 2.6em; margin: -1.3em 0 0 -1.3em; transform: rotate(var(--a)) translateY(-8.2em) rotate(calc(-1 * var(--a) - var(--spin))); }
}
.modal-collection > .col-body { flex-shrink: 1; }

/* ---------------------------------------------------------------- mains (équipements de mobilité) */
.hands-hud {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: repeat(2, minmax(0, 12.5em)); gap: 0.6em; justify-items: stretch;
  pointer-events: none; z-index: 2;
}
.hand-card {
  display: grid; grid-template-columns: 2.6em minmax(0, 1fr) auto; grid-template-rows: auto auto auto; column-gap: 0.55em; row-gap: 0.15em;
  align-items: center; padding: 0.5em 0.7em; border-radius: 1em;
  background: rgba(255, 255, 255, 0.9); box-shadow: var(--shadow); border: 2px solid rgba(255, 255, 255, 0.95);
}
.hand-card .hand-label { grid-column: 1 / 3; grid-row: 1; font-size: 0.66em; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.hand-card .hand-icon { grid-row: 2 / 4; display: grid; place-items: center; width: 2.6em; height: 2.6em; border-radius: 0.8em; background: var(--sky-pale); color: var(--sky-deep); }
.hand-card .hand-icon svg { width: 1.6em; height: 1.6em; }
.hand-icon.item-grapple { background: #dff6f4; color: #1f8f8a; }
.hand-icon.item-jetpack { background: #fde4de; color: #c23b2e; }
.hand-icon.item-rocket { background: #fff3cf; color: var(--gold-deep); }
.hand-icon.item-shotgun { background: #f6e6d6; color: #8d5a36; }
.hand-card.st-pump .hand-bar span { background: #c98a52; }
.hand-card .hand-name { grid-column: 2 / 4; grid-row: 2; font-family: var(--font-display); font-weight: 600; font-size: 1.02em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hand-card .hand-keys { grid-column: 3; grid-row: 1; justify-self: end; display: inline-flex; align-items: center; gap: 0.25em; }
.hand-card .hand-keys kbd { min-width: 1.8em; height: 1.8em; }
.hand-card .mouse-ico svg { width: 1.2em; height: 1.2em; color: var(--ink-soft); }
.hand-card .hand-bar { grid-column: 2 / 3; grid-row: 3; height: 0.45em; border-radius: 999px; background: rgba(30, 56, 80, 0.12); overflow: hidden; }
.hand-card .hand-bar span { display: block; height: 100%; width: var(--p); border-radius: inherit; background: var(--turq); transition: width 0.1s linear; }
.hand-card .hand-status { grid-column: 3; grid-row: 3; font-size: 0.72em; font-weight: 900; color: var(--ink-soft); white-space: nowrap; }
.hand-card.st-cooldown .hand-bar span, .hand-card.st-empty .hand-bar span { background: var(--stone-dark); }
.hand-card.st-thrust .hand-bar span { background: #4fb8ff; }
.hand-card.st-pulling, .hand-card.st-hooked, .hand-card.st-thrust, .hand-card.st-blast, .hand-card.st-firing { border-color: var(--turq); }
.hand-card.st-ready .hand-status { color: var(--sage); }
.hand-card.empty { grid-template-columns: 1fr; justify-items: center; opacity: 0.6; }
.hand-card .hand-empty svg { width: 1.6em; height: 1.6em; color: var(--ink-soft); }
.hands-hint { grid-column: 1 / -1; justify-self: center; margin: 0; font-size: 0.74em; font-weight: 800; color: #fff; text-shadow: 0 1px 4px rgba(27, 95, 150, 0.85); }
.prompt.with-hands { bottom: max(9.6em, calc(env(safe-area-inset-bottom, 0px) + 9.4em)); }
#ui.hc .hand-card { background: #fff; border: 2.5px solid var(--ink); }
#ui.hc .hands-hint { color: var(--ink); text-shadow: 0 0 4px #fff; }

/* réticule du grappin : la forme change (pas seulement la couleur) quand l'accroche est possible */
.reticle { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; pointer-events: none; z-index: 2; }
.reticle .ret-ring { position: absolute; inset: 4px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85); box-shadow: 0 0 0 1px rgba(30, 56, 80, 0.35); }
.reticle .ret-dot { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: rgba(255, 255, 255, 0.9); }
.reticle .ret-ticks { position: absolute; inset: 0; opacity: 0; transition: opacity 0.12s; background:
  linear-gradient(#3fc4c0, #3fc4c0) 50% 0 / 2px 6px no-repeat, linear-gradient(#3fc4c0, #3fc4c0) 50% 100% / 2px 6px no-repeat,
  linear-gradient(#3fc4c0, #3fc4c0) 0 50% / 6px 2px no-repeat, linear-gradient(#3fc4c0, #3fc4c0) 100% 50% / 6px 2px no-repeat; }
.reticle.valid .ret-ring { border-color: #3fc4c0; inset: 7px; background: rgba(63, 196, 192, 0.25); }
.reticle.valid .ret-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: #3fc4c0; }
.reticle.valid .ret-ticks { opacity: 1; }
/* grappin : un joueur dans le viseur (il sera attiré vers toi) */
.reticle.player .ret-ring { border-color: #ea6f57; background: rgba(234, 111, 87, 0.22); }
.reticle.player .ret-dot { background: #ea6f57; }
.reticle.cooldown { opacity: 0.45; }

@media (max-width: 760px) {
  .hands-hud { grid-template-columns: repeat(2, minmax(0, 1fr)); width: calc(100% - 32px); }
  .prompt.with-hands { bottom: 11.5em; }
}
#ui.has-hands .lobby-hint { display: none; }

/* ---------------------------------------------------------------- fusil à pompe : réticule, vitalité, dégâts */
.reticle.spread::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.7); box-shadow: 0 0 0 1px rgba(30, 56, 80, 0.2);
}
.reticle.spread.pump::after { border-color: rgba(255, 255, 255, 0.3); }
/* salon : joueurs prêts (en haut au centre) */
.ready-hud {
  /* centré en haut ; décalé vers la gauche si le panneau du salon (à droite) le recouvrirait */
  position: absolute; top: max(14px, env(safe-area-inset-top, 0px));
  left: min(50%, calc(100% - 23em - 48px - 11em)); transform: translateX(-50%);
  display: grid; justify-items: center; gap: 0.15em; padding: 0.45em 1.1em 0.5em; border-radius: 1.2em;
  background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); pointer-events: none; z-index: 2; text-align: center;
  width: max-content; max-width: min(22em, calc(100% - 32px));
}
.ready-hud .ready-count { display: inline-flex; align-items: center; gap: 0.45em; font-weight: 900; font-size: 1.05em; color: var(--ink); }
.ready-hud .ready-count svg { width: 1.1em; height: 1.1em; color: var(--ink-soft); }
.ready-hud .ready-count b { font-size: 1.35em; font-variant-numeric: tabular-nums; }
.ready-hud .ready-count small { font-size: 0.7em; color: var(--ink-soft); }
.ready-hud .ready-hint { font-size: 0.78em; font-weight: 800; color: var(--ink-soft); }
.ready-hud.me-ready .ready-count svg { color: #5cc46a; }
.ready-hud.all { background: rgba(232, 248, 236, 0.95); }
.ready-hud.all .ready-count b { color: #2f9a4a; }
/* pupitre de lancement (fenêtre) */
.modal-launch { width: min(30em, calc(100% - 32px)); }
.modal-launch .modal-head h2 { display: inline-flex; align-items: center; gap: 0.4em; }
.modal-launch .modal-head h2 svg { width: 1em; height: 1em; color: var(--coral, #ea6f57); }
.launch-row { display: flex; align-items: center; justify-content: space-between; gap: 0.8em; }
.launch-count { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.launch-count.all { color: #2f9a4a; }
.launch-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35em; }
.launch-player { display: flex; align-items: center; gap: 0.6em; padding: 0.4em 0.6em; border-radius: 0.8em; background: rgba(30, 56, 80, 0.05); }
.launch-player .pname { flex: 1; font-weight: 800; }
.launch-player.is-ready { background: rgba(92, 196, 106, 0.12); }
.launch-bots { display: inline-flex; align-items: center; gap: 0.4em; }
.launch-bots svg { width: 1.1em; height: 1.1em; }
.launch-status.ok { color: #2f9a4a; font-weight: 800; }
.modal-launch .stepper { display: inline-flex; align-items: center; gap: 0.5em; }
.modal-launch .stepper-n { min-width: 1.4em; text-align: center; font-variant-numeric: tabular-nums; font-size: 1.15em; }
.modal-launch .stepper .icon-btn[disabled] { opacity: 0.35; cursor: default; }
.modal-launch .modal-foot { justify-content: center; }
.modal-launch .start-btn { min-width: 14em; }
.btn .btn-kbd { margin-left: 0.4em; padding: 0.05em 0.45em; border-radius: 0.4em; font-size: 0.8em; font-family: inherit; font-weight: 900; background: rgba(255, 255, 255, 0.35); border: 1px solid rgba(30, 56, 80, 0.15); }
@media (max-width: 760px) { .ready-hud { left: 50%; } } /* panneau du salon en bas : compteur bien centré */
.health-hud {
  position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); top: max(14px, env(safe-area-inset-top, 0px));
  display: grid; grid-template-columns: auto minmax(8em, 13em) auto; align-items: center; gap: 0.55em;
  padding: 0.45em 0.8em; border-radius: 999px; background: rgba(255, 255, 255, 0.9); box-shadow: var(--shadow);
  pointer-events: none; z-index: 2; font-weight: 900;
}
.health-hud .health-label { font-size: 0.72em; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.health-hud .health-bar { height: 0.6em; border-radius: 999px; background: rgba(30, 56, 80, 0.12); overflow: hidden; }
.health-hud .health-bar span { display: block; height: 100%; border-radius: inherit; background: #5cc46a; transition: width 0.15s ease-out; }
.health-hud.low .health-bar span { background: var(--coral); }
.health-hud .health-val { font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: right; }
.health-hud.low .health-val { color: var(--coral); }
#ui.hc .health-hud { background: #fff; border: 2.5px solid var(--ink); }
.damage-flash { position: absolute; inset: 0; pointer-events: none; z-index: 1; opacity: 0; box-shadow: inset 0 0 90px 30px rgba(234, 111, 87, 0.55); }
.damage-flash.on { animation: dmg-flash 0.45s ease-out; }
@keyframes dmg-flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.popup.dmg { color: #fff1e8; font-size: 1.35em; text-shadow: 0 2px 0 #b8432f, 0 4px 14px rgba(184, 67, 47, 0.45); }
.popup.dmg.ko { font-size: 1.7em; }

/* lance-roquettes : réticule de tir ; viser vers le bas = propulsion (flèche vers le haut) */
.reticle.rocket .ret-ring { border-color: #f2be45; }
.reticle.rocket .ret-dot { background: #f2be45; }
.reticle.rocket.feet .ret-ring { border-color: #3fc4c0; border-style: dashed; }
.reticle.rocket.feet::before {
  content: ''; position: absolute; left: 50%; top: -14px; width: 0; height: 0; margin-left: -7px;
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 10px solid #3fc4c0;
  filter: drop-shadow(0 0 1px rgba(30, 56, 80, 0.5));
}

/* ---------- Portail des épreuves (une seule épreuve, objets au choix) ---------- */
.modal-portal { width: min(38em, calc(100% - 32px)); max-height: min(92vh, 52em); overflow-y: auto; }
.modal-portal .modal-head h2 { display: inline-flex; align-items: center; gap: 0.45em; }
.portal-glyph { width: 0.95em; height: 1.15em; border-radius: 50% 50% 0.25em 0.25em; border: 0.16em solid var(--turq); box-shadow: inset 0 0 0.35em rgba(47, 179, 174, 0.7); }
.modal-portal .section-title { margin: 0.6em 0 0.35em; }
.portal-games { display: grid; grid-template-columns: repeat(auto-fit, minmax(15em, 1fr)); gap: 0.45em; }
.portal-game {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.7em; align-items: center; text-align: left;
  padding: 0.55em 0.7em; border-radius: 1em; border: 2px solid transparent; background: rgba(255, 255, 255, 0.72);
  font: inherit; color: var(--ink); cursor: pointer;
}
.portal-game .mg-icon { width: 2.6em; height: 2.6em; border-radius: 0.85em; }
.portal-game b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 1.05em; }
.portal-game small { display: block; color: var(--ink-soft); font-weight: 700; font-size: 0.8em; }
.portal-game .pg-warn { color: var(--coral); }
.portal-game.on { border-color: var(--turq); background: #e6f8f6; box-shadow: 0 3px 0 rgba(47, 179, 174, 0.25); }
.portal-game:disabled { cursor: default; }
.portal-game:disabled:not(.on) { opacity: 0.55; }
.portal-game:not(:disabled):hover { border-color: rgba(47, 179, 174, 0.5); }
.portal-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5em, 1fr)); gap: 0.45em; }
.portal-item {
  display: grid; justify-items: center; gap: 0.15em; padding: 0.55em 0.4em; border-radius: 1em;
  border: 2px solid transparent; background: rgba(255, 255, 255, 0.72); font: inherit; color: var(--ink); cursor: pointer;
}
.portal-item .pi-icon { display: grid; place-items: center; width: 2.4em; height: 2.4em; border-radius: 0.8em; background: color-mix(in srgb, var(--ic) 18%, white); color: var(--ic); }
.portal-item .pi-icon svg { width: 70%; height: 70%; }
.portal-item b { font-size: 0.9em; }
.portal-item small { font-size: 0.74em; font-weight: 800; color: #fff; background: var(--ic); padding: 0.05em 0.55em; border-radius: 999px; }
.portal-item.on { border-color: var(--ic); background: color-mix(in srgb, var(--ic) 10%, white); }
.portal-item:disabled { cursor: default; }
.portal-item:disabled:not(.on) { opacity: 0.55; }
.portal-hands { margin-top: 0.4em; }
.portal-rules { font-size: 0.8em; }
.modal-portal .modal-foot {
  justify-content: center; position: sticky; bottom: -1px; margin-inline: -0.2em; padding-block: 0.6em 0.2em;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.96) 35%);
}
.modal-portal .portal-go { min-width: 14em; background: var(--turq); box-shadow: 0 4px 0 #23807c; }
.intro-items { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6em; font-weight: 800; }
.intro-items .item-ctrl svg { width: 1.2em; height: 1.2em; }
/* échoppe : acheter / revendre au même endroit */
.echoppe-head { display: flex; justify-content: center; margin-bottom: 0.6em; }
.echoppe-modes .seg { min-width: 7em; }
