/* =====================================================================
   MISTERY : LE MANOIR — Habillage
   Direction artistique : gothique chaleureux, ambre doré + bleu nuit.
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700;900&family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --night: #0d1020;
  --night-2: #161a33;
  --panel: rgba(22, 26, 51, 0.72);
  --gold: #d9b06a;
  --gold-bright: #f0d49a;
  --amber: #e8a14a;
  --blood: #8c2b2b;
  --blood-bright: #c0392b;
  --green: #4c9a6a;
  --cream: #f3ead7;
  --muted: #9aa0c0;
  --border: rgba(217, 176, 106, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Cormorant Garamond', Georgia, serif;
  color: var(--cream);
  background:
    radial-gradient(1200px 700px at 50% -10%, #20264a 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 110%, #2a1530 0%, transparent 55%),
    linear-gradient(160deg, var(--night) 0%, #0a0c18 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .title { font-family: 'Cinzel', serif; letter-spacing: 0.04em; }
.gold { color: var(--gold-bright); }
.muted { color: var(--muted); }
.center { text-align: center; }
button { font-family: 'Cinzel', serif; cursor: pointer; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-block; border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(217,176,106,0.18), rgba(217,176,106,0.06));
  color: var(--gold-bright); padding: 14px 26px; border-radius: 12px;
  font-size: 1rem; letter-spacing: 0.06em; text-transform: uppercase;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(217,176,106,0.18); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(180deg, var(--gold), #b98e4e); color: #2a1c08; border-color: var(--gold-bright); font-weight: 700; }
.btn-danger { background: linear-gradient(180deg, var(--blood-bright), var(--blood)); color: #fff; border-color: #e07a6a; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ---------- Cartes / panneaux ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 28px; backdrop-filter: blur(6px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.04);
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px; }
.flair { color: var(--gold); letter-spacing: .35em; text-transform: uppercase; font-size: .8rem; }

/* ---------- Écran d'accueil (index) ---------- */
.home { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.home .panel { max-width: 560px; width: 92%; text-align: center; }
.home h1 { font-size: 2.6rem; margin: 6px 0 2px; color: var(--gold-bright); }
.home .sub { font-style: italic; color: var(--muted); font-size: 1.3rem; margin-bottom: 26px; }
.home .choices { display: grid; gap: 16px; margin-top: 10px; }

/* =====================================================================
   ÉCRAN TV
   ===================================================================== */
.tv { min-height: 100vh; display: flex; flex-direction: column; }
.tv-top { display: flex; justify-content: space-between; align-items: center; padding: 18px 34px; border-bottom: 1px solid var(--border); }
.tv-top .chapter { font-family: 'Cinzel'; color: var(--gold); letter-spacing: .12em; }
.tv-timer { font-family: 'Cinzel'; font-size: 1.8rem; color: var(--gold-bright); min-width: 90px; text-align: right; }
.tv-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.tv-stage h1 { font-size: 3rem; margin: 0 0 10px; }
.tv-narration { font-size: 2.1rem; line-height: 1.45; max-width: 1000px; font-style: italic; color: var(--cream); text-shadow: 0 2px 18px rgba(0,0,0,.6); }
.tv-question { font-size: 2.6rem; max-width: 1000px; margin: 10px 0 22px; }
.tv-choices { display: grid; grid-template-columns: repeat(2, minmax(260px, 1fr)); gap: 16px; width: 100%; max-width: 900px; }
.tv-choice { padding: 22px; font-size: 1.6rem; border-radius: 14px; border: 1px solid var(--border); background: rgba(255,255,255,0.03); display: flex; align-items: center; gap: 14px; }
.tv-choice .key { font-family: 'Cinzel'; color: var(--gold); font-weight: 700; }
.tv-choice.correct { background: linear-gradient(180deg, rgba(76,154,106,.4), rgba(76,154,106,.15)); border-color: var(--green); }
.tv-choice.wrong { opacity: .4; }
.tv-choice.hidden-ans { opacity: .25; filter: blur(3px); }
.tv-media { width: 100%; max-width: 760px; height: 380px; border-radius: 16px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(45deg, #12152b, #12152b 16px, #161a33 16px, #161a33 32px); color: var(--muted); font-family: 'Cinzel'; margin-bottom: 16px; overflow: hidden; }
.tv-media img, .tv-media video { width: 100%; height: 100%; object-fit: cover; }

.tv-foot { padding: 16px 34px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 20px; }

/* Jauge de stabilité */
.stability { display: flex; align-items: center; gap: 14px; flex: 1; }
.stability .label { font-family: 'Cinzel'; color: var(--gold); white-space: nowrap; }
.gauge { flex: 1; height: 26px; border-radius: 14px; background: rgba(0,0,0,.4); border: 1px solid var(--border); overflow: hidden; position: relative; }
.gauge-fill { height: 100%; border-radius: 14px; transition: width .6s cubic-bezier(.2,.8,.2,1), background .6s; }
.gauge-val { font-family: 'Cinzel'; font-size: 1.4rem; color: var(--gold-bright); min-width: 70px; text-align: right; }

/* Lobby TV */
.lobby { display: flex; gap: 40px; width: 100%; max-width: 1000px; align-items: center; }
.lobby .qr-box { text-align: center; }
.lobby .qr-box img { background: #fff; padding: 12px; border-radius: 14px; width: 260px; height: 260px; }
.lobby .qr-box .code { font-family: 'Cinzel'; font-size: 2.4rem; letter-spacing: .3em; color: var(--gold-bright); margin-top: 12px; }
.lobby .joiners { flex: 1; }
.players-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.player-chip { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,0.04); font-size: 1.2rem; animation: pop .3s ease; }
.player-chip .av { font-size: 1.5rem; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.answered-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.ans-dot { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; opacity: .4; transition: .2s; }
.ans-dot.done { opacity: 1; border-color: var(--green); box-shadow: 0 0 16px rgba(76,154,106,.5); }

.tally-row { display: flex; align-items: center; gap: 14px; max-width: 640px; margin: 8px auto; }
.tally-bar { flex: 1; height: 30px; background: rgba(0,0,0,.35); border-radius: 8px; overflow: hidden; }
.tally-bar > div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--amber)); }

/* Event flash */
.event-card { animation: flashIn .5s ease; }
.event-card .ev-name { font-size: 3.2rem; color: var(--blood-bright); text-shadow: 0 0 30px rgba(192,57,43,.6); }
@keyframes flashIn { 0% { transform: scale(.8); opacity: 0; } 60% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }

/* Reveal */
.reveal-grid { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; max-width: 1000px; }
.reveal-card { width: 180px; padding: 18px; border-radius: 14px; border: 1px solid var(--border); text-align: center; }
.reveal-card.traitre { background: linear-gradient(180deg, rgba(140,43,43,.5), rgba(140,43,43,.2)); border-color: var(--blood-bright); }
.reveal-card.loyal { background: linear-gradient(180deg, rgba(76,154,106,.3), rgba(76,154,106,.12)); border-color: var(--green); }
.reveal-card .av { font-size: 2.6rem; }
.reveal-card .role { font-family: 'Cinzel'; letter-spacing: .1em; margin-top: 6px; }
.reveal-card.face-down { background: rgba(0,0,0,.4); }
.reveal-card.face-down .role, .reveal-card.face-down .av-name { visibility: hidden; }

.outcome-victory h1 { color: var(--green); text-shadow: 0 0 40px rgba(76,154,106,.5); }
.outcome-defeat h1 { color: var(--blood-bright); text-shadow: 0 0 40px rgba(192,57,43,.6); }
.rankings { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.rank-card { padding: 18px 24px; border-radius: 14px; border: 1px solid var(--border); background: rgba(255,255,255,.03); min-width: 200px; }
.rank-card .rtitle { font-family: 'Cinzel'; color: var(--gold); font-size: .9rem; letter-spacing: .1em; }
.rank-card .rname { font-size: 1.8rem; margin-top: 6px; }

/* =====================================================================
   ÉCRAN JOUEUR (téléphone)
   ===================================================================== */
.play { min-height: 100vh; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; }
.play-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.play-head .av { font-size: 2rem; }
.play-head .pname { font-family: 'Cinzel'; }
.play-head .ptag { margin-left: auto; font-size: .85rem; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); }
.ptag.loyal { color: var(--green); border-color: var(--green); }
.ptag.traitre { color: var(--blood-bright); border-color: var(--blood-bright); }
.play-body { flex: 1; padding: 22px; }
.play-body h2 { font-size: 1.5rem; margin: 0 0 16px; }

.choice-btn { display: block; width: 100%; text-align: left; margin: 10px 0; padding: 18px; font-family: 'Cormorant Garamond'; font-size: 1.25rem; border-radius: 14px; border: 1px solid var(--border); background: rgba(255,255,255,0.04); color: var(--cream); transition: .15s; }
.choice-btn:hover { border-color: var(--gold); }
.choice-btn.selected { background: linear-gradient(180deg, var(--gold), #b98e4e); color: #2a1c08; border-color: var(--gold-bright); font-weight: 600; }
.choice-btn.locked { opacity: .5; pointer-events: none; }
.choice-btn .k { font-family: 'Cinzel'; color: var(--gold); margin-right: 10px; }
.choice-btn.selected .k { color: #2a1c08; }

.avatar-pick { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 18px 0; }
.avatar-pick button { font-size: 2rem; width: 64px; height: 64px; border-radius: 14px; border: 1px solid var(--border); background: rgba(255,255,255,.04); }
.avatar-pick button.sel { border-color: var(--gold-bright); background: rgba(217,176,106,.25); transform: scale(1.05); }
input.field { width: 100%; padding: 16px; font-size: 1.2rem; border-radius: 12px; border: 1px solid var(--border); background: rgba(0,0,0,.3); color: var(--cream); font-family: 'Cormorant Garamond'; }

.role-banner { text-align: center; padding: 26px; border-radius: 16px; margin-bottom: 18px; }
.role-banner.loyal { background: linear-gradient(180deg, rgba(76,154,106,.35), rgba(76,154,106,.12)); border: 1px solid var(--green); }
.role-banner.traitre { background: linear-gradient(180deg, rgba(140,43,43,.45), rgba(140,43,43,.18)); border: 1px solid var(--blood-bright); }
.role-banner .rname { font-family: 'Cinzel'; font-size: 2rem; letter-spacing: .1em; }

.mission { border: 1px dashed var(--blood-bright); border-radius: 14px; padding: 16px; margin: 14px 0; background: rgba(140,43,43,.14); }
.mission .mtitle { font-family: 'Cinzel'; color: #e8a6a0; }
.mission .reward { color: var(--gold-bright); font-weight: 600; }
.mission.done { opacity: .55; border-style: solid; border-color: var(--muted); }

.toast { text-align: center; padding: 16px; color: var(--muted); font-style: italic; }
.big-status { text-align: center; padding: 40px 20px; }
.big-status .em { font-size: 3rem; }

.waiting { text-align: center; color: var(--muted); font-style: italic; padding: 30px; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }

@media (max-width: 760px) {
  .tv-choices { grid-template-columns: 1fr; }
  .lobby { flex-direction: column; }
}

/* =====================================================================
   ADMIN & DASHBOARD AFFILIÉ
   ===================================================================== */
.app { display: flex; min-height: 100vh; }
.side { width: 250px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 24px 18px; background: rgba(13,16,32,.5); }
.side .brand { font-family: 'Cinzel'; font-size: 1.5rem; color: var(--gold-bright); letter-spacing: .08em; }
.side .brand small { display: block; font-family: 'Cormorant Garamond'; font-size: .85rem; color: var(--muted); letter-spacing: .25em; text-transform: uppercase; }
.side nav { margin-top: 28px; display: flex; flex-direction: column; gap: 4px; }
.side nav a, .side nav button { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--cream); padding: 12px 14px; border-radius: 10px; font-family: 'Cinzel'; font-size: .9rem; letter-spacing: .04em; cursor: pointer; text-decoration: none; }
.side nav a:hover, .side nav button:hover { background: rgba(217,176,106,.1); }
.side nav a.active, .side nav button.active { background: linear-gradient(90deg, rgba(217,176,106,.22), transparent); color: var(--gold-bright); border-left: 3px solid var(--gold); }
.side .side-foot { margin-top: auto; padding-top: 20px; }

.main { flex: 1; padding: 30px 40px; max-width: 1300px; }
.main h1 { font-size: 2rem; color: var(--gold-bright); margin: 0 0 4px; }
.main .lead { color: var(--muted); font-style: italic; margin-bottom: 26px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; gap: 16px; flex-wrap: wrap; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 30px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 22px; }
.stat-card .k { font-family: 'Cinzel'; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat-card .v { font-family: 'Cinzel'; font-size: 2.4rem; color: var(--gold-bright); margin-top: 8px; line-height: 1; }
.stat-card .sub { color: var(--muted); font-size: .95rem; margin-top: 6px; }
.stat-card.accent { background: linear-gradient(160deg, rgba(217,176,106,.18), rgba(22,26,51,.7)); border-color: var(--gold); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 24px; margin-bottom: 24px; }
.card h2 { font-size: 1.3rem; margin: 0 0 16px; color: var(--cream); }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; font-family: 'Cinzel'; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.tbl td { padding: 12px; border-bottom: 1px solid rgba(217,176,106,.1); font-size: 1.05rem; }
table.tbl tr:hover td { background: rgba(255,255,255,.02); }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-family: 'Cinzel'; font-size: .72rem; letter-spacing: .06em; }
.pill.ok { background: rgba(76,154,106,.2); color: #8fe0b0; border: 1px solid var(--green); }
.pill.off { background: rgba(140,43,43,.2); color: #e8a6a0; border: 1px solid var(--blood-bright); }
.pill.pub { background: rgba(76,154,106,.2); color: #8fe0b0; border: 1px solid var(--green); }
.pill.draft { background: rgba(154,160,192,.15); color: var(--muted); border: 1px solid var(--muted); }
.pill.pro { background: rgba(217,176,106,.2); color: var(--gold-bright); border: 1px solid var(--gold); }
.pill.std { background: rgba(154,160,192,.12); color: var(--muted); border: 1px solid var(--border); }
.pill.win { color: #8fe0b0; } .pill.lose { color: #e8a6a0; }

.btn-sm { padding: 7px 14px; font-size: .78rem; border-radius: 8px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-row .bname { min-width: 180px; }
.bar-row .btrack { flex: 1; height: 22px; background: rgba(0,0,0,.3); border-radius: 6px; overflow: hidden; }
.bar-row .btrack > div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--amber)); }

.field-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 8px; }
.field-row label { display: block; font-size: .8rem; color: var(--muted); font-family: 'Cinzel'; letter-spacing: .06em; margin-bottom: 6px; }
.field-row input, .field-row select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: rgba(0,0,0,.3); color: var(--cream); font-family: 'Cormorant Garamond'; font-size: 1.05rem; }
.select-ident { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--gold); background: rgba(217,176,106,.12); color: var(--gold-bright); font-family: 'Cinzel'; }

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .side { width: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 20px; }
  .bar-row .bname { min-width: 110px; }
}
