/* ═══════════════════════════════════════════════════════
   MYTHERY — Where Legends Collide
   Aesthetic: Dark grimoire ink · molten gold · arcane mist
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Uncial+Antiqua&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* obsidian base */
  --void:      #050508;
  --ink:       #0a0a10;
  --deep:      #101018;
  --surface:   #161620;
  --raised:    #1e1e2c;
  --border:    #2a2a3e;
  --border-lt: #363650;
  --muted:     #6a6888;
  --text:      #bdb8cc;
  --bright:    #e8e4f0;
  --white:     #f4f2f8;

  /* molten gold spectrum */
  --gold-dark:  #9a7420;
  --gold:       #c9982c;
  --gold-light: #e8b840;
  --gold-glow:  #ffd466;

  /* realm accents */
  --pyralis:   #d4553a;
  --thalassa:  #3a8ec4;
  --verdania:  #3a9e5c;
  --nocturn:   #8b5ec4;
  --aethon:    #c9a82c;
  --glacius:   #6cc4d4;
  --umbra:     #8a4a6e;

  /* rarity */
  --r-common:    #8888a0;
  --r-uncommon:  #3a9e5c;
  --r-rare:      #3a8ec4;
  --r-legendary: #c9982c;
  --r-mythic:    #c44ad4;

  /* type */
  --font-display: 'Uncial Antiqua', cursive;
  --font-prose:   'Libre Baskerville', serif;
  --font-ui:      'Outfit', sans-serif;

  --radius:    6px;
  --radius-lg: 12px;
  --radius-xl: 20px;

  /* layout */
  --nav-h:     58px;
  --mob-bar-h: 62px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--void);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* subtle grain */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* ═══ SCROLLBARS ═══ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-lt); }

a { color: var(--gold); text-decoration: none; transition: color .2s; }
a:hover { color: var(--gold-glow); }

h1,h2,h3 { font-family: var(--font-display); color: var(--bright); line-height: 1.3; }
h4,h5,h6 { font-family: var(--font-ui); font-weight: 600; color: var(--bright); }

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; border: none; border-radius: var(--radius);
  font-family: var(--font-ui); font-size: .82rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  transition: all .25s; text-decoration: none; white-space: nowrap;
  min-height: 44px;
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold-light));
  color: var(--void); box-shadow: 0 0 24px rgba(201,152,44,.15);
}
.btn-gold:hover { box-shadow: 0 0 36px rgba(201,152,44,.3); transform: translateY(-1px); }
.btn-ghost {
  background: transparent; color: var(--gold); border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--gold-dark); background: rgba(201,152,44,.06); }
.btn-danger { background: rgba(212,85,58,.12); color: var(--pyralis); border: 1px solid rgba(212,85,58,.25); }
.btn-sm { padding: 8px 18px; font-size: .75rem; min-height: 38px; }

/* ═══ FORM ELEMENTS ═══ */
.field { margin-bottom: 20px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: .72rem; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.field-opt { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .7; }
input[type="text"],input[type="email"],input[type="password"],
input[type="number"],textarea,select {
  width: 100%; padding: 12px 16px; min-height: 44px;
  background: var(--ink); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--bright);
  font-family: var(--font-ui); font-size: .95rem; transition: border-color .2s;
}
input:focus,textarea:focus,select:focus {
  outline: none; border-color: var(--gold-dark);
  box-shadow: 0 0 0 3px rgba(201,152,44,.08);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
select { cursor: pointer; }

/* ═══ NAV ═══ */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  height: var(--nav-h);
  background: rgba(5,5,8,.9); backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(42,42,62,.6);
}
.nav-brand { display: flex; align-items: center; }
.nav-logo-wide   { display: none;  height: 30px; width: auto; }
.nav-logo-mobile { display: block; height: 28px; width: 28px; }
.nav-links { display: none; gap: 24px; align-items: center; }
.nav-links a { font-size: .82rem; color: var(--muted); letter-spacing: .03em; }
.nav-links a:hover, .nav-links a.active { color: var(--gold); }

/* ═══ MOBILE BOTTOM NAV ═══ */
.mob-nav-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 155;
  display: flex; align-items: stretch; justify-content: space-around;
  height: calc(var(--mob-bar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(5,5,8,.95); backdrop-filter: blur(16px);
  border-top: 1px solid rgba(42,42,62,.6);
}
.mob-tab {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; flex: 1; padding: 6px 4px;
  font-size: .58rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); text-decoration: none; transition: color .2s; min-height: 44px;
  /* button reset */
  background: none; border: none; cursor: pointer;
  font-family: var(--font-ui); -webkit-appearance: none; appearance: none;
  position: relative;
}
.mob-tab:hover, .mob-tab.active { color: var(--gold); }
.micon { font-size: 1.25rem; line-height: 1; }

/* ═══ LAYOUT ═══ */
.container { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.page {
  padding-top: var(--nav-h);
  padding-bottom: calc(var(--mob-bar-h) + env(safe-area-inset-bottom, 0px) + 20px);
  min-height: 100vh;
}

/* ═══ PAGE HEADER ═══ */
.page-hdr {
  padding: 24px 0 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.page-hdr h1 { font-size: 1.4rem; margin-bottom: 4px; }
.page-hdr .hdr-greeting { color: var(--muted); font-size: .85rem; margin-bottom: 10px; }
.hdr-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.hdr-stat {
  padding: 4px 12px; background: var(--raised); border: 1px solid var(--border);
  border-radius: 20px; font-size: .75rem; color: var(--text);
}
.hdr-stat strong { color: var(--gold); }
.hdr-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══ CARD UI ═══ */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  transition: border-color .3s, box-shadow .3s;
}
.panel:hover { border-color: var(--border-lt); }
.panel-gold:hover { border-color: var(--gold-dark); box-shadow: 0 0 28px rgba(201,152,44,.08); }

/* ═══ GAME CARD VISUAL ═══ */
.gcard {
  width: 180px; height: 254px; border-radius: var(--radius-lg);
  position: relative; overflow: hidden; cursor: pointer; flex-shrink: 0;
  transition: transform .3s, box-shadow .3s;
}
.gcard:hover { transform: scale(1.04) rotateY(-2deg); box-shadow: 0 8px 36px rgba(0,0,0,.5); }
.gcard-frame {
  position: absolute; inset: 0;
  background: linear-gradient(155deg, var(--deep), var(--surface) 50%, var(--raised));
  border: 2px solid var(--border); border-radius: var(--radius-lg);
}
.gcard.legendary .gcard-frame { border-color: var(--gold-dark); }
.gcard.mythic .gcard-frame    { border-color: var(--r-mythic); }
.gcard.rare .gcard-frame      { border-color: var(--r-rare); }
.gcard-art {
  position: absolute; top: 10px; left: 10px; right: 10px; height: 130px;
  background: var(--ink); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; overflow: hidden;
}
.gcard-art img { width: 100%; height: 100%; object-fit: cover; }
.gcard-body { position: absolute; bottom: 0; left: 0; right: 0; padding: 10px 12px; }
.gcard-name { font-family: var(--font-display); font-size: .72rem; color: var(--bright); margin-bottom: 2px; }
.gcard-sub  { font-size: .6rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.gcard-cost {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold-dark); color: var(--void);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
}

/* ═══ STAT BARS ═══ */
.stat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.stat-lbl { font-size: .65rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); width: 34px; }
.stat-track { flex: 1; height: 6px; background: var(--ink); border-radius: 3px; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 3px; transition: width .5s; }
.stat-fill.str { background: var(--pyralis); }
.stat-fill.mag { background: var(--nocturn); }
.stat-fill.def { background: var(--thalassa); }
.stat-fill.spd { background: var(--verdania); }
.stat-fill.cha { background: var(--aethon); }
.stat-val { font-size: .75rem; color: var(--bright); width: 20px; text-align: right; }

/* ═══ STORY BEAT ═══ */
.beat {
  background: linear-gradient(135deg, rgba(22,22,32,.85), rgba(16,16,24,.95));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 24px; margin-bottom: 16px; position: relative;
}
.beat::before {
  content: ''; position: absolute; top: 0; left: 20%; right: 20%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}
.beat-round {
  font-family: var(--font-ui); font-size: .6rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--gold-dark); margin-bottom: 10px;
}
.beat-text { font-family: var(--font-prose); font-size: 1rem; line-height: 1.85; color: var(--text); }

/* ═══ CINEMATIC OVERLAY ═══ */
.cinema {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(5,5,8,.96); display: none;
  align-items: center; justify-content: center;
}
.cinema.on { display: flex; }
.cinema-inner {
  max-width: 660px; width: calc(100% - 40px);
  max-height: 82vh; overflow-y: auto;
  padding: 40px 32px; text-align: center;
  background: rgba(12,10,18,.92); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 24px 80px rgba(0,0,0,.7);
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.cinema-title {
  font-family: var(--font-display); font-size: 1.05rem; color: var(--gold);
  letter-spacing: .1em; margin-bottom: 20px;
  opacity: 0; animation: cfade 1s ease .3s forwards;
}
.cinema-text {
  font-family: var(--font-prose); font-size: 1.1rem; line-height: 1.9;
  color: var(--text); font-style: italic;
  opacity: 0; animation: cfade 1.2s ease .8s forwards;
}
.cinema-skip {
  margin-top: 32px; font-size: .72rem; color: var(--muted); cursor: pointer;
  opacity: 0; animation: cfade .5s ease 1.2s forwards;
  position: sticky; bottom: 0;
  background: linear-gradient(to top, rgba(12,10,18,.95) 60%, transparent);
  padding: 16px 0 4px; letter-spacing: .04em;
}
@keyframes cfade { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }

/* ═══ TOAST ═══ */
.toasts { position: fixed; top: calc(var(--nav-h) + 12px); right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: var(--radius); font-size: .85rem; max-width: 320px; animation: tslide .3s ease; }
.toast-ok  { background: rgba(58,158,92,.12); border: 1px solid rgba(58,158,92,.25); color: var(--verdania); }
.toast-err { background: rgba(212,85,58,.12); border: 1px solid rgba(212,85,58,.25); color: var(--pyralis); }
.toast-nfo { background: rgba(58,142,196,.12); border: 1px solid rgba(58,142,196,.25); color: var(--thalassa); }
@keyframes tslide { from{transform:translateX(80px);opacity:0} to{transform:translateX(0);opacity:1} }

/* ═══ GRID — mobile first ═══ */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: 1fr 1fr; }

/* ═══ SPINNER ═══ */
.spin { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to{transform:rotate(360deg)} }

/* ═══ REALM COLORS ═══ */
.realm-tag {
  display: inline-block; padding: 3px 10px; border-radius: 14px;
  font-size: .65rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}

/* ═══ TABLET (640px+) ═══ */
@media (min-width: 640px) {
  .container { padding: 0 24px; }
  .g2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .g3 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .gcard { width: 200px; height: 280px; }
  .gcard-art { height: 138px; }
  .panel { padding: 24px; }
  .page-hdr h1 { font-size: 1.6rem; }
}

/* ═══ MOBILE DRAWER ═══ */
.mob-drawer {
  position: fixed; left: 0; right: 0; z-index: 150;
  bottom: calc(var(--mob-bar-h) + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border: 1px solid var(--border-lt); border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 8px 6px 12px;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.mob-drawer.open { transform: translateY(0); }
.mob-drawer-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border-lt); margin: 0 auto 10px; }
.mob-drawer-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: var(--radius);
  color: var(--text); font-size: .88rem; text-decoration: none;
  transition: all .15s; font-family: var(--font-ui);
  width: 100%; background: none; border: none; cursor: pointer;
  text-align: left; box-sizing: border-box;
  -webkit-appearance: none; appearance: none;
}
.mob-drawer-item:hover, .mob-drawer-item.active { color: var(--gold); background: rgba(201,152,44,.07); }
.mob-drawer-icon { font-size: 1.15rem; width: 26px; text-align: center; flex-shrink: 0; }
.mob-drawer-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.nav-badge {
  background: var(--gold); color: var(--void);
  border-radius: 50%; width: 18px; height: 18px;
  font-size: .6rem; font-weight: 700; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.mob-more-dot {
  position: absolute; top: 6px; left: calc(50% + 6px);
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); pointer-events: none;
}

/* ═══ DESKTOP (768px+) ═══ */
@media (min-width: 768px) {
  .nav { padding: 14px 36px; }
  .nav-links { display: flex; }
  .nav-logo-wide   { display: block; }
  .nav-logo-mobile { display: none; }
  .mob-nav-bar { display: none; }
  #mob-drawer, #mob-drawer-overlay { display: none !important; }
  .container { padding: 0 36px; }
  .page { padding-bottom: 60px; }
  .gcard { width: 220px; height: 310px; }
  .gcard-art { height: 150px; font-size: 2.8rem; }
  .gcard-cost { width: 28px; height: 28px; font-size: .75rem; }
  .gcard-name { font-size: .75rem; }
  .gcard-sub { font-size: .65rem; }
  .g2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .g3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .panel { padding: 28px; }
  .page-hdr { padding: 32px 0 24px; }
  .page-hdr h1 { font-size: 1.8rem; }
}

/* ═══ WIDE DESKTOP (1024px+) ═══ */
@media (min-width: 1024px) {
  .container { padding: 0 36px; }
  .beat { padding: 24px 28px; }
  .beat-text { font-size: 1.05rem; }
}
