/* Fartwin.me — charte « Lagon au coucher de soleil » (voir docs/CHARTE.md).
   Un canvas 3D fixe derrière des écrans HTML : accueil, préparation, salons, vestiaire, HUD. */
:root {
  --ink: #14304a;        /* bleu nuit du lagon : textes, relief des titres */
  --ink-soft: #5a7189;
  --card: #ffffff;
  --card-edge: #bfe6ea;  /* tranche turquoise des cartes en relief */
  --field: #eef8f9;
  --pink: #ff4f9a;       /* accent : survol, sélection, bouton principal */
  --pink-deep: #c41f6a;
  --aqua: #2ed3d9;       /* toboggans */
  --orange: #ff7d2e;     /* bouée */
  --sun: #ffcf3a;
  --mint: #8ff0b0;       /* pets */
  --violet: #5b4fc9;     /* ciel du soir */
  --f-chunk: "Luckiest Guy", "Arial Black", "Trebuchet MS", system-ui, sans-serif;
  --f-ui: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: only light; /* pas de mode sombre, même imposé par le navigateur */
}
html, body { height: 100%; margin: 0; overflow: hidden; background: #b783d6; color: var(--ink); font-family: var(--f-ui); font-weight: 800; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.screen { position: fixed; inset: 0; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.screen > * { pointer-events: auto; }

/* Titres en relief : blanc, tranche bleu lagon */
.chunk {
  font-family: var(--f-chunk); font-weight: 400; color: #fff; letter-spacing: .02em; line-height: .95;
  text-shadow: 0 1px 0 #d6f4f6, 0 2px 0 #b5e8ec, 0 3px 0 #8fd8df, 0 4px 0 #66c3cf, 0 5px 0 #44a9bb, 0 6px 0 #2f8ea6, 0 7px 0 #1f6f8c, 0 8px 0 #14506c, 0 14px 22px rgba(20, 48, 74, .45);
}
.chunk.hot, .mi:hover, .mi.sel {
  color: var(--pink);
  text-shadow: 0 1px 0 #f33f8d, 0 2px 0 #e93683, 0 3px 0 #dc2d78, 0 4px 0 #cf256e, 0 5px 0 #c01e64, 0 6px 0 #af185a, 0 7px 0 #9c1350, 0 8px 0 #860e45, 0 14px 22px rgba(90, 10, 50, .4);
}

/* ---------- ACCUEIL ---------- */
.logo { position: absolute; top: max(clamp(48px, 9vh, 96px), calc(env(safe-area-inset-top, 0px) + 32px)); left: max(22px, env(safe-area-inset-left, 0px)); font-size: clamp(38px, 5vw, 70px); transform: rotate(-5deg); transform-origin: left; margin: 0; }
.logo span { color: var(--sun); text-shadow: 0 1px 0 #f5bf25, 0 2px 0 #eab11d, 0 3px 0 #dba216, 0 4px 0 #c98f10, 0 5px 0 #b37c0b, 0 6px 0 #9c6a08, 0 10px 18px rgba(90, 50, 0, .4); }
.menu { position: absolute; left: clamp(16px, 6vw, 110px); top: 30%; display: flex; flex-direction: column; align-items: flex-start; gap: clamp(6px, 2vh, 26px); will-change: transform; }
.mi { appearance: none; background: none; border: 0; padding: 0; font-size: clamp(46px, 7.2vw, 112px); transition: transform .18s cubic-bezier(.3, 1.6, .5, 1), color .12s; }
.mi.m1 { transform: rotate(-3deg); }
.mi.m2 { transform: rotate(-7deg) translateX(1.5vw); font-size: clamp(38px, 5.8vw, 92px); }
.mi.m3 { transform: rotate(-12deg) translateX(.5vw); font-size: clamp(34px, 5vw, 80px); }
.mi.m1:hover, .mi.m1.sel { transform: rotate(-3deg) scale(1.06); }
.mi.m2:hover, .mi.m2.sel { transform: rotate(-7deg) translateX(1.5vw) scale(1.06); }
.mi.m3:hover, .mi.m3.sel { transform: rotate(-12deg) translateX(.5vw) scale(1.06); }
.mi.m4 { transform: rotate(-5deg) translateX(3vw); font-size: clamp(40px, 6.2vw, 98px); }
.mi.m4:hover, .mi.m4.sel { transform: rotate(-5deg) translateX(3vw) scale(1.06); }
.side { position: absolute; right: max(20px, env(safe-area-inset-right, 0px)); top: 50%; width: min(380px, 32vw); display: flex; flex-direction: column; gap: 14px; transform: translateY(-50%) perspective(900px) rotateY(-13deg); transform-origin: right center; will-change: transform; }
.tile { background: var(--card); border-radius: 22px; border: 0; box-shadow: 0 8px 0 var(--card-edge), 0 18px 30px rgba(20, 48, 74, .25); color: var(--ink); text-align: left; }
.garage { display: flex; align-items: center; gap: 14px; padding: 16px 20px; font-family: var(--f-chunk); font-size: clamp(30px, 3.6vw, 56px); line-height: 1; transition: transform .15s; }
.garage svg { width: 1.05em; height: 1.05em; flex: none; color: var(--orange); }
.garage:hover { transform: translateY(-3px); color: var(--pink); }
.profile { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.prow { display: flex; align-items: center; gap: 12px; }
.lvl { width: 46px; height: 46px; border-radius: 12px; background: var(--ink); color: #fff; display: grid; place-items: center; font-family: var(--f-chunk); font-size: 22px; flex: none; }
.pname { font-family: var(--f-chunk); font-size: 26px; line-height: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.psub { color: var(--ink-soft); font-size: 15px; }
.xpbar { height: 30px; border-radius: 10px; background: var(--field); position: relative; overflow: hidden; font-size: 13px; display: flex; justify-content: space-between; align-items: center; padding: 0 10px; font-variant-numeric: tabular-nums; }
.xpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--sun), var(--pink)); border-radius: 10px; width: 0; }
.xpbar span { position: relative; }
.icons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ib { aspect-ratio: 1 / 1; display: grid; place-items: center; padding: 0; transition: transform .15s; }
.ib svg { width: 44%; height: 44%; }
.ib:hover { transform: translateY(-3px); }
.ib:hover svg { color: var(--pink); }
.foot { position: absolute; right: max(20px, env(safe-area-inset-right, 0px)); bottom: max(14px, env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 32px); display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 22px; color: #fff; font-size: 15px; text-shadow: 0 1px 3px rgba(20, 48, 74, .7); background: rgba(20, 48, 74, .5); border-radius: 12px; padding: 6px 14px; }
.foot button { background: none; border: 0; padding: 0; color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #c9c9d6; margin-right: 6px; }
.dot.on { background: var(--mint); box-shadow: 0 0 6px var(--mint); }

/* ---------- PANNEAUX (préparation, salons) ---------- */
.sheet { position: absolute; left: max(20px, env(safe-area-inset-left, 0px)); top: max(20px, env(safe-area-inset-top, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px)); width: min(580px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 16px; overflow-y: auto; padding: 6px 6px 18px; }
.sheet h2 { font-size: clamp(44px, 6vw, 80px); margin: 14px 0 4px; transform: rotate(-4deg); transform-origin: left; }
.box { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.box h3 { margin: 0; font-family: var(--f-chunk); font-weight: 400; font-size: 22px; line-height: 1; }
.box p { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.4; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { border: 0; border-radius: 14px; padding: 10px 14px; background: var(--field); color: var(--ink); box-shadow: 0 4px 0 var(--card-edge); font-weight: 900; display: flex; align-items: center; gap: 8px; transition: transform .1s; }
.opt:hover:not(:disabled) { transform: translateY(-2px); }
.opt[aria-pressed="true"] { background: var(--pink); color: #fff; box-shadow: 0 4px 0 var(--pink-deep); }
.opt .sw { width: 16px; height: 16px; border-radius: 5px; background: var(--c); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12); }
.go-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.big { border: 0; border-radius: 18px; padding: 14px 26px; font-family: var(--f-chunk); font-size: 30px; line-height: 1; background: var(--pink); color: #fff; box-shadow: 0 7px 0 var(--pink-deep), 0 14px 24px rgba(90, 10, 50, .25); transition: transform .1s; }
.big:hover:not(:disabled) { transform: translateY(-2px); }
.big:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--pink-deep); }
.big.alt { background: var(--aqua); color: var(--ink); box-shadow: 0 7px 0 #1d9aa6, 0 14px 24px rgba(20, 48, 74, .2); }
.back { border: 0; border-radius: 14px; padding: 12px 18px; background: #fff; box-shadow: 0 5px 0 var(--card-edge); font-weight: 900; }
.medals { display: flex; gap: 10px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.medal { display: flex; align-items: center; gap: 6px; background: var(--field); border-radius: 12px; padding: 8px 12px; font-size: 15px; }
.medal i { width: 16px; height: 16px; border-radius: 50%; background: var(--c); }
.info { background: #fff3e6; border-radius: 14px; padding: 12px 14px; font-size: 14px; color: #8a4512; line-height: 1.4; }
.info.err { background: #ffe5ef; color: #a0174f; }
.joinrow { display: flex; gap: 10px; flex-wrap: wrap; }
.joinrow input { flex: 1 1 8rem; min-width: 0; border: 3px solid var(--card-edge); border-radius: 14px; padding: 10px 14px; font-family: var(--f-chunk); font-size: 30px; letter-spacing: .25em; text-transform: uppercase; background: #fff; }
.joinrow input:focus { border-color: var(--pink); outline: none; }
.code { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.code b { font-family: var(--f-chunk); font-weight: 400; font-size: 56px; letter-spacing: .14em; line-height: 1; color: var(--ink); background: var(--field); border-radius: 16px; padding: 10px 16px 4px; user-select: all; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li { display: flex; align-items: center; gap: 10px; background: var(--field); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.players .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 12px; font-weight: 900; padding: 3px 9px; border-radius: 99px; background: #fff; color: var(--ink-soft); flex: none; }
.chip.ok { background: var(--mint); color: #0f5a33; }
.chip.host { background: var(--sun); color: #6b4a00; }
.ring { width: 22px; height: 22px; border-radius: 50%; border: 6px solid var(--c); flex: none; background: transparent; }
.teams { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.team { border-radius: 16px; background: var(--field); padding: 10px; display: flex; flex-direction: column; gap: 6px; border-top: 6px solid var(--c); min-width: 0; }
.team b { font-size: 14px; }
.team span { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team button { margin-top: auto; border: 0; border-radius: 10px; padding: 6px; background: #fff; box-shadow: 0 3px 0 var(--card-edge); font-weight: 900; font-size: 13px; }

/* ---------- VESTIAIRE ---------- */
.locker { position: absolute; right: max(20px, env(safe-area-inset-right, 0px)); top: max(20px, env(safe-area-inset-top, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px)); width: min(380px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding: 6px; }
.locker h2 { font-size: clamp(40px, 5vw, 64px); margin: 0 0 4px; transform: rotate(-4deg); }
.locker .box { padding: 14px 16px; gap: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swb { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 2px var(--card-edge), 0 4px 0 var(--card-edge); padding: 0; }
.swb[aria-pressed="true"] { box-shadow: 0 0 0 4px var(--pink), 0 4px 0 var(--card-edge); }
.lhint { position: absolute; left: max(20px, env(safe-area-inset-left, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px)); color: #fff; font-size: 15px; text-shadow: 0 1px 3px rgba(20, 48, 74, .7); pointer-events: none; background: rgba(20, 48, 74, .45); border-radius: 12px; padding: 6px 12px; margin: 0; }

/* ---------- HUD ---------- */
#hud { font-variant-numeric: tabular-nums; }
.hpos { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); top: max(16px, env(safe-area-inset-top, 0px)); padding: 10px 18px; display: flex; align-items: baseline; gap: 10px; }
.hpos b { font-family: var(--f-chunk); font-weight: 400; font-size: 54px; line-height: 1; color: var(--pink); }
.hpos span { color: var(--ink-soft); font-size: 16px; }
.htime { position: absolute; left: 50%; top: max(16px, env(safe-area-inset-top, 0px)); transform: translateX(-50%); padding: 8px 18px; font-size: 22px; font-weight: 900; }
.hright { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: max(16px, env(safe-area-inset-top, 0px)); display: flex; gap: 10px; align-items: stretch; }
.hspeed { padding: 8px 16px; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; }
.hspeed b { font-family: var(--f-chunk); font-weight: 400; font-size: 34px; line-height: 1; }
.hspeed span { font-size: 12px; color: var(--ink-soft); }
.hmega { width: 84px; display: grid; place-items: center; position: relative; padding: 6px; }
.hmega svg { width: 66px; height: 66px; transform: rotate(-90deg); }
.hmega em { position: absolute; font-style: normal; font-family: var(--f-chunk); font-size: 14px; text-align: center; line-height: 1; }
.hmega.ready em { color: #1c8a50; }
.hstatus { position: absolute; left: 50%; top: 24%; transform: translateX(-50%) rotate(-4deg); font-family: var(--f-chunk); font-size: clamp(30px, 4.5vw, 54px); pointer-events: none; animation: wob .5s ease-in-out infinite alternate; }
.hstatus[data-k="stun"] { color: var(--sun); }
.hstatus[data-k="stop"] { color: var(--pink); }
.hstatus[data-k="slow"] { color: var(--mint); }
@keyframes wob { from { transform: translateX(-50%) rotate(-5deg) scale(1); } to { transform: translateX(-50%) rotate(3deg) scale(1.08); } }
.hwait { position: absolute; left: 50%; bottom: calc(max(20px, env(safe-area-inset-bottom, 0px)) + 96px); max-width: calc(100% - 32px); text-align: center; transform: translateX(-50%); padding: 10px 18px; font-size: 16px; }
.hprog { position: absolute; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(620px, calc(100% - 140px)); height: 14px; border-radius: 8px; background: rgba(20, 48, 74, .55); }
.hprog i { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid rgba(255, 255, 255, .8); }
.hprog i.me { width: 20px; height: 20px; border: 3px solid #fff; z-index: 2; }
.hprog::after { content: ""; position: absolute; right: -4px; top: -6px; width: 8px; height: 26px; border-radius: 3px; background: repeating-linear-gradient(#fff 0 6px, var(--ink) 6px 12px); }
kbd { font-family: var(--f-ui); font-weight: 900; background: #fff; color: var(--ink); border-radius: 6px; padding: 1px 7px; box-shadow: 0 2px 0 var(--card-edge); text-shadow: none; font-size: 12px; }
.hpause { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); border: 0; padding: 10px 14px; }
.count { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font-size: clamp(80px, 14vw, 200px); pointer-events: none; }
.touch { position: absolute; left: 0; right: 0; bottom: max(46px, calc(env(safe-area-inset-bottom, 0px) + 46px)); display: none; justify-content: space-between; padding: 0 max(14px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.touch div { display: flex; gap: 10px; pointer-events: auto; }
.touch button { width: 70px; height: 70px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .9); box-shadow: 0 5px 0 var(--card-edge); font-family: var(--f-chunk); font-size: 18px; touch-action: none; }
.touch .tf { background: var(--mint); }
.touch .tm { background: var(--pink); color: #fff; }
@media (pointer: coarse) { .touch { display: flex; } }

/* ---------- FENÊTRES ---------- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(20, 48, 74, .4); padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); z-index: 20; }
.mcard { width: min(480px, 100%); max-height: calc(100% - 20px); overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.mcard h2 { margin: 0; font-family: var(--f-chunk); font-weight: 400; font-size: 38px; line-height: 1; }
.mcard p { margin: 0; color: var(--ink-soft); line-height: 1.45; font-size: 15px; }
.mcard label { display: grid; grid-template-columns: 7rem 1fr; align-items: center; gap: 10px; font-size: 15px; }
.mcard input[type=range] { accent-color: var(--pink); width: 100%; min-width: 0; }
.mcard label.check { grid-template-columns: 1fr auto; }
.mcard label.check kbd { margin-left: 6px; }
.mcard input[type=checkbox] { accent-color: var(--pink); width: 22px; height: 22px; margin: 0; }
.mcard input[type=text] { border: 2px solid var(--card-edge); border-radius: 12px; padding: 10px 12px; font-weight: 900; width: 100%; min-width: 0; }
.mcard select { border: 2px solid var(--card-edge); border-radius: 12px; padding: 8px 10px; background: #fff; min-width: 0; }
.rows { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.rows li { display: grid; grid-template-columns: 2.4rem 1fr auto; gap: 10px; align-items: center; background: var(--field); border-radius: 12px; padding: 8px 12px; font-variant-numeric: tabular-nums; }
.rows li.me { background: var(--pink); color: #fff; }
.rows small { font-weight: 700; opacity: .8; }
.rows .p { font-family: var(--f-chunk); font-size: 20px; }
.rows .c { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: 8px; background: var(--c); box-shadow: 0 0 0 2px #fff; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.keyl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; font-size: 15px; }
#toast { position: fixed; left: 50%; bottom: max(80px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 14px; z-index: 30; pointer-events: none; font-size: 15px; max-width: calc(100% - 32px); text-align: center; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(#5b4fc9, #ffad8a); z-index: 40; font-size: 48px; text-align: center; padding: 16px; }

@media (max-width: 820px) {
  .menu { top: auto; bottom: max(70px, env(safe-area-inset-bottom, 0px)); gap: 4px; }
  .side { top: max(90px, env(safe-area-inset-top, 0px)); transform: perspective(900px) rotateY(-10deg); width: min(240px, 46vw); gap: 10px; }
  .profile { display: none; }
  .garage { font-size: min(26px, 5.6vw); padding: 12px; gap: 8px; }
  .ib { border-radius: 14px; }
  .foot { font-size: 12px; gap: 4px 12px; }
  .hpos b { font-size: 38px; }
  .hspeed { display: none; }
  .teams { grid-template-columns: 1fr; }
  /* Vestiaire en bas d'écran : le personnage reste visible au-dessus */
  .locker { top: auto; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: auto; height: 46%; }
  .locker h2 { display: none; }
  .lhint { display: none; }
}
@media (max-width: 560px) {
  /* la place et le chrono ne tiennent plus côte à côte : le chrono descend d'un rang */
  .htime { top: calc(max(16px, env(safe-area-inset-top, 0px)) + 74px); font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { .mi, .garage, .ib, .opt, .big { transition: none; } .hstatus { animation: none; } }

/* ---------- ESPACE D'ATTENTE DU SALON (piscine en 3D) ---------- */
.sheet.lsheet { width: min(430px, calc(100% - 32px)); transition: transform .25s ease, opacity .25s; }
.sheet.lsheet h2 { font-size: clamp(38px, 4.6vw, 60px); }
.sheet.lsheet .code b { font-size: 44px; }
#room.collapsed .sheet.lsheet { transform: translateX(calc(-100% - 40px)); opacity: 0; pointer-events: none; }
.roomtab { position: absolute; left: calc(min(430px, calc(100% - 32px)) + 34px); top: max(24px, env(safe-area-inset-top, 0px)); padding: 10px 16px; font-weight: 900; font-size: 14px; transition: left .25s ease; }
#room.collapsed .roomtab { left: max(20px, env(safe-area-inset-left, 0px)); }
.ltouch { position: absolute; left: 0; right: 0; bottom: max(30px, calc(env(safe-area-inset-bottom, 0px) + 30px)); display: none; justify-content: space-between; align-items: flex-end; padding: 0 max(20px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.ltouch > div { pointer-events: auto; display: flex; gap: 12px; }
.stick { width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .35); border: 3px solid rgba(255, 255, 255, .8); position: relative; touch-action: none; }
.stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: #fff; box-shadow: 0 4px 0 var(--card-edge); }
.ltouch button { width: 70px; height: 70px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); box-shadow: 0 5px 0 var(--card-edge); font-family: var(--f-chunk); font-size: 18px; touch-action: none; }
.ltouch button[data-l="fart"] { background: var(--mint); }
@media (pointer: coarse) { .ltouch { display: flex; } #room:not(.collapsed):not(.guest) .ltouch { display: none; } }
@media (max-width: 820px) {
  .roomtab { left: auto; right: max(16px, env(safe-area-inset-right, 0px)); top: max(16px, env(safe-area-inset-top, 0px)); }
  #room.collapsed .roomtab { left: auto; }
}
/* écran étroit : le bouton « Masquer le salon » passe au-dessus du panneau, qui commence en dessous pour ne pas être recouvert */
@media (max-width: 640px) { .sheet.lsheet { top: calc(max(16px, env(safe-area-inset-top, 0px)) + 58px); } }
.swb.none { background: repeating-linear-gradient(135deg, #eef8f9 0 6px, #ffffff 6px 12px); position: relative; }
.swb.none::after { content: ""; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 3px; margin-left: -1.5px; background: var(--pink); transform: rotate(45deg); border-radius: 2px; }

/* Vestiaire : vêtements et accessoires (vignettes tirées de assets/cosmetics/) */
.ctabs { display: flex; flex-wrap: wrap; gap: 6px; }
.ctabs .opt { padding: 6px 10px; font-size: 14px; }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.cz { aspect-ratio: 1; border-radius: 14px; border: 3px solid #fff; background: #f8f4ef; box-shadow: 0 0 0 2px var(--card-edge), 0 4px 0 var(--card-edge); padding: 2px; display: grid; place-items: center; font: 800 13px Nunito, sans-serif; color: #14304a; cursor: pointer; }
.cz img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.cz[aria-pressed="true"] { box-shadow: 0 0 0 4px var(--pink), 0 4px 0 var(--card-edge); }

/* ---------- PARCOURS, BOOSTS, AVENTURE ---------- */
.hflash { position: absolute; left: 50%; top: 32%; transform: translateX(-50%) rotate(-3deg); font-size: clamp(26px, 3.8vw, 46px); pointer-events: none; text-align: center; max-width: calc(100% - 32px); animation: flashin .35s cubic-bezier(.3, 1.6, .5, 1); }
.hflash[data-k="hurt"], .hflash[data-k="ko"] { color: var(--pink); }
.hflash[data-k="item"], .hflash[data-k="cp"] { color: var(--mint); }
.hflash[data-k="fork"], .hflash[data-k="jump"] { color: var(--sun); }
@keyframes flashin { from { transform: translateX(-50%) rotate(-3deg) scale(.4); opacity: 0; } to { transform: translateX(-50%) rotate(-3deg) scale(1); opacity: 1; } }
.hstatus[data-k="boost"] { color: var(--sun); }
.hadv { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); top: max(16px, env(safe-area-inset-top, 0px)); padding: 10px 14px; display: flex; align-items: center; gap: 14px; }
.hearts { display: flex; gap: 6px; }
.hearts i { width: 26px; height: 24px; background: #d9e6ea; clip-path: path("M13 23 C 5 16, 0 11, 0 6.5 A 6.3 6.3 0 0 1 13 4 A 6.3 6.3 0 0 1 26 6.5 C 26 11, 21 16, 13 23 Z"); transition: background .2s; }
.hearts i.on { background: var(--pink); }
.hbub { display: flex; align-items: center; gap: 6px; font-size: 18px; }
.hbub i { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6c2, #ffd84a 45%, #c98600); }
.hitem { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(max(16px, env(safe-area-inset-top, 0px)) + 96px); width: 84px; padding: 8px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hitem i { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--field); color: var(--ink-soft); font-style: normal; font-family: var(--f-chunk); font-size: 26px; }
.hitem i svg { width: 30px; height: 30px; }
.hitem.full i { background: var(--c); color: var(--ink); animation: wobi .6s ease-in-out infinite alternate; }
.hitem em { font-style: normal; font-size: 13px; color: var(--ink-soft); }
.hitem.full em { color: var(--ink); }
@keyframes wobi { from { transform: rotate(-6deg); } to { transform: rotate(6deg) scale(1.06); } }
.touch .tb { background: var(--sun); }
.sheet > .box { flex-shrink: 0; }
.world { border-left: 8px solid var(--c); }
.lvls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.alvl { border: 0; border-radius: 14px; padding: 10px 8px; background: var(--field); box-shadow: 0 4px 0 var(--card-edge); display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; transition: transform .1s; }
.alvl:hover:not(:disabled) { transform: translateY(-2px); }
.alvl b { font-family: var(--f-chunk); font-weight: 400; font-size: 22px; line-height: 1; color: var(--ink); white-space: nowrap; }
.alvl span { font-size: 13px; line-height: 1.2; overflow-wrap: anywhere; }
.alvl small { font-size: 12px; color: var(--ink-soft); }
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars i, .bigstars i { width: 16px; height: 16px; background: #cfd9de; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.stars i.on, .bigstars i.on { background: var(--sun); }
.advtot { display: flex; align-items: center; gap: 8px; font-weight: 900; color: var(--ink) !important; }
.bigstars { display: flex; justify-content: center; gap: 12px; }
.bigstars i { width: 56px; height: 56px; }
.bigstars i.on { animation: starpop .5s cubic-bezier(.3, 1.8, .5, 1) both; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
@media (max-width: 820px) { .hitem { top: calc(max(16px, env(safe-area-inset-top, 0px)) + 74px); } }
@media (max-width: 560px) { .lvls { grid-template-columns: 1fr; } .alvl { flex-direction: row; justify-content: space-between; } }
@media (max-width: 440px) { .touch div { gap: 6px; } .touch button { width: 60px; height: 60px; font-size: 15px; } }
@media (max-width: 360px) { .touch button { width: 54px; height: 54px; font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { .hflash, .hitem.full i, .bigstars i.on { animation: none; } }

/* Aides de commandes repliables (pause, salon) */
.mkeys summary { cursor: pointer; font-weight: 900; list-style: none; display: flex; align-items: center; gap: 8px; }
.mkeys summary::-webkit-details-marker { display: none; }
.mkeys summary::before { content: "▸"; color: var(--pink); transition: transform .15s; }
.mkeys[open] summary::before { transform: rotate(90deg); }
.mkeys[open] summary { margin-bottom: 10px; }
.mkeys.box summary { font-family: var(--f-chunk); font-weight: 400; font-size: 22px; line-height: 1; }
.mcard .mkeys { background: var(--field); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.mcard .mkeys p { font-size: 14px; }
.mcard .mh { margin: 4px 0 -4px; font-family: var(--f-chunk); font-weight: 400; font-size: 20px; }

/* ---------- PARCOURS D'ENTRAÎNEMENT ---------- */
.tutobox.new { box-shadow: 0 8px 0 var(--pink-deep), 0 0 0 4px var(--pink), 0 18px 30px rgba(20, 48, 74, .25); }
.hcoach { position: absolute; left: 50%; top: calc(max(16px, env(safe-area-inset-top, 0px)) + 62px); transform: translateX(-50%); width: min(560px, calc(100% - 32px)); padding: 16px 22px 18px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; transition: box-shadow .2s; }
.hcoach .cbar { position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--field); }
.hcoach .cbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--mint), var(--aqua)); transition: width .3s; }
.hcoach .cstep { font-size: 15px; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }
.hcoach > b { font-family: var(--f-chunk); font-weight: 400; font-size: 32px; line-height: 1.05; }
.hcoach p b { font-weight: 900; color: var(--pink-deep); }
.hcoach p { margin: 0; font-size: 21px; line-height: 1.35; font-weight: 600; color: var(--ink); }
.hcoach kbd { font-size: 18px; }
.hcoach .cmsg { background: #fff3e6; color: #8a4512; border-radius: 10px; padding: 8px 12px; font-size: 19px; }
.hcoach.ok { box-shadow: 0 8px 0 #4cc985, 0 0 0 4px var(--mint), 0 18px 30px rgba(20, 48, 74, .25); }
.hcoach.ok b::after { content: " ✓"; color: #1c8a50; }
.tips { margin: 0; padding-left: 1.2em; color: var(--ink-soft); line-height: 1.45; font-size: 15px; display: flex; flex-direction: column; gap: 4px; }

/* Vestiaire : niveaux, pièces verrouillées et bouée */
.closet h3 { margin: 0; }
.lkbox { padding: 12px 16px; gap: 6px; }
.lkrow { display: flex; align-items: center; gap: 12px; }
.lkrow > div { display: flex; flex-direction: column; min-width: 0; }
.lkrow b { font-size: 18px; }
.lkrow span:not(.lvl) { font-size: 14px; color: var(--ink-soft); }
.lkrow .lvl { flex: none; }
.cz { position: relative; }
.cz.lock { background: #e7edf0; cursor: help; }
.cz.lock img { filter: grayscale(1) brightness(.75) contrast(.8); opacity: .55; }
.cz.lock span { opacity: .5; }
.lkb { position: absolute; right: 3px; bottom: 3px; display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px 2px 4px; border-radius: 9px; background: var(--ink); color: #fff; font: 800 12px/1 Nunito, sans-serif; }
.lkb svg { width: 11px; height: 11px; }
.cz.new::after, .tdot { content: ""; position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 0 2px #fff; }
.ctabs .opt { position: relative; }
.tdot { top: -3px; right: -3px; width: 10px; height: 10px; }
.csub { margin: 2px 0 0; font-size: 14px; }
.csub small { color: var(--ink-soft); font-weight: 700; }
.swb.auto { position: relative; }
.swb.auto::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; border: 2px dashed #fff; }
.nbadge { display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; margin-left: auto; padding: 0 .3em; border-radius: .7em; background: var(--pink); color: #fff; font: 800 .45em/1 Nunito, sans-serif; }
.nbadge[hidden] { display: none; }
.lvlup { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; padding: 10px 14px; border-radius: 14px; background: #fff3c4; box-shadow: 0 0 0 2px var(--sun); }
.lvlup b { font-family: var(--f-chunk); font-size: 24px; color: var(--pink-deep); }
.lvlup span { font-size: 15px; }

/* ---------- COMPTE GOOGLE ---------- */
.acct { display: flex; align-items: center; gap: 10px; border: 0; background: var(--field); border-radius: 12px; padding: 8px 10px; font-size: 14px; text-align: left; color: var(--ink); }
.acct img, .accrow img { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.acct:hover span { text-decoration: underline; }
.gdot { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; background: #fff; color: #4285f4; font-style: normal; font-weight: 900; box-shadow: 0 0 0 2px var(--card-edge); }
.icons:has(#acct-btn:not([hidden])) { grid-template-columns: repeat(5, 1fr); }
#acct-btn.on svg { color: #1c8a50; }
.accrow { display: flex; align-items: center; gap: 12px; }
.accrow img { width: 48px; height: 48px; }
.accrow b { font-size: 20px; }
.gbtn { min-height: 44px; display: flex; justify-content: center; }
.mcard .small { font-size: 13px; }
.mcard .err { color: #a0174f; }
/* Code secret (Réglages) */
.mcard .scode { display: flex; gap: 10px; align-items: center; }
.mcard .scode input { flex: 1; text-transform: uppercase; letter-spacing: .08em; }
.mcard .scode input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 700; }
.mcard .smsg { border-radius: 12px; padding: 8px 12px; font-weight: 800; }
.mcard .smsg.ok { background: #dff8e9; color: #1c8a50; }
.mcard .smsg.err { background: #ffe5ef; color: #a0174f; }

/* ---------- PSEUDOS AU-DESSUS DES TÊTES (salon et course) ---------- */
#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.ntag { position: absolute; left: 0; top: 0; transform-origin: 50% 100%; display: flex; flex-direction: column; align-items: center; gap: 3px; will-change: transform; }
.ntag b { font-weight: 900; font-size: 15px; color: #fff; background: rgba(20, 48, 74, .78); border-radius: 99px; padding: 3px 11px 3px 9px; white-space: nowrap; max-width: 170px; overflow: hidden; text-overflow: ellipsis; box-shadow: inset 4px 0 0 var(--c, #fff), 0 2px 6px rgba(20, 48, 74, .3); }
/* il parle : trois barres qui sautillent et un halo autour du pseudo */
.ntag .vb { display: flex; gap: 3px; align-items: flex-end; height: 16px; padding: 2px 6px; border-radius: 8px; background: #fff; box-shadow: 0 2px 0 var(--card-edge); opacity: 0; transform: translateY(4px) scale(.6); transition: opacity .15s, transform .15s; }
.ntag .vb i { width: 4px; height: 4px; border-radius: 2px; background: var(--c, var(--pink)); }
.ntag.talk .vb { opacity: 1; transform: none; }
.ntag.talk .vb i { animation: vbar .42s ease-in-out infinite alternate; }
.ntag.talk .vb i:nth-child(2) { animation-delay: -.14s; }
.ntag.talk .vb i:nth-child(3) { animation-delay: -.28s; }
.ntag.talk b { box-shadow: inset 4px 0 0 var(--c, #fff), 0 0 0 3px var(--c, #fff), 0 2px 10px rgba(20, 48, 74, .35); }
@keyframes vbar { from { height: 3px; } to { height: calc(12px * var(--lv, 1)); } }

/* ---------- SALON : chat vocal et danses ---------- */
.lbar { position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; gap: 10px; align-items: stretch; max-width: calc(100% - 32px); flex-wrap: wrap; justify-content: center; }
.lvoice { border: 0; display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-weight: 900; font-size: 14px; }
.lvoice svg { width: 20px; height: 20px; color: var(--ink-soft); }
.lvoice.on svg { color: #1c8a50; }
.lvoice.off svg { color: var(--pink); }
.lvoice.talk { box-shadow: 0 8px 0 var(--card-edge), 0 0 0 4px var(--mint), 0 18px 30px rgba(20, 48, 74, .25); }
.lready, .lleave { border: 0; display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-weight: 900; font-size: 14px; }
.lready svg { width: 20px; height: 20px; color: var(--ink-soft); }
.lready.on { background: var(--mint); }
.lready.on svg { color: #1c8a50; }
/* Joueurs invités : pas de fiche du salon (réservée à l'hôte), le panneau de la piscine suffit */
#room.guest .lsheet, #room.guest .roomtab { display: none; }
.ldances { display: flex; gap: 4px; padding: 5px; }
.ldances button { border: 0; border-radius: 14px; background: var(--field); padding: 6px 10px; font-weight: 900; font-size: 13px; display: flex; align-items: center; gap: 5px; }
.ldances button kbd { font-size: 11px; padding: 0 5px; }
.ldances button[aria-pressed="true"] { background: #9b7bff; color: #fff; }
@media (max-width: 900px) { #room:not(.collapsed):not(.guest) .lbar { display: none; } }
@media (pointer: coarse) { .lbar { bottom: calc(max(30px, env(safe-area-inset-bottom, 0px)) + 140px); } .ldances kbd { display: none; } }
@media (max-width: 560px) { .ldances button { padding: 6px 7px; font-size: 12px; } }

/* équipes : cartes cliquables */
.teams.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
button.team { border: 0; text-align: left; font: inherit; color: var(--ink); cursor: pointer; transition: transform .1s, box-shadow .1s; box-shadow: 0 4px 0 var(--card-edge); }
button.team:hover:not(:disabled) { transform: translateY(-2px); }
button.team b { display: flex; justify-content: space-between; gap: 6px; }
button.team b small { font-weight: 800; color: var(--ink-soft); }
button.team .free { color: var(--ink-soft); font-style: italic; font-weight: 700; }
button.team em { font-style: normal; margin-top: auto; padding: 6px; text-align: center; border-radius: 10px; background: #fff; font-weight: 900; font-size: 13px; }
button.team.mine { background: #fff; box-shadow: 0 0 0 3px var(--c), 0 4px 0 var(--card-edge); }
button.team.mine em { background: var(--c); color: #fff; }
button.team:disabled em { color: var(--ink-soft); }
.chip.vc { background: #e7f8ee; color: #1c8a50; }
.chip.vc.off { background: #ffe5ef; color: #a0174f; }

/* ---------- COURSE : micro et score des équipes ---------- */
.hmic { position: absolute; right: calc(max(16px, env(safe-area-inset-right, 0px)) + 62px); bottom: max(16px, env(safe-area-inset-bottom, 0px)); border: 0; width: 48px; height: 44px; display: grid; place-items: center; padding: 0; }
.hmic svg { width: 22px; height: 22px; color: #1c8a50; }
.hmic.off svg { color: var(--pink); }
.hmic.off::after { content: ""; position: absolute; width: 3px; height: 28px; background: var(--pink); transform: rotate(45deg); border-radius: 2px; }
.hmic.talk { box-shadow: 0 8px 0 var(--card-edge), 0 0 0 4px var(--mint); }
.hteams { position: absolute; left: 50%; top: calc(max(16px, env(safe-area-inset-top, 0px)) + 54px); transform: translateX(-50%); display: flex; gap: 14px; padding: 6px 14px; font-size: 15px; }
.hteams span { display: flex; align-items: center; gap: 6px; }
.hteams span::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.hteams span:last-child { flex-direction: row-reverse; }
.hteams b { font-family: var(--f-chunk); font-weight: 400; font-size: 22px; }
@media (max-width: 560px) { .hteams { top: calc(max(16px, env(safe-area-inset-top, 0px)) + 116px); } }
.tscore { display: flex; justify-content: center; gap: 18px; font-size: 18px; }
.tscore span { display: flex; align-items: center; gap: 8px; background: var(--field); border-radius: 14px; padding: 8px 14px; border-left: 6px solid var(--c); }
.tscore b { font-family: var(--f-chunk); font-weight: 400; font-size: 30px; }

/* ---------- PAS D'AIDES DE TOUCHES EN JEU ----------
   Les touches ne s'affichent que dans les menus (pause, panneau du salon, Commandes). */
#hud kbd, .lbar kbd { display: none; }
#hud .hcoach kbd { display: inline; } /* sauf dans l'entraînement, dont c'est le but */

/* ---------- LISIBILITÉ SUR TÉLÉPHONE ---------- */
@media (max-width: 820px) {
  /* profil visible (niveau et XP) dans une version compacte */
  .side { width: min(260px, 60vw); }
  .profile { display: flex; padding: 10px 12px; gap: 8px; }
  .lvl { width: 38px; height: 38px; font-size: 19px; }
  .pname { font-size: 20px; }
  .psub { font-size: 14px; }
  .xpbar { height: 24px; font-size: 12px; padding: 0 8px; }
  .acct { font-size: 13px; padding: 6px 8px; }
  .icons:has(#acct-btn:not([hidden])) { grid-template-columns: repeat(4, 1fr); }
  #acct-btn { display: none; }
  .foot { font-size: 14px; gap: 6px 16px; padding: 8px 14px; }
  .foot button { padding: 4px 0; }
  /* textes et cibles tactiles plus grands */
  .box p, .mcard p, .keyl, .tips { font-size: 16px; }
  .opt { padding: 12px 14px; min-height: 44px; font-size: 16px; }
  .back { min-height: 46px; padding: 12px 18px; font-size: 16px; }
  .big { font-size: 26px; padding: 14px 22px; }
  .mcard { padding: 20px 18px; }
  .mcard label { grid-template-columns: 6rem 1fr; font-size: 16px; }
  .mcard input[type=range] { height: 32px; }
  .mcard select { min-height: 44px; font-size: 16px; }
  .mcard input[type=text] { font-size: 16px; } /* 16 px minimum : iOS ne zoome pas sur le champ */
  .keyl { gap: 10px 12px; }
  kbd { font-size: 13px; }
  .players li, .rows li { font-size: 16px; }
  #toast { font-size: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + 140px); }
}
@media (max-width: 560px) {
  /* course : pause (et micro) en haut à droite, la barre de progression garde toute la largeur en bas */
  .hpause { top: calc(max(16px, env(safe-area-inset-top, 0px)) + 104px); bottom: auto; min-width: 48px; min-height: 44px; }
  .hmic { top: calc(max(16px, env(safe-area-inset-top, 0px)) + 160px); bottom: auto; right: max(16px, env(safe-area-inset-right, 0px)); }
  .hprog { width: calc(100% - 48px); }
  .hpos { padding: 8px 14px; }
  .hpos span { font-size: 15px; }
  .count { top: 52%; white-space: nowrap; font-size: clamp(64px, 19vw, 200px); }
  .hstatus { top: 30%; }
  .hwait { font-size: 16px; bottom: calc(max(20px, env(safe-area-inset-bottom, 0px)) + 150px); }
  .hcoach { top: calc(max(16px, env(safe-area-inset-top, 0px)) + 104px); width: calc(100% - 96px); left: max(16px, env(safe-area-inset-left, 0px)); transform: none; padding: 12px 14px; }
  .hcoach > b { font-size: 26px; }
  .hcoach p { font-size: 18px; }
  .hcoach .cmsg { font-size: 17px; }
  #hud.tuto .htime { top: max(16px, env(safe-area-inset-top, 0px)); }
  .sheet h2 { font-size: 44px; }
  .code b { font-size: 44px; }
}

/* Boosts sur téléphone : la case du bonus passe à gauche (la pause occupe la droite) */
@media (max-width: 560px) { .hitem { right: auto; left: max(16px, env(safe-area-inset-left, 0px)); top: calc(max(16px, env(safe-area-inset-top, 0px)) + 74px); width: 72px; } }
