/* ═══════════════════════════════════════════════════════════════
   Quably Duel — feature styles
   Reuses the global design tokens from variables.css.
   Mobile-first, competitive feel. No redesign of existing chrome.
   ═══════════════════════════════════════════════════════════════ */

/* ── Shared layout ───────────────────────────────────────────── */
.duel-page {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space-8) var(--container-padding) var(--space-16);
}
.duel-page__foot {
  text-align: center;
  margin-top: var(--space-6);
  font-size: var(--text-sm);
}
.duel-page__foot a { color: var(--color-text-muted); text-decoration: none; }
.duel-page__foot a:hover { color: var(--color-text-secondary); }

.duel-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
}

.duel-muted { color: var(--color-text-secondary); font-size: var(--text-base); }

.duel-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-success);
  background: var(--color-success-dim);
  border: 1px solid var(--color-success-border);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
}

/* ═══════════════════════════════════════════════════════════════
   LANDING
   ═══════════════════════════════════════════════════════════════ */
.duel-landing { max-width: 860px; margin: 0 auto; padding: 0 var(--container-padding); }

.duel-hero {
  text-align: center;
  padding: var(--space-16) 0 var(--space-12);
}
.duel-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-yellow);
  background: var(--color-yellow-dim);
  border: 1px solid rgba(245, 197, 24, 0.25);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-6);
}
.duel-hero__title {
  font-family: var(--font-brand);
  font-size: clamp(2.5rem, 9vw, var(--text-hero));
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 var(--space-5);
  font-weight: 800;
}
.duel-hero__accent {
  color: var(--color-purple-light);
}
.duel-hero__sub {
  color: var(--color-text-secondary);
  font-size: var(--text-md);
  max-width: 34ch;
  margin: 0 auto var(--space-8);
  line-height: 1.6;
}
.duel-hero__note {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.duel-steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin: var(--space-8) 0 var(--space-16);
}
.duel-step {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.duel-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-purple-dim);
  color: var(--color-purple-light);
  font-weight: 700;
  margin-bottom: var(--space-3);
}
.duel-step__title { font-size: var(--text-md); margin: 0 0 var(--space-2); }
.duel-step__text { color: var(--color-text-secondary); font-size: var(--text-sm); margin: 0; line-height: 1.6; }

.duel-section-title {
  text-align: center;
  font-size: var(--text-xl);
  margin-bottom: var(--space-6);
}
.duel-cats { margin-bottom: var(--space-16); }
.duel-cats__grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
}
.duel-cat-chip {
  font-size: var(--text-sm);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}
.duel-cats__note {
  text-align: center;
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

@media (min-width: 640px) {
  .duel-steps { grid-template-columns: repeat(3, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════
   CREATE FORM
   ═══════════════════════════════════════════════════════════════ */
.duel-create__head { text-align: center; margin-bottom: var(--space-8); }
.duel-create__title { font-size: var(--text-2xl); letter-spacing: -0.02em; margin: 0 0 var(--space-2); }
.duel-create__sub { color: var(--color-text-secondary); font-size: var(--text-base); margin: 0; }

.duel-field { margin-bottom: var(--space-6); }
.duel-field .form-label { display: block; margin-bottom: var(--space-3); font-weight: 600; }

.duel-select-wrap { position: relative; }
.duel-select {
  width: 100%;
  appearance: none;
  cursor: pointer;
  padding-right: var(--space-10);
}
.duel-select-wrap::after {
  content: "";
  position: absolute;
  right: var(--space-4);
  top: 50%;
  width: 9px; height: 9px;
  border-right: 2px solid var(--color-text-muted);
  border-bottom: 2px solid var(--color-text-muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.duel-pills { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.duel-pill {
  flex: 1 1 auto;
  min-width: 64px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.duel-pill:hover { border-color: var(--color-purple-border); color: var(--color-text-primary); }
.duel-pill.is-active {
  background: var(--color-purple-dim);
  border-color: var(--color-purple);
  color: var(--color-purple-light);
}
.duel-create__actions { margin-top: var(--space-8); }

/* ═══════════════════════════════════════════════════════════════
   PLAY SHELL — screens
   ═══════════════════════════════════════════════════════════════ */
.duel-screen { text-align: center; }
.duel-screen[hidden] { display: none; }
.duel-screen__title { font-size: var(--text-2xl); letter-spacing: -0.02em; margin: 0 0 var(--space-2); }

/* Spinner */
.duel-spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-purple);
  border-radius: 50%;
  margin: var(--space-4) auto;
  animation: duel-spin 0.8s linear infinite;
}
.duel-spinner--sm { width: 18px; height: 18px; border-width: 2px; margin: 0; }
@keyframes duel-spin { to { transform: rotate(360deg); } }

/* Share block (waiting) */
.duel-share { margin: var(--space-6) 0; }
.duel-share__link {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background: var(--color-bg);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  word-break: break-all;
  user-select: all;
}

/* Players list (waiting) */
.duel-players {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-4) 0;
}
.duel-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-subtle);
  font-size: var(--text-sm);
}
.duel-player-row__name { font-weight: 600; }
.duel-player-row__state { font-size: var(--text-xs); color: var(--color-text-muted); }
.duel-player-row__state.is-ready { color: var(--color-success); }

.duel-waiting-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  margin-top: var(--space-2);
}

/* ═══════════════════════════════════════════════════════════════
   BATTLE
   ═══════════════════════════════════════════════════════════════ */
.duel-battle { text-align: left; }
.duel-battle__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.duel-battle__players {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  min-width: 0;
}
.duel-battle__me, .duel-battle__opp {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}
.duel-battle__me { color: var(--color-purple-light); }
.duel-battle__opp { color: var(--color-text-secondary); }
.duel-battle__vs { color: var(--color-text-muted); font-size: var(--text-xs); }

.duel-timer {
  font-family: var(--font-brand);
  font-size: var(--text-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-primary);
  min-width: 2.4ch;
  text-align: center;
}
.duel-timer.is-low { color: var(--color-error); animation: duel-pulse 1s ease infinite; }
@keyframes duel-pulse { 50% { opacity: 0.55; } }

.duel-progress {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.duel-question {
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: var(--space-5);
  min-height: 3em;
}
.duel-question__text { margin-bottom: var(--space-3); }

/* Code snippet inside a question or review item */
.duel-code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.55;
  color: var(--color-text-primary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}
.duel-code code { font-family: inherit; white-space: inherit; }
.duel-code--sm { font-size: var(--text-xs); padding: var(--space-3); margin: var(--space-2) 0; }

.duel-options { display: flex; flex-direction: column; gap: var(--space-3); }
.duel-option {
  width: 100%;
  text-align: left;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}
.duel-option:hover:not(:disabled) { border-color: var(--color-purple-border); background: var(--color-purple-dim); }
.duel-option:disabled { cursor: default; opacity: 0.9; }
.duel-option.is-correct { border-color: var(--color-success); background: var(--color-success-dim); color: var(--color-success); }
.duel-option.is-wrong { border-color: var(--color-error); background: var(--color-error-dim); color: var(--color-error); }

/* ═══════════════════════════════════════════════════════════════
   RESULT + shareable card
   ═══════════════════════════════════════════════════════════════ */
.duel-result__banner {
  font-family: var(--font-brand);
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-5);
}
.duel-result__banner.is-win  { color: var(--color-success); }
.duel-result__banner.is-lose { color: var(--color-error); }
.duel-result__banner.is-draw { color: var(--color-yellow); }

.duel-result-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 15% 0%, rgba(157,95,245,0.55) 0%, rgba(124,58,237,0) 55%),
    radial-gradient(120% 90% at 100% 100%, rgba(245,197,24,0.28) 0%, rgba(245,197,24,0) 50%),
    linear-gradient(155deg, #2a1470 0%, #5b21b6 45%, #7c3aed 100%);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6) var(--space-6);
  color: #fff;
  text-align: center;
  box-shadow: 0 20px 60px rgba(124,58,237,0.35);
}
/* subtle top sheen */
.duel-result-card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0));
  pointer-events: none;
}
.duel-result-card > * { position: relative; z-index: 1; }

.duel-result-card__brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  color: #fff;
  opacity: 0.95;
  margin-bottom: var(--space-5);
}
.duel-result-card__brand img { width: 20px; height: 20px; display: block; }

.duel-result-card__head {
  font-family: var(--font-brand);
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.15;
  margin-bottom: var(--space-6);
  text-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.duel-result-card__score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}
.duel-result-card__player {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
}
.duel-result-card__name {
  font-size: var(--text-sm);
  font-weight: 600;
  opacity: 0.92;
  max-width: 14ch;
  margin: 0 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.duel-result-card__pts {
  font-family: var(--font-brand);
  font-size: 3.4rem;
  font-weight: 800;
  line-height: 1;
}
/* Highlight the winning side */
.duel-result-card__player--win .duel-result-card__pts { color: var(--color-yellow-light); text-shadow: 0 0 24px rgba(255,215,64,0.5); }
.duel-result-card__player--win .duel-result-card__name::after { content: " 🏆"; }

.duel-result-card__dash {
  font-family: var(--font-brand);
  font-size: var(--text-2xl);
  font-weight: 700;
  opacity: 0.55;
  align-self: center;
}
.duel-result-card__meta {
  font-size: var(--text-xs);
  opacity: 0.85;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-2);
}
.duel-result-card__tag {
  font-size: var(--text-xs);
  font-weight: 600;
  opacity: 0.95;
  letter-spacing: 0.04em;
}

.duel-result__actions { margin-top: var(--space-6); }

/* Review */
.duel-review { margin-top: var(--space-8); text-align: left; }
.duel-review__item {
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.duel-review__q { font-weight: 600; font-size: var(--text-sm); margin-bottom: var(--space-2); }
.duel-review__a { font-size: var(--text-sm); color: var(--color-text-secondary); margin: 2px 0; }
.duel-review__a.is-correct { color: var(--color-success); }
.duel-review__a.is-wrong { color: var(--color-error); }
.duel-review__exp { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-2); line-height: 1.5; }

.duel-review__badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-2);
}
.duel-review__badge.is-correct { color: var(--color-success); background: var(--color-success-dim); }
.duel-review__badge.is-wrong { color: var(--color-error); background: var(--color-error-dim); }
