/* ================================================================
   Undercover — Thème Noir/Or v3
   Responsive corrigé · Sélecteur rôles · Modal vote · Timer indice
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-0:       #0a0a0a;
  --bg-1:       #111111;
  --bg-2:       #181818;
  --surface:    #1e1e1e;
  --surface-2:  #252525;
  --border:     rgba(255,255,255,0.08);
  --border-gold:rgba(212,175,55,0.35);
  --text:       #f0ece4;
  --text-dim:   #9a9080;
  --text-faint: #5a5248;
  --gold:       #d4af37;
  --gold-light: #f0d060;
  --gold-dark:  #a07820;
  --danger:     #e05555;
  --success:    #4caf7a;
  --warning:    #e0a030;
  --civil:      #4caf7a;
  --undercover: #e05555;
  --mrwhite:    #e0a030;
  --radius:     12px;
  --shadow:     0 8px 32px rgba(0,0,0,0.6);
}

html, body {
  min-height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(212,175,55,.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(212,175,55,.03) 0%, transparent 50%);
}

#app { position: relative; z-index: 1; min-height: 100vh; display: flex; justify-content: center; padding: 20px 16px 40px; }

/* ── Son ── */
.sound-btn {
  position: fixed; top: 14px; right: 14px; z-index: 999;
  background: var(--surface); border: 1px solid var(--border-gold);
  border-radius: 50%; width: 40px; height: 40px;
  font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.sound-btn:hover { background: var(--surface-2); }
.sound-btn.muted { opacity: .4; }

/* ── Screens ── */
.screen { display: none; width: 100%; max-width: 760px; animation: fadeIn .3s ease; }
.screen.active { display: block; }
#screen-game { max-width: 960px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card.hero { text-align: center; padding: 40px 28px; border-color: var(--border-gold); }

/* ── Hero ── */
.hero-icon { font-size: 52px; margin-bottom: 8px; }
.title {
  font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); text-shadow: 0 0 40px rgba(212,175,55,.3);
  margin-bottom: 6px;
}
.subtitle { color: var(--text-dim); font-style: italic; margin-bottom: 28px; }

/* ── Accueil ── */
.home-actions { display: flex; gap: 24px; flex-wrap: wrap; text-align: left; margin-bottom: 24px; }
.home-block { flex: 1; min-width: 200px; }
.home-block h2 { font-size: .9rem; color: var(--gold); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .08em; }
.divider { display: flex; align-items: center; padding-top: 24px; color: var(--text-faint); font-size: .85rem; }

/* ── Inputs ── */
input[type="text"],
input[type="number"],
input[type="password"] {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 11px 14px;
  font-size: 16px; /* 16px min pour éviter le zoom iOS */
  font-family: inherit;
  margin-bottom: 10px;
  transition: border-color .2s;
  -webkit-appearance: none;
}
input:focus { outline: none; border-color: var(--gold-dark); box-shadow: 0 0 0 2px rgba(212,175,55,.1); }
input.uppercase { text-transform: uppercase; letter-spacing: .15em; text-align: center; }
input[type="number"] { width: 80px; text-align: center; }

/* ── Boutons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; font-family: inherit;
  cursor: pointer;
  transition: all .18s;
  width: 100%; margin-top: 6px;
}
.btn:hover  { background: var(--bg-2); border-color: var(--border-gold); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--gold-dark), var(--gold)); border-color: var(--gold); color: #0a0a0a; font-weight: 700; }
.btn.primary:hover { background: linear-gradient(135deg, var(--gold), var(--gold-light)); }
.btn.ghost   { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn.ghost:hover { border-color: var(--gold-dark); color: var(--text); }
.btn.small   { width: auto; padding: 7px 14px; font-size: .85rem; margin-top: 0; }
.btn-icon    { background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 4px 6px; color: var(--text-dim); transition: color .18s; }
.btn-icon:hover { color: var(--gold); }

/* ── Règles ── */
.rules summary { cursor: pointer; color: var(--text-dim); font-size: .9rem; padding: 8px 0; }
.rules-content { padding: 10px 0; font-size: .87rem; color: var(--text-dim); }
.rules-content ul { padding-left: 18px; }
.rules-content li { margin-bottom: 5px; }
.rules-content strong { color: var(--text); }

/* ── Lobby ── */
.room-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.room-header-left {}
.room-code-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); margin-bottom: 3px; }
.room-code { font-size: 2rem; font-weight: 700; letter-spacing: .2em; color: var(--gold); font-family: 'Courier New', monospace; }
.password-badge { font-size: .78rem; color: var(--text-dim); margin-top: 4px; }
.section { margin-bottom: 22px; }
.section h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--gold); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border-gold); }

/* ── Sélecteur de rôles ── */
.role-selector { background: var(--bg-2); border: 1px solid var(--border-gold); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.role-selector-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.role-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.role-row:last-of-type { border-bottom: none; }
.role-icon  { font-size: 1.1rem; width: 24px; text-align: center; }
.role-label { flex: 1; font-size: .9rem; }
.role-stepper { display: flex; align-items: center; gap: 10px; }
.stepper-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .18s;
}
.stepper-btn:hover { border-color: var(--gold); color: var(--gold); }
.stepper-btn:disabled { opacity: .3; cursor: not-allowed; }
.stepper-val { min-width: 24px; text-align: center; font-size: 1rem; font-weight: 700; color: var(--gold); }
.civil-row { background: rgba(76,175,122,.06); border-radius: 6px; padding: 8px 6px; border-bottom: none !important; }
.civil-val  { color: var(--civil); }
.role-error { color: var(--danger); font-size: .82rem; margin-top: 8px; }

/* ── Settings grid ── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.setting { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--text-dim); }
.setting span { font-size: .78rem; }
.setting input[type="number"] { width: 100%; }
.setting input[type="password"] { margin-bottom: 0; }
.setting.switch { flex-direction: row; align-items: center; gap: 10px; padding: 10px; background: var(--bg-2); border-radius: 8px; cursor: pointer; }
.setting.switch input { width: auto; margin: 0; }

/* ── Players list ── */
.players-list { list-style: none; padding: 0; margin: 0; }
.players-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
  margin-bottom: 6px; font-size: .9rem; gap: 8px; flex-wrap: wrap;
}
.players-list li.host { border-color: var(--border-gold); }
.players-list li.you  { color: var(--gold); }
.players-list li.disconnected { opacity: .4; }
.players-list li.eliminated   { opacity: .4; text-decoration: line-through; }
.players-list li .right { display: flex; align-items: center; gap: 8px; }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border-gold);
  color: var(--gold); border-radius: 20px;
  padding: 2px 10px; font-size: .75rem; font-weight: 700; min-width: 26px;
}

/* Custom words */
.custom-words summary { cursor: pointer; font-size: .85rem; color: var(--text-dim); padding: 6px 0; }
.custom-words-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.custom-words-form input { flex: 1; min-width: 110px; margin-bottom: 0; }
.pairs-list { list-style: none; padding: 0; }
.pairs-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; font-size: .83rem; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.hint { color: var(--text-faint); font-size: .8rem; margin-top: 6px; font-style: italic; }

/* ── Rôle ── */
.role-card { text-align: center; }
.role-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 28px; border-radius: 10px;
  font-size: 1.1rem; font-weight: 700; margin: 14px 0;
  border: 2px solid var(--border); background: var(--bg-2);
  color: var(--text-dim); letter-spacing: .04em;
}
.role-badge.mrwhite { border-color: var(--mrwhite); color: var(--mrwhite); }

.role-word-container { margin: 14px 0; }
.role-word-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.role-word {
  font-size: 1.9rem; font-weight: 700; color: var(--gold); letter-spacing: .06em;
  transition: filter .3s;
}
.role-word.masked { color: var(--text-faint); letter-spacing: .2em; filter: none; }

.masked-word { color: var(--text-faint); letter-spacing: .2em; }
.masked-word.revealed { color: var(--gold); letter-spacing: .06em; }

.btn-eye {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
  font-size: 1rem; color: var(--text-dim); transition: all .18s;
}
.btn-eye:hover { border-color: var(--gold-dark); color: var(--gold); }
.btn-eye-mini {
  background: none; border: none; cursor: pointer;
  font-size: .85rem; color: var(--text-faint); padding: 2px 4px;
  transition: color .18s; vertical-align: middle;
}
.btn-eye-mini:hover { color: var(--gold); }

/* ── Game layout (main + sidebar) ── */
.game-layout { display: flex; gap: 16px; align-items: flex-start; width: 100%; }
.game-card   { flex: 1; min-width: 0; }
.sidebar {
  width: 210px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto;
}
.sidebar h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--gold); margin-bottom: 10px; }
#sidebar-list { list-style: none; padding: 0; margin: 0 0 14px; }
#sidebar-list li {
  padding: 6px 8px; border-radius: 6px; font-size: .82rem;
  margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center;
}
#sidebar-list li.current    { background: rgba(212,175,55,.12); color: var(--gold); }
#sidebar-list li.eliminated { opacity: .35; text-decoration: line-through; }
#sidebar-list li.voted      { color: var(--success); }
#sidebar-list li.host-player::before { content: "👑 "; }
#sidebar-list li .typing-dot { font-size: .7rem; color: var(--gold); animation: blink .8s infinite; }
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:.2;} }

#clue-history-details summary { font-size: .72rem; color: var(--text-faint); cursor: pointer; }
.clue-history { list-style: none; padding: 0; margin: 6px 0 0; max-height: 260px; overflow-y: auto; }
.clue-history li { font-size: .76rem; padding: 4px 0; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.clue-history li strong { color: var(--text); }

/* ── Game header ── */
.game-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border-gold); gap: 8px; }
.your-word-mini { font-size: .83rem; color: var(--text-dim); margin-top: 4px; }
.room-mini { font-size: .78rem; color: var(--text-faint); text-align: right; white-space: nowrap; }
.room-mini strong { color: var(--gold); font-size: .95rem; letter-spacing: .1em; }

/* ── Phases ── */
.phase { }
.phase.hidden { display: none; }
.phase h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); margin: 0 0 12px; }

/* Timers communs */
.timer-wrap-common {
  height: 5px; background: var(--bg-2); border-radius: 4px;
  margin-bottom: 6px; overflow: hidden;
}
#clue-timer-wrap, #vote-timer-wrap {
  height: 5px; background: var(--bg-2); border-radius: 4px;
  margin-bottom: 6px; overflow: hidden;
}
#clue-timer-bar, #vote-timer-bar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  border-radius: 4px; transition: width 1s linear;
}
#clue-timer-bar.urgent, #vote-timer-bar.urgent {
  background: linear-gradient(90deg, var(--danger), #ff8888);
}
.timer-text { font-size: .78rem; color: var(--text-dim); text-align: right; margin-bottom: 10px; }

/* Clues list */
.clues-list { list-style: none; padding: 0; margin: 0 0 14px; }
.clues-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 13px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
  margin-bottom: 6px; font-size: .88rem; gap: 8px;
}
.clues-list li.current { border-color: var(--gold); background: rgba(212,175,55,.06); }
.clues-list li.done    { opacity: .65; }
.clue-text { color: var(--text-dim); font-style: italic; font-size: .83rem; }
.clue-text.filled { color: var(--gold-light); font-style: normal; font-weight: 600; }
.clue-text.typing { color: var(--gold); animation: blink .7s infinite; }

.input-zone { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.input-zone input  { flex: 1; min-width: 160px; margin-bottom: 0; }
.input-zone .btn   { width: auto; margin-top: 0; flex-shrink: 0; }

/* Vote list */
.vote-list { list-style: none; padding: 0; margin: 0 0 12px; }
.vote-list li { margin-bottom: 7px; }
.vote-list button {
  width: 100%; padding: 11px 16px; text-align: left;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-size: 16px; font-family: inherit; cursor: pointer; transition: all .18s;
}
.vote-list button:hover:not(:disabled) { border-color: var(--gold-dark); background: rgba(212,175,55,.06); }
.vote-list button.selected { border-color: var(--gold); background: rgba(212,175,55,.12); color: var(--gold); font-weight: 700; }
.vote-list button:disabled { opacity: .38; cursor: not-allowed; }

.row-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.row-buttons .btn { flex: 1; min-width: 120px; }

.votes-summary { list-style: none; padding: 0; margin: 6px 0 14px; font-size: .83rem; color: var(--text-dim); }
.votes-summary li { padding: 4px 0; border-bottom: 1px solid var(--border); }

/* Reveal box */
.reveal-box { background: var(--bg-2); border: 1px solid var(--border-gold); border-radius: 10px; padding: 18px; margin-bottom: 16px; text-align: center; }
.reveal-box h2 { margin-bottom: 8px; color: var(--gold); font-size: 1.2rem; }
.reveal-box p  { color: var(--text-dim); font-size: .88rem; margin: 5px 0; }
.reveal-box.civils     { border-color: var(--civil);      } .reveal-box.civils h2     { color: var(--civil);      }
.reveal-box.undercover { border-color: var(--undercover); } .reveal-box.undercover h2 { color: var(--undercover); }
.reveal-box.mrwhite    { border-color: var(--mrwhite);    } .reveal-box.mrwhite h2    { color: var(--mrwhite);    }

#reveal-tie-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
#reveal-tie-actions .btn { flex: 1; }

/* Role tags */
.role-tag { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .73rem; font-weight: 700; letter-spacing: .04em; }
.role-tag.civil      { background: rgba(76,175,122,.15);  color: var(--civil);      border: 1px solid var(--civil);      }
.role-tag.undercover { background: rgba(224,85,85,.15);   color: var(--undercover); border: 1px solid var(--undercover); }
.role-tag.mrwhite    { background: rgba(224,160,48,.15);  color: var(--mrwhite);    border: 1px solid var(--mrwhite);    }

/* Scores */
.scores-list { list-style: none; padding: 0; margin: 0 0 14px; }
.scores-list li { display: flex; justify-content: space-between; align-items: center; padding: 9px 13px; border-radius: 8px; background: var(--bg-2); margin-bottom: 5px; font-size: .88rem; }
.scores-list li.winner { border: 1px solid var(--gold); color: var(--gold); }
.scores-list .pts { font-weight: 700; color: var(--gold); }
.scores-list.big li { padding: 13px 16px; font-size: .95rem; }

/* Mr. White */
#mrwhite-info { margin-bottom: 16px; text-align: center; }
#mrwhite-info h2 { color: var(--mrwhite); margin-bottom: 8px; }

/* Game over */
#screen-gameover .card { text-align: center; }
#screen-gameover h2 { color: var(--gold); margin-bottom: 20px; font-size: 1.5rem; }

/* ── Modal confirmation vote ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--surface); border: 1px solid var(--border-gold);
  border-radius: var(--radius); padding: 28px 24px;
  max-width: 340px; width: 100%; text-align: center;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 1.1rem; margin-bottom: 8px; }
.modal-title strong { color: var(--danger); }
.modal-sub   { font-size: .83rem; color: var(--text-dim); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; margin-top: 0; }

/* ── Host/guest visibility ── */
body:not(.is-host) .host-only { display: none !important; }
body.is-host .guest-only      { display: none !important; }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border-gold); color: var(--text); padding: 11px 22px; border-radius: 8px; font-size: .88rem; z-index: 9999; white-space: nowrap; box-shadow: var(--shadow); }
.toast.hidden { display: none; }

/* ── Conn banner ── */
.conn-banner { position: fixed; top: 0; left: 0; right: 0; background: var(--danger); color: #fff; text-align: center; padding: 8px; font-size: .83rem; z-index: 9998; }
.conn-banner.hidden { display: none; }

/* ── Responsive ── */
@media (max-width: 700px) {
  #app { padding: 10px 10px 32px; }
  .card { padding: 18px 14px; }
  .card.hero { padding: 28px 14px; }

  .home-actions { flex-direction: column; gap: 14px; }
  .divider { display: none; }

  /* Game : sidebar sous la carte principale, largeurs identiques */
  .game-layout { flex-direction: column; gap: 12px; width: 100%; }

  /* game-card et sidebar : même largeur, même box-sizing, bords alignés */
  .game-card,
  .sidebar {
    width: 100%;
    min-width: 0;
    flex: none;
    box-sizing: border-box;
    padding: 18px 14px;
  }
  .sidebar { position: static; max-height: none; }

  /* Header jeu : empilé */
  .game-header { flex-direction: column; gap: 6px; }
  .room-mini   { text-align: left; }

  .input-zone { flex-direction: column; }
  .input-zone .btn { width: 100%; }

  .row-buttons { flex-direction: column; }
  .row-buttons .btn { width: 100%; }

  #reveal-tie-actions { flex-direction: column; }
  #reveal-tie-actions .btn { width: 100%; }

  .settings-grid { grid-template-columns: 1fr 1fr; }

  .modal-card { padding: 22px 16px; }
}

@media (max-width: 400px) {
  .settings-grid { grid-template-columns: 1fr; }
  .title { font-size: 1.6rem; }
  .role-word { font-size: 1.5rem; }
  .room-code { font-size: 1.6rem; }
}
