html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: #111;
  color: #f3f3f3;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
}

#unity-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: var(--unity-viewport-height, 100vh);
  background: #181818;
  overflow: hidden;
}

#unity-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: var(--unity-viewport-height, 100vh);
  background: #000;
  overflow: hidden;
}

#unity-canvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* The desktop footer must not cover in-game download progress or controls. */
body:not(.unity-mobile):not(.is-fullscreen) #unity-container {
  height: calc(var(--unity-viewport-height, 100vh) - 36px);
  bottom: 36px;
}

#unity-mobile-fullscreen-button {
  position: absolute;
  left: max(8px, env(safe-area-inset-left));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 25;
  display: none;
  width: 42px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.46);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.unity-mobile #unity-mobile-fullscreen-button {
  display: block;
}

#unity-mobile-fullscreen-button:active {
  background: rgba(0, 0, 0, 0.72);
}

body.paypal-open #unity-mobile-fullscreen-button {
  display: none;
}

body.is-fullscreen #unity-mobile-fullscreen-button,
body.fullscreen-button-hidden #unity-mobile-fullscreen-button {
  display: none !important;
}

.unity-mobile #unity-shell {
  width: 100vw;
  height: var(--unity-viewport-height, 100dvh);
}

.unity-mobile #unity-container,
.unity-mobile #unity-canvas {
  width: 100vw;
  height: var(--unity-viewport-height, 100dvh);
  aspect-ratio: auto;
}

@media (orientation: portrait) {
  body.unity-mobile.game-ready:not(.paypal-open) #unity-container::after {
    content: "Rotate your device to play in landscape";
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 24px;
    background: #111;
    color: #f3f3f3;
    font-size: 21px;
    line-height: 1.4;
    text-align: center;
  }

  body.unity-mobile.game-ready #unity-mobile-fullscreen-button {
    display: none;
  }
}

#unity-loading-bar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
  overflow: hidden;
  background: #171532;
  z-index: 5;
}

#unity-loading-bar::before,
#unity-loading-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#unity-loading-bar::before {
  z-index: -2;
  background: url("loading-academy-beasts-wide.webp") center center / cover no-repeat;
  animation: academy-arrive 16s ease-out both;
}

#unity-loading-bar::after {
  z-index: -1;
  background: linear-gradient(90deg, rgba(12, 9, 36, .2), rgba(15, 11, 40, .48) 37%, rgba(15, 11, 40, .48) 63%, rgba(12, 9, 36, .2)),
    linear-gradient(0deg, rgba(9, 7, 27, .58), transparent 36%, transparent 70%, rgba(9, 7, 27, .22));
}

.loading-content {
  box-sizing: border-box;
  position: relative;
  width: min(620px, 86vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-2vh);
  text-align: center;
  filter: drop-shadow(0 8px 24px rgba(8, 6, 30, .5));
}

.loading-eyebrow {
  color: #f9e5ae;
  font-family: Georgia, serif;
  font-size: clamp(10px, 1.2vw, 13px);
  font-weight: 700;
  letter-spacing: .27em;
  text-shadow: 0 2px 12px #14102f;
}

.loading-eyebrow span { color: #ffe9aa; padding: 0 .35em; }

.loading-logo {
  display: block;
  width: min(550px, 100%);
  height: auto;
  margin: -10px auto -8px;
  object-fit: contain;
  filter: drop-shadow(0 9px 12px rgba(5, 3, 22, .65));
}

.loading-progress-wrap {
  width: min(460px, 84%);
  margin-top: -4px;
}

.loading-progress-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  text-align: left;
}

.loading-tip {
  margin-top: 14px;
  color: #eadab7;
  font-family: Georgia, serif;
  font-size: 13px;
  letter-spacing: .05em;
  text-shadow: 0 2px 8px #110d2d;
}

body:not(.game-ready) #unity-footer,
body:not(.game-ready) #unity-fullscreen-button { display: none; }

@keyframes academy-arrive {
  from { transform: scale(1.045); }
  to { transform: scale(1); }
}

#unity-loading-bar[hidden] {
  display: none;
}

#unity-mobile-start {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  width: 100%;
  height: 100%;
  border: 0;
  background: #090909;
  color: #f4f4f4;
  cursor: pointer;
  touch-action: manipulation;
}

.unity-mobile #unity-mobile-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

#unity-mobile-start[hidden] {
  display: none;
}

.mobile-start-title {
  font-size: 26px;
  font-weight: 700;
}

.mobile-start-action {
  min-width: 220px;
  padding: 12px 18px;
  border: 1px solid #d3a21c;
  background: #bd8400;
  color: #fff;
  font-size: 18px;
}

.loading-caption {
  color: #fff4d7;
  font-size: clamp(12px, 1.3vw, 15px);
  font-weight: 600;
  text-shadow: 0 2px 8px #110d2d;
}

.loading-percent {
  flex: 0 0 auto;
  color: #ffe4a5;
  font: 700 15px Georgia, serif;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 8px #110d2d;
}

#unity-progress-bar-empty {
  box-sizing: border-box;
  width: 100%;
  height: 19px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid #e6bd6e;
  border-radius: 20px;
  background: rgba(17, 11, 45, .83);
  box-shadow: 0 0 0 3px rgba(24, 16, 54, .56), inset 0 2px 5px rgba(0, 0, 0, .6), 0 0 23px rgba(171, 116, 247, .28);
}

#unity-progress-bar-full {
  width: 0%;
  height: 100%;
  position: relative;
  border-radius: 20px;
  background: linear-gradient(90deg, #9a66e5 0%, #e7a8f6 58%, #ffe7a1 100%);
  box-shadow: 0 0 15px #d7a9ff, inset 0 1px 2px rgba(255, 255, 255, .75);
  transition: width 160ms ease-out;
}

#unity-progress-bar-full::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: min(36px, 30%);
  border-radius: 20px;
  background: rgba(255, 255, 255, .48);
  filter: blur(4px);
}

@media (orientation: portrait) {
  #unity-loading-bar::before {
    background-image: url("loading-academy-beasts-portrait.webp");
    background-position: center center;
  }

  #unity-loading-bar::after {
    background: linear-gradient(0deg, rgba(8, 6, 24, .32), rgba(17, 11, 47, .5) 35%, rgba(17, 11, 47, .43) 68%, rgba(8, 6, 24, .2));
  }

  .loading-content { width: min(500px, 90vw); transform: translateY(-4vh); }
  .loading-logo { margin: 0 auto 5px; }
  .loading-progress-wrap { width: min(430px, 88%); }
  .loading-eyebrow { font-size: 9px; letter-spacing: .16em; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .loading-content { width: min(540px, 68vw); transform: none; }
  .loading-logo { width: min(350px, 85%); margin: -20px auto -14px; }
  .loading-tip { display: none; }
  .loading-eyebrow { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  #unity-loading-bar::before { animation: none; }
  #unity-progress-bar-full { transition: none; }
}

#unity-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  width: 100vw;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  padding: 0 10px;
  background: #222;
  color: #ddd;
  font-size: 13px;
}

.unity-mobile #unity-footer,
body.is-fullscreen #unity-footer {
  display: none;
}

#unity-fullscreen-button {
  position: static;
  flex: 0 0 auto;
  min-width: 92px;
  height: 26px;
  border: 1px solid #777;
  background: #333;
  color: #f4f4f4;
  cursor: pointer;
}

#unity-fullscreen-button:hover {
  background: #444;
}

body.is-fullscreen #unity-fullscreen-button,
body.fullscreen-button-hidden #unity-fullscreen-button {
  display: none !important;
}

#unity-warning {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 10;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

#unity-warning[hidden] {
  display: none;
}

#unity-warning button,
#unity-retry {
  pointer-events: auto;
  cursor: pointer;
  padding: 10px 18px;
  color: #fff;
  background: #705011;
  border: 1px solid #d3a21c;
}

#unity-retry[hidden] {
  display: none;
}

#unity-retry {
  margin-top: 22px;
  min-width: 152px;
  border: 1px solid #ffe3a0;
  border-radius: 22px;
  background: linear-gradient(#eac474, #a97035);
  box-shadow: 0 4px 14px rgba(4, 2, 22, .45);
  color: #26183e;
  font-weight: 700;
}

.unity-warning-item {
  padding: 10px 12px;
  color: #111;
  background: #f3d36b;
  font-size: 13px;
}

.unity-warning-item.error {
  background: #d94d4d;
  color: white;
}

body.paypal-open #unity-canvas {
  pointer-events: none;
}

#paypal-dialog {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  pointer-events: none;
  align-items: safe center;
  justify-content: center;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: auto;
  user-select: auto;
}

#paypal-dialog.is-open {
  display: flex;
  pointer-events: auto;
}

.paypal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.paypal-panel {
  position: relative;
  width: min(440px, 100%);
  min-height: 0;
  max-height: min(
    680px,
    calc(var(--unity-viewport-height, 100dvh) - max(24px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)))
  );
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  padding: 18px;
  background: #fff;
  color: #222;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.paypal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.paypal-header h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

#paypal-status {
  min-height: 18px;
  margin: 0;
  color: #666;
  font-size: 13px;
}

.paypal-close {
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  color: #333;
  cursor: pointer;
}

.paypal-close:hover {
  background: #ececec;
}

#payment-methods {
  display: grid;
  gap: 10px;
  touch-action: pan-y;
}

@media (max-height: 520px) {
  #paypal-dialog {
    align-items: flex-start;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .paypal-panel {
    max-height: calc(
      var(--unity-viewport-height, 100dvh) -
      max(16px, env(safe-area-inset-top)) -
      max(16px, env(safe-area-inset-bottom))
    );
    padding: 12px;
  }

  .paypal-header {
    margin-bottom: 8px;
  }

  #payment-methods {
    gap: 8px;
  }
}

#payment-methods[hidden],
.payment-method[hidden],
#paypal-loading[hidden] {
  display: none;
}

.payment-method {
  width: 100%;
  min-height: 48px;
}

#googlepay-button-container > div,
#googlepay-button-container button,
#applepay-button-container apple-pay-button {
  width: 100%;
  min-width: 100%;
  height: 48px;
  display: block;
  --apple-pay-button-width: 100%;
  --apple-pay-button-height: 48px;
  --apple-pay-button-border-radius: 4px;
}

.paypal-loading {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.paypal-spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #ddd;
  border-top-color: #0070ba;
  border-radius: 50%;
  animation: paypal-spin 900ms linear infinite;
}

@keyframes paypal-spin {
  to {
    transform: rotate(360deg);
  }
}
