:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  color: #f8fbff;
  background: #020617;
  --panel: rgba(5, 12, 35, 0.9);
  --line: rgba(125, 161, 255, 0.24);
  --pink: #ff55d6;
  --purple: #a63cff;
  --violet: #704cff;
  --cyan: #39d7ff;
  --gold: #ffc742;
  --muted: #9daac8;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #020617; }
body { min-height: 100%; margin: 0; overflow-x: hidden; background: radial-gradient(circle at 72% 6%, rgba(60, 65, 180, 0.18), transparent 30rem), #020617; }
button, input, select, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(circle, #77dfff 0 1px, transparent 1.5px),
    radial-gradient(circle, #bd76ff 0 1px, transparent 1.5px);
  background-position: 0 0, 43px 31px;
  background-size: 86px 86px, 123px 123px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

.realmverse-shell { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }
.realm-sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 13px;
  border-right: 1px solid rgba(93, 139, 255, 0.24);
  background: linear-gradient(180deg, rgba(3, 8, 28, 0.98), rgba(3, 6, 24, 0.94));
  box-shadow: 18px 0 50px rgba(0, 0, 0, 0.28);
}
.realm-brand { text-align: center; }
.realm-logo { display: inline-flex; align-items: center; gap: 12px; margin: 0 auto 10px; color: #fff; text-decoration: none; font-size: 1.18rem; font-weight: 900; }
.brand-mark { position: relative; display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: 10px; background: linear-gradient(135deg, var(--pink), var(--purple) 48%, var(--cyan)); box-shadow: 0 0 28px rgba(141,71,255,.6); transform: rotate(45deg); }
.brand-mark span { width: 15px; height: 15px; border-radius: 5px; background: #020817; }
.realm-brand b { display: block; font: 800 1.65rem/1 "Baloo 2", sans-serif; letter-spacing: 0; background: linear-gradient(90deg, #ff70df, #6fc8ff); color: transparent; background-clip: text; }
.realm-brand p { margin: 9px auto 0; max-width: 180px; color: #d2d8eb; font-size: 0.72rem; line-height: 1.45; }
.realm-sidebar nav { display: grid; gap: 4px; }
.realm-sidebar nav a {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 800;
}
.realm-sidebar nav a span { width: 20px; color: #87e6ff; text-align: center; font-size: 1rem; }
.realm-sidebar nav a:hover, .realm-sidebar nav a.is-active {
  border-color: #c54eff;
  background: linear-gradient(90deg, rgba(117, 30, 209, 0.72), rgba(74, 27, 147, 0.5));
  box-shadow: 0 0 20px rgba(183, 50, 255, 0.42);
}
.daily-quest, .realm-profile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 22, 60, 0.76);
}
.daily-quest { display: grid; gap: 6px; margin-top: auto; padding: 11px; font-size: 0.68rem; }
.daily-quest span, .daily-quest small { color: var(--muted); }
.daily-quest div, .profile-xp { height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.daily-quest i, .profile-xp i { display: block; width: 66%; height: 100%; background: linear-gradient(90deg, #633cff, #db38f5); }
.realm-profile { display: grid; grid-template-columns: 46px 1fr; gap: 9px; align-items: center; padding: 10px; }
.profile-avatar { width: 46px; height: 46px; display: grid; place-items: center; border: 2px solid #8c6cff; border-radius: 50%; background: #182552; font-weight: 900; }
.realm-profile strong, .realm-profile small, .realm-profile span { display: block; }
.realm-profile strong { font-size: 0.72rem; }
.realm-profile small, .realm-profile div + span { color: var(--muted); font-size: 0.58rem; }
.profile-xp { margin: 5px 0; }

.realm-main { min-width: 0; padding: 12px 18px 30px; }
.realm-topbar { height: 54px; display: grid; grid-template-columns: minmax(260px, 520px) 1fr auto auto; gap: 12px; align-items: center; }
.menu-button { display: none; }
.universal-search {
  min-height: 44px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  border: 1px solid rgba(176, 89, 255, 0.45);
  border-radius: 999px;
  background: rgba(8, 10, 37, 0.8);
}
.universal-search span { color: #d88cff; font-size: 1.2rem; }
.universal-search input { min-width: 0; border: 0; outline: 0; background: transparent; color: #fff; }
.universal-search kbd { padding: 2px 7px; border: 1px solid rgba(255,255,255,.14); border-radius: 5px; color: var(--muted); }
.realm-wallet { justify-self: end; display: flex; gap: 8px; }
.realm-wallet span, .top-icon {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 9, 28, 0.78);
  color: #fff;
  font-weight: 800;
}
.realm-wallet b { font-size: 1rem; }
.crystal { color: var(--cyan); }.coin { color: var(--gold); }.star { color: #d579ff; }
.top-icon { position: relative; width: 42px; padding: 0; justify-content: center; }
.top-icon i { position: absolute; top: -6px; right: -4px; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: #ef3155; font-size: 0.6rem; font-style: normal; }

.featured-hero {
  position: relative;
  min-height: 450px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid rgba(132, 114, 255, 0.25);
  border-radius: 8px;
  background: #061126;
}
.hero-backdrop { position: absolute; inset: 0; background-image: var(--hero-image, url("/assets/character-creator/environments/underwater-realm.png")); background-size: cover; background-position: center; transition: background-image 500ms ease; animation: hero-drift 18s ease-in-out infinite alternate; }
.featured-hero.has-book-cover .hero-backdrop { background-size: contain; background-position: right center; background-repeat: no-repeat; background-color: #071229; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(3, 7, 22, 0.96) 0%, rgba(3, 8, 24, 0.76) 32%, rgba(3, 8, 24, 0.08) 70%), linear-gradient(0deg, rgba(3, 7, 22, 0.82), transparent 50%); }
@keyframes hero-drift { from { transform: scale(1.02); } to { transform: scale(1.08) translateX(1%); } }
.hero-content { position: relative; z-index: 2; width: min(590px, 60%); padding: 58px 48px; }
.featured-label { margin: 0; color: #fff; font-size: 0.76rem; font-weight: 900; text-transform: uppercase; }
.featured-label span { color: var(--gold); font-size: 1.4rem; vertical-align: middle; }
.hero-content h1 { margin: 14px 0 10px; font-family: "Baloo 2", sans-serif; font-size: clamp(2.35rem, 4vw, 4.25rem); line-height: 0.95; letter-spacing: 0; }
.hero-description { max-width: 510px; margin: 0; color: #edf2ff; line-height: 1.55; }
.hero-origin { margin: 12px 0; font-size: 0.8rem; }
.hero-origin a { margin-left: 8px; color: #dcb8ff; text-decoration: none; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.hero-stats span { padding: 5px 8px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; background: rgba(3, 8, 22, 0.58); font-size: 0.7rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.hero-actions a, .hero-actions button, .modal-actions a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid rgba(142, 159, 255, 0.3);
  border-radius: 7px;
  background: rgba(7, 15, 42, 0.78);
  color: #fff;
  text-decoration: none;
  font-weight: 900;
}
.hero-actions .primary-play, .modal-actions a:first-child { border-color: #db66ff; background: linear-gradient(180deg, #b33cff, #6423ce); box-shadow: 0 0 24px rgba(184, 53, 255, 0.5); }
.hero-dots { position: absolute; z-index: 3; left: 50%; bottom: 16px; display: flex; gap: 7px; transform: translateX(-50%); }
.hero-dots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 999px; background: rgba(255,255,255,.36); }
.hero-dots button.is-active { width: 22px; background: linear-gradient(90deg, #ef53ff, #53dcff); }

.content-tabs { display: flex; gap: 8px; margin: 12px 0; overflow-x: auto; scrollbar-width: none; }
.content-tabs button { flex: 0 0 auto; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 8px; background: rgba(9, 14, 43, 0.82); color: #fff; font-weight: 800; }
.content-tabs button.is-active { border-color: #c55eff; background: linear-gradient(180deg, rgba(143, 41, 234, 0.8), rgba(78, 24, 164, 0.8)); box-shadow: 0 0 18px rgba(173, 57, 255, 0.38); }
.realm-columns { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 14px; }
.discovery-feed { min-width: 0; }
.discovery-section, .side-card, .feature-strip { border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(145deg, rgba(8, 15, 45, 0.86), rgba(3, 9, 29, 0.88)); }
.discovery-section { margin-bottom: 13px; padding: 13px; }
.section-heading, .side-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-heading h2, .side-heading h2 { margin: 0; font-size: 1rem; }
.section-heading h2 span { color: var(--gold); }
.section-heading button, .side-heading a, .side-heading button { border: 0; background: transparent; color: #d5c1ff; text-decoration: none; font-size: 0.7rem; font-weight: 800; }
.creation-rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: 9px; margin-top: 10px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-color: #7544d2 transparent; }
.creation-card { min-width: 0; overflow: hidden; border: 1px solid rgba(124, 151, 255, 0.22); border-radius: 8px; background: rgba(2, 8, 25, 0.92); scroll-snap-align: start; transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease; }
.creation-card:hover { z-index: 2; transform: translateY(-4px) scale(1.018); border-color: #b95cff; box-shadow: 0 12px 30px rgba(99, 37, 188, 0.36); }
.card-art { position: relative; width: 100%; aspect-ratio: 16 / 9; display: block; overflow: hidden; border: 0; background: #111b3f var(--card-image) center / cover no-repeat; }
.creation-card.has-book-cover .card-art { background-size: contain; background-color: #091227; }
.card-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(2,6,20,.78), transparent 55%); }
.card-play { position: absolute; z-index: 2; right: 9px; bottom: 8px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg, #ba3dff, #5425d6); box-shadow: 0 0 18px rgba(182, 62, 255, 0.7); opacity: 0; transform: scale(.8); transition: 160ms ease; }
.creation-card:hover .card-play { opacity: 1; transform: scale(1); }
.creation-type, .rank-badge { position: absolute; z-index: 2; top: 7px; padding: 4px 7px; border-radius: 5px; font-size: 0.58rem; font-weight: 900; text-transform: uppercase; }
.creation-type { right: 7px; background: rgba(3,8,22,.76); }
.rank-badge { left: 7px; background: var(--gold); color: #281400; font-size: 0.75rem; }
.card-copy { padding: 8px 9px 10px; }
.card-copy h3, .card-copy p { margin: 0; }
.card-copy h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; }
.card-copy p, .card-copy a { margin-top: 3px; color: var(--muted); font-size: 0.62rem; text-decoration: none; }
.card-copy a { display: block; color: #adccff; }
.card-copy div { display: flex; gap: 10px; margin-top: 7px; color: #dce6ff; font-size: 0.62rem; }
.compact-rail { grid-auto-columns: minmax(170px, .8fr); }

.category-grid { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.category-card { position: relative; min-height: 112px; overflow: hidden; display: grid; align-content: end; justify-items: start; padding: 11px; border: 1px solid rgba(137, 161, 255, 0.26); border-radius: 8px; background: linear-gradient(0deg, rgba(5,7,25,.92), rgba(5,7,25,.22)), var(--category-image) center / cover; color: #fff; text-align: left; }
.category-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(86, 35, 184, .24), transparent); }
.category-card > * { position: relative; z-index: 1; }
.category-card span { color: #b8efff; font-size: 1.2rem; }
.category-card strong { font-size: 0.78rem; }
.category-card small { color: #c1cbe2; font-size: 0.58rem; }
.category-card:hover { border-color: #c85eff; filter: brightness(1.16); }

.feature-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; }
.feature-strip a { min-height: 105px; display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: center; padding: 14px; background: rgba(7, 14, 42, 0.82); text-decoration: none; }
.feature-strip a + a { border-left: 1px solid var(--line); }
.feature-strip a > span { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; background: linear-gradient(145deg, #7333df, #1e9ccb); font-size: 1.3rem; }
.feature-strip strong { display: block; }
.feature-strip p { margin: 4px 0 0; color: var(--muted); font-size: 0.67rem; line-height: 1.4; }

.discovery-sidebar { display: grid; align-content: start; gap: 12px; }
.side-card { padding: 13px; }
.side-eyebrow { margin: 0 0 8px; color: #c9a8ff; font-size: 0.68rem; font-weight: 900; text-transform: uppercase; }
.planet-feature { overflow: hidden; }
.planet-art { min-height: 125px; margin: -13px -13px 10px; background: linear-gradient(0deg, rgba(5,10,31,.76), transparent), url("/assets/character-creator/environments/sky-islands.png") center / cover; }
.planet-feature h2, .planet-feature p { margin: 0; }
.planet-feature p { margin-top: 5px; color: var(--muted); font-size: 0.7rem; line-height: 1.45; }
.planet-feature > a { min-height: 38px; display: flex; align-items: center; justify-content: center; margin-top: 10px; border: 1px solid #a94dff; border-radius: 7px; background: rgba(105, 38, 178, .42); text-decoration: none; font-size: 0.72rem; font-weight: 900; }
.creator-list { display: grid; margin-top: 8px; }
.creator-list article { display: grid; grid-template-columns: 20px 38px 1fr auto; gap: 7px; align-items: center; padding: 7px 0; border-top: 1px solid rgba(126, 161, 255, .13); }
.creator-list article > b { color: var(--gold); text-align: center; font-size: .7rem; }
.creator-list img { width: 38px; height: 38px; object-fit: cover; border-radius: 7px; }
.creator-list strong, .creator-list span { display: block; }
.creator-list strong { font-size: .72rem; }.creator-list span { color: var(--muted); font-size: .58rem; }
.creator-list button { min-height: 28px; padding: 0 8px; border: 1px solid #8b64ff; border-radius: 6px; background: rgba(91,45,183,.35); color: #fff; font-size: .58rem; font-weight: 800; }
.creator-list button.is-following { border-color: #43dcb0; color: #72ffd2; }
.discover-filter-card { display: grid; gap: 9px; }
.discover-filter-card label { display: grid; gap: 5px; color: var(--muted); font-size: .64rem; font-weight: 800; }
.discover-filter-card select { min-height: 37px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: #09122e; color: #fff; }
.empty-discovery { min-width: 100%; min-height: 150px; display: grid; place-content: center; gap: 5px; color: var(--muted); text-align: center; }
.empty-discovery strong { color: #fff; }

.realm-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(1, 4, 15, .82); backdrop-filter: blur(8px); }
.realm-modal > section { position: relative; width: min(760px, 100%); display: grid; grid-template-columns: 46% 1fr; overflow: hidden; border: 1px solid #8d5cff; border-radius: 8px; background: #071027; box-shadow: 0 24px 80px rgba(0,0,0,.6); }
.realm-modal > section > button { position: absolute; z-index: 2; top: 9px; right: 9px; width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.2); border-radius: 7px; background: rgba(3,7,20,.72); color: #fff; font-size: 1.4rem; }
.modal-art { min-height: 360px; background-position: center; background-size: cover; }
.modal-copy { align-self: center; padding: 28px; }
.modal-copy > p:first-child { color: #c391ff; text-transform: uppercase; font-size: .68rem; font-weight: 900; }
.modal-copy h2 { margin: 7px 0; font-family: "Baloo 2"; font-size: 2rem; line-height: 1; }
.modal-copy p { color: #b8c4dc; line-height: 1.55; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; }

@media (max-width: 1180px) {
  .realmverse-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .realm-columns { grid-template-columns: minmax(0, 1fr) 260px; }
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .realm-wallet span:nth-child(2) { display: none; }
}

@media (max-width: 900px) {
  .realmverse-shell { display: block; }
  .realm-sidebar { position: fixed; left: 0; width: 230px; transform: translateX(-105%); transition: transform 220ms ease; }
  .realm-sidebar.is-open { transform: translateX(0); }
  .realm-main { padding: 10px 12px 24px; }
  .realm-topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .menu-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: #08122f; color: #fff; }
  .realm-wallet { display: none; }
  .realm-columns { grid-template-columns: minmax(0, 1fr); }
  .discovery-sidebar { grid-template-columns: repeat(3, 1fr); }
  .featured-hero { min-height: 410px; }
  .hero-content { width: 72%; padding: 48px 34px; }
}

@media (max-width: 640px) {
  .realm-main { padding: 8px 8px 20px; }
  .realm-topbar { height: auto; grid-template-columns: auto minmax(0,1fr) auto; }
  .universal-search { min-height: 40px; padding: 0 10px; }
  .universal-search kbd { display: none; }
  .top-icon { width: 38px; min-height: 38px; }
  .featured-hero { min-height: 470px; }
  .hero-backdrop { background-position: 62% center; }
  .hero-shade { background: linear-gradient(0deg, rgba(3,7,22,.98) 0%, rgba(3,7,22,.76) 52%, rgba(3,7,22,.12) 100%); }
  .hero-content { position: absolute; inset: auto 0 0; width: 100%; padding: 24px 18px 34px; }
  .hero-content h1 { font-size: 2.2rem; }
  .hero-description { font-size: .8rem; }
  .hero-origin { font-size: .7rem; }
  .hero-actions a, .hero-actions button { flex: 1 1 120px; padding: 0 10px; font-size: .7rem; }
  .creation-rail { grid-auto-columns: 72%; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .feature-strip { grid-template-columns: 1fr; }
  .feature-strip a + a { border-left: 0; border-top: 1px solid var(--line); }
  .discovery-sidebar { grid-template-columns: 1fr; }
  .realm-modal > section { grid-template-columns: 1fr; max-height: 90vh; overflow-y: auto; }
  .modal-art { min-height: 230px; }
  .modal-copy { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
