:root {
  color-scheme: dark;
  --bg: #07080d;
  --panel: rgba(16, 20, 32, 0.62);
  --panel-strong: rgba(23, 29, 46, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --text: #edf4ff;
  --muted: #9aa7ba;
  --cyan: #36e4ff;
  --violet: #a866ff;
  --green: #69ff9f;
  --pink: #ff5fa8;
  --gold: #ffd36a;
  --danger: #ff416d;
  font-family: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 8%, rgba(61, 228, 255, 0.16), transparent 28rem),
    radial-gradient(circle at 82% 18%, rgba(168, 102, 255, 0.18), transparent 31rem),
    radial-gradient(circle at 35% 88%, rgba(105, 255, 159, 0.13), transparent 26rem),
    linear-gradient(135deg, #05060a 0%, #0a0d16 46%, #05070a 100%);
  color: var(--text);
}

a { color: inherit; }
button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#particles,
.ambient,
.screen-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#particles {
  z-index: 0;
  opacity: 0.75;
}

.ambient {
  z-index: 0;
  filter: blur(44px);
  opacity: 0.72;
  mix-blend-mode: screen;
}

.ambient-one {
  background: radial-gradient(circle at 70% 40%, rgba(89, 255, 214, 0.16), transparent 25rem);
  animation: drift 13s ease-in-out infinite;
}

.ambient-two {
  background: radial-gradient(circle at 28% 62%, rgba(255, 95, 168, 0.16), transparent 25rem);
  animation: drift 18s ease-in-out infinite reverse;
}

.glass {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(24, 29, 47, 0.72), rgba(10, 13, 22, 0.48));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
}

.is-hidden {
  display: none !important;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(168, 102, 255, 0.2), transparent 28rem),
    rgba(3, 4, 8, 0.86);
}

.gate.shake .gate-panel {
  animation: shake 420ms ease;
}

.gate-panel,
.auth-card {
  width: min(100%, 31rem);
  border-radius: 8px;
  padding: 32px;
}

.eyebrow {
  color: var(--green);
  font-family: Orbitron, Inter, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
.brand strong {
  font-family: Orbitron, Inter, sans-serif;
  letter-spacing: 0;
}

.gate h1,
.auth-card h1,
.page-heading h1 {
  margin: 8px 0 10px;
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  line-height: 0.95;
  text-shadow: 0 0 34px rgba(54, 228, 255, 0.26);
}

.gate p,
.auth-card p {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

input {
  width: 100%;
  min-height: 3.35rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  outline: 0;
  padding: 0 14px;
  background: rgba(4, 7, 13, 0.62);
  color: var(--text);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

input:focus {
  border-color: rgba(54, 228, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(54, 228, 255, 0.12);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.primary-btn,
.roll-btn,
.primary-link,
.ghost-btn,
.effect-card button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 180ms ease, border-color 180ms ease, opacity 180ms ease;
}

.primary-btn,
.primary-link {
  display: inline-grid;
  place-items: center;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--cyan), var(--violet) 52%, var(--green));
  color: #02040a;
  font-weight: 800;
  box-shadow: 0 0 34px rgba(54, 228, 255, 0.28);
}

.ghost-btn {
  display: inline-grid;
  place-items: center;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.primary-btn:hover,
.primary-link:hover,
.ghost-btn:hover,
.roll-btn:hover,
.effect-card button:hover {
  transform: translateY(-1px);
}

.form-error {
  min-height: 1.2rem;
  color: #ff7898;
}

.app {
  position: relative;
  z-index: 2;
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 4.8rem;
  border-radius: 8px;
  padding: 10px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 13rem;
  text-decoration: none;
}

.brand-sigil {
  display: grid;
  width: 3rem;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 8px;
  background: radial-gradient(circle, var(--cyan), var(--violet));
  color: #05070a;
  font-family: Orbitron, Inter, sans-serif;
  font-weight: 900;
  box-shadow: 0 0 28px rgba(54, 228, 255, 0.36);
}

.brand strong,
.brand em {
  display: block;
}

.brand strong {
  font-size: 1.05rem;
}

.brand em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
}

.nav {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.nav a {
  min-height: 2.45rem;
  padding: 10px 14px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.nav a:hover,
.nav a.active {
  background: rgba(54, 228, 255, 0.12);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(54, 228, 255, 0.18);
}

.account-actions {
  display: flex;
  gap: 8px;
}

.user-only,
body.logged-in .guest-only {
  display: none;
}

body.logged-in .user-only {
  display: inline-grid;
}

#view {
  padding-top: 22px;
}

.roll-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 23rem;
  gap: 18px;
}

.roll-stage {
  position: relative;
  display: grid;
  min-height: calc(100vh - 8.2rem);
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  padding: 32px;
}

.roll-stage::before {
  position: absolute;
  inset: -20%;
  content: "";
  background:
    repeating-conic-gradient(from 0deg, rgba(54, 228, 255, 0.06) 0 7deg, transparent 7deg 16deg),
    radial-gradient(circle, rgba(168, 102, 255, 0.18), transparent 48%);
  animation: rotate 38s linear infinite;
}

.equipped-vignette {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 300ms ease;
}

.equipped-vignette.active {
  opacity: 0.7;
  background:
    radial-gradient(circle at 50% 46%, color-mix(in srgb, var(--fx-a), transparent 70%), transparent 21rem),
    linear-gradient(120deg, color-mix(in srgb, var(--fx-b), transparent 88%), transparent);
}

.ring {
  position: absolute;
  width: min(62vw, 36rem);
  aspect-ratio: 1;
  border: 1px solid rgba(54, 228, 255, 0.19);
  border-radius: 50%;
  box-shadow: 0 0 80px rgba(54, 228, 255, 0.08), inset 0 0 60px rgba(168, 102, 255, 0.1);
  animation: rotate 24s linear infinite;
}

.ring-b {
  width: min(46vw, 26rem);
  border-style: dashed;
  animation-duration: 15s;
  animation-direction: reverse;
}

.roll-core {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, 34rem);
  min-height: 21rem;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 1px solid color-mix(in srgb, var(--fx-a, var(--cyan)), transparent 62%);
  border-radius: 50%;
  padding: 42px;
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--fx-a, var(--cyan)), transparent 66%), transparent 44%),
    rgba(0, 0, 0, 0.24);
  text-align: center;
  box-shadow: 0 0 90px color-mix(in srgb, var(--fx-a, var(--cyan)), transparent 78%);
  transition: transform 240ms ease, filter 240ms ease, border-color 240ms ease;
}

.roll-core.slam {
  animation: slam 620ms cubic-bezier(.15, 1.4, .3, 1);
}

.result-rarity {
  color: var(--fx-a, var(--cyan));
  font-family: Orbitron, Inter, sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
}

.roll-core h1 {
  max-width: 100%;
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 5.7rem);
  line-height: 0.9;
  overflow-wrap: anywhere;
  text-shadow: 0 0 34px color-mix(in srgb, var(--fx-a, var(--cyan)), transparent 54%);
}

.roll-core p {
  max-width: 28rem;
  margin: 0;
  color: var(--muted);
}

.rarity-common {
  filter: saturate(0.9);
}

.rarity-rare {
  animation: rarePulse 2s ease-in-out infinite;
}

.rarity-veryRare {
  animation: veryRarePulse 1.3s ease-in-out infinite;
}

.rarity-superRare {
  animation: superRarePulse 800ms ease-in-out infinite;
}

.roll-btn {
  position: absolute;
  right: 50%;
  bottom: 58px;
  z-index: 2;
  min-width: 15rem;
  min-height: 4.2rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(135deg, rgba(54, 228, 255, 0.96), rgba(168, 102, 255, 0.94), rgba(105, 255, 159, 0.92));
  color: #03050b;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
  transform: translateX(50%);
  box-shadow: 0 0 44px rgba(54, 228, 255, 0.35);
}

.roll-btn:hover {
  transform: translateX(50%) translateY(-1px) scale(1.02);
}

.roll-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.roll-status {
  position: absolute;
  bottom: 28px;
  z-index: 2;
  color: var(--muted);
  text-align: center;
}

.side-stack {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  border-radius: 8px;
  padding: 12px;
}

.stat-strip article,
.metric {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.stat-strip span,
.metric span {
  color: var(--muted);
  font-size: 0.78rem;
}

.stat-strip strong,
.metric strong {
  overflow-wrap: anywhere;
  font-family: Orbitron, Inter, sans-serif;
}

.feed-panel {
  border-radius: 8px;
  padding: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-family: Orbitron, Inter, sans-serif;
}

.section-title i {
  width: 0.62rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 18px var(--green);
  animation: rarePulse 1.4s ease-in-out infinite;
}

.feed-list {
  display: grid;
  gap: 10px;
}

.feed-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 3.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  animation: feedIn 420ms ease both;
}

.feed-item i {
  width: 9px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 16px currentColor;
}

.feed-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.feed-item time,
.empty {
  color: var(--muted);
}

.rarity-common { color: #aeb8c9; }
.rarity-rare { color: var(--cyan); }
.rarity-veryRare { color: var(--violet); }
.rarity-superRare { color: var(--gold); }

.auth-page {
  display: grid;
  min-height: calc(100vh - 8rem);
  place-items: center;
}

.auth-swap a {
  color: var(--cyan);
  font-weight: 800;
}

.page-stack,
.profile-layout {
  display: grid;
  gap: 18px;
}

.page-heading {
  padding: 18px 2px 0;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 14px;
}

.effect-card {
  position: relative;
  display: grid;
  gap: 10px;
  min-height: 20rem;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--fx-a), transparent 70%);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--fx-a), transparent 90%), rgba(14, 17, 28, 0.72)),
    rgba(0, 0, 0, 0.24);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.24);
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.effect-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 28px 70px color-mix(in srgb, var(--fx-a), transparent 88%);
}

.effect-card.locked {
  opacity: 0.48;
  filter: grayscale(0.7);
}

.effect-preview {
  min-height: 7rem;
  border-radius: 8px;
  background:
    radial-gradient(circle at center, var(--fx-a), transparent 34%),
    radial-gradient(circle at 25% 70%, var(--fx-b), transparent 30%),
    rgba(255, 255, 255, 0.04);
  animation: previewPulse 2.6s ease-in-out infinite;
}

.type-name { clip-path: polygon(8% 20%, 92% 10%, 82% 82%, 13% 92%); }
.type-screen { filter: contrast(1.5) saturate(1.5); }
.type-ui { border-radius: 8px; }
.type-background { background-size: 40px 40px; }
.type-particles { mask-image: radial-gradient(circle, black 20%, transparent 70%); }

.effect-card span {
  color: var(--fx-a);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.effect-card h2 {
  margin: 0;
  font-size: 1.2rem;
}

.effect-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.effect-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.effect-card em {
  color: var(--muted);
  font-style: normal;
}

.effect-card button {
  min-height: 2.35rem;
  padding: 0 14px;
  background: color-mix(in srgb, var(--fx-a), #05070a 30%);
  color: #05070a;
  font-weight: 900;
}

.effect-card button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.profile-hero {
  position: relative;
  min-height: 28rem;
  overflow: hidden;
  border-radius: 8px;
  padding: 34px;
}

.profile-aura {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--fx-a, var(--cyan)), transparent 50%), transparent 24rem),
    conic-gradient(from 90deg, transparent, color-mix(in srgb, var(--fx-b, var(--violet)), transparent 70%), transparent);
  animation: rotate 20s linear infinite;
  opacity: 0.8;
}

.profile-hero > :not(.profile-aura) {
  position: relative;
  z-index: 1;
}

.profile-hero h1 {
  max-width: 100%;
  margin: 6rem 0 10px;
  font-size: clamp(3.1rem, 10vw, 8.8rem);
  line-height: 0.88;
  overflow-wrap: anywhere;
  text-shadow: 0 0 40px rgba(54, 228, 255, 0.34);
}

.profile-hero p {
  max-width: 58rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.name-name,
.name-aura,
.name-particles {
  background: linear-gradient(90deg, var(--cyan), var(--pink), var(--green));
  background-clip: text;
  color: transparent;
  animation: textShift 2.5s linear infinite;
}

.profile-grid,
.leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.board {
  border-radius: 8px;
  padding: 18px;
}

.leaderboard-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.board h2 {
  margin: 0 0 14px;
}

.board-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) minmax(5rem, auto);
  gap: 10px;
  align-items: center;
  min-height: 3.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.board-row b {
  display: grid;
  width: 1.75rem;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.board-row span,
.board-row em {
  min-width: 0;
  overflow-wrap: anywhere;
}

.board-row em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

.screen-fx {
  z-index: 30;
  display: none;
  place-items: center;
  background:
    radial-gradient(circle at center, color-mix(in srgb, var(--fx-a), transparent 55%), transparent 32rem),
    rgba(0, 0, 0, 0.76);
}

.screen-fx.active {
  display: grid;
  animation: cutsceneIn 1.6s ease both;
}

.screen-fx.rarity-superRare {
  animation-duration: 2.3s;
}

.screen-fx div {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.screen-fx span {
  color: var(--fx-a);
  font-family: Orbitron, Inter, sans-serif;
  font-weight: 900;
  text-transform: uppercase;
}

.screen-fx strong {
  max-width: min(88vw, 60rem);
  font-family: Orbitron, Inter, sans-serif;
  font-size: clamp(3rem, 10vw, 9rem);
  line-height: 0.85;
  overflow-wrap: anywhere;
  text-shadow: 0 0 60px var(--fx-a), 0 0 120px var(--fx-b);
}

@media (max-width: 980px) {
  .topbar,
  .roll-layout,
  .leaderboard-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    position: static;
  }

  .nav {
    overflow-x: auto;
  }

  .roll-layout {
    display: grid;
  }

  .roll-stage {
    min-height: 42rem;
  }

  .side-stack,
  .leaderboard-grid,
  .profile-grid {
    display: grid;
  }
}

@media (max-width: 620px) {
  .app {
    width: min(100% - 20px, 1360px);
  }

  .account-actions,
  .stat-strip {
    grid-template-columns: 1fr;
    display: grid;
  }

  .nav a {
    white-space: nowrap;
  }

  .roll-stage {
    min-height: 39rem;
    padding: 18px;
  }

  .roll-core {
    min-height: 18rem;
    padding: 24px;
  }
}

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(4vw, -3vh, 0) scale(1.08); }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
}

@keyframes rarePulse {
  0%, 100% { filter: drop-shadow(0 0 10px currentColor); }
  50% { filter: drop-shadow(0 0 22px currentColor); }
}

@keyframes veryRarePulse {
  0%, 100% { transform: scale(1); filter: saturate(1.1) drop-shadow(0 0 18px currentColor); }
  50% { transform: scale(1.025); filter: saturate(1.7) drop-shadow(0 0 40px currentColor); }
}

@keyframes superRarePulse {
  0%, 100% { transform: scale(1) rotate(0deg); filter: hue-rotate(0deg) drop-shadow(0 0 28px currentColor); }
  50% { transform: scale(1.045) rotate(-0.7deg); filter: hue-rotate(45deg) drop-shadow(0 0 68px currentColor); }
}

@keyframes slam {
  0% { transform: scale(0.92); }
  62% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes previewPulse {
  0%, 100% { transform: scale(1); filter: saturate(1); }
  50% { transform: scale(1.03); filter: saturate(1.7); }
}

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

@keyframes textShift {
  to { filter: hue-rotate(360deg); }
}

@keyframes cutsceneIn {
  0% { opacity: 0; transform: scale(1.16); filter: blur(12px); }
  22% { opacity: 1; transform: scale(1); filter: blur(0); }
  70% { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0; transform: scale(0.96); }
}
