html, body {
  margin: 0;
  height: 100%;
  background: #1b1440;
  color: #fff6ea;
  font-family: "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

body {
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
}

#app {
  position: relative;
  height: 100%;
  overflow: hidden;
}

#app::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 90px rgba(10, 6, 28, 0.45);
  z-index: 1;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

#top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

#title, #wave, #score, #boss-name, #hint, #callout {
  margin: 0;
}

#title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

#wave, #score {
  font-size: 14px;
  font-weight: 700;
  color: #ffe7c4;
}

#top-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

#pause {
  pointer-events: auto;
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  background: rgba(28, 18, 56, 0.88);
  color: #fff6ea;
  font-weight: 800;
  cursor: pointer;
}

#bears {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 58px);
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}

.bear {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  max-width: 180px;
  padding: 6px 10px 6px 6px;
  border-radius: 16px;
  background: rgba(24, 14, 52, 0.78);
  box-shadow: 0 8px 20px rgba(10, 6, 28, 0.25);
}

.bear img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: contain;
  object-position: center bottom;
  background: #3a2468;
}

.bear b {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.bear.is-down {
  opacity: 0.72;
}

.bear.is-down img {
  filter: grayscale(0.85);
}

.hp {
  height: 8px;
  width: 76px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.hp > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8aa8, #ffd0a8);
}

#bossbar {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 124px);
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 28px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 18px;
  background: rgba(48, 24, 18, 0.78);
}

#bossbar[hidden] {
  display: none;
}

#boss-face {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: contain;
  object-position: center bottom;
  background: #8a4a28;
}

.boss-copy {
  flex: 1;
}

.hp.boss {
  width: 100%;
}

.hp.boss > span {
  background: linear-gradient(90deg, #e88828, #ffd56a);
}

#hint {
  position: absolute;
  left: 50%;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 118px);
  transform: translateX(-50%);
  max-width: min(440px, calc(100% - 120px));
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(24, 14, 52, 0.72);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  transition: opacity 0.4s ease;
}

#hint.is-gone {
  opacity: 0;
}

#callout {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 6px 0 rgba(42, 20, 48, 0.35);
  opacity: 0;
  transition: opacity 0.35s ease;
}

#callout.show {
  opacity: 1;
}

#super-wrap {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  pointer-events: auto;
}

#super {
  --p: 0;
  width: 92px;
  height: 92px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: conic-gradient(#ffd56a calc(var(--p) * 1%), rgba(255, 255, 255, 0.18) 0);
  box-shadow: 0 10px 24px rgba(10, 6, 28, 0.35);
  touch-action: none;
}

#super-face {
  width: 74%;
  height: 74%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #2a1848 center / cover no-repeat;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

#super:not(.is-ready) #super-face {
  filter: saturate(0.45) brightness(0.82);
}

#super.is-ready #super-face {
  box-shadow: 0 0 0 3px #fff6ea;
}

#super.shake {
  animation: super-pop 0.6s ease;
}

@keyframes super-pop {
  0% { transform: scale(1) rotate(0deg); }
  35% { transform: scale(1.12) rotate(-6deg); }
  70% { transform: scale(0.96) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

#super:focus-visible, #retry:focus-visible, #pause:focus-visible, #resume:focus-visible {
  outline: 3px solid #fff6ea;
  outline-offset: 3px;
}

#paused {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: rgba(14, 8, 32, 0.55);
  pointer-events: none;
}

#paused[hidden] {
  display: none;
}

#paused .card {
  pointer-events: auto;
}

#paused-note {
  margin: 0 0 16px;
  color: #ffe7c4;
  font-weight: 700;
}

#resume {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: #ff8aa8;
  color: #3a1830;
  font-weight: 800;
  cursor: pointer;
}

#result {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(14, 8, 32, 0.72);
  pointer-events: auto;
}

#result[hidden] {
  display: none;
}

.card {
  width: min(360px, calc(100% - 36px));
  padding: 28px 22px;
  text-align: center;
  border-radius: 28px;
  background: rgba(28, 18, 56, 0.94);
  border: 3px solid rgba(255, 214, 170, 0.45);
}

.card h1 {
  margin: 0 0 12px;
  font-size: 28px;
}

#stars {
  margin: 0 0 18px;
  font-size: 42px;
  letter-spacing: 0.12em;
  color: rgba(255, 246, 234, 0.35);
}

#stars .on {
  color: #ffd56a;
}

#retry {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: #ff8aa8;
  color: #3a1830;
  font-weight: 800;
  cursor: pointer;
}

#loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  margin: 0;
  background: #1b1440;
  font-size: 20px;
  font-weight: 800;
}

#loading.is-done {
  display: none;
}

#app.is-landscape #bears {
  top: 50%;
  right: auto;
  transform: translateY(-50%);
  flex-direction: column;
  width: 190px;
}

#app.is-landscape #bossbar {
  top: max(12px, env(safe-area-inset-top));
  width: min(360px, 46vw);
}

#app.is-landscape #super-wrap {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}

#app.is-landscape #hint {
  bottom: max(14px, env(safe-area-inset-bottom));
}

@media (prefers-reduced-motion: reduce) {
  #hint, #callout, #super.shake {
    transition: none;
    animation: none;
  }
}
#model-notice {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 92px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  padding: 6px 12px;
  border-radius: 10px;
  background: #5e431d;
  color: #fff2cb;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}
