/* ============================================================
   THE LEGEND — cinematic intro
   ============================================================ */

.legend-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 216, 107, .35);
  background: rgba(255, 216, 107, .06);
  color: var(--gold);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
  cursor: pointer;
}
.legend-link:hover { background: rgba(255, 216, 107, .12); border-color: var(--line-strong); }
.legend-link-play {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #1d1605;
  font-size: 9px;
  padding-left: 1px;
}
.legend-link small { color: var(--muted); font-size: 7px; letter-spacing: 1px; font-weight: 600; }

body.legend-open .lobby-screen { overflow: hidden; }

.legend {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  overflow: hidden;
  background: #050509;
  color: var(--text);
}
.legend-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity .9s ease, transform 6s ease;
  filter: saturate(.9) brightness(.8);
}
.legend-shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 28% 45%, rgba(4, 4, 9, .35), rgba(4, 4, 9, .86) 68%),
    linear-gradient(180deg, rgba(4, 4, 8, .72), rgba(4, 4, 8, .28) 35%, rgba(4, 4, 8, .9));
  pointer-events: none;
}
.legend-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px clamp(14px, 3vw, 36px);
}
.legend-brand {
  color: var(--gold);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 2px;
}
.legend-brand span { color: var(--muted); font-weight: 700; }
.legend-tools { display: flex; align-items: center; gap: 10px; }
.legend-count { font-size: 8px; letter-spacing: 1.5px; color: var(--muted); }
.legend-skip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 216, 107, .4);
  background: rgba(0, 0, 0, .45);
  color: var(--gold);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
}
.legend-skip:hover { background: rgba(255, 216, 107, .14); }

.legend-stage {
  position: relative;
  z-index: 2;
  width: min(1320px, 100%);
  margin: auto;
  padding: 78px clamp(16px, 4vw, 56px) 70px;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr);
  gap: clamp(18px, 4vw, 54px);
  align-items: center;
}
.legend-panel {
  padding: clamp(18px, 2.6vw, 30px);
  border: 1px solid rgba(255, 216, 107, .2);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(10, 10, 16, .72), rgba(6, 6, 10, .86));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
  backdrop-filter: blur(3px);
}
.legend-chapter {
  color: var(--gold-2);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 3px;
  margin-bottom: 10px;
}
.legend-title {
  margin: 0 0 14px;
  font-size: clamp(28px, 4.6vw, 58px);
  line-height: .98;
  letter-spacing: 1px;
  font-weight: 900;
  background: linear-gradient(135deg, #fff6cd 0%, var(--gold) 42%, #b98e22 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.legend-text {
  min-height: 7.2em;
  margin: 0;
  max-width: 60ch;
  color: #dcd7e6;
  font-size: clamp(12px, 1.15vw, 15px);
  line-height: 1.7;
  letter-spacing: .2px;
}
.legend-text::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -.15em;
  background: var(--gold);
  animation: legendCaret 1s steps(1) infinite;
}
@keyframes legendCaret { 50% { opacity: 0; } }
.legend-nav { display: flex; gap: 8px; margin-top: 20px; }
.legend-nav-btn {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .3);
  color: #ddd;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
}
.legend-nav-btn:hover { border-color: var(--line-strong); color: var(--gold); }
.legend-nav-btn:disabled { opacity: .3; cursor: default; }
.legend-nav-btn.next { margin-left: auto; border-color: rgba(255, 216, 107, .45); color: var(--gold); background: rgba(255, 216, 107, .08); }

.legend-art {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.4vw, 16px);
  min-height: 260px;
}
.legend-art.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(6px, .9vw, 12px);
  align-content: center;
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
}
.legend-art.grid .legend-cover { width: 100%; }
.legend-card {
  position: relative;
  width: clamp(84px, 8.6vw, 124px);
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .18);
  background: #15151c;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
  opacity: 0;
  transform: translateY(18px) rotate(-2deg);
}
.legend-art.enter .legend-card { animation: legendCardIn .7s cubic-bezier(.2, .9, .25, 1.1) forwards; }
.legend-art.enter .legend-card:nth-child(2) { animation-delay: .16s; transform: translateY(18px) rotate(1.5deg); }
.legend-art.enter .legend-card:nth-child(3) { animation-delay: .32s; transform: translateY(18px) rotate(-1deg); }
.legend-art.enter .legend-card:nth-child(4) { animation-delay: .48s; transform: translateY(18px) rotate(2deg); }
@keyframes legendCardIn { to { opacity: 1; transform: translateY(0) rotate(0); } }
.legend-card img { width: 100%; display: block; aspect-ratio: 2 / 2.9; object-fit: cover; }
.legend-card figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 12px 7px 6px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .9));
  font-size: 8px;
  letter-spacing: .4px;
}
.legend-card figcaption b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-card figcaption span { color: var(--gold); font-weight: 900; }
.legend-card.nft {
  border-color: rgba(255, 216, 107, .65);
  box-shadow: 0 0 0 1px rgba(255, 216, 107, .25), 0 0 28px rgba(255, 216, 107, .22), 0 18px 40px rgba(0, 0, 0, .55);
}
.legend-card.nft::after {
  content: "NFT";
  position: absolute;
  top: 5px; right: 5px;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--gold);
  color: #1d1605;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: .8px;
}

.legend-cover {
  position: relative;
  width: clamp(74px, 8.2vw, 116px);
  margin: 0;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .15);
  background: #111;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
  opacity: 0;
  transform: translateY(12px);
}
.legend-art.enter .legend-cover {
  animation: legendCoverIn .55s ease forwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes legendCoverIn { to { opacity: 1; transform: none; } }
.legend-cover img { width: 100%; aspect-ratio: 2 / 2.9; object-fit: cover; display: block; }
.legend-cover figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 12px 4px 4px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .88));
  font-size: 6.5px;
  letter-spacing: .2px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.legend-cover.league { width: clamp(84px, 9vw, 126px); border-width: 2px; }
.legend-cover.league.bronze { border-color: #b87333; }
.legend-cover.league.silver { border-color: #cfd8e3; }
.legend-cover.league.gold { border-color: var(--gold); box-shadow: 0 0 24px rgba(255, 216, 107, .3); }

.legend-duel { display: flex; align-items: center; justify-content: center; gap: clamp(8px, 2vw, 22px); width: 100%; }
.legend-duel .legend-card { width: clamp(90px, 11vw, 140px); }
.legend-duel .legend-card.duel-a { transform: translateY(18px) rotate(-4deg); }
.legend-duel .legend-card.duel-b { transform: translateY(18px) rotate(4deg); }
.legend-vs {
  font-size: clamp(18px, 3vw, 34px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 216, 107, .5);
}

.legend-progress-wrap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  height: 4px;
  background: rgba(255, 255, 255, .08);
}
.legend-progress-wrap span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
  box-shadow: 0 0 12px rgba(255, 216, 107, .6);
  transition: width .4s ease;
}

.legend-gate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 216, 107, .08), transparent 55%),
    radial-gradient(ellipse at 50% 60%, rgba(4, 4, 9, .6), rgba(4, 4, 9, .95));
  backdrop-filter: blur(2px);
}
.legend-gate-box {
  position: relative;
  z-index: 2;
  width: min(640px, 100%);
  text-align: center;
  padding: clamp(20px, 4vw, 38px);
}
.legend-gate-cards {
  position: relative;
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: clamp(4px, .8vw, 10px);
  margin-top: 18px;
  opacity: .9;
  pointer-events: none;
}
.legend-gate-cards::before {
  content: "";
  position: absolute;
  inset: -16px -30px;
  z-index: -1;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 216, 107, .16), transparent 70%);
  pointer-events: none;
}
.legend-gate-cards img {
  height: clamp(96px, 16vh, 150px);
  width: auto;
  aspect-ratio: 2 / 2.9;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid rgba(255, 216, 107, .42);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .6), 0 0 20px rgba(255, 216, 107, .12);
  transform: rotate(calc((var(--i, 0) - 2) * 3deg));
  filter: saturate(1) brightness(1.03);
}
@media (max-width: 620px) {
  .legend-gate { padding: 14px; }
  .legend-gate-cards { gap: 4px; margin-top: 14px; opacity: .9; }
  .legend-gate-cards img { height: clamp(64px, 12vh, 86px); }
}
.legend-gate-kicker { color: var(--gold-2); font-size: 8px; letter-spacing: 4px; font-weight: 900; }
.legend-gate-title {
  margin: 10px 0 14px;
  font-size: clamp(40px, 5.7vw, 84px);
  line-height: .92;
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255, 216, 107, .25);
}
.legend-gate-title span { color: #fff; }
.legend-gate-box p { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 0 0 20px; }
.legend-begin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 16px;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-align: center;
  opacity: .84;
  transition: opacity .18s ease, transform .18s ease;
}
.legend-begin:hover { opacity: 1; transform: translateY(-1px); }
.legend-auto {
  margin-top: 9px;
  font-size: 8px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, .42);
}
.legend-gate-skip {
  display: block;
  margin: 12px auto 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 1.2px;
  cursor: pointer;
  text-decoration: underline;
}
.legend-gate-box small { display: block; margin-top: 12px; color: rgba(255, 255, 255, .3); font-size: 7px; letter-spacing: 1px; }

@media (max-width: 900px) {
  .legend { overflow-y: auto; }
  .legend-stage { grid-template-columns: 1fr; padding-top: 64px; gap: 16px; }
  .legend-art { order: 2; min-height: 0; }
  .legend-panel { order: 1; }
  .legend-text { min-height: 8.4em; }
  .legend-card { width: clamp(78px, 16vw, 104px); }
  .legend-art.grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
}
@media (max-width: 620px) {
  .legend-link { font-size: 8px; padding: 7px 11px; }
  .legend-link small { display: none; }
  .legend-topbar { padding: 10px 12px; }
  .legend-brand { font-size: 7px; letter-spacing: 1.2px; }
  .legend-skip { font-size: 7px; padding: 6px 9px; }
  .legend-stage { padding: 56px 10px 30px; gap: 12px; }
  .legend-panel { padding: 14px; border-radius: 14px; }
  .legend-chapter { font-size: 7px; letter-spacing: 2px; margin-bottom: 7px; }
  .legend-title { font-size: clamp(24px, 8vw, 34px); margin-bottom: 10px; }
  .legend-text { font-size: 11.5px; line-height: 1.55; min-height: 9.5em; }
  .legend-nav { margin-top: 12px; }
  .legend-nav-btn { padding: 8px 11px; font-size: 8px; }
  .legend-art { gap: 6px; }
  .legend-card { width: 78px; border-radius: 8px; }
  .legend-card figcaption { font-size: 6.5px; padding: 10px 5px 4px; }
  .legend-cover { width: 64px; }
  .legend-cover figcaption { font-size: 5.5px; }
  .legend-cover.league { width: 74px; }
  .legend-duel .legend-card { width: 92px; }
  .legend-gate-box { padding: 16px; }
  .legend-gate-title { font-size: clamp(40px, 14vw, 64px); }
  .legend-gate-box p { font-size: 10px; }
  .legend-begin { padding: 13px 12px; font-size: 10px; }
}
