:root {
  color-scheme: dark;
  --bg: #07080c;
  --ink: #fff7fb;
  --muted: rgba(255, 247, 251, 0.62);
  --line: rgba(255, 180, 214, 0.22);
  --pink: #ff9fc7;
  --cyan: #7bdff2;
  --gold: #ffe08a;
  --violet: #b7a7ff;
}

* {
  box-sizing: border-box;
}

html,
body,
#stage {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "Microsoft JhengHei", "PingFang TC", "Noto Sans TC",
    "Helvetica Neue", Arial, sans-serif;
}

button {
  font: inherit;
}

#stage {
  position: relative;
  isolation: isolate;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #07080c;
}

.hud {
  position: fixed;
  z-index: 3;
  pointer-events: none;
}

.topbar {
  top: max(16px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.title-lockup p,
.title-lockup h1 {
  margin: 0;
  letter-spacing: 0;
}

.title-lockup {
  min-width: 0;
}

.title-lockup p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.title-lockup h1 {
  margin-top: 5px;
  font-size: clamp(28px, 5.5vh, 58px);
  line-height: 0.95;
  font-weight: 780;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 84px));
  gap: 8px;
  text-align: right;
}

.status-grid div {
  min-height: 48px;
  border-bottom: 1px solid var(--line);
}

.status-grid span {
  display: block;
  color: rgba(255, 247, 251, 0.48);
  font-size: 10px;
  line-height: 1.2;
}

.status-grid strong {
  display: block;
  margin-top: 7px;
  color: rgba(255, 247, 251, 0.92);
  font-size: 18px;
  line-height: 1;
  font-weight: 740;
}

.bottombar {
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 48px minmax(152px, 26vw) 48px;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
}

.icon-button {
  pointer-events: auto;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--pink);
  background: rgba(10, 12, 19, 0.62);
  box-shadow: inset 0 0 18px rgba(255, 159, 199, 0.08);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.icon-button span {
  display: block;
  font-size: 25px;
  line-height: 1;
}

.icon-button:active {
  transform: translateY(1px) scale(0.96);
}

.meter {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 180, 214, 0.28);
  border-radius: 999px;
  background: rgba(10, 12, 19, 0.68);
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--cyan), var(--gold));
  box-shadow: 0 0 22px rgba(255, 159, 199, 0.46);
  transition: width 0.08s linear;
}

.mission-feed {
  position: fixed;
  z-index: 3;
  left: max(18px, env(safe-area-inset-left));
  bottom: calc(max(84px, env(safe-area-inset-bottom)) + 12px);
  max-width: min(520px, calc(100vw - 36px));
  color: rgba(255, 247, 251, 0.74);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: none;
  text-shadow: 0 0 18px rgba(255, 159, 199, 0.32);
}

.touch-ring {
  position: fixed;
  z-index: 2;
  left: -80px;
  top: -80px;
  width: 76px;
  height: 76px;
  border: 1px solid rgba(255, 159, 199, 0.44);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 159, 199, 0.12),
    rgba(123, 223, 242, 0.05) 58%,
    transparent 60%
  );
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: opacity 0.14s ease;
}

.touch-ring.is-visible {
  opacity: 1;
}

.restart {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: 58%;
  width: 150px;
  height: 48px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 180, 214, 0.74);
  border-radius: 8px;
  color: #170b12;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  box-shadow:
    0 0 26px rgba(255, 159, 199, 0.28),
    0 14px 32px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  font-size: 15px;
  font-weight: 760;
}

.restart:active {
  transform: translateX(-50%) translateY(1px) scale(0.98);
}

.restart.is-hidden {
  display: none;
}

@media (max-width: 700px) {
  .title-lockup h1 {
    max-width: 180px;
    font-size: 24px;
    line-height: 1.02;
  }

  .status-grid {
    grid-template-columns: repeat(3, 52px);
    gap: 6px;
  }

  .status-grid strong {
    font-size: 15px;
  }

  .bottombar {
    grid-template-columns: 44px minmax(132px, 46vw) 44px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }
}
