:root {
  color-scheme: dark;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: #100d16;
  --ink: #f7f0dc;
  --muted: #cbbfa8;
  --ember: #f0b450;
  --ember-deep: #a85c21;
  --night: #100d16;
  --night-soft: #1d1725;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  overscroll-behavior: none;
}

body {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
}

#app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(circle at 50% 115%, rgba(168, 92, 33, 0.24), transparent 45%),
    var(--night);
}

#game-frame {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100dvw, calc(100dvh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  height: min(100dvh, calc(100dvw * 9 / 16));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #17121d;
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #17121d;
  outline: none;
  touch-action: none;
}

.screen-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(16, 13, 22, 0.98), rgba(29, 23, 37, 0.96)),
    #100d16;
  opacity: 1;
  transition: opacity 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.screen-layer.hidden {
  pointer-events: none;
  opacity: 0;
}

#loading-screen {
  align-content: center;
  justify-items: center;
  gap: clamp(0.45rem, 1.5vw, 0.9rem);
  visibility: hidden;
}

#loading-screen.visible {
  visibility: visible;
}

.loading-mark {
  width: clamp(2rem, 5vw, 3.5rem);
  aspect-ratio: 1;
  border: 2px solid rgba(240, 180, 80, 0.3);
  border-top-color: var(--ember);
  transform: rotate(45deg);
  animation: loading-turn 1.4s linear infinite;
}

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

.eyebrow {
  margin: 0;
  color: var(--ember);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.72rem, 1.5vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.24em;
}

#loading-status {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.78rem, 1.5vw, 1rem);
}

.progress-track {
  width: min(48vw, 22rem);
  height: 3px;
  overflow: hidden;
  background: rgba(247, 240, 220, 0.14);
}

#progress-fill {
  width: 100%;
  height: 100%;
  background: var(--ember);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 120ms linear;
}

#start-screen {
  position: fixed;
  z-index: 40;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  text-align: center;
}

.start-panel {
  display: grid;
  justify-items: center;
  width: min(92vw, 34rem);
}

.rotate-symbol {
  position: relative;
  width: 5.5rem;
  height: 4rem;
  margin-bottom: clamp(0.4rem, 2vh, 1rem);
  color: var(--ember);
}

.phone-shape {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3.8rem;
  height: 2.15rem;
  border: 2px solid currentColor;
  border-radius: 0.45rem;
  transform: translate(-50%, -50%);
}

.phone-shape::after {
  content: "";
  position: absolute;
  right: 0.22rem;
  top: 50%;
  width: 0.16rem;
  height: 0.42rem;
  border-radius: 999px;
  background: currentColor;
  transform: translateY(-50%);
}

.rotate-arrow {
  position: absolute;
  right: -0.1rem;
  bottom: -0.45rem;
  font-size: 1.55rem;
  line-height: 1;
}

#start-title {
  max-width: 18ch;
  margin: clamp(0.45rem, 1.8vh, 0.9rem) 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 5vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

#start-description {
  max-width: 35rem;
  margin: clamp(0.7rem, 2vh, 1.15rem) 0 0;
  color: var(--muted);
  font-size: clamp(0.88rem, 2.3vw, 1.05rem);
  line-height: 1.55;
}

#start-button {
  min-width: min(100%, 18rem);
  min-height: 3.25rem;
  margin-top: clamp(1rem, 3vh, 1.6rem);
  padding: 0.8rem 1.5rem;
  border: 1px solid #f2bd65;
  border-radius: 0.25rem;
  color: #211509;
  background: #f0b450;
  box-shadow: 0 0.65rem 2rem rgba(109, 52, 15, 0.28);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease-out, background 140ms ease-out;
  -webkit-tap-highlight-color: transparent;
}

#start-button:active {
  transform: translateY(2px);
  background: #d99a38;
}

#start-button:focus-visible,
#fullscreen-button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

#start-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

#orientation-help {
  margin: 0.75rem 0 0;
  color: rgba(203, 191, 168, 0.72);
  font-size: clamp(0.72rem, 1.8vw, 0.86rem);
}

#fullscreen-button {
  position: fixed;
  z-index: 30;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid rgba(247, 240, 220, 0.36);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(16, 13, 22, 0.72);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#app-shell:fullscreen #fullscreen-button,
#app-shell:-webkit-full-screen #fullscreen-button {
  pointer-events: none;
  opacity: 0;
}

#warning-banner {
  position: absolute;
  z-index: 50;
  left: 50%;
  top: max(0.75rem, env(safe-area-inset-top));
  display: none;
  width: min(90%, 42rem);
  transform: translateX(-50%);
}

#warning-banner.visible {
  display: grid;
  gap: 0.35rem;
}

.warning-item {
  padding: 0.65rem 0.9rem;
  color: #2b1b0b;
  background: #f0b450;
  font-size: 0.85rem;
  text-align: center;
}

.warning-item.error {
  color: #fff1e8;
  background: #8f2c25;
}

@media (orientation: portrait) {
  #game-frame {
    width: min(100vw, 100dvw);
    height: calc(min(100vw, 100dvw) * 9 / 16);
  }

  .mobile-device #fullscreen-button {
    display: none;
  }
}

@media (max-height: 430px) and (orientation: landscape) {
  .rotate-symbol {
    display: none;
  }

  #start-title {
    font-size: clamp(1.15rem, 5vh, 1.8rem);
  }

  #start-description {
    margin-top: 0.45rem;
    font-size: 0.82rem;
  }

  #start-button {
    min-height: 2.85rem;
    margin-top: 0.7rem;
  }

  #orientation-help {
    margin-top: 0.45rem;
    font-size: 0.68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
