:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #201a17;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 223, 116, 0.24), transparent 38%),
    #201a17;
}

button {
  font: inherit;
}

.game-frame {
  position: relative;
  isolation: isolate;
  width: min(100vw, calc(100svh * 750 / 1334));
  height: min(100svh, calc(100vw * 1334 / 750));
  overflow: hidden;
  background: #fff8d6;
  box-shadow: 0 0 3rem rgba(0, 0, 0, 0.45);
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: #fff8d6;
  touch-action: none;
}

.loading-screen,
.error-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #5f2d20;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.88), transparent 20%),
    linear-gradient(180deg, #fff8cf, #f5bd54);
  text-align: center;
  transition: opacity 220ms ease, visibility 220ms ease;
}

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

.loading-icon {
  width: clamp(5.5rem, 25vw, 8.5rem);
  height: auto;
  border: 0.35rem solid rgba(255, 255, 255, 0.72);
  border-radius: 26%;
  box-shadow: 0 0.7rem 1.6rem rgba(107, 56, 23, 0.24);
}

.loading-title {
  margin-top: 1.5rem;
  font-size: clamp(1.7rem, 8vw, 2.7rem);
  letter-spacing: 0.08em;
}

.loading-track {
  width: min(76%, 19rem);
  height: 0.85rem;
  margin-top: 1.5rem;
  overflow: hidden;
  border: 0.18rem solid #873f27;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
}

.loading-progress {
  display: block;
  width: 4%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f35141, #ff9e32);
  transition: width 180ms ease;
}

.loading-status {
  min-height: 1.5em;
  margin-top: 0.9rem;
  font-size: clamp(0.82rem, 3.5vw, 1rem);
  font-weight: 700;
}

.error-panel[hidden] {
  display: none;
}

.error-panel {
  z-index: 30;
  gap: 0.85rem;
  background: rgba(255, 247, 222, 0.98);
}

.error-panel strong {
  color: #b42d29;
  font-size: 1.5rem;
}

.error-panel p {
  max-width: 25rem;
  margin: 0;
  color: #684139;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.error-panel button {
  padding: 0.72rem 1.45rem;
  border: 0.16rem solid #843f27;
  border-radius: 999px;
  color: #fff;
  background: #ef5145;
  box-shadow: 0 0.3rem 0 #843f27;
  font-weight: 800;
  cursor: pointer;
}

.game-controls {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.round-control {
  position: absolute;
  top: max(0.7rem, env(safe-area-inset-top));
  display: grid;
  width: clamp(2.55rem, 11vw, 3.25rem);
  aspect-ratio: 1;
  place-items: center;
  border: 0.16rem solid rgba(86, 49, 32, 0.86);
  border-radius: 50%;
  color: #5a3021;
  background: rgba(255, 244, 197, 0.9);
  box-shadow: 0 0.24rem 0.55rem rgba(73, 42, 21, 0.27);
  font-size: clamp(1.35rem, 5.5vw, 1.7rem);
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(5px);
}

.round-control:focus-visible {
  outline: 0.2rem solid #fff;
  outline-offset: 0.15rem;
}

.home-control {
  left: max(0.7rem, env(safe-area-inset-left));
}

.fullscreen-control {
  right: max(0.7rem, env(safe-area-inset-right));
}

.victory-share-button {
  position: absolute;
  left: 50%;
  bottom: max(17.5%, calc(env(safe-area-inset-bottom) + 5.8rem));
  z-index: 14;
  width: min(48%, 15rem);
  min-height: clamp(3.1rem, 8vw, 4rem);
  padding: 0.55rem 1rem;
  transform: translateX(-50%);
  border: 0.18rem solid #8b421e;
  border-radius: 999px;
  color: #6b2e16;
  background: linear-gradient(180deg, #ffe362, #ffad2f);
  box-shadow: 0 0.38rem 0 #9b4b1c, 0 0.65rem 1.1rem rgba(48, 24, 10, 0.34);
  font-size: clamp(1.05rem, 4.8vw, 1.45rem);
  font-weight: 900;
  line-height: 1.15;
  cursor: pointer;
  pointer-events: auto;
}

.victory-share-button[hidden],
.share-toast[hidden] {
  display: none;
}

.victory-share-button:disabled {
  cursor: wait;
  filter: saturate(0.72);
  opacity: 0.86;
}

.victory-share-button:focus-visible {
  outline: 0.2rem solid #fff;
  outline-offset: 0.18rem;
}

.share-toast {
  position: absolute;
  left: 50%;
  top: max(5.3rem, calc(env(safe-area-inset-top) + 4.1rem));
  z-index: 32;
  width: max-content;
  max-width: 84%;
  margin: 0;
  padding: 0.72rem 1rem;
  transform: translateX(-50%);
  border: 0.12rem solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  color: #fff;
  background: rgba(54, 39, 27, 0.92);
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.3);
  font-size: clamp(0.82rem, 3.5vw, 1rem);
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}

.share-toast[data-kind="error"] {
  background: rgba(155, 42, 36, 0.94);
}

@media (display-mode: fullscreen) {
  .game-frame {
    box-shadow: none;
  }
}
