/* ============================================
   SpankSomeone - 打屁股大赛
   Mobile-first with SVG human figures
   ============================================ */

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

:root {
  --bg-start: #1a1a2e;
  --bg-mid: #2d1b3d;
  --bg-end: #16213e;
  --primary: #ff6b6b;
  --accent: #feca57;
  --gold: #ffd700;
  --text: #f0e6d3;
  --text-muted: #a09585;
  --card-bg: rgba(255,255,255,0.07);
  --card-border: rgba(255,255,255,0.1);
  --bench: #8B5E3C;
  --bench-dark: #6B3F1F;
  --radius-md: 16px;
  --font: 'PingFang SC','Hiragino Sans GB','Microsoft YaHei','Noto Sans SC',system-ui,-apple-system,sans-serif;
}

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font);
  background: linear-gradient(170deg, var(--bg-start), var(--bg-mid) 50%, var(--bg-end));
  color: var(--text);
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
  user-select: none; -webkit-user-select: none;
}

body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(circle at 20% 25%, rgba(255,107,107,0.10) 0%, transparent 50%),
    radial-gradient(circle at 80% 55%, rgba(254,202,87,0.08) 0%, transparent 50%);
}

.app-container {
  position: relative; z-index: 1; max-width: 480px; margin: 0 auto;
  padding: 12px 8px 20px; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}

/* --- Header --- */
.header { text-align: center; padding: 8px 0 4px; }
.title {
  font-size: clamp(1.05rem, 4.2vw, 1.5rem); font-weight: 900;
  background: linear-gradient(135deg, #ff6b6b, #feca57, #ff6b6b);
  background-size: 200% 200%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 3s ease-in-out infinite;
  letter-spacing: 1px; margin-bottom: 2px;
  white-space: nowrap;
}
@keyframes gradientShift {
  0%,100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.subtitle { font-size: 0.8rem; color: var(--text-muted); }

/* --- Bench Section --- */
.bench-section { position: relative; margin: 8px 0 4px; }

/* --- Figures Row --- */
.figures-row {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 2px; position: relative; z-index: 2;
  min-height: 220px;
}

.figure-card {
  flex: 1; max-width: 140px;
  display: flex; flex-direction: column; align-items: center;
  position: relative;
}

.figure-card.shaking {
  animation: figureShake 0.5s ease-out;
}
@keyframes figureShake {
  0%,100% { transform: translateY(0); }
  15% { transform: translateY(-10px) rotate(-4deg); }
  30% { transform: translateY(3px) rotate(3deg); }
  50% { transform: translateY(-5px) rotate(-2deg); }
  70% { transform: translateY(2px); }
  85% { transform: translateY(-3px); }
}

/* SVG figure wrapper */
.figure-svg-wrap {
  position: relative;
  width: 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.figure-svg-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Spank hit overlay on butt */
.butt-hit-zone {
  position: absolute;
  /* Positioned by JS to overlay the butt area */
  border-radius: 50%;
  cursor: pointer;
  z-index: 5;
}

/* Name below figure */
.figure-name {
  font-size: 0.85rem; font-weight: 700;
  margin-top: -4px; position: relative; z-index: 3;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Counter below name */
.figure-counter {
  font-size: 0.75rem; font-weight: 700;
  color: var(--accent);
  background: rgba(0,0,0,0.35); backdrop-filter: blur(4px);
  border-radius: 12px; padding: 2px 10px;
  border: 1px solid rgba(255,255,255,0.08);
  transition: transform 0.15s;
}
.figure-counter.bump {
  animation: counterPop 0.35s ease-out;
}
@keyframes counterPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* Spank button - positioned overlapping butt */
.spank-btn {
  position: absolute;
  /* Position set dynamically by JS to overlap butt */
  padding: 8px 16px;
  border: none; border-radius: 20px;
  font-size: 0.85rem; font-weight: 900; letter-spacing: 1px;
  cursor: pointer; color: #fff;
  background: linear-gradient(180deg, #ff5252, #d32f2f);
  box-shadow: 0 4px 0 rgba(0,0,0,0.3), 0 2px 10px rgba(255,50,50,0.4);
  transition: transform 0.08s;
  z-index: 10; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.spank-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.3), 0 1px 4px rgba(255,50,50,0.3);
}
.spank-btn .hand {
  display: inline-block;
  animation: handWiggle 0.5s infinite;
}
@keyframes handWiggle {
  0%,100% { transform: rotate(0); }
  25% { transform: rotate(12deg); }
  75% { transform: rotate(-12deg); }
}

/* Crown on #1 */
.figure-crown {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  font-size: 1.4rem; z-index: 6; pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
  animation: crownBounce 1.2s ease-in-out infinite;
}
@keyframes crownBounce {
  0%,100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5px); }
}

/* --- CSS Bench --- */
.bench { position: relative; z-index: 1; padding: 0 2px; }
.bench-top {
  height: 16px;
  background: linear-gradient(180deg, #A0724A, #8B5E3C 15%, #9B6B4A 30%, #7A4E2E 55%, #8B5E3C 75%, #6B3F1F);
  border-radius: 5px;
  box-shadow: 0 2px 0 rgba(255,255,255,0.06) inset, 0 4px 12px rgba(0,0,0,0.4);
}
.bench-top::before {
  content: ''; position: absolute; top: 3px; left: 8px; right: 8px; height: 1px;
  background: rgba(0,0,0,0.18);
  box-shadow: 0 3px 0 rgba(0,0,0,0.12), 0 6px 0 rgba(0,0,0,0.08);
}
.bench-legs { display: flex; justify-content: space-between; padding: 0 10px; }
.bench-leg {
  width: 12px; height: 20px;
  background: linear-gradient(180deg, #6B3F1F, #5C3A1E);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.floor {
  height: 3px; background: rgba(255,255,255,0.03);
  border-radius: 50%; margin: 0 8%; filter: blur(2px);
}

/* --- Toast --- */
.toast-container {
  position: fixed; top: 16%; left: 50%; transform: translateX(-50%);
  z-index: 100; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.toast-bubble {
  background: rgba(0,0,0,0.88); color: #fff;
  padding: 10px 18px; border-radius: 18px;
  font-size: 0.9rem; font-weight: 700;
  white-space: normal; max-width: 86vw; line-height: 1.4;
  text-align: left; word-break: break-word;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  animation: toastFly 2s ease-out forwards;
}
.toast-bubble::after {
  content: ''; position: absolute; bottom: -7px; left: 20%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid rgba(0,0,0,0.88);
}
@keyframes toastFly {
  0% { opacity: 0; transform: translateY(15px) scale(0.7); }
  15% { opacity: 1; transform: translateY(-8px) scale(1.06); }
  25% { transform: translateY(0) scale(1); }
  80% { opacity: 1; transform: translateY(-5px); }
  100% { opacity: 0; transform: translateY(-45px) scale(0.75); }
}

/* --- Combo --- */
.combo-display {
  position: fixed; top: 45%; left: 50%; transform: translate(-50%,-50%);
  z-index: 99; pointer-events: none; text-align: center;
}
.combo-text {
  font-size: clamp(1.1rem, 4vw, 1.8rem); font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(254,202,87,0.8), 0 4px 8px rgba(0,0,0,0.6);
  animation: comboAppear 1.5s ease-out forwards;
}
@keyframes comboAppear {
  0% { opacity: 0; transform: scale(0.3) rotate(-10deg); }
  20% { opacity: 1; transform: scale(1.25) rotate(4deg); }
  30% { transform: scale(1) rotate(0); }
  70% { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(0.75) translateY(-35px); }
}

/* --- Stats --- */
.stats-section { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.total-bar {
  text-align: center; background: var(--card-bg);
  border: 1px solid var(--card-border); border-radius: var(--radius-md);
  padding: 8px 14px; font-size: 0.85rem; font-weight: 700;
  backdrop-filter: blur(4px);
}
.total-count {
  font-size: 1.2rem; color: var(--accent); font-weight: 900;
  display: inline-block; transition: transform 0.15s;
}
.total-count.pulse { animation: counterPop 0.4s ease-out; }

.leaderboard {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); padding: 10px 14px;
  backdrop-filter: blur(4px);
}
.leaderboard-title { font-size: 0.95rem; font-weight: 800; text-align: center; margin-bottom: 8px; }
.ranking-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ranking-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: rgba(255,255,255,0.03);
  border-radius: 8px; font-size: 0.82rem; font-weight: 700;
}
.ranking-item.rank-1 { background: rgba(255,215,0,0.10); border: 1px solid rgba(255,215,0,0.20); }
.ranking-item.rank-2 { background: rgba(192,192,192,0.06); border: 1px solid rgba(192,192,192,0.12); }
.ranking-item.rank-3 { background: rgba(205,127,50,0.06); border: 1px solid rgba(205,127,50,0.12); }
.rank-icon { font-size: 1.2rem; width: 26px; text-align: center; }
.rank-name { flex: 1; }
.rank-count { color: var(--accent); font-size: 0.9rem; }
.rank-bar-bg { flex: 2; height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.rank-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.5s ease-out;
}

/* --- Particles --- */
.particles-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.particle {
  position: absolute; font-size: 1.2rem;
  animation: particleFly 1s ease-out forwards;
  pointer-events: none;
}
@keyframes particleFly {
  0% { opacity: 1; transform: translate(0,0) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(var(--dx),var(--dy)) scale(0.15) rotate(var(--rot)); }
}

/* --- Screen Shake --- */
.screen-shake { animation: screenShake 0.4s ease-out; }
@keyframes screenShake {
  0%,100% { transform: translate(0); }
  10% { transform: translate(-4px,2px); }
  20% { transform: translate(4px,-1px); }
  30% { transform: translate(-3px,-2px); }
  40% { transform: translate(3px,1px); }
  50% { transform: translate(-2px,-1px); }
  60% { transform: translate(2px,1px); }
  70% { transform: translate(-1px,0); }
  80% { transform: translate(1px,0); }
}

/* --- SVG Butt Flash --- */
.butt-flash {
  animation: buttFlash 0.3s ease-out;
}
@keyframes buttFlash {
  0% { fill: #ff0000; r: 24; }
  100% { fill: #ffaaaa; r: 18; }
}

/* --- Footer --- */
.footer { text-align: center; margin-top: auto; padding-top: 16px; font-size: 0.7rem; color: var(--text-muted); opacity: 0.5; }

/* --- Responsive --- */
@media (max-width: 340px) {
  .figures-row { gap: 0; }
  .figure-card { max-width: 115px; }
  .spank-btn { font-size: 0.75rem; padding: 6px 10px; }
}
@media (min-width: 420px) {
  .figures-row { gap: 8px; }
  .figure-card { max-width: 145px; }
}
