* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #14101F;
  color: #FFF6EA;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  overflow: hidden;
  user-select: none;
}
.stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 12px);
  overflow: hidden;
}
.bg-art {
  position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(120% 60% at 50% 0%, #3A2A5C 0%, #241B3B 45%, #14101F 100%), #14101F;
}
.bg-art::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 14%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(2px 2px at 78% 9%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1.6px 1.6px at 34% 26%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1.6px 1.6px at 62% 32%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(2px 2px at 88% 44%, rgba(255,255,255,.3), transparent 60%),
    radial-gradient(1.6px 1.6px at 20% 52%, rgba(255,255,255,.28), transparent 60%);
  opacity: .9;
}
.bg-art::before {
  content: "";
  position: absolute; left: 50%; top: -60px; transform: translateX(-50%);
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,138,61,.42) 0%, rgba(255,138,61,.12) 45%, transparent 70%);
}

.hud {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.hud-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 14px;
  background: linear-gradient(160deg, #FFB06B, #FF8A3D);
  display: flex; align-items: center; justify-content: center;
  color: #2A1A0C; font-size: 22px;
  box-shadow: 0 6px 16px rgba(255,138,61,.35);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who { min-width: 0; }
.nick {
  font-size: 15px; font-weight: 700; letter-spacing: .2px;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lv { font-size: 11px; color: #B9AEDA; margin-top: 2px; }
.hud-right { display: flex; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 11px; border-radius: 999px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.14);
  font-size: 14px; font-weight: 700;
}
.chip i { font-size: 16px; color: #FFC46B; }
.chip.time i { color: #7FE0C8; }
.chip.time.low { border-color: rgba(255,90,90,.6); background: rgba(255,90,90,.18); }
.chip.time.low i, .chip.time.low span { color: #FF9A9A; }

.board-wrap {
  position: relative; z-index: 2;
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  margin: 14px 0 10px;
  min-height: 0;
}
.board {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 3 / 4;
  max-height: 100%;
  border-radius: 26px;
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(255,138,61,.16), transparent 70%),
    linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 18px 40px rgba(0,0,0,.45);
  overflow: hidden;
}
.board::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 33.333% 25%;
  pointer-events: none;
}

.cell {
  position: absolute;
  width: 33.333%; height: 25%;
  display: flex; align-items: center; justify-content: center;
  padding: 4px;
}
.target {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  border: none; padding: 0;
  background: transparent;
  transition: transform .12s ease, opacity .18s ease;
  cursor: pointer;
}
.target:active { transform: scale(.9); }
.target.hit { animation: pop .28s ease forwards; }
.target.miss { animation: shake .3s ease; }

@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.22); } 100% { transform: scale(.2); opacity: 0; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.float {
  position: absolute;
  font-size: 15px; font-weight: 800;
  pointer-events: none;
  animation: floatUp .8s ease-out forwards;
  z-index: 5;
}
.float.plus { color: #FFD08A; }
.float.minus { color: #FF8F8F; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.7); }
  25% { opacity: 1; transform: translate(-50%, -10px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

.combo {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  font-size: 13px; font-weight: 800; letter-spacing: .5px;
  color: #FFD08A; opacity: 0; transition: opacity .2s ease;
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
  z-index: 4;
}
.combo.show { opacity: 1; }

.foot { position: relative; z-index: 2; }
.tip { font-size: 12px; color: #A99EC9; text-align: center; margin-bottom: 8px; min-height: 16px; }
.bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; }
.bar-fill {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FF8A3D, #FFC46B);
  transition: width .25s ease;
}

.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(12,9,20,.72);
  transition: opacity .22s ease;
}
.overlay.hide { opacity: 0; pointer-events: none; }
.panel {
  width: 100%; max-width: 340px;
  background: linear-gradient(180deg, #2C2347, #221A38);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 26px;
  padding: 26px 22px 22px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
.panel-icon {
  width: 62px; height: 62px; margin: -52px auto 12px;
  border-radius: 22px;
  background: linear-gradient(160deg, #FFB06B, #FF8A3D);
  display: flex; align-items: center; justify-content: center;
  color: #2A1A0C; font-size: 30px;
  box-shadow: 0 10px 26px rgba(255,138,61,.45);
}
.panel h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: .5px; }
.panel p { margin: 0; font-size: 13.5px; line-height: 1.65; color: #B9AEDA; }
.ov-stats { display: flex; justify-content: center; gap: 10px; margin: 16px 0 4px; flex-wrap: wrap; }
.ov-stats .st {
  flex: 1 1 0; min-width: 84px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 10px 8px;
}
.ov-stats .st b { display: block; font-size: 19px; color: #FFD08A; }
.ov-stats .st span { font-size: 11px; color: #A99EC9; }
.btn {
  display: block; width: 100%;
  margin-top: 14px;
  padding: 15px 18px;
  border: none; border-radius: 18px;
  font-size: 16px; font-weight: 800; letter-spacing: .5px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  color: #2A1A0C;
  background: linear-gradient(160deg, #FFB06B, #FF8A3D);
  box-shadow: 0 10px 24px rgba(255,138,61,.4);
}
.btn.ghost {
  color: #CBB8FF;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: none;
}

/* 小鬼与灯笼的卡通造型（纯 CSS，不依赖图片） */
.ghost-body {
  position: relative;
  width: 60%;
  height: 58%;
  border-radius: 50% 50% 42% 42% / 58% 58% 42% 42%;
  background: linear-gradient(180deg, #E6DCFF 0%, #B9A6F2 70%, #8E77D6 100%);
  box-shadow: 0 8px 18px rgba(0,0,0,.45), inset 0 -6px 12px rgba(80,50,140,.35);
  animation: bob 1.8s ease-in-out infinite;
}
.ghost-body::before,
.ghost-body::after {
  content: "";
  position: absolute;
  top: 34%;
  width: 18%;
  height: 22%;
  border-radius: 50%;
  background: #2A1E45;
}
.ghost-body::before { left: 24%; }
.ghost-body::after { right: 24%; }
.ghost-mouth {
  position: absolute;
  left: 50%; top: 62%;
  width: 22%; height: 14%;
  transform: translateX(-50%);
  border-radius: 0 0 999px 999px;
  background: #2A1E45;
}
.ghost-tail {
  position: absolute;
  left: 0; right: 0; bottom: -8%;
  height: 26%;
  background: linear-gradient(180deg, #8E77D6, #6E58B8);
  clip-path: polygon(0 0, 100% 0, 100% 40%, 84% 100%, 68% 40%, 50% 100%, 32% 40%, 16% 100%, 0 40%);
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

.lamp-body {
  position: relative;
  width: 52%;
  height: 60%;
  border-radius: 46% 46% 40% 40% / 40% 40% 56% 56%;
  background: radial-gradient(circle at 50% 34%, #FFE2A8 0%, #FFB35C 55%, #E8762A 100%);
  box-shadow: 0 0 22px rgba(255,179,92,.55), inset 0 -8px 14px rgba(180,80,20,.35);
  animation: sway 2.4s ease-in-out infinite;
}
.lamp-body::before {
  content: "";
  position: absolute;
  left: 50%; top: -18%;
  width: 34%; height: 20%;
  transform: translateX(-50%);
  border-radius: 6px 6px 0 0;
  background: #6B4A2A;
}
.lamp-body::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -16%;
  width: 12%; height: 18%;
  transform: translateX(-50%);
  border-radius: 0 0 6px 6px;
  background: #6B4A2A;
}
.lamp-char {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: 15px;
  font-weight: 800;
  color: #7A3A12;
  letter-spacing: 1px;
}
@keyframes sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}
