/* ============================================================
   UNDERCOVER — Multijoueur
   Thème "arcade nocturne" (accent turquoise), 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:#5eead4;
  --accent-2:#99f6e4;
  --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(94,234,212,0.12), transparent 70%),
    radial-gradient(50% 40% at 90% 100%, rgba(167,139,250,0.08), 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 (Dynamic Island / status bar + home indicator) ===== */
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(94,234,212,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94,234,212,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;
  transition:border-color .15s, background .15s;
}
input:focus, select:focus{outline:none; border-color:var(--accent); background:rgba(0,0,0,0.35);}
.check-row{display:flex; align-items:center; gap:10px; margin-top:14px; color:var(--text); font-size:0.9rem;}
.check-row input{width:auto; accent-color:var(--accent); width:18px; height:18px;}

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, box-shadow .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:#06251f; border:none; font-weight:700;
  box-shadow:0 6px 20px rgba(94,234,212,0.28);
}
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(94,234,212,0.45);
}
.count-badge{
  font-family:var(--font-display); font-size:0.8rem; color:var(--accent);
  background:rgba(94,234,212,0.14); border:1px solid rgba(94,234,212,0.3);
  border-radius:20px; padding:2px 10px; margin-left:auto;
}

/* ---------- Liste joueurs ---------- */
#players-list, #game-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.45;}
.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-role, .tag-ok{
  font-size:0.68rem; font-weight:600; padding:1px 7px; border-radius:10px; margin-left:4px;
}
.tag-host{background:rgba(94,234,212,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-ok{background:rgba(52,211,153,0.16); color:var(--success);}
.tag-role{background:rgba(255,255,255,0.08); color:var(--muted);}
.tag-role.civil{background:rgba(56,189,248,0.16); color:var(--info);}
.tag-role.undercover{background:rgba(251,113,133,0.16); color:var(--danger);}
.tag-role.white{background:rgba(251,191,36,0.16); color:var(--warn);}
.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 de tour ---------- */
.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);}
.phase-badge{
  font-family:var(--font-display); font-size:0.78rem; color:var(--accent);
  background:rgba(94,234,212,0.12); border:1px solid rgba(94,234,212,0.3);
  border-radius:20px; padding:6px 12px;
}

.turn-card{text-align:center;}
.turn-role{font-family:var(--font-display); font-weight:600; font-size:1.1rem; margin-bottom:8px;}

/* ---------- Carte du mot secret ---------- */
.word-card{
  margin:16px 0 4px; border-radius:18px; cursor:pointer;
  border:1px solid var(--line-2); background:rgba(0,0,0,0.3);
  min-height:150px; display:flex; align-items:center; justify-content:center;
  padding:20px; transition:border-color .2s, background .2s;
  user-select:none;
}
.word-card:hover{border-color:var(--accent);}
.word-hidden{display:flex; flex-direction:column; align-items:center; gap:10px; font-size:2rem; color:var(--muted);}
.word-hidden span{font-size:0.85rem; letter-spacing:0.05em;}
.word-role{
  font-size:0.75rem; text-transform:uppercase; letter-spacing:0.18em;
  color:var(--muted); margin-bottom:8px;
}
.word-value{
  font-family:var(--font-display); font-weight:700; font-size:2.2rem; line-height:1.15;
  color:var(--accent); text-shadow:0 0 28px rgba(94,234,212,0.35); word-break:break-word;
}
.word-value.white{color:var(--warn); text-shadow:0 0 28px rgba(251,191,36,0.35); font-size:1.6rem;}
.word-note{font-size:0.8rem; color:var(--dim); margin-top:10px; line-height:1.5;}
.fill-status{font-size:0.82rem; color:var(--muted); margin-top:12px;}

/* ---------- Vote ---------- */
.vote-list{display:flex; flex-direction:column; gap:8px; margin-top:6px;}
.vote-btn{
  width:100%; margin:0; text-align:left; display:flex; align-items:center; gap:10px;
  background:rgba(0,0,0,0.22); border:1px solid var(--line);
}
.vote-btn.selected{border-color:var(--accent); background:rgba(94,234,212,0.12); color:var(--text);}
.vote-btn .vb-name{flex:1;}
.vote-btn .vb-mark{color:var(--accent); font-weight:700;}

/* ---------- Indices ---------- */
.clues{display:flex; flex-direction:column; gap:6px; max-height:260px; overflow-y:auto;}
.clue-round{font-size:0.72rem; text-transform:uppercase; letter-spacing:0.12em; color:var(--dim); margin-top:8px;}
.clue-round:first-child{margin-top:0;}
.clue-item{
  display:flex; align-items:baseline; gap:8px; font-size:0.9rem;
  padding:8px 11px; border-radius:10px; background:rgba(0,0,0,0.2);
}
.clue-who{color:var(--muted); font-size:0.8rem; flex:none; min-width:70px;}
.clue-text{flex:1; font-weight:500; word-break:break-word;}
.clues-empty{color:var(--dim); font-size:0.85rem; font-style:italic; text-align:center; padding:8px;}

/* ---------- Résultat de tour ---------- */
.res-name{font-family:var(--font-display); font-weight:700; font-size:1.5rem; margin:6px 0;}
.res-role{display:inline-block; margin:8px 0; padding:5px 14px; border-radius:20px; font-weight:600; font-size:0.9rem;}
.res-role.civil{background:rgba(56,189,248,0.16); color:var(--info);}
.res-role.undercover{background:rgba(251,113,133,0.16); color:var(--danger);}
.res-role.white{background:rgba(251,191,36,0.16); color:var(--warn);}
.tally{display:flex; flex-direction:column; gap:5px; margin-top:14px; text-align:left;}
.tally-row{display:flex; align-items:center; gap:8px; font-size:0.85rem; color:var(--muted);}
.tally-bar{height:8px; border-radius:6px; background:var(--accent); min-width:6px;}

/* ---------- 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(94,234,212,0.35));}
.trophy svg{width:100%; height:100%;}
.end-card h2{border:none; justify-content:center; font-size:1.4rem; display:block; margin-bottom:14px;}
.end-words{display:flex; flex-direction:column; gap:8px; margin-bottom:18px;}
.end-word{padding:12px; border-radius:14px; background:rgba(0,0,0,0.22); border:1px solid var(--line);}
.end-word .ew-label{font-size:0.72rem; text-transform:uppercase; letter-spacing:0.14em; color:var(--muted);}
.end-word .ew-value{font-family:var(--font-display); font-weight:700; font-size:1.2rem; margin-top:3px;}
.end-word.civil .ew-value{color:var(--info);}
.end-word.under .ew-value{color:var(--danger);}
#final-roles{display:flex; flex-direction:column; gap:7px; margin-bottom:18px;}
.final-row{
  display:flex; align-items:center; gap:10px;
  padding:10px 14px; border-radius:12px;
  background:rgba(0,0,0,0.22); border:1px solid var(--line);
}
.final-row .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.82); 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;}

/* --- Mode performance : écran étroit OU appareil tactile --- */
@media (max-width: 780px), (hover: none) and (pointer: coarse){
  .card{backdrop-filter:none; -webkit-backdrop-filter:none;}
  button{padding:13px 20px;}
  .vote-btn{min-height:46px;}
}
