:root {
  --bg: #14061c;
  --ink: #fff6e8;
  --muted: #c9b8d4;
  --gold: #ffd56a;
  --pink: #ff3d7f;
  --cyan: #3ef0ff;
  --fail: #ff6b6b;
  --ok: #7dffb3;
  --thumb-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #07030b;
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: min(100%, 430px);
  height: 100dvh;
  margin: 0 auto;
  background:
    radial-gradient(120% 80% at 50% 100%, #2a0d28 0%, transparent 55%),
    linear-gradient(180deg, #1c0a28 0%, var(--bg) 40%, #0a0410 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.spot {
  position: absolute;
  inset: auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  filter: blur(40px);
  pointer-events: none;
  opacity: 0.45;
}
.spot-a { top: -40px; left: -20px; background: #ffb020; }
.spot-b { top: 10%; right: -40px; background: #ff2d7a; }

#bgm-toggle {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 10px;
  z-index: 16;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 8, 28, 0.42);
  color: var(--gold);
  font-size: 15px;
  line-height: 1;
  opacity: 0.5;
  cursor: pointer;
}
#bgm-toggle.off { color: var(--muted); opacity: 0.4; }
#bgm-toggle:active { transform: scale(0.94); }

.hud {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 8px;
  gap: 8px;
}

.hud-cell { text-align: center; }
.hud-cell:first-child { text-align: left; }
.hud-cell:last-child { text-align: right; }
.hud-k {
  display: block;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.hud-cell span:last-child {
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
}
.hud-title h1 {
  font-size: 20px;
  letter-spacing: 0.1em;
  text-shadow: 0 0 18px rgba(255, 213, 106, 0.45);
}
.hud-title p {
  font-size: 11px;
  color: var(--pink);
  letter-spacing: 0.2em;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

#balloon-wrap {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 180px;
  height: 240px;
  transform: translate(-50%, -50%) scale(0.38);
  transform-origin: 50% 70%;
  transition: none;
  z-index: 1;
}
#balloon-wrap[hidden] { display: none; }

.balloon { width: 100%; height: 100%; overflow: visible; }
.balloon-body {
  fill: url(#none);
  fill: #ff4b8b;
  stroke: #ffd6e6;
  stroke-width: 1.2;
  filter: drop-shadow(0 10px 16px rgba(255, 61, 127, 0.35));
}
.balloon-shine { fill: rgba(255, 255, 255, 0.45); }
.balloon-knot { fill: #c81d58; }
.balloon-string { fill: none; stroke: #e8d5a8; stroke-width: 2; }

#hiss-ring {
  position: absolute;
  inset: 18% 22% auto;
  height: 52%;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(62, 240, 255, 0);
  pointer-events: none;
}
#hiss-ring.on {
  animation: hisspulse 0.9s ease-out infinite;
}
@keyframes hisspulse {
  0% { box-shadow: 0 0 0 0 rgba(62, 240, 255, 0.35); }
  100% { box-shadow: 0 0 0 28px rgba(62, 240, 255, 0); }
}

#fake-timer {
  position: absolute;
  top: 8%;
  left: auto;
  right: 6%;
  transform: none;
  z-index: 3;
  min-width: 148px;
  padding: 8px 14px 10px;
  border: 1px solid rgba(255, 213, 106, 0.55);
  border-radius: 12px;
  background: rgba(8, 4, 12, 0.72);
  text-align: center;
  box-shadow: 0 0 24px rgba(255, 213, 106, 0.15);
}
#fake-timer[hidden] { display: none; }
#fake-timer { pointer-events: none; }
.fake-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--gold);
}
#fake-digits {
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--cyan);
}

#pop-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.popup {
  position: absolute;
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff1c4, #ffd56a);
  color: #3a1608;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 8px 0 #c98916, 0 12px 24px rgba(0, 0, 0, 0.35);
  animation: popin 0.28s cubic-bezier(0.2, 1.4, 0.3, 1);
  pointer-events: none;
}
.popup.alt {
  background: linear-gradient(180deg, #ffd0e4, #ff3d7f);
  color: #fff;
  box-shadow: 0 8px 0 #a31448, 0 12px 24px rgba(0, 0, 0, 0.35);
}
.popup.cyan {
  background: linear-gradient(180deg, #d9fbff, #3ef0ff);
  color: #083038;
  box-shadow: 0 8px 0 #1298a6, 0 12px 24px rgba(0, 0, 0, 0.35);
}
@keyframes popin {
  from { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  to { transform: scale(1) rotate(var(--rot, 0deg)); opacity: 1; }
}

#flash {
  position: absolute;
  inset: 28% 8% auto;
  z-index: 6;
  text-align: center;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: #fff;
  text-shadow: 0 0 20px var(--pink), 0 4px 0 #8b1038;
  animation: flashbang 0.7s ease-out;
}
#flash[hidden] { display: none; }

#liar-clock {
  position: absolute;
  left: 80%;
  top: 36%;
  transform: translate(-50%, -50%);
  z-index: 3;
  text-align: center;
  pointer-events: none;
}
#liar-clock[hidden] { display: none; }
.liar-face {
  position: relative;
  width: 116px;
  height: 116px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 71%, #2a1608 72% 74%, transparent 75%),
    radial-gradient(circle at 40% 35%, #fffaf0, #e8d7b0);
  border: 6px solid var(--gold);
  box-shadow: 0 0 0 3px #5a3a10, 0 10px 22px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.liar-marks {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: repeating-conic-gradient(from -1deg, #2a1608 0 2deg, transparent 2deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%);
  mask: radial-gradient(circle, transparent 62%, #000 63%);
}
.hand.liar-hour { width: 4px; height: 28px; margin-left: -2px; background: #2a1608; }
.hand.liar-minute { width: 3px; height: 40px; margin-left: -1.5px; background: #2a1608; }
.hand.liar-second { width: 2px; height: 46px; margin-left: -1px; background: var(--pink); }
.liar-num {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #7a2010;
  text-shadow: 0 1px 0 #fff6e8;
  line-height: 1;
}
.liar-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--gold);
}

#fake-fail {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px 8px 8px;
  background: rgba(6, 2, 10, 0.78);
}
#fake-fail[hidden] { display: none; }
.fake-fail-card { pointer-events: auto; }
.fake-fail-dismiss {
  margin-top: 8px;
  min-height: 56px;
  font-size: 22px;
  letter-spacing: 0.2em;
}

#app.lights-out {
  background: #000;
}
#app.lights-out .spot,
#app.lights-out .hud {
  opacity: 0;
}
#app.lights-out #stage > * {
  opacity: 0;
  pointer-events: none;
}

#balloon-wrap.scare-burst {
  animation: burst 0.35s ease-out forwards;
}
#balloon-wrap.near-burst .balloon {
  animation: balloon-wobble 0.12s linear infinite;
}
@keyframes balloon-wobble {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-3px, 2px) rotate(-1.6deg); }
  50% { transform: translate(3px, -2px) rotate(1.6deg); }
  75% { transform: translate(-2px, -1px) rotate(-1deg); }
}

@keyframes flashbang {
  0% { transform: scale(0.6); opacity: 0; }
  30% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 0;
  overflow: hidden;
  padding: 16px 18px calc(18px + var(--safe-b));
  background: linear-gradient(180deg, transparent 0%, rgba(10, 4, 16, 0.55) 36%, rgba(10, 4, 16, 0.88) 100%);
}
.screen[hidden] { display: none; }
.screen > .thumb {
  flex-shrink: 0;
}

#screen-title {
  justify-content: center;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 18px calc(18px + var(--safe-b) + var(--thumb-h) + 20px);
  background:
    radial-gradient(120% 80% at 50% 100%, #2a0d28 0%, transparent 55%),
    linear-gradient(180deg, #1c0a28 0%, #14061c 40%, #0a0410 100%);
}
#screen-title > .thumb {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(16px + var(--safe-b));
  width: auto;
  z-index: 2;
}
#screen-title .plaque {
  flex: 0 1 auto;
  width: 100%;
  margin: 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#app.title-up .hud {
  visibility: hidden;
}
#app.title-up .spot {
  visibility: hidden;
}

#screen-countdown {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: rgba(8, 3, 12, 0.72);
}
#target-flash {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  line-height: 0.9;
  color: var(--gold);
  text-shadow: 0 0 48px rgba(255, 213, 106, 0.65);
  animation: target-in 0.35s cubic-bezier(0.2, 1.4, 0.3, 1);
}
#target-flash[hidden] { display: none; }
#target-flash-num {
  font-size: clamp(92px, 28vw, 148px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.target-flash-unit {
  font-size: clamp(28px, 8vw, 42px);
  font-weight: 800;
  letter-spacing: 0.16em;
}
#count-num {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  min-height: 72px;
  margin-top: 8px;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255, 213, 106, 0.55);
}
#count-num.wait { opacity: 0; }
.count-hint, .count-sub { color: var(--muted); letter-spacing: 0.12em; }
.count-hint { margin-bottom: 8px; color: var(--cyan); }
@keyframes target-in {
  from { transform: scale(0.72); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.count-prompt {
  margin-top: 14px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 213, 106, 0.35);
}

.plaque {
  position: relative;
  margin-bottom: 16px;
  padding: 18px 16px 16px;
  border: 1px solid rgba(255, 213, 106, 0.35);
  border-radius: 18px;
  background: rgba(20, 8, 28, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.ver-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0.62;
}

.clock-face {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fffaf0, #e8d7b0);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 2px #5a3a10, 0 6px 16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform-origin: 50% 100%;
  background: #2a1608;
  border-radius: 2px;
}
.hand.hour { width: 3px; height: 16px; margin-left: -1.5px; }
.hand.minute { width: 2px; height: 22px; margin-left: -1px; }
.hand.second { width: 2px; height: 25px; margin-left: -1px; background: var(--pink); }
.clock-cloth {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, #5b1a3a 0 10px, #3a1026 10px 20px);
  transform: translateY(-110%);
  transition: transform 0.45s ease;
}
.clock-cloth.on { transform: translateY(0); }

.title-name {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 213, 106, 0.4);
  margin: 4px 0 10px;
}
.lead {
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 8px;
  text-align: center;
}
.lead strong { color: var(--gold); }
.rules {
  margin: 10px 0 12px 1.1em;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
.best-line { font-size: 14px; color: var(--gold); text-align: center; }

.result-card {
  margin-bottom: 16px;
  padding: 22px 16px 18px;
  border-radius: 18px;
  text-align: center;
  background: rgba(20, 8, 28, 0.88);
  border: 1px solid rgba(125, 255, 179, 0.4);
}
.result-card.fail { border-color: rgba(255, 107, 107, 0.5); }
.result-tag {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--ok);
  margin-bottom: 10px;
}
.result-card.fail .result-tag { color: var(--fail); }
.result-judge {
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.result-time { font-size: 18px; margin-bottom: 6px; }
.result-time strong {
  display: inline-block;
  font-size: 36px;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.result-error {
  font-size: 16px;
  color: var(--cyan);
  margin-bottom: 12px;
}
.result-score { color: var(--muted); font-size: 14px; }
.result-score strong { color: var(--ink); }

.thumb {
  width: 100%;
  min-height: var(--thumb-h);
  border: 0;
  border-radius: 20px;
  font: inherit;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.28em;
  color: #2a1408;
  background: linear-gradient(180deg, #ffe7a1, var(--gold) 55%, #e0a020);
  box-shadow: 0 6px 0 #a36b10, 0 12px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.thumb:active { transform: translateY(3px); box-shadow: 0 3px 0 #a36b10; }

#play-actions {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: auto;
  margin: 0;
  padding-bottom: calc(16px + var(--safe-b));
}
#play-actions[hidden] { display: none; }
#play-hint {
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 213, 106, 0.35);
}

.play-stop {
  width: 100%;
  background: linear-gradient(180deg, #ff8eb3, var(--pink) 55%, #c41858);
  color: #fff;
  box-shadow: 0 6px 0 #8b1038, 0 12px 24px rgba(0, 0, 0, 0.35);
}
.play-stop:active { box-shadow: 0 3px 0 #8b1038; }
.play-stop[hidden] { display: none; }

#app.shake { animation: shake 0.45s linear; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

#app.popped #balloon-wrap {
  animation: burst 0.35s ease-out forwards;
}
@keyframes burst {
  60% { transform: translate(-50%, -50%) scale(1.25); filter: brightness(2); }
  100% { transform: translate(-50%, -50%) scale(0.1); opacity: 0; }
}

.confetti {
  position: absolute;
  width: 8px;
  height: 12px;
  z-index: 9;
  pointer-events: none;
  animation: fall 1.1s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(70vh) rotate(280deg); opacity: 0; }
}


#fx-veil {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  background: #fff;
}
#fx-veil.boom { animation: fx-white 0.24s ease-out; }
#fx-veil.fail { animation: fx-red 0.32s ease-out; }
#fx-veil.win { animation: fx-green 0.36s ease-out; }
@keyframes fx-white {
  0% { opacity: 0.74; background: #fff7ee; }
  100% { opacity: 0; background: #fff7ee; }
}
@keyframes fx-red {
  0% { opacity: 0.52; background: #ff3d4a; }
  100% { opacity: 0; background: #ff3d4a; }
}
@keyframes fx-green {
  0% { opacity: 0.4; background: #7dffb3; }
  100% { opacity: 0; background: #7dffb3; }
}

#fx-burst {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

#level-target {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 9;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255, 213, 106, 0.7);
  pointer-events: none;
  animation: target-in 0.28s cubic-bezier(0.2, 1.4, 0.3, 1);
}
#level-target[hidden] { display: none; }
#level-target.out { opacity: 0; transform: translate(-50%, -50%) scale(0.88); transition: opacity 0.24s ease, transform 0.24s ease; }
#level-target-num {
  font-size: clamp(88px, 26vw, 136px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
}
.level-target-unit {
  font-size: clamp(26px, 7vw, 38px);
  font-weight: 800;
  letter-spacing: 0.16em;
}
.spark {
  position: absolute;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  border-radius: 50%;
  pointer-events: none;
  animation: spark-out 0.62s ease-out forwards;
}
@keyframes spark-out {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

.tap-ripple {
  position: absolute;
  left: 50%;
  bottom: 6%;
  width: 70px;
  height: 70px;
  margin-left: -35px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 6;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55), rgba(255, 61, 127, 0) 70%);
  animation: tap-ripple 0.3s ease-out forwards;
}
@keyframes tap-ripple {
  from { transform: scale(0.35); opacity: 0.9; }
  to { transform: scale(2.5); opacity: 0; }
}

.play-stop.pulse {
  animation: stop-pulse 0.22s ease-out;
}
@keyframes stop-pulse {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.05); filter: brightness(1.22); }
  100% { transform: scale(1); filter: brightness(1); }
}
