:root {
  color-scheme: dark;
  --bg-main: #17140f;
  --panel: rgba(25, 27, 20, 0.9);
  --panel-border: rgba(255, 210, 112, 0.24);
  --text-primary: #fff4d8;
  --text-muted: #c4b99d;
  --accent-gold: #ffd24f;
  --bar-fill: #ea9a26;
  --bar-track: #332d20;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#unity-container {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(101, 105, 47, 0.2), transparent 55%),
    linear-gradient(145deg, #171b14 0%, var(--bg-main) 65%);
}

#unity-canvas {
  width: 100%;
  height: 100%;
  background: #171a15;
}

#preloader {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background: rgba(13, 16, 13, 0.78);
  opacity: 1;
  transition: opacity 350ms ease, visibility 350ms ease;
}

#preloader::before,
#preloader::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

#preloader::before {
  background: url("Robin-Village-Backdrop.jpg") center 58% / cover no-repeat;
  opacity: 0.52;
  transform: scale(1.025);
}

#preloader::after {
  background:
    linear-gradient(90deg, rgba(13, 16, 13, 0.68), transparent 48%, rgba(13, 16, 13, 0.68)),
    linear-gradient(0deg, rgba(13, 16, 13, 0.7), rgba(13, 16, 13, 0.12) 55%, rgba(13, 16, 13, 0.55));
}

#preloader.is-hidden,
#preloader[hidden] {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loader-card {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 440px);
  flex-direction: column;
  align-items: center;
  padding: 32px 40px 30px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.52), 0 0 50px rgba(255, 194, 63, 0.12);
  text-align: center;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

#custom-logo {
  width: min(100%, 360px);
  height: clamp(82px, 16vw, 112px);
  margin-bottom: 12px;
  background-image: url("Robin-Game-Logo.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.6));
  animation: logo-arrive 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.loader-heading {
  margin-bottom: 32px;
}

.loader-kicker {
  margin-bottom: 8px;
  color: var(--accent-gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.24em;
}

.loader-heading h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(27px, 7vw, 34px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.loader-caption {
  margin-top: 9px;
  color: var(--text-muted);
  font-size: 14px;
}

#custom-loader {
  width: 100%;
  text-align: left;
}

.loader-meta {
  display: flex;
  min-height: 20px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

#custom-loader .label {
  overflow: hidden;
  color: #d0d0c3;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#custom-loader .label.is-error {
  color: #ff8e83;
}

#custom-loader .percentage {
  flex: 0 0 auto;
  color: var(--accent-gold);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#custom-loader .track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  background: var(--bar-track);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.55);
}

#custom-loader .fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d78018 0%, var(--bar-fill) 55%, var(--accent-gold) 100%);
  box-shadow: 0 0 14px rgba(255, 190, 50, 0.45);
  transition: width 180ms ease-out;
}

.loader-footnote {
  margin-top: 16px;
  color: #777d70;
  font-size: 11px;
  line-height: 1.5;
}

.loader-footnote.is-error {
  color: #ffd0ca;
  overflow-wrap: anywhere;
}

#unity-warning {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 20;
  display: none;
  width: max-content;
  max-width: min(680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(27, 30, 25, 0.96);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

#unity-warning.is-error {
  border-color: rgba(255, 107, 107, 0.45);
  color: #ffd0ca;
}

#unity-warning.is-warning {
  border-color: rgba(255, 208, 90, 0.4);
}

@keyframes logo-arrive {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 480px) {
  #preloader {
    padding: 16px;
  }

  .loader-card {
    padding: 25px 24px 23px;
    border-radius: 18px;
  }

  #custom-logo {
    height: 82px;
    margin-bottom: 10px;
  }

  .loader-heading {
    margin-bottom: 27px;
  }
}

@media (max-height: 520px) {
  .loader-card {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    column-gap: 22px;
    padding: 22px;
  }

  #custom-logo {
    width: min(44%, 280px);
    height: 78px;
    margin: 0;
  }

  .loader-heading {
    margin: 0;
    text-align: left;
  }

  .loader-heading h1 {
    font-size: 26px;
  }

  #custom-loader {
    max-width: 340px;
    margin-top: 20px;
  }

  .loader-footnote {
    margin-top: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
