/* ===========================================
   EVER AFTER GAMES — Dark Fantasy Gamer UI
   =========================================== */

:root {
  /* Surfaces — deep charcoal stack */
  --bg-0: #0A0B0F;        /* outermost */
  --bg-1: #0E0F13;        /* app bg */
  --bg-2: #14151B;        /* elevated panel */
  --bg-3: #1C1E26;        /* card surface */
  --bg-4: #232631;        /* hover / pressed */

  /* Borders */
  --line-1: #2A2D38;
  --line-2: #353846;
  --line-soft: rgba(255,255,255,0.06);

  /* Text */
  --ink-0: #F4F4F7;
  --ink-1: #EDEDF0;       /* headings */
  --ink-2: #C9CAD3;
  --ink-3: #9A9CA5;       /* body */
  --ink-4: #6C6E78;       /* muted / meta */
  --ink-5: #4A4C56;

  /* Accents */
  --crimson: #C2384A;
  --crimson-hi: #E04256;
  --crimson-dim: #8C2434;
  --crimson-glow: rgba(194,56,74,0.45);

  --ember: #E07239;
  --ember-glow: rgba(224,114,57,0.4);

  --gold: #C8A24B;
  --gold-hi: #E6BD63;
  --gold-dim: #8A6E2E;

  /* Rarity */
  --rare-common:    #9A9CA5;
  --rare-rare:      #4FA3D1;
  --rare-epic:      #A266D9;
  --rare-legendary: #E6BD63;

  /* Status */
  --online: #4FD18A;
  --away:   #E6BD63;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Type */
  --f-display: "Cinzel", "Trajan Pro", "Times New Roman", serif;
  --f-ui: "Inter", "Geist", -apple-system, system-ui, sans-serif;
  --f-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 800px at 50% -10%, #1a0c12 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 100%, #0e1320 0%, transparent 60%),
    var(--bg-0);
  color: var(--ink-1);
  font-family: var(--f-ui);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- Page layout: mobile-first app, full-bleed ---------- */
.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  position: relative;
}
.stage::before {
  /* faint film grain */
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.45 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.05;
  pointer-events: none;
  z-index: 2;
}

.phone {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-1);
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

.phone-screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Content column (everything except the nav). Positioned so screen sub-headers
   and sticky bars anchor to the content area, not under the desktop sidebar. */
.app-main {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- iOS-ish status bar ---------- */
.status-bar {
  height: max(env(safe-area-inset-top, 0px), 8px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px 0 32px;
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-0);
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
}
.status-bar .notch {
  position: absolute;
  left: 50%; top: 8px;
  transform: translateX(-50%);
  width: 110px; height: 28px;
  background: #000;
  border-radius: 20px;
}
.status-icons { display: flex; gap: 6px; align-items: center; }

/* ---------- Scroll content area ---------- */
.screen-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  padding-bottom: 96px; /* room for bottom nav */
}
.screen-scroll::-webkit-scrollbar { display: none; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  height: 84px;
  background: linear-gradient(180deg, rgba(14,15,19,0.65) 0%, rgba(10,11,15,0.96) 60%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line-1);
  display: flex;
  align-items: flex-start;
  padding: 10px 8px 18px;
  z-index: 10;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  background: none;
  border: 0;
  color: var(--ink-4);
  font-family: var(--f-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 120ms;
  position: relative;
}
.nav-item svg { width: 22px; height: 22px; stroke-width: 1.6; }
.nav-item.active { color: var(--crimson-hi); }
.nav-item.active::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px; height: 2px;
  background: var(--crimson);
  box-shadow: 0 0 10px var(--crimson-glow);
}

/* Sidebar brand logo — desktop sidebar only (hidden in the mobile bottom bar). */
.nav-brand { display: none; }

/* ---------- Tablet / desktop: bottom bar -> left sidebar ---------- */
@media (min-width: 768px) {
  .phone-screen { flex-direction: row; }

  .status-bar { display: none; }          /* no notch on desktop — drop the spacer */

  .nav-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: none;
    border: 0;
    cursor: pointer;
    padding: 8px 0 18px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line-1);
  }
  .nav-brand-name {
    font-family: var(--f-display);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.09em;
    line-height: 1.1;
    color: var(--ink-0);
    text-align: center;
  }

  .bottom-nav {
    position: static;
    order: -1;
    width: 240px;
    height: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    padding: 22px 14px;
    border-top: 0;
    border-right: 1px solid var(--line-1);
    background: linear-gradient(180deg, rgba(14,15,19,0.92), rgba(10,11,15,0.98));
  }

  .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    padding: 14px 16px;
    font-size: 12px;
    border-radius: 10px;
  }
  .nav-item:hover { color: var(--ink-1); background: rgba(255,255,255,0.03); }
  .nav-item.active { background: rgba(194,56,74,0.12); }
  .nav-item.active::before {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    border-radius: 0 3px 3px 0;
  }

  .app-main .screen-scroll { padding-bottom: 24px; }
}

/* ---------- Headings & text ---------- */
.h-display {
  font-family: var(--f-display);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-0);
  text-transform: uppercase;
  line-height: 1.05;
}
.h-section {
  font-family: var(--f-display);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--ink-1);
}
.h-section .ornament {
  display: inline-block;
  width: 18px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
  vertical-align: middle;
  margin-right: 10px;
}
.h-section .ornament-r {
  display: inline-block;
  width: 18px; height: 1px;
  background: linear-gradient(90deg, var(--gold), transparent);
  vertical-align: middle;
  margin-left: 10px;
}

.eyebrow {
  font-family: var(--f-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.meta { color: var(--ink-4); font-size: 12px; }
.body-text { color: var(--ink-3); font-size: 14px; line-height: 1.5; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--f-ui);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 12px;
  border-radius: var(--r-sm);
  padding: 14px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 80ms, box-shadow 120ms, background 120ms;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, var(--crimson-hi), var(--crimson));
  color: #fff;
  border-color: rgba(255,255,255,0.06);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 8px 24px -8px var(--crimson-glow),
    0 0 0 1px rgba(0,0,0,0.4);
}
.btn-primary:hover {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.28),
    0 12px 30px -8px var(--crimson-glow),
    0 0 0 1px rgba(0,0,0,0.4);
}

.btn-gold {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  color: #1a140a;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 6px 18px -6px rgba(200,162,75,0.4);
}

.btn-ghost {
  background: var(--bg-3);
  color: var(--ink-1);
  border: 1px solid var(--line-2);
}
.btn-ghost:hover { background: var(--bg-4); }

/* ---------- Army Builder ---------- */
.ab-select {
  background: var(--bg-3);
  color: var(--ink-1);
  border: 1px solid var(--line-1);
  border-radius: 6px;
  padding: 9px 12px;
  font-family: var(--f-ui);
  font-size: 12px;
  letter-spacing: 0.02em;
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-4) 50%), linear-gradient(135deg, var(--ink-4) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.ab-pill {
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: 4px; padding: 3px 7px; cursor: pointer;
}
.ab-pill-on { color: var(--gold); border-color: var(--gold-dim); background: rgba(200,162,75,0.08); }
.ab-pill-gold { color: var(--gold); border-color: var(--gold-dim); background: rgba(200,162,75,0.1); cursor: default; }
.ab-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--line-1); border-radius: 8px;
  padding: 9px 12px; margin-bottom: 10px;
}
.ab-search input { flex: 1; background: none; border: 0; outline: none; color: var(--ink-0); font-size: 13px; font-family: var(--f-ui); }
.ab-sheet {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(6,7,10,0.6); backdrop-filter: blur(3px);
  display: flex; flex-direction: column; justify-content: flex-end;
  animation: screenIn 160ms ease-out;
}
.ab-sheet-panel {
  background: var(--bg-1); border-top: 1px solid var(--line-2);
  border-radius: 16px 16px 0 0; padding: 16px 18px 20px;
  max-height: 82%; display: flex; flex-direction: column;
  box-shadow: 0 -16px 40px -10px rgba(0,0,0,0.7);
}
.ab-sheet-scroll { overflow-y: auto; scrollbar-width: none; }
.ab-sheet-scroll::-webkit-scrollbar { display: none; }

.btn-outline {
  background: transparent;
  color: var(--ink-1);
  border: 1px solid var(--line-2);
}

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(28,30,38,0.7);
  border: 1px solid var(--line-1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-1);
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.icon-btn:hover { background: var(--bg-3); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.8; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: all 120ms;
}
.chip:hover { border-color: var(--line-2); color: var(--ink-1); }
.chip.active {
  background: linear-gradient(180deg, rgba(194,56,74,0.18), rgba(194,56,74,0.08));
  border-color: var(--crimson);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  overflow: hidden;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 4px;
  border: 1px solid currentColor;
}
.badge-gold { color: var(--gold); background: rgba(200,162,75,0.08); }
.badge-crimson { color: var(--crimson-hi); background: rgba(194,56,74,0.12); }
.badge-new { color: var(--ember); background: rgba(224,114,57,0.1); }
.badge-stock-in { color: var(--online); background: rgba(79,209,138,0.08); }
.badge-stock-low { color: var(--away); background: rgba(230,189,99,0.08); }
.badge-stock-pre { color: var(--gold); background: rgba(200,162,75,0.12); }

/* ---------- Rarity dots ---------- */
.rarity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ---------- Progress bar ---------- */
.xp-track {
  height: 4px;
  background: var(--bg-4);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--crimson), var(--crimson-hi));
  box-shadow: 0 0 8px var(--crimson-glow);
}
.xp-fill-gold {
  background: linear-gradient(90deg, var(--gold), var(--gold-hi));
  box-shadow: 0 0 8px rgba(200,162,75,0.5);
}

/* ---------- Section header row ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px 12px;
}
.section-head .right {
  color: var(--ink-4);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  cursor: pointer;
}

/* ---------- Horizontal scroller ---------- */
.h-scroll {
  display: flex;
  gap: 12px;
  padding: 0 20px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.h-scroll::-webkit-scrollbar { display: none; }

/* ---------- Star ratings ---------- */
.stars {
  display: inline-flex;
  gap: 1px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 1px;
}

/* ---------- Filigree divider ---------- */
.filigree {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  color: var(--gold);
  opacity: 0.65;
}
.filigree::before, .filigree::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

/* ---------- Floating top-right action buttons (overlay the hero) ---------- */
.top-actions-float {
  position: absolute;
  top: 24px;
  right: 34px;
  z-index: 6;
  display: flex;
  gap: 8px;
}

/* ---------- Detail page hero ---------- */
.detail-hero {
  position: relative;
  height: 460px;
  overflow: hidden;
}
.detail-hero .grad {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(14,15,19,0) 30%, rgba(14,15,19,0.7) 70%, var(--bg-1) 100%);
  z-index: 2;
}
.detail-hero .top-grad {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 120px;
  background: linear-gradient(180deg, rgba(0,0,0,0.7), transparent);
  z-index: 2;
}

/* ---------- Tabs (segmented) ---------- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-sm);
  padding: 4px;
  gap: 4px;
  margin: 0 20px;
}
.seg-item {
  background: none;
  border: 0;
  color: var(--ink-3);
  font-family: var(--f-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 120ms;
}
.seg-item.active {
  background: linear-gradient(180deg, var(--bg-4), var(--bg-3));
  color: var(--ink-0);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 2px 8px rgba(0,0,0,0.4);
}

/* ---------- Avatar frame ---------- */
.avatar-frame {
  position: relative;
  width: 96px;
  height: 96px;
}
.avatar-frame .ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--gold) 0%, var(--gold-dim) 25%, var(--gold-hi) 50%, var(--gold-dim) 75%, var(--gold) 100%);
  padding: 2px;
}
.avatar-frame .inner {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--bg-2);
  overflow: hidden;
  border: 2px solid var(--bg-1);
}

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; }
.spacer { flex: 1; }

/* ---------- Subtle hover / press feel for taps ---------- */
.tap { cursor: pointer; transition: transform 80ms, opacity 80ms; }
.tap:active { transform: scale(0.985); opacity: 0.9; }

/* ---------- Screen transition ---------- */
@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen-in { position: relative; animation: screenIn 220ms ease-out; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- Embers / motion ---------- */
@keyframes ember {
  0%   { transform: translateY(0) scale(1); opacity: 0; }
  20%  { opacity: 0.8; }
  100% { transform: translateY(-200px) scale(0.4); opacity: 0; }
}
.ember-particle {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffb070, var(--ember) 50%, transparent 70%);
  animation: ember 4s linear infinite;
  pointer-events: none;
}

/* ---------- Page rail (used in sub-screens for the back chevron header) ---------- */
.sub-header {
  position: absolute;
  top: 44px;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  z-index: 9;
}

/* ---------- Pulsing live dot ---------- */
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--crimson-hi);
  display: inline-block;
  animation: pulseDot 1.6s ease-in-out infinite;
}
.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--bg-2);
  display: inline-block;
}
