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

:root {
  --pink:     #FF69B4;
  --hot:      #FF1493;
  --deep:     #C7006C;
  --soft:     #FFF0F8;
  --shadow:   0 4px 20px rgba(255,105,180,0.3);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--soft);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#game {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ── Header ─────────────────────────── */
#hdr {
  flex-shrink: 0;
  height: 8dvh;
  min-height: 48px;
  max-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: linear-gradient(135deg, #FF69B4 0%, #FF1493 100%);
  box-shadow: var(--shadow);
  z-index: 20;
}

#title-text {
  font-size: clamp(1.05rem, 4.5vw, 1.6rem);
  font-weight: 900;
  color: white;
  letter-spacing: 1.5px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

#spin-btn {
  width: 46px; height: 46px;
  border: none;
  border-radius: 50%;
  background: white;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.18);
  transition: transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}
#spin-btn:active { transform: scale(0.85); }

/* ── Stage ──────────────────────────── */
#stage {
  flex-shrink: 0;
  height: 50dvh;
  min-height: 200px;
  position: relative;
  overflow: hidden;
}

#bg-layer {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #FFB6C1 0%, #FFF0F5 55%, #FFE4E1 100%);
  transition: background 0.45s ease, background-image 0.45s ease;
  background-size: cover;
  background-position: center top;
}

/* Character container — maintains 2:3 aspect ratio, fills stage height */
#char-wrap {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 100%;
  aspect-ratio: 2 / 3;
  max-width: 56%;
}

.char-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Dance animation */
@keyframes dance {
  0%   { transform: translateX(-50%) rotate(0deg)   scale(1); }
  15%  { transform: translateX(-50%) rotate(-12deg) scale(1.06); }
  35%  { transform: translateX(-50%) rotate(12deg)  scale(1.06); }
  55%  { transform: translateX(-50%) rotate(-8deg)  scale(1.03); }
  75%  { transform: translateX(-50%) rotate(6deg)   scale(1.03); }
  90%  { transform: translateX(-50%) rotate(-3deg)  scale(1); }
  100% { transform: translateX(-50%) rotate(0deg)   scale(1); }
}
@keyframes bounce {
  0%,100% { transform: translateX(-50%) translateY(0); }
  25%      { transform: translateX(-50%) translateY(-8px); }
  75%      { transform: translateX(-50%) translateY(4px); }
}

#char-wrap.dancing {
  animation: dance 0.7s ease-in-out;
}

#sparkle-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* ── Tabs ───────────────────────────── */
#tabs {
  flex-shrink: 0;
  display: flex;
  background: white;
  border-top: 3px solid #FFD6EC;
  border-bottom: 3px solid #FFD6EC;
}

.tab {
  flex: 1;
  border: none;
  background: white;
  font-size: clamp(1.8rem, 7.5vw, 2.5rem);
  padding: 12px 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s;
  position: relative;
}
.tab.active {
  background: linear-gradient(180deg, #FFE8F5 0%, #FFD0EC 100%);
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 15%;
  width: 70%; height: 4px;
  background: var(--hot);
  border-radius: 2px 2px 0 0;
}
.tab:active { transform: scale(0.88); }

/* ── Picker ─────────────────────────── */
#picker {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #FFF5FB 0%, #FFE8F5 100%);
  position: relative;
}

.item-row {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  gap: 14px;
  padding: 10px 18px;
  scrollbar-width: none;
}
.item-row::-webkit-scrollbar { display: none; }
.item-row.hidden { display: none; }

.item-btn {
  flex-shrink: 0;
  width: 115px; height: 115px;
  border-radius: 24px;
  border: 4px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  scroll-snap-align: start;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 5px 14px rgba(0,0,0,0.13);
  position: relative;
  overflow: hidden;
}
.item-btn:active { transform: scale(0.85) !important; }
.item-btn.selected {
  border-color: var(--hot);
  box-shadow: 0 0 0 3px var(--hot), 0 6px 18px rgba(255,20,147,0.4);
  transform: scale(1.07);
}

/* Shine shimmer on selected */
.item-btn.selected::after {
  content: '';
  position: absolute;
  top: -40%; left: -40%;
  width: 60%; height: 180%;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.45) 50%, transparent 60%);
  animation: shimmer 1.8s infinite;
}
@keyframes shimmer {
  0%   { transform: translateX(-100%) rotate(10deg); }
  100% { transform: translateX(400%)  rotate(10deg); }
}

/* ── Tablet ─────────────────────────── */
@media (min-width: 600px) {
  #stage { height: 55dvh; }
  #char-wrap { max-width: 38%; }
  .item-btn { width: 145px; height: 145px; font-size: 4rem; border-radius: 30px; }
  #spin-btn { width: 54px; height: 54px; font-size: 1.8rem; }
}
