:root {
  --lr-navy: #14213d;
  --lr-sky: #8fd4ff;
  --lr-sky-deep: #3fa9f5;
  --lr-sun: #ffd23f;
  --lr-orange: #ff7a00;
  --lr-cream: #fff8e7;
  --lr-sunscorch: #ff8a3d;
  --lr-starlight: #7b6cff;
  --lr-fossil: #3fae5a;
  --lr-coral: #19b8c9;
  --lr-snowglow: #e23b3b;
}

body:has(.library) {
  background: linear-gradient(180deg, var(--lr-sky) 0%, #bfe6ff 34%, var(--lr-cream) 100%);
  color: var(--lr-navy);
}

.lr-skip {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 20;
  transform: translateY(-160%);
  background: #fff;
  color: var(--lr-navy);
  border: 3px solid var(--lr-navy);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 700;
}

.lr-skip:focus {
  transform: none;
  outline: 5px solid var(--lr-sky-deep);
  outline-offset: 3px;
}

.library {
  width: min(1180px, 100%);
  padding: calc(12px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    calc(28px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.library .hero {
  max-width: none;
}

.library .brand-lockup {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.library .logo-mark,
.library .brand-lockup > div {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.library .lr-logo {
  display: block;
  height: clamp(52px, 9vw, 92px);
  width: auto;
  max-width: min(78vw, 520px);
  margin: 4px 0;
}

.library .lr-grownups-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 16px;
  border: 3px solid var(--lr-navy);
  border-radius: 999px;
  background: #fff;
  color: var(--lr-navy);
  box-shadow: 0 3px 0 var(--lr-navy);
  font-family: Nunito, sans-serif;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
}

.library .lr-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  align-items: stretch;
  margin: 10px 0 8px;
  overflow: hidden;
  border: 4px solid var(--lr-navy);
  border-radius: 36px;
  background: #e7c79a;
  box-shadow: 0 6px 0 var(--lr-navy);
}

.library .lr-hero-pic,
.library .lr-hero-pic img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: cover;
  object-position: 68% 50%;
}

.library .lr-hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: clamp(18px, 3vw, 40px);
  background: linear-gradient(90deg, rgba(255, 248, 231, 0.97) 0%, rgba(255, 248, 231, 0.9) 78%, rgba(255, 248, 231, 0.2) 100%);
}

.library .lr-headline {
  margin: 0;
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--lr-navy);
}

.library .lr-headline span {
  color: var(--lr-orange);
}

.library .steps {
  display: grid;
  gap: 8px;
  margin: 4px 0 0;
}

.library .steps li {
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
  padding: 0;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
}

.library .steps span {
  width: 44px;
  height: 44px;
  border: 3px solid var(--lr-navy);
  background: var(--lr-sun);
  color: var(--lr-navy);
  font-size: 1.25rem;
}

.library .steps li:nth-child(2) span { background: var(--lr-sky); }
.library .steps li:nth-child(3) span { background: #9be59b; }

.library .lede,
.library .hero-instruction {
  max-width: none;
  margin: 0;
  color: var(--lr-navy);
  background: transparent;
  box-shadow: none;
  padding: 0;
  font-size: 1rem;
}

.library .hero-instruction {
  display: inline-block;
  width: fit-content;
  padding: 8px 12px;
  border: 2px dashed var(--lr-navy);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
}

.library .lr-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  margin-top: 4px;
  padding: 12px 26px;
  border: 4px solid var(--lr-navy);
  border-radius: 999px;
  background: var(--lr-sun);
  color: var(--lr-navy);
  box-shadow: 0 6px 0 var(--lr-navy);
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  width: fit-content;
}

.library .notice {
  border: 3px solid var(--lr-navy);
  background: #fff4c2;
  color: var(--lr-navy);
}

.library .road-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 28px);
  margin-top: 18px;
}

.library .lr-worlds-head {
  margin: 22px 0 0;
  text-align: center;
}

.library .lr-worlds-head h2 {
  margin: 0;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 700;
}

.library .lr-worlds-head p {
  margin: 4px 0 0;
  font-weight: 800;
}

.library .road-card {
  border: 4px solid var(--lr-navy);
  border-radius: 28px;
  padding: 0;
  background: #fff;
  box-shadow: 0 8px 0 var(--lr-accent, var(--lr-sunscorch)), 0 8px 0 4px var(--lr-navy);
  overflow: hidden;
}

.library .road-card[data-world="starlight-skyway"] { --lr-accent: var(--lr-starlight); }
.library .road-card[data-world="fossil-fury-freeway"] { --lr-accent: var(--lr-fossil); }
.library .road-card[data-world="coral-shellway"] { --lr-accent: var(--lr-coral); }
.library .road-card[data-world="sunscorch-straight"] { --lr-accent: var(--lr-sunscorch); }
.library .road-card[data-world="snowglow-sleighway"] { --lr-accent: var(--lr-snowglow); }

@media (min-width: 1080px) {
  .library .road-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .library .road-grid > li {
    grid-column: span 2;
  }
  .library .road-grid > li:nth-child(4) { grid-column: 2 / span 2; }
  .library .road-grid > li:nth-child(5) { grid-column: 4 / span 2; }
}

@media (min-width: 861px) and (max-width: 1079px) {
  .library .road-grid > li:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    width: min(520px, calc(50% - 10px));
    justify-self: center;
  }
}

.library .card-preview {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: 0;
  border-bottom: 4px solid var(--lr-navy);
  background: #d7c4a4;
}

.library .preview-canvas {
  display: none;
}

.library .lr-card-art,
.library .lr-card-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library .lr-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 6px 12px;
  border: 3px solid var(--lr-navy);
  border-radius: 999px;
  background: var(--lr-accent, var(--lr-sun));
  color: #fff;
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(20, 33, 61, 0.35);
}

.library .card-copy {
  padding: 14px 16px 8px;
}

.library .card-chip { display: none; }

.library .card-title {
  font-size: clamp(1.5rem, 2.2vw, 2rem);
}

.library .card-blurb {
  color: var(--lr-navy);
  font-size: 1.05rem;
}

.library .card-play {
  min-height: 72px;
  margin: 8px 12px 14px;
  border: 4px solid var(--lr-navy);
  border-radius: 22px;
  background: var(--lr-sun);
  box-shadow: 0 6px 0 var(--lr-navy);
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.library .road-card:focus-visible,
.library .lr-cta:focus-visible,
.library .lr-grownups-chip:focus-visible {
  outline: 5px solid var(--lr-sky-deep);
  outline-offset: 4px;
}

.library .lr-grownups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 28px 0 0;
  padding: 18px 20px 22px;
  border: 4px solid var(--lr-navy);
  border-radius: 28px;
  background: #fff;
}

.library .lr-grownups h2 {
  grid-column: 1 / -1;
  margin: 0;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 1.7rem;
}

.library .lr-grownups strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.library .lr-grownups p {
  margin: 0;
  font-weight: 700;
  line-height: 1.35;
}

.library .colophon {
  text-align: center;
  color: var(--lr-navy);
}

.fixed.inset-0.z-50 {
  pointer-events: none;
}

[role="dialog"].fixed {
  pointer-events: auto;
  top: 8px !important;
  translate: none !important;
  transform: translateX(-50%) !important;
  max-height: calc(100dvh - 320px) !important;
}

@media (max-height: 520px) and (orientation: landscape) {
  [role="dialog"].fixed {
    left: auto !important;
    right: max(8px, env(safe-area-inset-right)) !important;
    width: min(680px, calc(100% - 200px)) !important;
    translate: none !important;
    transform: none !important;
    max-height: calc(100dvh - 16px) !important;
  }
}

[role="dialog"] .card-preview {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #efe6d4;
}

[role="dialog"] .preview-canvas { display: none; }

[role="dialog"] .lr-card-art,
[role="dialog"] .lr-card-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

[role="dialog"] .road-card {
  border: 3px solid var(--lr-navy);
  border-radius: 22px;
}

[role="dialog"] .card-play {
  min-height: 52px;
  border: 3px solid var(--lr-navy);
  background: var(--lr-sun);
  box-shadow: 0 4px 0 var(--lr-navy);
}

.instruction-banner {
  border: 3px solid var(--lr-navy);
  background: rgba(20, 33, 61, 0.94);
}

.control-dock {
  border-color: var(--lr-navy);
  border-radius: 28px;
}

.boost-fab {
  border-color: var(--lr-navy);
  background: var(--lr-sun);
  color: var(--lr-navy);
}

.boost-fab.is-on {
  background: #ef4d2f;
  color: #fff;
}

.show-controls {
  border: 3px solid var(--lr-navy);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--lr-navy);
}

@media (max-width: 860px) {
  .library .lr-hero {
    grid-template-columns: 1fr;
  }

  .library .lr-hero-pic,
  .library .lr-hero-pic img {
    height: auto;
    min-height: 0;
    aspect-ratio: 4 / 3;
    object-position: 50% 70%;
  }

  .library .lr-hero-copy {
    background: var(--lr-cream);
    border-top: 4px solid var(--lr-navy);
  }

  .library .road-grid,
  .library .lr-grownups {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .library .lr-logo { height: 48px; }
  .library .lr-hero-pic,
  .library .lr-hero-pic img { max-height: 46vh; aspect-ratio: auto; }
  .library .lr-headline { font-size: 1.7rem; }
  .library .steps span { width: 36px; height: 36px; }
  .library .card-play,
  .library .lr-cta { min-height: 52px; }
  .library .road-grid { grid-template-columns: 1fr 1fr; }
  .library .road-grid > li:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    width: min(420px, calc(50% - 8px));
    justify-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .library *,
  .library *::before,
  .library *::after {
    transition: none !important;
    animation: none !important;
  }
}
