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

/* Art direction: Tibia-themed prop firm → prestige, dark, medieval-gold
   Palette: deep dark surfaces, gold accent, teal secondary
   Typography: Cinzel (display headings) + Inter (body/UI)
   Density: balanced — dashboard dense, landing generous */

/* ============================================================
   DESIGN SYSTEM — CSS CUSTOM PROPERTIES
   ============================================================ */

:root {
  /* Typography */
  --font-display: 'Cinzel', 'Georgia', serif;
  --font-body:    'Inter', 'Helvetica Neue', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Fluid type scale */
  --text-xs:   clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl:  clamp(2.5rem, 1rem + 4vw, 5rem);

  /* Surfaces */
  --bg:             #0d0d12;
  --surface:        #141418;
  --surface-2:      #1c1c24;
  --surface-3:      #22222c;
  --surface-offset: #1a1a22;
  --border:         #2a2a38;
  --border-2:       #333344;
  --divider:        #232330;

  /* Text */
  --text-primary:   #e8e6e0;
  --text-secondary: #a09e9a;
  --text-muted:     #6b6968;
  --text-faint:     #3d3c3a;
  --text-inverse:   #0d0d12;

  /* Gold accent — primary brand color */
  --gold:        #f5c842;
  --gold-hover:  #e0b43a;
  --gold-active: #c49a2e;
  --gold-dim:    rgba(245, 200, 66, 0.2);
  --gold-glow:   rgba(245, 200, 66, 0.08);

  /* Teal — secondary accent */
  --teal:       #4f98a3;
  --teal-hover: #3d7f8a;
  --teal-dim:   rgba(79, 152, 163, 0.2);

  /* Purple — tertiary/challenge accent */
  --purple:       #7c6af5;
  --purple-hover: #6558d4;
  --purple-dim:   rgba(124, 106, 245, 0.2);

  /* Semantic */
  --green:      #3ddc84;
  --green-hover:#2fc070;
  --green-dim:  rgba(61, 220, 132, 0.15);
  --green-glow: rgba(61, 220, 132, 0.08);
  --red:        #f87171;
  --red-hover:  #e05555;
  --red-dim:    rgba(248, 113, 113, 0.15);
  --red-glow:   rgba(248, 113, 113, 0.08);
  --orange:     #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.15);
  --verified:     #3b82f6;
  --verified-dim: rgba(59, 130, 246, 0.18);

  /* Radius */
  --radius-sm:   0.375rem;
  --radius-md:   0.5rem;
  --radius-lg:   0.75rem;
  --radius-xl:   1rem;
  --radius-2xl:  1.5rem;
  --radius-pill: 9999px;

  /* Spacing — 4px base */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:   0 12px 32px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 20px rgba(245,200,66,0.12);

  /* Transitions */
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --sidebar-width:   240px;
  --header-height:   60px;
  --container-max:   1100px;
  --content-narrow:  640px;
  --content-default: 960px;
  --content-wide:    1200px;
}

:root[data-theme="light"] {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #ebebef;
  --border: #d4d4dc;
  --text-primary: #1a1a1f;
  --text-secondary: #5a5a66;
}

/* Legacy aliases — maps old names to new tokens */
:root {
  --bg-dark:       var(--bg);
  --bg-card:       var(--surface);
  --bg-surface:    var(--surface);
  --bg-surface-2:  var(--surface-2);
  --color-bg:      var(--bg);
  --color-surface: var(--surface);
  --color-border:  var(--border);
  --color-gold:    var(--gold);
  --color-green:   var(--green);
  --color-red:     var(--red);
  --color-purple:  var(--purple);
  --color-text:    var(--text-primary);
  --color-muted:   var(--text-muted);
  --accent:        var(--gold);
  --accent-hover:  var(--gold-hover);
  /* HTML files reference --font-base; remap to new --font-body */
  --font-base:     var(--font-body);
  /* Slow transition — sidebar animation + hunt card */
  --transition-slow: 0.32s ease;
  /* Purple glow — used by .badge-purple */
  --purple-glow:   rgba(124, 106, 245, 0.18);
}

/* ============================================================
   BASE RESET
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  text-wrap: balance;
  line-height: 1.15;
  color: var(--text-primary);
}

h1 { font-size: var(--text-2xl); font-weight: 700; }
h2 { font-size: var(--text-xl);  font-weight: 600; }
h3 { font-size: var(--text-lg);  font-weight: 600; }
h4 { font-size: var(--text-base); font-weight: 600; }

p, li {
  text-wrap: pretty;
  max-width: 72ch;
}

p {
  color: var(--text-secondary);
  line-height: 1.7;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

ul, ol { list-style: none; }

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--gold-hover);
}

code, kbd, pre {
  font-family: var(--font-mono);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

::selection {
  background: var(--gold-dim);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

a, button, [role="button"], input, textarea, select {
  transition: color var(--transition),
              background var(--transition),
              border-color var(--transition),
              box-shadow var(--transition);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border-width: 0;
}

/* ── Display heading utility — forces Cinzel only where needed */
.display-heading {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

/* ── Force body font (for elements that need Inter, not Cinzel) */
.body-font { font-family: var(--font-body); }

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.flex {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.flex-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

.w-full     { width: 100%; }
.text-center { text-align: center; }
.text-mono  { font-family: var(--font-mono); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.hidden { display: none !important; }

/* ============================================================
   CARD
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition);
}

.card:hover {
  border-color: var(--border-2);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
}

.card-footer {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.card-gold {
  border-color: var(--gold-dim);
  box-shadow: var(--shadow-md), var(--shadow-gold);
}

.card-surface-2 {
  background: var(--surface-2);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5625rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              opacity var(--transition);
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
}

.btn-block { width: 100%; }

/* Primary — gold */
.btn-primary {
  background: var(--gold);
  color: var(--text-inverse);
  border-color: var(--gold);
}

.btn-primary:hover {
  background: var(--gold-hover);
  border-color: var(--gold-hover);
  box-shadow: 0 0 14px rgba(245, 200, 66, 0.4);
}

/* Secondary — transparent gold border */
.btn-secondary {
  background: transparent;
  color: var(--gold);
  border-color: var(--gold);
}

.btn-secondary:hover {
  background: var(--gold-glow);
  box-shadow: 0 0 10px rgba(245, 200, 66, 0.2);
}

/* Danger — red */
.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-danger:hover {
  background: var(--red-hover);
  border-color: var(--red-hover);
  box-shadow: 0 0 14px rgba(248, 113, 113, 0.35);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-2);
}

/* Success — green */
.btn-success {
  background: var(--green);
  color: var(--text-inverse);
  border-color: var(--green);
}

.btn-success:hover {
  background: var(--green-hover);
  border-color: var(--green-hover);
  box-shadow: 0 0 14px rgba(61, 220, 132, 0.35);
}

.btn-save-char {
  margin-top: 0.75rem;
}

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.label {
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.input,
.select,
.textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.5625rem 0.875rem;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition),
              background var(--transition);
  outline: none;
  appearance: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
  background: var(--surface-3);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-mono {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}

.textarea {
  resize: vertical;
  min-height: 90px;
}

.form-error {
  font-size: 0.8rem;
  color: var(--red);
  margin-top: 0.2rem;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.5;
  border: 1px solid transparent;
}

.alert-success {
  background: var(--green-glow);
  border-color: var(--green-dim);
  color: var(--green);
}

.alert-error {
  background: var(--red-glow);
  border-color: var(--red-dim);
  color: var(--red);
}

.alert-warning {
  background: var(--gold-glow);
  border-color: var(--gold-dim);
  color: var(--gold);
}

.alert-info {
  background: var(--purple-glow);
  border-color: var(--purple-dim);
  color: var(--purple);
}

/* ============================================================
   BADGE / TIER SYSTEM
   14 Tibia-inspired tiers
   ============================================================ */

.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.625rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.725rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

/* Tier 1 — Rook */
.tier-1 {
  background: rgba(120, 120, 140, 0.15);
  color: #9090a8;
  border-color: #3a3a50;
}

/* Tier 2 — Knight */
.tier-2 {
  background: rgba(140, 110, 80, 0.15);
  color: #b07040;
  border-color: #5a3820;
}

/* Tier 3 — Paladin */
.tier-3 {
  background: rgba(60, 140, 200, 0.12);
  color: #5ab0e0;
  border-color: #1e5a80;
}

/* Tier 4 — Sorcerer */
.tier-4 {
  background: rgba(124, 106, 245, 0.12);
  color: var(--purple);
  border-color: #4a3aaa;
}

/* Tier 5 — Druid */
.tier-5 {
  background: rgba(61, 220, 132, 0.1);
  color: var(--green);
  border-color: #1a7040;
}

/* Tier 6 — Elite Knight */
.tier-6 {
  background: rgba(200, 160, 40, 0.12);
  color: #d4a030;
  border-color: #6a4a10;
}

/* Tier 7 — Royal Paladin */
.tier-7 {
  background: rgba(80, 160, 230, 0.14);
  color: #50a0e6;
  border-color: #1a4a80;
}

/* Tier 8 — Master Sorcerer */
.tier-8 {
  background: rgba(160, 80, 240, 0.14);
  color: #b050f0;
  border-color: #6020a0;
}

/* Tier 9 — Elder Druid */
.tier-9 {
  background: rgba(40, 200, 120, 0.13);
  color: #28c878;
  border-color: #106040;
}

/* Tier 10 — Hero */
.tier-10 {
  background: rgba(245, 200, 66, 0.12);
  color: var(--gold);
  border-color: #7a5010;
}

/* Tier 11 — Legend */
.tier-11 {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
  border-color: #801818;
}

/* Tier 12 — God of War */
.tier-12 {
  background: rgba(255, 120, 40, 0.13);
  color: #ff7828;
  border-color: #8a3010;
}

/* Tier 13 — Celestial */
.tier-13 {
  background: rgba(100, 200, 255, 0.13);
  color: #64c8ff;
  border-color: #1060a0;
  box-shadow: 0 0 8px rgba(100, 200, 255, 0.2);
}

/* Tier 14 — Omniscient */
.tier-14 {
  background: linear-gradient(135deg,
    rgba(245, 200, 66, 0.18),
    rgba(124, 106, 245, 0.18));
  color: #ffe080;
  border-color: var(--gold-active);
  box-shadow: 0 0 12px rgba(245, 200, 66, 0.3), 0 0 24px rgba(124, 106, 245, 0.2);
  text-shadow: 0 0 8px rgba(245, 200, 66, 0.6);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.175rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.725rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-gold   { background: var(--gold-glow);   color: var(--gold);   border: 1px solid var(--gold-dim); }
.badge-green  { background: var(--green-glow);  color: var(--green);  border: 1px solid var(--green-dim); }
.badge-red    { background: var(--red-glow);    color: var(--red);    border: 1px solid var(--red-dim); }
.badge-purple { background: var(--purple-glow); color: var(--purple); border: 1px solid var(--purple-dim); }
.badge-muted  { background: var(--surface-2);   color: var(--text-muted); border: 1px solid var(--border); }

/* ============================================================
   AUTH PAGE
   ============================================================ */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%,
      rgba(124, 106, 245, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 110%,
      rgba(245, 200, 66, 0.05) 0%, transparent 60%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.02em;
}

.auth-logo p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0.25rem 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */

.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.01em;
}

.sidebar-logo-sub {
  font-size: 0.65rem;
  color: #7ab5bc;
  font-family: 'Cinzel', Georgia, serif;
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
  opacity: 0.8;
}

.sidebar-section { padding: 1rem 0; }

.sidebar-section-label {
  padding: 0 1.25rem 0.4rem;
  font-size: 0.675rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0 0.625rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5625rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.sidebar-nav-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: var(--gold-glow);
  color: var(--gold);
  font-weight: 600;
}

.sidebar-nav-item.active .nav-icon { color: var(--gold); opacity: 1; }

.nav-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 0.625rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: var(--surface-2); }

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-glow);
  border: 2px solid var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================
   DASHBOARD MAIN CONTENT
   ============================================================ */

.dashboard-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ============================================================
   DASHBOARD HEADER
   ============================================================ */

.dashboard-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
}

.dashboard-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dashboard-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.header-character {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 500;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.menu-toggle:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}

/* ============================================================
   DASHBOARD CONTENT AREA
   ============================================================ */

.dashboard-content {
  flex: 1;
  padding: 1.75rem 1.5rem;
}

/* ============================================================
   STAT CARDS
   ============================================================ */

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--border-2); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.625rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }
.stat-value.gold     { color: var(--gold); }

.stat-change {
  font-size: 0.775rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.stat-change.up   { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ============================================================
   TABLE
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead { background: var(--surface-2); }

thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

.td-mono {
  font-family: var(--font-mono);
  font-size: 0.825rem;
}

.td-primary {
  color: var(--text-primary);
  font-weight: 500;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--gold);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-fill.green  { background: var(--green); }
.progress-fill.purple { background: var(--purple); }
.progress-fill.red    { background: var(--red); }

/* ============================================================
   SPINNER / LOADING
   ============================================================ */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.spinner-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.loading-text {
  animation: pulse 1.4s ease-in-out infinite;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ============================================================
   MODAL / OVERLAY
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}

.modal-body { padding: 1.25rem 1.5rem; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.625rem;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   MISC COMPONENTS
   ============================================================ */

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.725rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.character-name {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--gold);
  font-size: 0.9rem;
}

.amount-positive {
  font-family: var(--font-mono);
  color: var(--green);
  font-weight: 500;
}

.amount-negative {
  font-family: var(--font-mono);
  color: var(--red);
  font-weight: 500;
}

.amount-neutral {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-green  { background: var(--green);      box-shadow: 0 0 6px var(--green); }
.dot-red    { background: var(--red);        box-shadow: 0 0 6px var(--red); }
.dot-gold   { background: var(--gold);       box-shadow: 0 0 6px var(--gold); }
.dot-muted  { background: var(--text-muted); }

/* Tooltip */
[data-tooltip] { position: relative; }

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 0.3rem 0.625rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 999;
}

[data-tooltip]:hover::after { opacity: 1; }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* ============================================================
   RESPONSIVE — MOBILE (<768px)
   ============================================================ */

@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }

  .dashboard-main { margin-left: 0; }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .dashboard-content { padding: 1.25rem 1rem; }

  .grid-2,
  .grid-3,
  .grid-4 { grid-template-columns: 1fr; }

  .modal { max-width: 100%; }

  .auth-page {
    align-items: flex-start;
    padding-top: 3rem;
  }

  .dashboard-header { padding: 0 1rem; }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   RESPONSIVE — MOBILE PATCHES (Day 7)
   ============================================================ */

@media (max-width: 767px) {
  .dashboard-header {
    padding: 0 1rem;
    gap: 0.5rem;
  }

  .dashboard-header-right {
    gap: 0.5rem;
    min-width: 0;
  }

  #user-email { display: none; }

  #char-input {
    min-width: 0;
    flex: 1;
  }

  .dashboard-content .flex { flex-wrap: wrap; }

  .auth-page {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
  }

  .btn-sm {
    padding: 0.5rem 0.875rem;
    min-height: 36px;
  }

  .stat-value { font-size: 1.375rem; }
}

@media (max-width: 400px) {
  .card { padding: 1rem; }
  .stat-card { padding: 1rem; }
  .dashboard-content { padding: 1rem 0.875rem; }
}

/* ============================================================
   HUNT SESSION UI — Day 8
   ============================================================ */

@keyframes huntPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 200, 66, 0); border-color: var(--gold-dim); }
  50%       { box-shadow: 0 0 0 6px rgba(245, 200, 66, 0.18); border-color: var(--gold); }
}

@keyframes huntFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hunt-active-card {
  background: var(--surface-2);
  border: 2px solid var(--gold-dim);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  animation: huntPulse 2.4s ease-in-out infinite;
}

.hunt-active-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.hunt-icon { font-size: 1.25rem; }

.hunt-active-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.hunt-active-char {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.hunt-active-timer {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.hunt-active-xphr {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.hunt-active-xphr span {
  font-family: var(--font-mono);
  color: var(--gold);
}

.hunt-active-timer span {
  font-family: var(--font-mono);
  color: var(--gold);
  font-weight: 600;
}

.hunt-results-card {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  animation: huntFadeIn 0.35s var(--transition-slow) both;
}

.hunt-results-header {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.hunt-results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.hunt-stat { text-align: center; }

.hunt-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.hunt-stat-value {
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hunt-stat-value.gold {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(245, 200, 66, 0.35);
}

.hunt-history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  transition: border-color var(--transition), background var(--transition);
}

.hunt-history-item:hover {
  border-color: var(--border-2);
  background: var(--surface-2);
}

.session-card--active {
  border: 2px solid var(--gold);
  box-shadow: 0 0 10px rgba(245, 200, 66, 0.3);
}

@keyframes activePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}
.hunt-active-pulse-dot {
  display: inline-block;
  color: #22c55e;
  font-size: 0.75rem;
  animation: activePulse 1.5s ease-in-out infinite;
  margin-right: 0.2rem;
}
.hunt-view-active-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.7rem;
  border-radius: 9999px;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s, color 0.18s;
}
.hunt-view-active-btn:hover { background: var(--gold); color: #0a0a0f; }

.hunt-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.hunt-history-char {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.hunt-history-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.hunt-history-stats .stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-right: 0.2rem;
}

.hunt-btn-start,
.hunt-btn-stop {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), box-shadow var(--transition),
              opacity var(--transition);
  white-space: nowrap;
}

.hunt-btn-start {
  background: var(--gold);
  color: var(--text-inverse);
}

.hunt-btn-start:hover:not(:disabled) {
  background: var(--gold-hover);
  box-shadow: var(--shadow-gold);
}

.hunt-btn-stop {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red-dim);
}

.hunt-btn-stop:hover:not(:disabled) {
  background: var(--red-glow);
  border-color: var(--red);
}

.hunt-btn-start:disabled,
.hunt-btn-stop:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hunt-char-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.875rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font-body);
  transition: border-color var(--transition);
}

.hunt-char-input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

@media (max-width: 480px) {
  .hunt-results-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.625rem;
  }
  .hunt-stat-value { font-size: 1.125rem; }
  .hunt-history-stats { gap: 0.625rem; }
  .hunt-active-card { padding: 1rem; }
  .hunt-results-card { padding: 1rem; }
}

/* ── Session history dismiss button ──────────────────────────── */
.hunt-dismiss-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.hunt-dismiss-btn:hover {
  color: var(--red, #e53e3e);
}

@keyframes huntDismiss {
  from { opacity: 1; transform: translateY(0);  max-height: 200px; }
  to   { opacity: 0; transform: translateY(-8px); max-height: 0;   padding: 0; margin: 0; }
}
.hunt-history-item--dismissing {
  animation: huntDismiss 0.2s ease forwards;
  overflow: hidden;
  pointer-events: none;
}

/* ============================================================
   PAGE HERO / SUBTITLE CENTERING
   The base reset sets max-width: 72ch on <p> which causes the
   paragraph block to sit at the left edge even when its parent
   has text-align: center. Fix by centering the block itself.
   ============================================================ */

/* Generic containers (current and future pages) */
.page-header p,
.hero-header p,
.page-hero p {
  text-align: center;
  margin-inline: auto;
}

/* Leaderboard hero subtitle */
.lb-hero p {
  text-align: center;
  margin-inline: auto;
}

/* Challenges hero subtitle */
.ch-hero p {
  text-align: center;
  margin-inline: auto;
}

/* ── Nav Logo Wordmark ─────────────────────────────────────── */
.nav-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo-link img {
  display: block;
  height: 38px;
  width: auto;
  object-fit: contain;
}

/* ── Logo Animations ──────────────────────────────────────────── */
@keyframes logoGlowPulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(79,152,163,0.5))
                     drop-shadow(0 0 12px rgba(245,200,66,0.2)); }
  50%       { filter: drop-shadow(0 0 8px rgba(79,152,163,0.9))
                     drop-shadow(0 0 20px rgba(245,200,66,0.35)); }
}

@keyframes logoGlowHover {
  0%   { filter: drop-shadow(0 0 6px rgba(79,152,163,0.7))
                 drop-shadow(0 0 16px rgba(245,200,66,0.4)); }
  100% { filter: drop-shadow(0 0 10px rgba(79,152,163,1))
                 drop-shadow(0 0 28px rgba(245,200,66,0.6)); }
}

/* Subtle idle pulse on all logo images */
.nav-logo-link img,
.sidebar-logo-text img {
  animation: logoGlowPulse 4s ease-in-out infinite;
  transition: filter 0.3s ease, transform 0.3s ease;
}

/* On hover: stronger glow + micro lift */
.nav-logo-link:hover img,
.sidebar-logo-text:hover img {
  animation: logoGlowHover 0.4s ease forwards;
  transform: translateY(-1px);
}

/* Player avatar icon glow */
.pl-avatar {
  animation: logoGlowPulse 4s ease-in-out infinite;
}

/* Index auth logo: larger glow, centered, no hover transform */
.brand-title img {
  animation: logoGlowPulse 5s ease-in-out infinite;
  display: block;
  margin: 0 auto;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .nav-logo-link img,
  .sidebar-logo-text img,
  .pl-avatar,
  .brand-title img {
    animation: none;
  }
}

/* ── FAQ Book ─────────────────────────────────────────────────── */

.faq-book-scene {
  position: relative;
  padding-bottom: 60px;
  perspective: 1200px;
  max-width: 720px;
}

/* Ambient ember glow behind the book */
.faq-book-glow {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  max-width: 580px;
  height: 55%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(245,165,40,0) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  transition: background 1.2s ease 0.5s;
}
.faq-book--open .faq-book-glow {
  background: radial-gradient(ellipse, rgba(245,165,40,0.15) 0%, rgba(245,165,40,0.04) 55%, transparent 70%);
}

/* Book container */
.faq-book {
  position: relative;
  display: flex;
  width: min(720px, 100%);
  margin-inline: 0;
  border-radius: 3px 10px 10px 3px;
  border: 3px solid #3d1a00;
  box-shadow:
    0 30px 80px rgba(0,0,0,0.88),
    0 0 0 1px rgba(100,55,10,0.5),
    0 0 60px rgba(245,165,40,0);
  transform: scaleX(0.04) rotateY(-18deg);
  transform-origin: center center;
  transform-style: preserve-3d;
  opacity: 0;
  will-change: transform, opacity;
  transition:
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease,
    box-shadow 1.1s ease 0.4s;
  z-index: 2;
}
.faq-book--open .faq-book {
  transform: scaleX(1) rotateY(0deg);
  opacity: 1;
  box-shadow:
    0 30px 80px rgba(0,0,0,0.88),
    0 0 0 1px rgba(100,55,10,0.5),
    0 0 60px rgba(245,165,40,0.13);
}

/* ── Left page — aged parchment ── */
.faq-page--left {
  flex: 1;
  position: relative;
  overflow: hidden;
  box-shadow: inset -10px 0 28px rgba(0,0,0,0.18), inset 6px 0 10px rgba(255,255,255,0.1);
  animation: pageFlicker 7s ease-in-out infinite;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.68' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E") repeat,
    radial-gradient(ellipse at 65% 18%, rgba(255,215,130,0.28) 0%, transparent 55%),
    linear-gradient(165deg, #f8e8c6 0%, #e8cc98 45%, #d0a868 100%);
}
/* Horizontal ruled lines */
.faq-page--left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 23px,
    rgba(0,0,0,0.058) 23px, rgba(0,0,0,0.058) 24px
  );
  pointer-events: none;
}
/* Ink border inset */
.faq-page--left::after {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(100,68,14,0.42);
  pointer-events: none;
}

/* ── Spine ── */
.faq-book-spine {
  width: 22px;
  flex-shrink: 0;
  background: linear-gradient(to right,
    #0c0500 0%, #251008 22%, #3c1600 48%,
    #251008 78%, #0c0500 100%
  );
  position: relative;
  box-shadow: inset -3px 0 12px rgba(0,0,0,0.72), inset 3px 0 12px rgba(0,0,0,0.72);
  flex-shrink: 0;
}
/* Gold stitching on spine */
.faq-book-spine::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 14px;
  bottom: 14px;
  transform: translateX(-50%);
  width: 1.5px;
  background: repeating-linear-gradient(
    to bottom,
    #c8983a 0px, #c8983a 4px,
    transparent 4px, transparent 10px
  );
}

/* ── Right page — same parchment ── */
.faq-page--right {
  flex: 1;
  position: relative;
  overflow: visible;
  box-shadow: inset 10px 0 28px rgba(0,0,0,0.14), inset -6px 0 10px rgba(255,255,255,0.08);
  animation: pageFlicker 7s ease-in-out infinite 0.9s;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.68' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.055'/%3E%3C/svg%3E") repeat,
    radial-gradient(ellipse at 35% 18%, rgba(255,215,130,0.22) 0%, transparent 55%),
    linear-gradient(200deg, #f4e2be 0%, #e4c890 45%, #cca068 100%);
}
.faq-page--right::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 23px,
    rgba(0,0,0,0.048) 23px, rgba(0,0,0,0.048) 24px
  );
  pointer-events: none;
}
/* Crossed-swords watermark */
.faq-page--right::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cline x1='28' y1='28' x2='172' y2='172' stroke='%23442c08' stroke-width='5' opacity='0.065'/%3E%3Cline x1='172' y1='28' x2='28' y2='172' stroke='%23442c08' stroke-width='5' opacity='0.065'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  pointer-events: none;
}

/* Page content wrapper */
.faq-page-inner {
  padding: 1.5rem 1.25rem;
  position: relative;
  z-index: 1;
}

/* Quill flourish on left page */
.faq-quill {
  position: absolute;
  top: 14px;
  right: 18px;
  z-index: 2;
  opacity: 0.28;
  pointer-events: none;
}

/* Left page title */
.faq-page-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: #2c1800;
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(100,65,14,0.42);
  letter-spacing: 0.04em;
}

.faq-qa-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.faq-qa-item {
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(100,65,14,0.18);
}
.faq-qa-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-q {
  font-family: var(--font-display);
  font-size: 0.67rem;
  font-weight: 700;
  color: #2c1800;
  max-width: none;
  margin-bottom: 0.18rem;
  line-height: 1.4;
}

.faq-a {
  font-size: 0.75rem;
  color: #4a2e08;
  max-width: none;
  line-height: 1.62;
}

/* Right page: logo layout */
.faq-crest-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 340px;
  position: relative;
  z-index: 1;
  padding: 1.5rem;
}

.faq-logo-svg {
  width: min(96px, 62%);
  height: auto;
  filter: drop-shadow(0 0 16px rgba(245,200,66,0.38));
  animation: logoGlowPulse 4s ease-in-out infinite;
}

.faq-crest-label {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: #2c1800;
  letter-spacing: 0.12em;
  text-align: center;
  margin-top: 0.3rem;
}

.faq-crest-sub {
  font-size: 0.62rem;
  color: #6b4818;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

.faq-wax-seal {
  margin-top: 0.75rem;
  filter: drop-shadow(0 3px 10px rgba(80,8,8,0.65));
}

/* ── Armored Hands ───────────────────────────────────────────── */
.faq-hands {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: min(660px, 98%);
  margin: -45px 0 0;
  pointer-events: none;
  position: relative;
  z-index: 3;
}

/* Contact shadow where hands grip the book bottom */
.faq-contact-shadow {
  position: absolute;
  bottom: 55px;
  left: 4%;
  right: 4%;
  height: 18px;
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  filter: blur(10px);
  z-index: 1;
  pointer-events: none;
}

.faq-hand-wrap {
  opacity: 0;
  transform: translateY(120px);
  will-change: transform, opacity;
  transition: opacity 0.5s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.faq-hand-wrap--left  { transition-delay: 200ms; }
.faq-hand-wrap--right { transition-delay: 290ms; }

.faq-book--open .faq-hand-wrap {
  opacity: 1;
  transform: translateY(0);
}

@keyframes handFloat {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-4px); }
}
.faq-hand-wrap--floating {
  animation: handFloat 4s ease-in-out infinite;
}

.faq-hand {
  display: block;
  width: 148px;
  height: auto;
  filter: drop-shadow(0 -8px 24px rgba(70,18,8,0.9));
}
.faq-hand--right {
  transform: scaleX(-1);
}

/* ── Ember particles ─────────────────────────────────────────── */
.faq-embers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}
.faq-ember {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #f5c842;
  opacity: 0;
  box-shadow: 0 0 5px rgba(245,200,66,0.9);
}
@keyframes emberFloat {
  0%   { opacity: 0; transform: translateY(0) translateX(0) scale(1.3); }
  14%  { opacity: 1; }
  78%  { opacity: 0.45; }
  100% { opacity: 0; transform: translateY(-85px) translateX(var(--ember-drift, 8px)) scale(0.2); }
}

@keyframes pageFlicker {
  0%, 100% { filter: brightness(1); }
  8%        { filter: brightness(0.96); }
  20%       { filter: brightness(1.03); }
  45%       { filter: brightness(0.98); }
  70%       { filter: brightness(1.02); }
  88%       { filter: brightness(0.97); }
}

/* ── Rope / string connector ─────────────────────────────────── */
.faq-rope {
  display: block;
  width: 3px;
  height: 48px;
  margin: 0 0 0 36px;
  background: linear-gradient(to bottom, #6b4015 0%, #8c5a1e 40%, #6b4015 100%);
  border-radius: 2px;
  box-shadow: 1px 0 3px rgba(0,0,0,0.55), -1px 0 2px rgba(0,0,0,0.3);
  transform-origin: top center;
  animation: ropeSway 3.2s ease-in-out infinite;
  position: relative;
}
.faq-rope::before {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4a2c0a;
  box-shadow: 0 2px 6px rgba(0,0,0,0.7);
}
.faq-rope::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3d1a00;
  box-shadow: 0 2px 5px rgba(0,0,0,0.6);
}

@keyframes ropeSway {
  0%, 100% { transform: rotate(0deg); }
  25%       { transform: rotate(2.5deg); }
  75%       { transform: rotate(-2.5deg); }
}

/* ── Bottom vignette ─────────────────────────────────────────── */
.faq-vignette {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 90px;
  background: linear-gradient(to top, var(--bg) 0%, transparent 100%);
  pointer-events: none;
  z-index: 4;
}

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .faq-book {
    flex-direction: column;
    border-radius: 8px;
  }
  .faq-book-spine {
    width: 100%;
    height: 16px;
    background: linear-gradient(to bottom,
      #0c0500 0%, #251008 22%, #3c1600 50%, #251008 78%, #0c0500 100%);
    box-shadow: inset 0 -3px 12px rgba(0,0,0,0.72), inset 0 3px 12px rgba(0,0,0,0.72);
  }
  .faq-book-spine::before {
    top: 50%;
    left: 14px;
    right: 14px;
    bottom: auto;
    width: auto;
    height: 1px;
    transform: translateY(-50%);
    background: repeating-linear-gradient(
      to right,
      rgba(175,128,38,0.75) 0px, rgba(175,128,38,0.75) 7px,
      transparent 7px, transparent 11px
    );
  }
  .faq-page--left { border-right: none; border-bottom: none; }
  .faq-crest-page { min-height: 240px; }
  .faq-hand { width: 70px; }
  .faq-hands { margin: -30px 0 0; }
  .faq-embers { display: none; }
  .faq-book-scene { padding-bottom: 36px; }
  .faq-q { font-size: 0.72rem; }
  .faq-a { font-size: 0.7rem; }
  .faq-rope { margin-left: 20px; }
}

/* ── Daily XP Tracker ── */
#daily-xp-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  padding: 0.875rem 1rem;
  margin-top: 1rem;
}
.dxp-label {
  font-size: 0.875rem;
  color: var(--text-secondary, #a09e9a);
  margin-bottom: 0.5rem;
}
.dxp-label strong {
  color: var(--gold);
  font-weight: 700;
}
.dxp-bar-track {
  width: 100%;
  height: 8px;
  border-radius: 9999px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.dxp-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: var(--gold);
  width: 0%;
  transition: width 0.4s ease;
}
.dxp-bar-fill.target-met {
  background: var(--green);
}
.dxp-bar-fill.flagged {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}
.dxp-meta {
  font-size: 0.75rem;
  color: var(--text-muted, #6b6968);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ── Invite Notification Banner ─────────────────────────────────────────────── */
@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.invite-notification-banner {
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-left:   3px solid var(--gold);
  border-radius: var(--radius-md);
  padding:       1rem 1.25rem;
  margin-bottom: 1rem;
  display:       flex;
  align-items:   center;
  gap:           1rem;
  flex-wrap:     wrap;
  animation:     slideDownFade 0.3s ease both;
}

.invite-banner-icon {
  font-size:  1.5rem;
  flex-shrink: 0;
}

.invite-banner-text {
  flex:      1;
  min-width: 0;
  font-size: 0.875rem;
  color:     var(--text-primary);
}

.invite-banner-actions {
  display:     flex;
  gap:         0.5rem;
  flex-shrink: 0;
  flex-wrap:   wrap;
}

.invite-banner-dismiss {
  transition:     opacity 300ms, transform 300ms;
  opacity:        0;
  pointer-events: none;
}

/* ── Enrollment Pending-Invite State Block ───────────────────────────────────── */
.enrollment-pending-state {
  display:       flex;
  align-items:   center;
  gap:           0.5rem;
  color:         var(--gold);
  font-size:     0.875rem;
  margin-bottom: 0.75rem;
}

.enrollment-pending-dot {
  width:         8px;
  height:        8px;
  border-radius: 50%;
  background:    var(--gold);
  flex-shrink:   0;
  animation:     pulse 1.8s ease-in-out infinite;
}

/* ── Party / Duo Progress Card ───────────────────────────────────────────────── */
.party-progress-card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  padding:       1.25rem;
  margin-bottom: 1rem;
}

.party-card-header {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  margin-bottom:   1rem;
}

.party-card-title {
  color:       var(--gold);
  font-weight: 700;
  font-size:   1rem;
}

.party-member-row {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  padding:         0.5rem 0;
  border-bottom:   1px solid var(--border);
  font-size:       0.875rem;
}

.party-member-row:last-of-type { border-bottom: none; }

.party-member-xp {
  color:               var(--gold);
  font-weight:         700;
  font-variant-numeric: tabular-nums;
}

.party-combined-section { margin-top: 1rem; }

.party-combined-label {
  font-size:      0.75rem;
  color:          var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom:  0.5rem;
}

.party-progress-track {
  height:        8px;
  background:    var(--border);
  border-radius: 99px;
  overflow:      hidden;
  margin-bottom: 0.5rem;
}

.party-progress-fill {
  height:        100%;
  background:    linear-gradient(90deg, var(--gold-active, #c49a2e), var(--gold, #f5c842));
  border-radius: 99px;
  transition:    width 500ms ease;
}

.party-progress-text {
  font-size: 0.8rem;
  color:     var(--text-secondary);
}

.skeleton-party-card {
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  padding:       1.25rem;
  margin-bottom: 1rem;
  animation:     shimmer 1.5s ease-in-out infinite;
}

/* ── Challenge Detail Slide-in Panel ────────────────────────────── */
.panel-backdrop {
  position:       fixed;
  inset:          0;
  background:     rgba(0,0,0,0.55);
  z-index:        400;
  opacity:        0;
  pointer-events: none;
  transition:     opacity 0.3s ease;
}
.panel-backdrop.open {
  opacity:        1;
  pointer-events: all;
}
.challenge-detail-panel {
  position:    fixed;
  top:         0;
  right:       0;
  width:       min(480px, 96vw);
  height:      100dvh;
  background:  var(--surface);
  border-left: 1px solid var(--border);
  box-shadow:  -8px 0 32px rgba(0,0,0,0.35);
  z-index:     401;
  overflow-y:  auto;
  padding:     1.5rem;
  transform:   translateX(105%);
  transition:  transform 0.35s cubic-bezier(0.4,0,0.2,1);
}
.challenge-detail-panel.open { transform: translateX(0); }
.panel-close-btn {
  position:        absolute;
  top:             1rem;
  right:           1rem;
  background:      var(--surface-2);
  border:          1px solid var(--border);
  border-radius:   var(--radius-sm);
  color:           var(--text-secondary);
  font-size:       1rem;
  width:           2rem;
  height:          2rem;
  cursor:          pointer;
  display:         flex;
  align-items:     center;
  justify-content: center;
  transition:      background 0.15s, color 0.15s;
}
.panel-close-btn:hover { background: var(--border); color: var(--text-primary); }

/* ── Scroll-reveal ───────────────────────────────────────────────── */
.reveal {
  opacity:    0;
  transform:  translateY(18px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ── Inline cancel confirm ───────────────────────────────────────── */
.cancel-confirm-block {
  margin-top:    0.75rem;
  padding:       0.75rem 1rem;
  background:    rgba(239,68,68,0.08);
  border:        1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  font-size:     0.85rem;
}
.cancel-confirm-block p { margin: 0 0 0.5rem; color: var(--text-secondary); }
.btn-danger-outline {
  background:    transparent;
  border:        1px solid #ef4444;
  color:         #ef4444;
  border-radius: var(--radius-sm);
  padding:       0.3rem 0.75rem;
  font-size:     0.8rem;
  font-weight:   600;
  cursor:        pointer;
  transition:    background 0.15s;
}
.btn-danger-outline:hover { background: rgba(239,68,68,0.12); }
.btn-danger-outline:disabled { opacity: 0.5; cursor: default; }

/* ── Challenge card actions row ──────────────────────────────────── */
.challenge-card-actions {
  display:     flex;
  gap:         0.5rem;
  align-items: center;
  flex-wrap:   wrap;
}

/* ── Why Safe section ────────────────────────────────────────────── */
.why-safe-grid {
  display:               grid;
  grid-template-columns: repeat(3, 1fr);
  gap:                   1.25rem;
  margin-top:            1rem;
}
.why-safe-pillar {
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  padding:       1.25rem 1rem;
  text-align:    center;
}
.why-safe-icon  { font-size: 2rem; margin-bottom: 0.5rem; }
.why-safe-title { font-weight: 700; font-size: 0.95rem; color: var(--text-primary); margin-bottom: 0.4rem; }
.why-safe-desc  { font-size: 0.825rem; color: var(--text-secondary); line-height: 1.55; }

/* ── Mobile overrides ────────────────────────────────────────────── */
@media (max-width: 767px) {
  .why-safe-grid          { grid-template-columns: 1fr; }
  .challenge-detail-panel { width: 100vw; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .why-safe-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Challenge Detail Panel — sections ───────────────────────────── */
.panel-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.panel-section:last-child { border-bottom: none; margin-bottom: 0; }
.panel-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}
.panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  padding: 0.25rem 0;
}
.panel-row-label { color: var(--text-secondary); }
.panel-row-value { color: var(--text-primary); font-weight: 600; }
.panel-member-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.35rem 0;
  color: var(--text-primary);
}
