@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg: #0b0e13;
  --bg-panel: #12161d;
  --bg-panel-raised: #171c24;
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #eef0f3;
  --text-muted: #8b929e;
  --text-dim: #565d68;
  --brand: #ef4266;
  --brand-dim: rgba(239, 66, 102, 0.14);
  --brand-line: rgba(239, 66, 102, 0.45);
  --signal: #3ecf8e;
  --signal-dim: rgba(62, 207, 142, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100%;
}

a { color: inherit; }

h1, h2, h3, .display {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  margin: 0;
}

.mono { font-family: 'JetBrains Mono', monospace; }

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  flex-shrink: 0;
}

.avatar.small { width: 44px; height: 44px; border-radius: 11px; font-size: 16px; background: var(--bg-panel-raised); border: 1px solid var(--brand-line); color: var(--brand); }

.topbar h1 {
  font-size: 19px;
  color: var(--text);
}

.topbar .sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.mode-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--brand);
  background: var(--brand-dim);
  border: 1px solid var(--brand-line);
  padding: 6px 12px;
  border-radius: 100px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mode-tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}
.mode-tag.admin-tag { color: var(--text-muted); background: var(--bg-panel-raised); border-color: var(--line-strong); }
.mode-tag.admin-tag .dot { background: var(--text-dim); }

/* ---------- Panel ---------- */

.card, .bracket {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 22px;
  border-radius: var(--radius);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 11px;
  border-radius: 100px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.pill.locked-pill { color: var(--brand); background: var(--brand-dim); border: 1px solid var(--brand-line); }

/* ---------- Mission clock ---------- */

.clock-panel { text-align: center; margin-bottom: 20px; }

.clock-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 18px;
}

.clock-digits {
  font-family: 'JetBrains Mono', monospace;
  font-size: 46px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  gap: 14px;
  justify-content: center;
}
.clock-digits .unit { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.clock-digits .unit small {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-top: 8px;
}
.clock-digits .sep {
  width: 5px;
  height: 5px;
  border-radius: 2px;
  background: var(--brand);
  align-self: center;
  margin-top: -14px;
}
.clock-digits .value.expired { color: var(--brand); }

/* ---------- Two-up row: current duelist / wins ---------- */

.dual-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}
@media (max-width: 640px) {
  .dual-row { grid-template-columns: 1fr; }
}

.duelliste-main { display: flex; gap: 14px; align-items: flex-start; }
.duelliste-main .name { font-size: 18px; font-weight: 800; letter-spacing: 0.01em; }
.duelliste-main .meta { font-size: 12px; color: var(--text-dim); margin: 3px 0 6px; }
.duelliste-main .tagline { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.duelliste-main .placeholder { font-size: 13px; color: var(--text-dim); font-style: italic; }

.wins-card .count { font-size: 18px; font-weight: 800; color: var(--text); }
.wins-card .count b { color: var(--brand); }

.wins-track {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.win-pip {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
.win-pip.filled {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.sub-note { font-size: 12px; color: var(--text-dim); }

/* ---------- Section headers ---------- */

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title .title-group { display: flex; align-items: center; gap: 9px; }
.section-title h2 { font-size: 15px; color: var(--text); font-weight: 800; }
.section-title .count { font-size: 13px; font-weight: 800; color: var(--text); }
.section-title .count.muted { font-weight: 500; color: var(--text-dim); }

section { margin-bottom: 32px; }

/* ---------- Duelist grid ---------- */

.duelist-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 640px) {
  .duelist-grid { grid-template-columns: repeat(2, 1fr); }
}

.duelist-pill {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-align: center;
  cursor: default;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.duelist-pill.selectable { cursor: pointer; }
.duelist-pill.selectable:hover { border-color: var(--line-strong); color: var(--text); }

.duelist-pill.active {
  border-color: var(--brand-line);
  background: var(--brand-dim);
  color: var(--text);
}
.duelist-pill.active::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

.duelist-pill.locked-out { opacity: 0.35; }

/* ---------- Challenge cards ---------- */

.challenge-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.challenge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 15px 16px;
  border-radius: var(--radius-sm);
}
.challenge.done { opacity: 0.5; }
.challenge .idx {
  font-size: 14px;
  font-weight: 800;
  color: var(--brand);
  flex-shrink: 0;
}
.challenge p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}
.challenge.done p { text-decoration: line-through; color: var(--text-muted); }

.check-btn {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}
.check-btn.checked { background: var(--signal); border-color: var(--signal); }

.empty-note {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

/* ---------- History ---------- */

.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: grid;
  grid-template-columns: 90px 1fr 70px 60px;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.history-row .date { color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.history-row .character { color: var(--text); }
.history-row .result { font-family: 'JetBrains Mono', monospace; text-align: right; letter-spacing: 0.05em; }
.history-row .result.win { color: var(--signal); }
.history-row .result.loss { color: var(--brand); }
.history-row .done-count { color: var(--text-muted); text-align: right; font-family: 'JetBrains Mono', monospace; }

/* ---------- Buttons ---------- */

.btn {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-panel-raised);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:hover { border-color: var(--text-muted); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary { background: var(--signal); border-color: var(--signal); color: #06201c; }
.btn-primary:hover { background: #55dc9d; border-color: #55dc9d; }

.btn-win { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-win:hover { background: #f65c7e; border-color: #f65c7e; }

.btn-loss { border-color: var(--line-strong); }
.btn-loss:hover { border-color: var(--text-muted); }

.btn-danger { color: var(--brand); border-color: var(--brand-line); background: transparent; }
.btn-danger:hover { background: var(--brand-dim); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Banners ---------- */

.banner {
  border: 1px solid var(--signal);
  background: var(--signal-dim);
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--text);
}
.banner b { color: var(--signal); }

.error-banner {
  border: 1px solid var(--brand-line);
  background: var(--brand-dim);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}
.error-banner.show { display: block; }

/* ---------- Loading ---------- */

.loading-dots::after {
  content: '';
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
  100% { content: ''; }
}

footer.foot {
  margin-top: 60px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

@media (prefers-reduced-motion: reduce) {
  .loading-dots::after { animation: none; content: '...'; }
}

/* ---------- Intro 3D (une seule fois par navigateur) ---------- */

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #06070a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: introFadeIn 0.6s ease both;
}
.intro-overlay.closing { animation: introFadeOut 0.45s ease both; }

@keyframes introFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes introFadeOut { from { opacity: 1; } to { opacity: 0; } }

.intro-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.intro-skip {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 2;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 100px;
  cursor: pointer;
}
.intro-skip:hover { color: var(--text); border-color: var(--text-muted); }

.intro-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  padding: 0 24px;
  text-align: center;
}

.intro-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-bottom: 26px;
}
.intro-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.2s ease, transform 0.2s ease;
}
.intro-dot.active { background: var(--brand); transform: scale(1.3); }

.intro-slide {
  min-height: 140px;
  opacity: 0;
  transform: translateY(10px);
}
.intro-slide.in { animation: introSlideIn 0.5s ease forwards; }
@keyframes introSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.intro-slide h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 14px;
  text-shadow: 0 0 30px rgba(239, 66, 102, 0.35);
}
.intro-slide p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
}

.intro-actions { margin-top: 30px; }
.intro-actions .btn { padding: 13px 28px; }

@media (max-width: 480px) {
  .intro-slide h2 { font-size: 23px; }
}
