/* AVALE — thème Camelot nocturne : bleu nuit + or, bien = azur, mal = pourpre. */

:root {
  --bg: #0d1322;
  --bg2: #141d33;
  --panel: #1a2440;
  --line: #2b3a63;
  --ink: #e8e4d8;
  --dim: #8d94ab;
  --gold: #d4af37;
  --gold2: #f3d97a;
  --good: #4f8ef7;
  --evil: #d54545;
  font-size: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  background: radial-gradient(120% 100% at 50% 0%, var(--bg2) 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}

.hidden { display: none !important; }

.screen {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
}

/* ---------- boutons ---------- */
.big-btn {
  display: block; width: 100%;
  padding: 15px 18px;
  font: bold 1.05rem Georgia, serif; letter-spacing: .08em;
  color: #1a1405;
  background: linear-gradient(180deg, var(--gold2), var(--gold));
  border: none; border-radius: 12px;
  box-shadow: 0 3px 0 #8a6d1c, 0 6px 18px rgba(0,0,0,.45);
  cursor: pointer;
}
.big-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a6d1c; }
.big-btn:disabled { filter: grayscale(.8) brightness(.6); box-shadow: none; }
.mid-btn {
  padding: 9px 14px; font: .85rem Georgia, serif;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer;
}
.mid-btn.ghost { background: transparent; color: var(--dim); }

/* ---------- accueil ---------- */
#screen-home { justify-content: center; }
.home-box { text-align: center; }
.logo {
  font-size: 3.4rem; letter-spacing: .18em; color: var(--gold);
  text-shadow: 0 0 24px rgba(212,175,55,.35);
}
.tagline { color: var(--dim); margin: 6px 0 28px; font-style: italic; }
#joinForm input {
  display: block; width: 100%; margin-bottom: 12px;
  padding: 14px 16px; font: 1.05rem Georgia, serif;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
#joinForm input:focus { border-color: var(--gold); }
.hint { color: var(--dim); font-size: .85rem; margin-top: 14px; line-height: 1.45; }
.error { color: #ff9c9c; font-size: .9rem; margin-top: 12px; }

/* ---------- lobby ---------- */
.room-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.room-label { font-size: .7rem; letter-spacing: .25em; color: var(--dim); }
.room-code { font-size: 1.9rem; letter-spacing: .12em; color: var(--gold); font-weight: bold; }

.player-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.player-list li {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px; font-size: 1rem;
  transition: border-color .15s, background .15s;
}
.player-list .dot { width: 9px; height: 9px; border-radius: 50%; background: #45d06c; flex: none; }
.player-list .off .dot { background: #666; }
.player-list .off { opacity: .55; }
.player-list .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .tag { font-size: .72rem; color: var(--dim); }
.player-list .badge { font-size: .95rem; }

/* sélection d'équipe */
.player-list li.selectable { cursor: pointer; }
.player-list li.selected { border-color: var(--gold); background: #263252; box-shadow: 0 0 0 1px var(--gold) inset; }
.player-list li.onteam .shield { color: var(--gold2); }
.player-list li .role-tag { font-size: .78rem; font-style: italic; }
.role-tag.evil { color: var(--evil); }
.role-tag.good { color: var(--good); }

.config-box, .config-view {
  margin-top: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 15px;
}
.config-title { font-size: .72rem; letter-spacing: .2em; color: var(--dim); margin-bottom: 9px; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: .98rem; }
.toggle input { width: 20px; height: 20px; accent-color: var(--gold); }
.config-view { color: var(--dim); font-size: .88rem; line-height: 1.6; }
.lobby-foot { margin-top: auto; padding-top: 16px; }
.lobby-foot .hint { text-align: center; margin-bottom: 10px; }

/* ---------- entête de partie ---------- */
.game-head { margin-bottom: 12px; }
.quest-track { display: flex; justify-content: center; gap: 10px; margin-bottom: 9px; }
.quest-med {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--panel); border: 2px solid var(--line);
  font-weight: bold; font-size: 1.15rem; color: var(--dim);
  position: relative;
}
.quest-med .n { line-height: 1; }
.quest-med .sub { font-size: .55rem; letter-spacing: .05em; color: var(--dim); }
.quest-med.current { border-color: var(--gold); color: var(--gold2); box-shadow: 0 0 14px rgba(212,175,55,.3); }
.quest-med.success { background: #16345e; border-color: var(--good); color: #cfe1ff; }
.quest-med.fail { background: #4a1620; border-color: var(--evil); color: #ffd2d2; }
.head-sub { display: flex; justify-content: space-between; align-items: center; }
.vote-track { display: flex; gap: 6px; align-items: center; }
.vote-track .pip {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid var(--line); background: transparent;
}
.vote-track .pip.filled { background: var(--evil); border-color: var(--evil); }
.vote-track .lbl { font-size: .68rem; color: var(--dim); margin-right: 4px; letter-spacing: .1em; }
.role-chip {
  font-size: .8rem; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--gold2);
  cursor: pointer;
}

/* ---------- panneau d'action ---------- */
.action-panel {
  margin-top: auto; padding-top: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.panel-msg { text-align: center; color: var(--dim); font-style: italic; line-height: 1.5; padding: 8px 4px; }
.panel-title { text-align: center; font-size: 1.02rem; color: var(--ink); line-height: 1.45; }
.btn-row { display: flex; gap: 10px; }
.btn-row .big-btn { flex: 1; }
.big-btn.approve { background: linear-gradient(180deg, #7fb0ff, var(--good)); box-shadow: 0 3px 0 #234a8c, 0 6px 18px rgba(0,0,0,.45); color: #06122b; }
.big-btn.reject, .big-btn.fail { background: linear-gradient(180deg, #ef8080, var(--evil)); box-shadow: 0 3px 0 #6e1f1f, 0 6px 18px rgba(0,0,0,.45); color: #2b0606; }
.big-btn.picked { outline: 3px solid var(--gold2); }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(6, 9, 18, .93);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 22px; gap: 18px;
}
.overlay .big-btn { max-width: 380px; }

/* carte de rôle, retournement au maintien */
.role-card { width: min(78vw, 300px); aspect-ratio: 5 / 7; perspective: 1000px; cursor: pointer; }
.role-card-inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d; transition: transform .45s;
}
.role-card.flipped .role-card-inner { transform: rotateY(180deg); }
.role-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 16px; border: 2px solid var(--gold);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 18px; text-align: center;
}
.role-back { background: repeating-linear-gradient(45deg, #1a2440 0 14px, #16203a 14px 28px); }
.role-back-mark { font-size: 4rem; color: var(--gold); }
.role-back-hint { color: var(--dim); font-size: .85rem; margin-top: 12px; }
.role-front { transform: rotateY(180deg); gap: 9px; }
.role-front.good { background: linear-gradient(180deg, #12274a, #0d1a33); border-color: var(--good); }
.role-front.evil { background: linear-gradient(180deg, #3d1020, #240811); border-color: var(--evil); }
.role-front .side-lbl { font-size: .68rem; letter-spacing: .28em; color: var(--dim); }
.role-front .rname { font-size: 1.55rem; color: var(--gold2); line-height: 1.15; }
.role-front .rblurb { font-size: .86rem; color: var(--ink); opacity: .85; line-height: 1.45; font-style: italic; }
.role-front .known { margin-top: 6px; font-size: .9rem; }
.role-front .known .klabel { color: var(--dim); font-size: .72rem; letter-spacing: .12em; margin-bottom: 4px; }
.role-front .known .knames { color: var(--gold2); font-weight: bold; line-height: 1.5; }

/* résultats */
.result-box {
  width: min(88vw, 400px); background: var(--panel);
  border: 1px solid var(--gold); border-radius: 16px;
  padding: 24px 20px; text-align: center;
}
.result-box h2 { color: var(--gold2); letter-spacing: .06em; margin-bottom: 14px; font-size: 1.3rem; }
.result-box .votes { display: flex; flex-direction: column; gap: 6px; text-align: left; margin: 10px 0; }
.result-box .votes div { display: flex; justify-content: space-between; font-size: .95rem; }
.vote-yes { color: var(--good); } .vote-no { color: var(--evil); }
.cards-row { display: flex; justify-content: center; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.qcard {
  width: 54px; height: 76px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
  border: 2px solid var(--line); background: var(--bg2);
  animation: qflip .5s ease both;
}
.qcard.s { border-color: var(--good); color: var(--good); }
.qcard.f { border-color: var(--evil); color: var(--evil); }
@keyframes qflip { from { transform: rotateY(90deg); opacity: 0; } to { transform: none; opacity: 1; } }
.result-verdict { font-size: 1.1rem; margin-top: 6px; }
.result-verdict.good { color: var(--good); }
.result-verdict.evil { color: var(--evil); }

/* fin de partie */
.endgame { text-align: center; padding: 10px 0; }
.endgame .crown { font-size: 3rem; }
.endgame h2 { color: var(--gold2); font-size: 1.5rem; margin: 8px 0 4px; }
.endgame .why { color: var(--dim); font-style: italic; margin-bottom: 10px; }
