:root {
  --bg1: #fff5c2;
  --bg2: #ffe1f0;
  --bg3: #dff4ff;
  --panel: rgba(255, 255, 255, 0.8);
  --text: #3b3b66;
  --primary: #ff6b9f;
  --primary-dark: #e5528a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
}

body {
  overflow: hidden;
  background: linear-gradient(130deg, var(--bg1), var(--bg2), var(--bg3));
}

.bg-decor {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 114, 173, 0.3) 0 35px, transparent 36px),
    radial-gradient(circle at 82% 16%, rgba(255, 214, 102, 0.35) 0 42px, transparent 43px),
    radial-gradient(circle at 20% 78%, rgba(112, 214, 255, 0.3) 0 36px, transparent 37px),
    radial-gradient(circle at 87% 73%, rgba(156, 255, 142, 0.28) 0 44px, transparent 45px);
  animation: floatBg 12s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes floatBg {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-14px);
  }
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 14px;
}

.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: var(--panel);
  border-radius: 18px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(20, 20, 40, 0.12);
}

h1 {
  margin: 0;
  text-align: center;
  font-size: clamp(22px, 3.2vw, 42px);
  letter-spacing: 1px;
}

.top-spacer {
  min-height: 1px;
}

.timer-box {
  justify-self: end;
  min-width: 110px;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 6px 12px;
  box-shadow: 0 6px 16px rgba(20, 20, 40, 0.1);
}

#timerText {
  font-weight: 700;
  font-size: clamp(18px, 2.2vw, 32px);
}

.stage-wrap {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.52);
  border-radius: 20px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8), 0 8px 28px rgba(20, 20, 40, 0.08);
  overflow: hidden;
}

#photo {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  max-height: none;
  transform-origin: center center;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  user-select: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 2;
}

#photo.show {
  opacity: 1;
}

.hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(95%, 920px);
  text-align: center;
  font-size: clamp(14px, 1.6vw, 24px);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 8px 12px;
  z-index: 3;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border-radius: 16px;
  padding: 10px;
}

.controls-side {
  display: flex;
  align-items: center;
}

.controls-main {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.progress-chip {
  display: inline-block;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: clamp(13px, 1.2vw, 18px);
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(20, 20, 40, 0.1);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: clamp(14px, 1.4vw, 20px);
  font-weight: 700;
  cursor: pointer;
  background: #ffffff;
  color: #435;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.mode-active {
  background: #6b7dff;
  color: #fff;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bubble-layer {
  position: absolute;
  inset: 10px;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.bubble-layer::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5%;
  width: min(92%, 920px);
  height: min(46%, 320px);
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.2) 48%, rgba(255, 255, 255, 0.05) 100%);
  filter: blur(2px);
}

.bubble-layer.active {
  pointer-events: auto;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 14px 26px rgba(20, 20, 40, 0.26), 0 0 20px rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(5px) saturate(1.12);
  -webkit-backdrop-filter: blur(5px) saturate(1.12);
}

.bubble img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(1.06) contrast(1.05) blur(2.2px) brightness(1.02);
  opacity: 0.92;
}

.bubble::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.45), transparent 45%);
}

@keyframes bubbleFloat {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-16px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(46, 46, 70, 0.92);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: clamp(13px, 1.3vw, 18px);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 10;
}

.toast.show {
  opacity: 1;
}

@media (max-width: 1000px) {
  .controls {
    grid-template-columns: 1fr;
  }
  .controls-side {
    justify-content: center;
  }
}
