:root {
  color-scheme: dark;
  --bg: #04050a;
  --ink: #f5eef1;
  --line: rgba(236, 238, 248, 0.16);
  --glass: rgba(5, 6, 11, 0.62);
  --glow: rgba(125, 178, 255, 0.2);
  --accent: rgba(178, 124, 255, 0.36);
  --radius: 8px;
}

@font-face {
  font-family: "Valnarok";
  src: url("assets/fonts/ValnarokbyNarosaki.otf") format("opentype");
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: transparent;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.intro-active {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.world-map {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(2, 3, 7, 0.44), rgba(2, 3, 7, 0.7)),
    url("assets/dragon-bg.jpg") center / cover no-repeat;
  filter: brightness(0.72) saturate(0.9);
  transform: scale(1.02);
}

.world-map::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(3, 4, 9, 0.58), transparent 34%, transparent 66%, rgba(3, 4, 9, 0.58)),
    linear-gradient(180deg, rgba(3, 4, 9, 0.18), rgba(3, 4, 9, 0.76)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 6px);
}

.intro-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #020309;
  opacity: 1;
  transition: opacity 850ms ease, visibility 850ms ease;
}

.intro-gate--hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.intro-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.56) saturate(0.86) contrast(1.05);
}

.intro-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(2, 3, 8, 0.3), rgba(2, 3, 8, 0.74)),
    linear-gradient(90deg, rgba(2, 3, 8, 0.86), transparent 30%, transparent 70%, rgba(2, 3, 8, 0.82));
}

.intro-copy {
  position: relative;
  display: grid;
  max-width: min(920px, calc(100vw - 42px));
  gap: 18px;
  padding: 0 18px;
  text-align: center;
}

.intro-copy h2 {
  margin: 0;
  font-family: "Valnarok", Georgia, "Times New Roman", serif;
  font-size: clamp(3.6rem, 10vw, 9rem);
  font-weight: 900;
  line-height: 0.88;
  letter-spacing: 0;
  background: linear-gradient(135deg, #92fff1 0%, #84dfff 32%, #b36cff 68%, #f0d8ff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(146, 255, 241, 0.3))
    drop-shadow(0 0 28px rgba(179, 108, 255, 0.32))
    drop-shadow(0 12px 36px rgba(0, 0, 0, 0.92));
}

.intro-copy p {
  max-width: 700px;
  margin: 0 auto;
  font-family: "Valnarok", Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 2.2vw, 1.75rem);
  line-height: 1.45;
  background: linear-gradient(120deg, #b6fff6 0%, #8fb8ff 48%, #d58bff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 8px rgba(146, 255, 241, 0.28))
    drop-shadow(0 0 22px rgba(179, 108, 255, 0.24))
    drop-shadow(0 8px 24px rgba(0, 0, 0, 0.92));
}

.intro-skip,
.modal-close,
.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(3, 4, 9, 0.58);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.intro-skip {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 2;
  color: rgba(245, 238, 241, 0.86);
  font-size: 1.45rem;
}

.intro-skip:hover,
.modal-close:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(236, 238, 248, 0.34);
  background: rgba(16, 18, 30, 0.76);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.52), 0 0 24px var(--glow);
}

.icon-button--active {
  border-color: rgba(236, 238, 248, 0.5);
  background: rgba(52, 40, 82, 0.78);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.54), 0 0 26px rgba(178, 124, 255, 0.2);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 22px 18px 18px;
  background: linear-gradient(180deg, rgba(4, 5, 10, 0.94), rgba(4, 5, 10, 0.6) 72%, transparent);
  pointer-events: none;
}

.app-shell,
.legal-footer {
  position: relative;
  z-index: 1;
}

.app-header h1 {
  margin: 0;
  font-family: "Valnarok", Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 5vw, 5.8rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
  text-align: center;
  background: linear-gradient(135deg, #92fff1 0%, #84dfff 32%, #b36cff 68%, #f0d8ff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 9px rgba(146, 255, 241, 0.28))
    drop-shadow(0 0 24px rgba(179, 108, 255, 0.28))
    drop-shadow(0 10px 32px rgba(0, 0, 0, 0.9));
}

.app-shell {
  width: min(1540px, calc(100% - 28px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 78px) 0 92px;
}

.collection-panel {
  padding: clamp(4px, 1vw, 16px);
}

.card-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(164px, 16vw, 238px), 1fr));
  gap: clamp(20px, 3vw, 40px);
  align-items: start;
}

.card-tile {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 1000px;
}

.card-portrait,
.detail-card {
  position: relative;
  display: block;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(236, 238, 248, 0.16);
  border-radius: var(--radius);
  background: rgba(3, 4, 9, 0.72);
  transform-style: preserve-3d;
  will-change: transform;
}

.card-portrait {
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.56);
  transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) translateY(0) scale(1);
  transition: transform 160ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.card-tile:hover .card-portrait,
.card-tile:focus-visible .card-portrait {
  border-color: rgba(236, 238, 248, 0.34);
  box-shadow: 0 34px 72px rgba(0, 0, 0, 0.64), 0 0 30px rgba(125, 178, 255, 0.12);
  transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) translateY(-8px) scale(1.025);
}

.card-portrait img,
.detail-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.card-portrait img {
  aspect-ratio: 744 / 1016;
}

.empty-state {
  min-height: 30vh;
  margin: 0;
}

.legal-footer {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 46px;
  border-top: 1px solid rgba(236, 238, 248, 0.12);
  color: rgba(245, 238, 241, 0.58);
  font-size: 0.78rem;
  line-height: 1.55;
  text-align: center;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.86);
}

.legal-footer p {
  max-width: 980px;
  margin: 0 auto 7px;
}

.legal-footer p:first-child {
  font-family: "Valnarok", Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 1.7vw, 1.45rem);
  background: linear-gradient(120deg, #b6fff6 0%, #8fb8ff 48%, #d58bff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 7px rgba(146, 255, 241, 0.18))
    drop-shadow(0 0 14px rgba(179, 108, 255, 0.16));
}

.card-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background:
    linear-gradient(180deg, rgba(2, 3, 8, 0.82), rgba(2, 3, 8, 0.96)),
    transparent;
  color: var(--ink);
}

.card-dialog::backdrop {
  background: rgba(1, 2, 5, 0.82);
  backdrop-filter: blur(18px);
}

.modal-close {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 4;
  font-size: 1.35rem;
}

.detail-stage {
  display: grid;
  min-height: 100vh;
  padding: clamp(76px, 8vw, 110px) clamp(16px, 4vw, 64px) clamp(112px, 14vh, 160px);
  place-items: center;
}

.detail-card {
  width: min(610px, 84vw, 64vh);
  aspect-ratio: 744 / 1016;
  cursor: default;
  box-shadow: 0 40px 96px rgba(0, 0, 0, 0.78), 0 0 42px rgba(178, 124, 255, 0.13);
  transform: perspective(1100px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 150ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.detail-card:hover {
  border-color: rgba(236, 238, 248, 0.34);
  box-shadow: 0 44px 104px rgba(0, 0, 0, 0.82), 0 0 46px rgba(125, 178, 255, 0.13);
}

.detail-card img {
  transform-origin: center center;
  will-change: transform;
}

.viewer-controls {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(calc(100vw - 28px), 650px);
  padding: 10px;
  border: 1px solid rgba(236, 238, 248, 0.14);
  border-radius: 999px;
  background: rgba(3, 4, 9, 0.68);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
}

.viewer-controls .icon-button {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  font-size: 1.18rem;
}

#zoomRange {
  flex: 1 1 auto;
  min-width: 96px;
  accent-color: #a87cff;
}

.card-text-panel {
  position: fixed;
  top: 92px;
  right: clamp(14px, 4vw, 52px);
  z-index: 4;
  width: min(430px, calc(100vw - 28px));
  max-height: calc(100vh - 206px);
  overflow: auto;
  padding: clamp(18px, 2.6vw, 28px);
  border: 1px solid rgba(236, 238, 248, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(9, 10, 18, 0.94), rgba(4, 5, 10, 0.97)),
    rgba(4, 5, 10, 0.94);
  box-shadow: 0 26px 72px rgba(0, 0, 0, 0.66), 0 0 34px rgba(125, 178, 255, 0.08);
  backdrop-filter: blur(18px);
}

.card-text-content {
  font-family: "Valnarok", Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.5vw, 1.24rem);
  line-height: 1.58;
  white-space: pre-wrap;
  background: linear-gradient(120deg, #b6fff6 0%, #8fb8ff 50%, #d58bff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 7px rgba(146, 255, 241, 0.18))
    drop-shadow(0 0 16px rgba(179, 108, 255, 0.18))
    drop-shadow(0 6px 18px rgba(0, 0, 0, 0.88));
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 1540px);
    padding-bottom: 78px;
  }

  .card-gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 18px;
  }

  .intro-copy h2 {
    font-size: clamp(3rem, 18vw, 5.4rem);
  }

  .detail-card {
    width: min(88vw, 58vh);
  }

  .viewer-controls {
    gap: 6px;
    padding: 8px;
  }

  .viewer-controls .icon-button {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }

  .card-text-panel {
    top: auto;
    right: 9px;
    bottom: 86px;
    left: 9px;
    width: auto;
    max-height: 42vh;
    padding: 18px;
  }
}

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