/* ============================================================
   PÉRUDO — Multijoueur
   Thème "arcade nocturne" (accent orange), cohérent avec le hub.
   ============================================================ */
:root{
  --bg:#0a0e1a;
  --surface:rgba(255,255,255,0.04);
  --surface-2:rgba(255,255,255,0.07);
  --line:rgba(255,255,255,0.10);
  --line-2:rgba(255,255,255,0.16);
  --text:#eef1f8;
  --muted:#9aa3bd;
  --dim:#626b86;
  --accent:#f97316;
  --accent-2:#fdba74;
  --success:#34d399;
  --info:#38bdf8;
  --warn:#fbbf24;
  --danger:#fb7185;
  --panel-solid:#131a2c;
  --font-display:'Space Grotesk', system-ui, sans-serif;
  --font-body:'Inter', system-ui, sans-serif;
}
*{margin:0;padding:0;box-sizing:border-box;}
html{-webkit-text-size-adjust:100%;}
body{
  font-family:var(--font-body);
  background:
    radial-gradient(60% 45% at 50% 0%, rgba(249,115,22,0.13), transparent 70%),
    radial-gradient(50% 40% at 90% 100%, rgba(251,191,36,0.07), transparent 70%),
    var(--bg);
  color:var(--text);
  min-height:100vh; min-height:100dvh;
  -webkit-font-smoothing:antialiased;
  padding-bottom:calc(40px + env(safe-area-inset-bottom));
}

/* ===== Intégration iOS ===== */
body::before, body::after{
  content:""; position:fixed; left:0; right:0; z-index:60; pointer-events:none;
  background:rgba(0,0,0,0.18);
  -webkit-backdrop-filter:saturate(140%) blur(16px);
  backdrop-filter:saturate(140%) blur(16px);
}
body::before{ top:0; height:env(safe-area-inset-top); }
body::after{ bottom:0; height:env(safe-area-inset-bottom); }

.bg-grid{
  position:fixed; inset:0; z-index:0; pointer-events:none;
  background-image:
    linear-gradient(rgba(249,115,22,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(249,115,22,0.03) 1px, transparent 1px);
  background-size:48px 48px;
  mask-image:radial-gradient(ellipse 90% 55% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image:radial-gradient(ellipse 90% 55% at 50% 0%, #000 30%, transparent 75%);
}

/* ---------- Header ---------- */
.app-header{
  position:relative; z-index:1; text-align:center;
  padding:calc(26px + env(safe-area-inset-top)) 16px 18px;
  border-bottom:1px solid var(--line);
}
.app-header h1{
  font-family:var(--font-display); font-weight:700; font-size:1.5rem;
  letter-spacing:-0.01em; display:inline-flex; align-items:center; gap:10px;
}
.game-logo{width:30px; height:30px; color:var(--accent); filter:drop-shadow(0 2px 8px var(--accent));}
.home-btn{
  position:absolute; left:16px; top:calc(24px + env(safe-area-inset-top));
  width:40px; height:40px; display:flex; align-items:center; justify-content:center;
  border-radius:12px; background:var(--surface); border:1px solid var(--line);
  color:var(--muted); transition:color .15s, border-color .15s;
}
.home-btn:hover{color:var(--accent); border-color:var(--accent);}
.home-btn svg{width:20px; height:20px;}

/* ---------- Layout ---------- */
.wrap{position:relative; z-index:1; max-width:560px; margin:0 auto; padding:16px;}
.screen{display:none;}
.screen.active{display:block; animation:fade .25s ease;}
@keyframes fade{from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:none;}}

.card{
  background:var(--surface); border:1px solid var(--line);
  border-radius:18px; padding:18px; margin-bottom:14px;
  box-shadow:0 8px 30px rgba(0,0,0,0.25);
  backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
}
.card h2{
  font-family:var(--font-display); font-weight:600; font-size:1rem;
  border-bottom:1px solid var(--line); padding-bottom:10px; margin-bottom:14px;
  display:flex; align-items:center; gap:8px;
}

label{display:block; font-size:0.82rem; color:var(--muted); font-weight:500; margin:12px 0 5px;}
input[type=text], select{
  width:100%; padding:12px; border-radius:12px;
  border:1px solid var(--line); background:rgba(0,0,0,0.25);
  color:var(--text); font-family:var(--font-body); font-size:0.95rem;
}
input:focus, select:focus{outline:none; border-color:var(--accent); background:rgba(0,0,0,0.35);}
.check-row{display:flex; align-items:flex-start; gap:10px; margin-top:14px; color:var(--text); font-size:0.88rem; line-height:1.45;}
.check-row input{width:18px; height:18px; flex:none; accent-color:var(--accent); margin-top:1px;}

button{
  font-family:var(--font-body); font-weight:600; cursor:pointer;
  border-radius:12px; padding:13px 18px; font-size:0.95rem;
  border:1px solid var(--line); background:var(--surface-2); color:var(--text);
  transition:transform .12s, background .18s, border-color .18s, filter .18s;
  margin-top:12px;
}
button:active{transform:scale(0.98);}
button.primary{
  width:100%;
  background:linear-gradient(120deg, var(--accent), var(--accent-2));
  color:#2b1405; border:none; font-weight:700;
  box-shadow:0 6px 20px rgba(249,115,22,0.30);
}
button.primary:hover{filter:brightness(1.06); transform:translateY(-2px);}
button.ghost{background:transparent; border:1px solid var(--line-2); color:var(--muted);}
button.ghost:hover{background:var(--surface); color:var(--text);}
button.full{width:100%;}
button:disabled{opacity:0.4; cursor:not-allowed; transform:none; box-shadow:none; filter:none;}

.hint{font-size:0.8rem; color:var(--dim); margin-top:10px; line-height:1.5;}
.or-sep{display:flex; align-items:center; gap:12px; margin:6px 2px 18px; color:var(--dim);}
.or-sep::before,.or-sep::after{content:""; flex:1; height:1px; background:var(--line);}
.or-sep span{font-size:0.8rem; text-transform:uppercase; letter-spacing:0.1em;}

/* ---------- Code de salon ---------- */
.code-input{text-transform:uppercase; letter-spacing:0.4em; font-family:var(--font-display); font-size:1.3rem; text-align:center;}
.code-card{text-align:center;}
.code-label{font-size:0.8rem; text-transform:uppercase; letter-spacing:0.15em; color:var(--muted); margin-bottom:8px;}
.code-display{
  font-family:var(--font-display); font-weight:700; font-size:3rem;
  letter-spacing:0.35em; text-indent:0.35em;
  color:var(--accent); text-shadow:0 0 24px rgba(249,115,22,0.45);
}
.count-badge{
  font-family:var(--font-display); font-size:0.8rem; color:var(--accent);
  background:rgba(249,115,22,0.14); border:1px solid rgba(249,115,22,0.3);
  border-radius:20px; padding:2px 10px; margin-left:auto;
}

/* ---------- Joueurs ---------- */
#players-list, #table-players{display:flex; flex-direction:column;}
.player-row{
  display:flex; align-items:center; gap:8px; padding:9px 4px;
  border-top:1px solid var(--line);
}
.player-row:first-child{border-top:none;}
.player-row.dead{opacity:0.42;}
.player-row.turn{background:rgba(249,115,22,.08); border-radius:10px;}
.pr-dot{width:8px; height:8px; border-radius:50%; background:var(--success); flex:none;}
.pr-dot.off{background:#5a637d;}
.pr-name{flex:1; font-size:0.95rem;}
.player-row.dead .pr-name{text-decoration:line-through;}
.tag-host,.tag-you,.tag-off,.tag-turn{
  font-size:0.68rem; font-weight:600; padding:1px 7px; border-radius:10px; margin-left:4px;
}
.tag-host{background:rgba(249,115,22,0.15); color:var(--accent);}
.tag-you{background:rgba(56,189,248,0.16); color:var(--info);}
.tag-off{background:rgba(148,163,184,0.15); color:#94a3b8;}
.tag-turn{background:rgba(251,191,36,0.16); color:var(--warn);}
.pr-dice{display:flex; gap:3px; align-items:center;}
.mini-die{
  width:11px; height:11px; border-radius:3px;
  background:var(--accent); box-shadow:0 0 6px rgba(249,115,22,.5);
}
.mini-die.lost{background:rgba(255,255,255,.12); box-shadow:none;}
.kick-btn{
  flex:none; width:30px; height:30px; margin:0; padding:0;
  border-radius:8px; font-size:0.9rem; line-height:1;
  background:rgba(251,113,133,0.12); border:1px solid rgba(251,113,133,0.3);
  color:var(--danger);
}
.settings-summary{display:flex; flex-wrap:wrap; gap:8px;}
.sum-chip{
  font-size:0.8rem; color:var(--muted);
  background:rgba(255,255,255,0.05); border:1px solid var(--line);
  border-radius:20px; padding:5px 12px;
}
.lobby-actions{margin-top:4px;}
.waiting-note{text-align:center;}

/* ---------- Entête ---------- */
.round-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; gap:10px;}
.round-badge{
  font-family:var(--font-display); font-size:0.9rem; color:var(--muted);
  background:var(--surface); border:1px solid var(--line);
  border-radius:20px; padding:6px 14px;
}
.round-badge b{color:var(--accent);}
.dice-badge{
  font-family:var(--font-display); font-size:0.82rem; color:var(--accent);
  background:rgba(249,115,22,0.12); border:1px solid rgba(249,115,22,0.3);
  border-radius:20px; padding:6px 12px;
}

/* ============================================================
   LES DÉS
   ============================================================ */
.my-dice-card{text-align:center; padding:16px 18px;}
.mydice-lab{
  font-size:0.75rem; text-transform:uppercase; letter-spacing:0.16em;
  color:var(--muted); margin-bottom:12px;
}
.secret-note{text-transform:none; letter-spacing:0; color:var(--dim); font-size:0.72rem;}
.dice-row{display:flex; justify-content:center; flex-wrap:wrap; gap:9px;}

.die{
  width:46px; height:46px; border-radius:11px;
  background:linear-gradient(160deg,#fff8f2,#f0e2d6);
  box-shadow:0 3px 10px rgba(0,0,0,.45), inset 0 -2px 4px rgba(0,0,0,.12);
  display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(3,1fr);
  padding:6px; flex:none;
}
.die .pip{width:8px; height:8px; border-radius:50%; background:#1e1b16; align-self:center; justify-self:center;}
/* Le 1 est joker : on le distingue nettement */
.die.joker{background:linear-gradient(160deg,#ffd9a8,#f9a03f); box-shadow:0 3px 12px rgba(249,115,22,.5);}
.die.joker .pip{background:#5a2c06;}
.die.small{width:34px; height:34px; border-radius:9px; padding:4px;}
.die.small .pip{width:6px; height:6px;}

/* Positions des points dans la grille 3×3 */
.p-tl{grid-area:1/1;} .p-tc{grid-area:1/2;} .p-tr{grid-area:1/3;}
.p-ml{grid-area:2/1;} .p-mc{grid-area:2/2;} .p-mr{grid-area:2/3;}
.p-bl{grid-area:3/1;} .p-bc{grid-area:3/2;} .p-br{grid-area:3/3;}

/* ---------- Enchère en cours ---------- */
.bid-card{text-align:center; padding:16px 18px;}
.bid-current{font-size:0.95rem; color:var(--muted); line-height:1.5;}
.bid-big{
  display:flex; align-items:center; justify-content:center; gap:10px; margin-top:6px;
  font-family:var(--font-display); font-weight:700; font-size:1.7rem; color:var(--accent);
}
.bid-who{font-size:0.8rem; color:var(--dim); margin-top:4px;}

/* ---------- Mon tour ---------- */
.turn-card{text-align:center;}
.turn-role{font-family:var(--font-display); font-weight:600; font-size:1.1rem; margin-bottom:10px;}
.bid-builder{
  background:rgba(0,0,0,.22); border:1px solid var(--line);
  border-radius:14px; padding:14px; margin-bottom:4px;
}
.bb-row{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px;}
.bb-row:last-child{margin-bottom:0; flex-direction:column; align-items:stretch; gap:8px;}
.bb-lab{font-size:0.85rem; color:var(--muted);}
.stepper{display:flex; align-items:center; gap:10px;}
.step{
  width:40px; height:40px; margin:0; padding:0; border-radius:11px;
  font-size:1.3rem; font-weight:700; line-height:1;
  background:var(--surface-2); border:1px solid var(--line-2); color:var(--text);
}
.step-val{
  font-family:var(--font-display); font-weight:700; font-size:1.6rem;
  min-width:34px; text-align:center; color:var(--accent);
}
.face-picker{display:flex; justify-content:space-between; gap:6px;}
.face-opt{
  flex:1; margin:0; padding:6px 0; border-radius:11px;
  background:rgba(0,0,0,.25); border:1px solid var(--line);
  display:flex; align-items:center; justify-content:center;
}
.face-opt.selected{border-color:var(--accent); background:rgba(249,115,22,.14);}
.face-opt .die{width:30px; height:30px; border-radius:8px; padding:4px;}
.face-opt .die .pip{width:5px; height:5px;}

.challenge-row{display:flex; gap:10px; margin-top:10px;}
.challenge-row button{flex:1; margin-top:0;}
.exact-btn{border-color:rgba(52,211,153,.45) !important; color:var(--success) !important;}
.exact-btn:hover{background:rgba(52,211,153,.12) !important; color:#fff !important;}

/* ---------- Dévoilement ---------- */
.sd-verdict{
  font-family:var(--font-display); font-weight:700; font-size:1.25rem;
  margin:8px 0 4px;
}
.sd-count{font-size:0.92rem; color:var(--muted); margin-bottom:12px; line-height:1.5;}
.sd-count b{color:var(--accent); font-family:var(--font-display); font-size:1.1rem;}
.sd-player{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  padding:9px 11px; border-radius:11px; background:rgba(0,0,0,.22); margin-bottom:6px;
}
.sd-player.dead{opacity:.45;}
.sd-name{font-size:0.88rem; min-width:74px; text-align:left; flex:none;}
.sd-dice{display:flex; gap:5px; flex-wrap:wrap;}
.sd-change{
  font-family:var(--font-display); font-weight:700; margin-top:10px; font-size:1.05rem;
}
.sd-change.minus{color:var(--danger);}
.sd-change.plus{color:var(--success);}

/* ---------- Fin ---------- */
.end-card{text-align:center;}
.trophy{color:var(--accent); width:64px; height:64px; margin:0 auto 12px; filter:drop-shadow(0 4px 16px rgba(249,115,22,0.35));}
.trophy svg{width:100%; height:100%;}
.end-card h2{border:none; justify-content:center; font-size:1.4rem; display:block; margin-bottom:16px;}
#final-list{display:flex; flex-direction:column; gap:7px; margin-bottom:18px;}
.final-row{
  display:flex; align-items:center; gap:10px;
  padding:11px 14px; border-radius:12px;
  background:rgba(0,0,0,0.22); border:1px solid var(--line);
}
.final-row.first{border-color:rgba(249,115,22,0.4); background:rgba(249,115,22,0.08);}
.fr-name{flex:1; text-align:left; font-weight:600;}

/* ---------- Zone hôte ---------- */
.emergency-card{border-color:rgba(251,113,133,0.25);}
.danger-btn{border-color:rgba(251,113,133,0.45) !important; color:var(--danger) !important;}
.danger-btn:hover{background:rgba(251,113,133,0.12) !important; color:#fff !important;}

/* ---------- Modale ---------- */
.modal-bg{
  display:none; position:fixed; inset:0; z-index:80;
  background:rgba(5,8,16,0.85); align-items:center; justify-content:center; padding:18px;
}
.modal-bg.active{display:flex;}
.modal{
  background:var(--panel-solid); border:1px solid var(--line-2); border-radius:18px;
  padding:22px; max-width:460px; width:100%; max-height:82vh; overflow-y:auto;
}
.modal h3{font-family:var(--font-display); color:var(--accent); margin-bottom:12px;}
.modal-body p{font-size:0.88rem; color:var(--muted); line-height:1.6; margin-bottom:12px;}
.modal-body b{color:var(--text);}

/* ---------- Toast ---------- */
.toast{
  position:fixed; left:50%; bottom:calc(24px + env(safe-area-inset-bottom));
  transform:translate(-50%, 20px);
  background:var(--panel-solid); border:1px solid var(--line-2);
  color:var(--text); font-size:0.9rem; font-weight:500;
  padding:12px 20px; border-radius:14px;
  box-shadow:0 12px 40px rgba(0,0,0,0.5);
  opacity:0; pointer-events:none; transition:opacity .2s, transform .2s;
  z-index:100; max-width:90%; text-align:center;
}
.toast.show{opacity:1; transform:translate(-50%, 0);}

*::-webkit-scrollbar{width:8px; height:8px;}
*::-webkit-scrollbar-thumb{background:rgba(255,255,255,0.12); border-radius:8px;}

@media (max-width:780px), (hover:none) and (pointer:coarse){
  .card{backdrop-filter:none; -webkit-backdrop-filter:none;}
}
@media (max-width:420px){
  .die{width:40px; height:40px; border-radius:10px; padding:5px;}
  .die .pip{width:7px; height:7px;}
  .face-opt .die{width:26px; height:26px;}
  .code-display{font-size:2.5rem;}
  .sd-name{min-width:62px; font-size:0.82rem;}
}
