/* Panneaux superposés (aide, dés, journal, menu) et boîtes de dialogue. */

.panel-backdrop,
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(8, 6, 12, 0.55);
  animation: fade 0.18s both;
}
.dialog-backdrop { z-index: 60; align-items: center; padding: 16px; }

.panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  height: min(88dvh, 900px);
  border-radius: 20px 20px 0 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-bottom: 0;
  box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
  animation: slide-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.panel-backdrop.closing { animation: fade 0.18s reverse both; }
.panel-backdrop.closing .panel { animation: slide-up 0.18s reverse both; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 1.2rem; color: var(--gold); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; }

@media (min-width: 900px) {
  .panel-backdrop { align-items: center; }
  .panel { border-radius: 20px; border-bottom: 1px solid var(--border); }
}

@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- Dialogue ---------- */

.dialog {
  width: 100%;
  max-width: 420px;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 18px;
  border-radius: 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.dialog h2 { margin: 0 0 14px; font-size: 1.15rem; line-height: 1.35; }
.dialog p { margin: 0 0 14px; }
.dialog .input { margin-bottom: 14px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.dialog-actions .btn { flex: 1 1 140px; }

/* ---------- Menu ---------- */

.menu { display: flex; flex-direction: column; }
.menu-item {
  min-height: 54px;
  padding: 12px 6px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  text-align: left;
  font-size: 1.05rem;
}
.menu-item.danger { color: var(--red); }
.menu-sep { height: 12px; }

/* ---------- Partage ---------- */

.share { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.share .qr { width: min(260px, 70vw); }

/* ---------- Journal ---------- */

.log-list { list-style: none; margin: 14px 0 0; padding: 0; }
.log-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 10px;
  align-items: baseline;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.log-time { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.log-who { font-weight: 600; }
.log-delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.log-list li.neg .log-delta { color: var(--red); }
.log-list li.pos .log-delta { color: var(--green); }
.log-by { grid-column: 2 / 4; color: var(--muted); font-size: 0.8rem; }

/* ---------- Dés ---------- */

.dice { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.dice-result {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border-radius: 28px;
  border: 3px solid var(--gold);
  background: var(--surface);
  font-family: var(--font-num);
  font-size: 3.4rem;
  font-weight: 700;
  color: var(--gold);
}
.dice-result.pop { animation: die-pop 0.45s both; }
.dice-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.dice-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.dice-history { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; color: var(--muted); font-size: 0.85rem; }

/* ---------- Aide ---------- */

.help { display: flex; flex-direction: column; height: 100%; margin: -14px; }
.help .tabs { position: sticky; top: 0; background: var(--bg-2); z-index: 1; }
.help-content { flex: 1; overflow-y: auto; padding: 14px; }
.help-intro { color: var(--muted); margin-top: 0; }

.phase { margin-bottom: 18px; }
.phase h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 1.05rem; color: var(--gold); }
.phase-num {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--on-gold);
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.steps { margin: 0; padding-left: 38px; }
.steps li { margin-bottom: 10px; }
.steps p { margin: 2px 0 0; color: var(--text); opacity: 0.9; }

.help-card {
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.help-card summary {
  min-height: 50px;
  padding: 12px 14px;
  font-weight: 600;
  cursor: pointer;
  list-style-position: inside;
}
.help-card[open] summary { color: var(--gold); }
.help-card p { margin: 0; padding: 0 14px 14px; }

.search { margin-bottom: 12px; position: sticky; top: 0; z-index: 1; }
.kw { padding: 12px 0; border-bottom: 1px solid var(--border); }
.kw h4 { margin: 0 0 4px; font-family: var(--font-title); font-size: 1.05rem; color: var(--gold); }
.kw p { margin: 0; }
.ruling { margin-top: 6px !important; font-size: 0.92rem; color: var(--muted); }
.ruling-label {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Mention « À vérifier » : terme ou règle à confirmer */
.verify {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px dashed var(--red);
  color: var(--red);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
  text-transform: uppercase;
}
