@font-face {
  font-family: "Yellowtail";
  src: url("../assets/fonts/yellowtail-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Bowlby One SC";
  src: url("../assets/fonts/bowlby-one-sc-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Barlow";
  src: url("../assets/fonts/barlow-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Barlow";
  src: url("../assets/fonts/barlow-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  cursor: default;
}

.backdrop,
.stage,
.overlay,
.vignette,
.grain {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
}

.backdrop {
  background:
    radial-gradient(120% 90% at 50% 40%, var(--bg) 0%, var(--bg-deep) 100%);
  overflow: hidden;
}

.aura {
  position: absolute;
  top: 50%;
  width: 90vh;
  height: 90vh;
  margin-top: -50vh;
  color: #8f7dff;
  background: radial-gradient(closest-side, currentColor 0%, transparent 100%);
  opacity: 0.16;
  transition: color 2.4s ease, left 2.4s ease;
  left: 58%;
}

.aura.is-left {
  left: 4%;
}

.stage {
  overflow: hidden;
}

.piece {
  position: absolute;
  opacity: 0;
  visibility: hidden;
}

.piece.is-active,
.piece.is-leaving {
  visibility: visible;
}

.piece.is-active.from-right {
  animation: piece-in-right var(--piece-enter) cubic-bezier(0.2, 0.75, 0.2, 1) forwards;
}

.piece.is-active.from-left {
  animation: piece-in-left var(--piece-enter) cubic-bezier(0.2, 0.75, 0.2, 1) forwards;
}

.piece.is-leaving {
  animation: piece-out var(--piece-leave) ease-in forwards;
}

@keyframes piece-in-right {
  from {
    opacity: 0;
    transform: translate3d(7vw, 2vh, 0) scale(1.04);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes piece-in-left {
  from {
    opacity: 0;
    transform: translate3d(-7vw, 2vh, 0) scale(1.04);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes piece-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translate3d(0, 1.5vh, 0) scale(0.985);
  }
}

.piece-drift,
.piece-mask {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.piece-drift {
  will-change: transform;
}

.piece-mask {
  overflow: hidden;
  -webkit-mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: 0 0;
}

.layer {
  position: absolute;
  will-change: transform;
}

.layer-base {
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
}

.layer-pattern,
.layer-fine {
  background-repeat: repeat;
}

.layer-fine {
  opacity: 0.1;
}

.layer-scene {
  top: -6%;
  left: -12%;
  width: 124%;
  height: 112%;
  background-size: cover;
  background-position: center;
}

.layer-shade {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background:
    radial-gradient(90% 70% at 72% 18%, rgba(255, 255, 255, 0.22) 0%, transparent 60%),
    linear-gradient(180deg, transparent 55%, rgba(30, 10, 60, 0.28) 100%);
  will-change: auto;
}

.layer-sheen {
  top: -20%;
  left: 0;
  width: 60%;
  height: 140%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0) 70%, transparent 100%);
}

.credits {
  position: fixed;
  top: 50%;
  width: var(--credits-width);
  transform: translateY(-46%);
  z-index: 3;
}

.credits.is-left {
  left: var(--credits-gutter);
  text-align: right;
}

.credits.is-right {
  right: var(--credits-gutter);
  text-align: left;
}

.credit-group + .credit-group {
  margin-top: 2.6vh;
}

.credit-role,
.credit-name,
.credit-tip {
  display: block;
  opacity: 0;
}

.credit-role {
  font-family: var(--font-script);
  font-size: var(--role-size);
  line-height: 1.15;
  color: var(--neon);
  text-shadow: 0 0 4px var(--neon-glow), 0 0 18px var(--neon-glow);
  padding: 0 0.2em;
  margin-bottom: 0.25em;
}

.credit-name {
  font-family: var(--font-display);
  font-size: var(--name-size);
  line-height: 1.04;
  color: var(--text-main);
  text-shadow: 0 0 14px var(--name-glow);
  overflow-wrap: break-word;
}

.credit-group.is-big .credit-name {
  font-size: var(--name-big-size);
  line-height: 0.96;
}

.credit-tip {
  margin-top: 0.6vh;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--tip-size);
  line-height: 1.32;
  color: var(--text-main);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.credits.is-in .credit-role {
  animation: neon-in 1100ms linear forwards;
}

.credits.is-in .credit-name,
.credits.is-in .credit-tip {
  animation: rise-in 800ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.credits.is-out {
  opacity: 0;
  transform: translateY(-48%);
  transition: opacity 600ms ease, transform 600ms ease;
}

@keyframes neon-in {
  0% { opacity: 0; }
  8% { opacity: 0.85; }
  12% { opacity: 0.1; }
  20% { opacity: 1; }
  26% { opacity: 0.35; }
  34% { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(1.6vh);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overlay {
  z-index: 4;
}

.vignette {
  background: radial-gradient(130% 110% at 50% 45%, transparent 55%, var(--vignette) 100%);
}

.grain {
  top: -50%;
  left: -50%;
  right: auto;
  bottom: auto;
  width: 200%;
  height: 200%;
  background: url("../assets/images/grain.png") repeat;
  opacity: var(--grain-opacity);
  animation: grain 1.2s steps(6) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-6%, 4%); }
  40% { transform: translate(5%, -7%); }
  60% { transform: translate(-3%, 8%); }
  80% { transform: translate(7%, 2%); }
  100% { transform: translate(0, 0); }
}

.subtitle {
  position: fixed;
  left: var(--subtitle-side);
  right: var(--subtitle-side);
  bottom: calc(var(--letterbox-h) + 2.6vh);
  margin: 0;
  text-align: center;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: clamp(13px, 1.9vh, 20px);
  color: var(--text-main);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 5;
}

.letterbox {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--letterbox-h);
  background: #05060a;
  z-index: 5;
}

.track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--bar-h);
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #b58cff 0%, var(--neon) 55%, #ffc49a 100%);
  box-shadow: 0 0 10px var(--neon-glow);
  transition: width 0.45s ease;
}

.track.is-indeterminate .bar {
  width: 28% !important;
  animation: indeterminate 1.8s ease-in-out infinite;
}

@keyframes indeterminate {
  from { transform: translateX(-110%); }
  to { transform: translateX(380%); }
}

.hud {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1.8vw;
  height: 100%;
  padding: 0 var(--gmod-safe-w) 0 2.6vw;
}

.phase {
  font-family: var(--font-script);
  font-size: clamp(18px, 3vh, 30px);
  color: var(--neon);
  text-shadow: 0 0 10px var(--neon-glow);
  padding: 0 0.2em;
}

.files {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(10px, 1.4vh, 14px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.percent {
  min-width: 3.4em;
  text-align: left;
  font-family: var(--font-display);
  font-size: clamp(14px, 2.2vh, 24px);
  color: var(--text-main);
}

.music {
  display: flex;
  align-items: center;
  gap: 0.7em;
  margin: 0 0 0 auto;
  padding: 0.5em 0.2em;
  border: 0;
  background: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(9px, 1.2vh, 12px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-soft);
  opacity: var(--music-idle-opacity);
  cursor: pointer;
  transition: opacity 0.3s ease, color 0.3s ease;
  -webkit-appearance: none;
  outline: none;
}

.music[hidden] {
  display: none;
}

.music:hover,
.music:focus-visible {
  opacity: 1;
  color: var(--text-main);
}

.music:focus-visible .eq {
  box-shadow: 0 0 0 1px var(--neon-glow);
}

.eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 17px;
  height: 13px;
  border-radius: 2px;
}

.eq i {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: 1px;
  background: var(--neon);
  transform: scaleY(0.18);
  transform-origin: 50% 100%;
  transition: transform 0.4s ease;
}

.music.is-playing .eq i {
  box-shadow: 0 0 6px var(--neon-glow);
  animation: eq 1.1s ease-in-out infinite alternate;
}

.music.is-playing .eq i:nth-child(2) { animation-duration: 0.8s; animation-delay: -0.3s; }
.music.is-playing .eq i:nth-child(3) { animation-duration: 1.3s; animation-delay: -0.6s; }
.music.is-playing .eq i:nth-child(4) { animation-duration: 0.95s; animation-delay: -0.15s; }

.music.is-waiting {
  animation: music-hint 2.4s ease-in-out infinite;
}

.music-label {
  max-width: 22vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes eq {
  0% { transform: scaleY(0.2); }
  35% { transform: scaleY(0.95); }
  65% { transform: scaleY(0.45); }
  100% { transform: scaleY(0.8); }
}

@keyframes music-hint {
  0%, 100% { opacity: var(--music-idle-opacity); }
  50% { opacity: 1; }
}

@media (max-aspect-ratio: 5/4) {
  :root {
    --credits-width: 44vw;
    --credits-gutter: 4vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain,
  .music.is-playing .eq i {
    animation: none;
  }
}
