:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #141b22;
  --text: #f4ead6;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 10%, rgba(222, 145, 55, 0.16), transparent 32%),
    linear-gradient(180deg, #0b1118 0%, #05070a 100%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
}

#stage-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 10px;
}

#game {
  display: block;
  width: min(100vw - 20px, calc((100vh - 20px) * 1.4222222222));
  height: min(100vh - 20px, calc((100vw - 20px) / 1.4222222222));
  max-width: 1280px;
  max-height: 900px;
  background: #0a0e13;
  border: 1px solid rgba(255, 215, 150, 0.28);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.58), 0 0 42px rgba(218, 126, 42, 0.12);
  image-rendering: auto;
  touch-action: none;
  transition: opacity 220ms ease;
}

.studio-intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 219, 117, 0.18), transparent 18rem),
    radial-gradient(circle at 50% 58%, rgba(126, 194, 75, 0.08), transparent 22rem),
    linear-gradient(145deg, #0b0907 0%, #15101c 50%, #201307 100%);
  animation: studio-intro-fade 2.55s ease 0.15s forwards;
}

.studio-intro.done,
.studio-intro[aria-hidden="true"] {
  display: none;
}

.studio-card {
  display: grid;
  place-items: center;
  gap: 9px;
  transform: translateY(4px) scale(0.98);
  animation: studio-card-in 1.6s cubic-bezier(.18, .8, .2, 1) forwards;
}

.studio-logo {
  position: relative;
  width: 112px;
  height: 112px;
  overflow: hidden;
  border: 1px solid rgba(255, 226, 155, 0.22);
  border-radius: 30px;
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.1), transparent 24%),
    linear-gradient(145deg, #1d1626, #2d1c10 64%, #6d4515 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 22px 46px rgba(0, 0, 0, 0.48);
}

.studio-logo::before {
  position: absolute;
  inset: 9px;
  content: "";
  border: 1px solid rgba(255, 229, 160, 0.16);
  border-radius: 24px;
}

.studio-moon {
  position: absolute;
  top: 19px;
  left: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 28%, #fff7c1 0 13%, transparent 14%),
    radial-gradient(circle at 63% 59%, #c9822d 0 8%, transparent 9%),
    radial-gradient(circle at 35% 34%, #fff1a6 0 28%, #ffdc72 29% 61%, #d4932c 62% 100%);
  box-shadow: 0 0 24px rgba(255, 213, 102, 0.42), inset -7px -8px 0 rgba(94, 55, 18, 0.22);
}

.studio-fang {
  position: absolute;
  bottom: 19px;
  width: 24px;
  height: 42px;
  background: linear-gradient(180deg, #fffaf0, #d9c8a5 70%, #8a5a24 100%);
  clip-path: polygon(50% 0, 92% 40%, 64% 100%, 36% 100%, 8% 40%);
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.25));
}

.studio-fang.left {
  left: 31px;
  transform: rotate(14deg);
}

.studio-fang.right {
  right: 31px;
  transform: rotate(-14deg);
}

.studio-spark {
  position: absolute;
  bottom: 41px;
  left: 45px;
  width: 21px;
  height: 21px;
  background: linear-gradient(180deg, #fff5bf, #ffb83d 60%, #d95d25 100%);
  clip-path: polygon(50% 0, 61% 33%, 96% 20%, 70% 50%, 100% 74%, 62% 66%, 50% 100%, 38% 66%, 0 74%, 30% 50%, 4% 20%, 39% 33%);
  filter: drop-shadow(0 0 10px rgba(255, 197, 79, 0.5));
}

.studio-name {
  color: #fff4c9;
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(1.5rem, 3vw, 2.65rem);
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 0 #160b03, 0 0 18px rgba(255, 213, 102, 0.18), 0 12px 32px rgba(0, 0, 0, 0.5);
  text-transform: uppercase;
}

.studio-subtitle {
  margin-top: -8px;
  color: #9fd46b;
  font-weight: 900;
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  text-transform: uppercase;
}

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 13px;
  background:
    radial-gradient(circle at 50% 44%, rgba(76, 199, 193, 0.15), transparent 29%),
    linear-gradient(180deg, #0b1219 0%, #05080c 100%);
  opacity: 1;
  visibility: visible;
  transition: opacity 220ms ease, visibility 220ms ease;
}

#loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#loading-screen h1 {
  margin: 8px 0 0;
  color: #fff8e8;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: 0;
  text-transform: uppercase;
}

#loading-screen p,
#loading-screen strong {
  margin: 0;
  color: #aeb8b5;
  font-size: 15px;
}

.loading-sigil {
  position: relative;
  width: 98px;
  height: 98px;
  animation: loading-turn 7s linear infinite;
}

.loading-sigil::before,
.loading-sigil::after,
.loading-sigil span {
  position: absolute;
  inset: 10px;
  content: "";
  border: 2px solid rgba(233, 184, 87, 0.72);
  transform: rotate(45deg);
}

.loading-sigil::after {
  inset: 25px;
  border-color: rgba(76, 199, 193, 0.82);
  animation: loading-counterturn 3.5s linear infinite;
}

.loading-sigil span:nth-child(1) {
  inset: 2px 46px;
  border-color: rgba(191, 212, 228, 0.72);
}

.loading-sigil span:nth-child(2) {
  inset: 46px 2px;
  border-color: rgba(191, 212, 228, 0.72);
}

.loading-sigil span:nth-child(3) {
  inset: 37px;
  border-radius: 50%;
  border-color: #e76732;
  box-shadow: 0 0 22px rgba(231, 103, 50, 0.55);
}

.loading-track {
  width: min(520px, 72vw);
  height: 18px;
  padding: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.44);
}

#loading-progress {
  width: 0;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #4cc7c1, #bfd4e4 68%, #e9b857);
  box-shadow: 0 0 16px rgba(76, 199, 193, 0.38);
  transition: width 120ms ease-out;
}

#loading-retry {
  min-width: 180px;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  background: #e76732;
  color: #090d12;
  font: 700 15px "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  cursor: pointer;
}

@keyframes loading-turn {
  to { transform: rotate(360deg); }
}

@keyframes loading-counterturn {
  to { transform: rotate(-315deg); }
}

@keyframes studio-intro-fade {
  0%, 62% { opacity: 1; visibility: visible; }
  100% { opacity: 0; visibility: hidden; }
}

@keyframes studio-card-in {
  0% { transform: translateY(16px) scale(0.92); opacity: 0; filter: blur(3px); }
  28% { opacity: 1; filter: blur(0); }
  100% { transform: translateY(0) scale(1); opacity: 1; filter: blur(0); }
}

@media (prefers-reduced-motion: reduce) {
  .studio-intro { animation-duration: 0.35s; }
  .studio-card { animation: none; }
}
