:root {
  color-scheme: light;
  --ink: #581c87;
  --pink: #ec4899;
  --card: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(#fbcfe8, #e9d5ff, #bfdbfe);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

main {
  width: min(960px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.back {
  color: #6b21a8;
  font-weight: 700;
  text-decoration: none;
}

.back:hover {
  color: #be185d;
}

.title-block {
  text-align: center;
}

h1 {
  margin: 0 0 10px;
  color: #6b21a8;
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  line-height: 1.1;
}

h2, h3 {
  margin: 0;
}

.flower-pill {
  display: inline-block;
  margin: 0;
  padding: 8px 22px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(88, 28, 135, 0.15);
  color: #db2777;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 800;
}

.card,
.stage,
.modal-card {
  background: var(--card);
  border-radius: 28px;
  box-shadow: 0 16px 40px rgba(88, 28, 135, 0.16);
}

.card {
  padding: 20px;
}

.center {
  text-align: center;
}

.door {
  font-size: 6rem;
  line-height: 1;
  animation: bounce 1s ease-in-out infinite;
}

.twinkle {
  margin: 8px 0 16px;
  font-size: 3.5rem;
  animation: pulse 1.4s ease-in-out infinite;
}

.how-to {
  max-width: 640px;
  margin: 0 auto 18px;
  padding: 18px 18px 8px;
  border-radius: 24px;
  background: #f3e8ff;
  text-align: left;
}

.how-to h3 {
  margin-bottom: 10px;
  text-align: center;
  font-size: 1.5rem;
}

.how-to ul {
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
}

.how-to li {
  margin: 0 0 10px;
  font-size: 1.05rem;
  line-height: 1.4;
}

.teacher {
  display: flex;
  align-items: center;
  gap: 14px;
}

.teacher.compact {
  margin-bottom: 14px;
}

.teacher-face {
  font-size: 4rem;
  line-height: 1;
}

.bubble {
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: #f3e8ff;
  color: #6b21a8;
  font-size: 1.15rem;
  line-height: 1.4;
}

.center-title {
  margin-bottom: 14px;
  text-align: center;
  font-size: 1.7rem;
}

.character-grid,
.outfit-grid,
.theme-grid {
  display: grid;
  gap: 12px;
}

.character-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.character-card,
.song-btn,
.item-btn,
.pill-btn,
.move,
.action-btn,
.tab {
  font-family: inherit;
  cursor: pointer;
}

.character-card {
  border: 4px solid transparent;
  border-radius: 24px;
  padding: 16px 12px;
  color: #4c1d95;
  text-align: center;
}

.character-card:hover,
.song-btn:hover {
  transform: scale(1.03);
}

.character-card .face,
.dancer-still,
.dancer {
  font-size: clamp(4rem, 12vw, 6.5rem);
  line-height: 1;
}

.character-card strong {
  display: block;
  margin: 6px 0;
  font-size: 1.6rem;
}

.stage {
  padding: 18px;
  border: 8px solid #9333ea;
}

.stage[data-theme="pink"] {
  background: linear-gradient(#fbcfe8, #f9a8d4);
}

.stage[data-theme="purple"] {
  background: linear-gradient(#e9d5ff, #d8b4fe);
}

.stage[data-theme="rainbow"] {
  background: linear-gradient(#fecaca, #fef08a, #bfdbfe);
}

.stage[data-theme="gold"] {
  background: linear-gradient(#fef08a, #fcd34d);
}

.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.stage-head h2 {
  font-size: clamp(1.2rem, 4vw, 1.7rem);
}

.studio-room {
  position: relative;
  min-height: 320px;
  padding: 16px;
  border-radius: 20px;
  background: #fff;
}

.mirror {
  height: 88px;
  border: 4px solid #9ca3af;
  border-radius: 18px;
  background: linear-gradient(to right, #dbeafe, #bfdbfe);
  color: rgba(30, 64, 175, 0.35);
  font-size: clamp(1.4rem, 5vw, 2.4rem);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.studio-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.action-btn {
  min-width: 108px;
  border-radius: 16px;
  padding: 10px 12px;
  color: #fff;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.action-btn span {
  font-size: 1.8rem;
  line-height: 1;
}

.practice {
  background: #ef4444;
  border: 4px solid #b91c1c;
}

.perform {
  background: #eab308;
  border: 4px solid #a16207;
}

.studio-dancer {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.studio-dancer p {
  margin: 0 0 6px;
  font-weight: 700;
}

.floor {
  height: 14px;
  margin-top: 12px;
  border-radius: 999px;
}

.stage[data-theme="pink"] .floor { background: #f472b6; }
.stage[data-theme="purple"] .floor { background: #c084fc; }
.stage[data-theme="rainbow"] .floor { background: linear-gradient(to right, #f87171, #60a5fa); }
.stage[data-theme="gold"] .floor { background: #eab308; }

.stats {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  text-align: center;
}

.stats span {
  display: block;
  color: #7e22ce;
  font-weight: 800;
}

.stats strong {
  color: #ec4899;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
}

.combo { color: #f97316; }
.bonus { color: #16a34a; }

.dance-stage[data-mode="practice"] {
  background: linear-gradient(#d8b4fe, #c084fc);
  border-color: #9333ea;
}

.dance-stage[data-mode="performance"] {
  background: linear-gradient(#fde047, #f9a8d4, #d8b4fe);
  border-color: #eab308;
}

.lights {
  display: flex;
  justify-content: space-around;
  font-size: 2.4rem;
}

.lights span {
  animation: pulse 1.2s ease-in-out infinite;
}

.lights span:nth-child(2) { animation-delay: 0.3s; }
.lights span:nth-child(3) { animation-delay: 0.6s; }

.banner {
  margin: 8px 0 12px;
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(to right, #ef4444, #ec4899);
  color: #fff;
  text-align: center;
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  font-weight: 800;
}

.dance-floor {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  padding: 12px;
  border-radius: 20px;
  background: #fff;
}

.audience {
  padding: 8px;
  border: 4px solid #c084fc;
  border-radius: 14px;
  background: #e9d5ff;
  text-align: center;
}

.audience-row {
  display: flex;
  justify-content: space-around;
  font-size: clamp(1.6rem, 6vw, 2.6rem);
}

.audience p {
  margin: 4px 0 0;
  font-weight: 800;
  font-size: 0.9rem;
}

.flower-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.audience-flower {
  position: absolute;
  top: 18%;
  font-size: 2rem;
  animation: fall 2s linear forwards;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: 220px;
  margin-top: 12px;
}

.lane {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.lane.is-active {
  transform: scale(1.08);
}

.dancer.is-bounce {
  animation: bounce 0.7s ease-in-out infinite;
}

.dancer.is-down {
  transform: scale(0.75);
}

.lane-marks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.lane-marks span {
  height: 8px;
  border-radius: 999px;
}

.lane-marks span:nth-child(1) { background: #f472b6; }
.lane-marks span:nth-child(2) { background: #c084fc; }
.lane-marks span:nth-child(3) { background: #60a5fa; }

.move-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.move {
  min-height: 68px;
  border-radius: 18px;
  color: #fff;
  font-size: 1.8rem;
  font-weight: 800;
  touch-action: manipulation;
}

.move:active {
  transform: scale(0.96);
}

.left { background: #f472b6; border: 4px solid #db2777; }
.up { background: #facc15; border: 4px solid #ca8a04; }
.down { background: #4ade80; border: 4px solid #16a34a; }
.right { background: #60a5fa; border: 4px solid #2563eb; }

.pill-btn,
.item-btn,
.tab,
.song-btn {
  border: 0;
  border-radius: 999px;
  font-weight: 800;
}

.pill-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px 18px;
  color: #fff;
  font-size: 1.15rem;
}

#come-inside,
.shop-btn {
  width: auto;
  margin: 0 auto;
  background: #ec4899;
}

.shop-btn {
  margin: 0;
  padding: 8px 16px;
}

.stop { background: #ef4444; }
.close-shop { background: #9333ea; font-size: 1.3rem; }
.close-radio { background: #6b7280; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.5);
}

.modal-card {
  width: min(920px, 100%);
  margin: 24px 0;
  padding: 22px 16px;
}

.modal-card h2,
.panel h3 {
  text-align: center;
}

.shop-balance {
  margin: 8px 0 14px;
  text-align: center;
  color: #db2777;
  font-size: 1.4rem;
  font-weight: 800;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  padding: 12px 8px;
  background: #e5e7eb;
  color: #374151;
  font-size: clamp(1rem, 3vw, 1.3rem);
}

.tab.is-on {
  background: #ec4899;
  color: #fff;
  transform: scale(1.03);
}

#tab-themes.is-on {
  background: #a855f7;
}

.panel {
  margin-bottom: 8px;
  padding: 14px;
  border-radius: 24px;
}

.outfits-panel {
  background: #fdf2f8;
  border: 4px solid #f9a8d4;
}

.themes-panel {
  background: #faf5ff;
  border: 4px solid #d8b4fe;
}

.panel h3 {
  margin-bottom: 6px;
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.hint {
  margin: 0 0 12px;
  text-align: center;
  color: #4b5563;
}

.outfit-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.theme-grid {
  grid-template-columns: 1fr 1fr;
}

.item {
  padding: 12px;
  border: 4px solid #f472b6;
  border-radius: 18px;
  background: #fff;
  text-align: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
}

.theme-card {
  border-color: #c084fc;
}

.item .emoji {
  font-size: 3rem;
  line-height: 1;
}

.item strong {
  display: block;
  margin: 6px 0;
}

.multiplier,
.cost {
  margin: 0 0 8px;
  font-weight: 800;
}

.multiplier { color: #16a34a; }
.cost { color: #7e22ce; }

.swatch {
  height: 88px;
  margin-bottom: 8px;
  border: 4px solid #d1d5db;
  border-radius: 12px;
}

.swatch.pink { background: linear-gradient(to right, #fbcfe8, #f9a8d4); }
.swatch.purple { background: linear-gradient(to right, #e9d5ff, #d8b4fe); }
.swatch.rainbow { background: linear-gradient(to right, #fecaca, #fef08a, #bfdbfe); }
.swatch.gold { background: linear-gradient(to right, #fef08a, #fcd34d); }

.item-btn {
  width: 100%;
  padding: 8px;
  color: #fff;
}

.item-btn.wear { background: #d1d5db; color: #374151; }
.item-btn.wearing { background: #22c55e; }
.item-btn.buy-outfit { background: #ec4899; }
.item-btn.buy-theme { background: #a855f7; }
.item-btn:disabled {
  background: #d1d5db;
  color: #6b7280;
  cursor: not-allowed;
}

.song-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.song-btn {
  width: 100%;
  border-radius: 18px;
  padding: 14px;
  color: #3b0764;
  text-align: left;
}

.song-btn span {
  display: flex;
  align-items: center;
  gap: 12px;
}

.song-btn .emoji {
  font-size: 2.6rem;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid #7c3aed;
  outline-offset: 3px;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

@keyframes pulse {
  50% { opacity: 0.45; }
}

@keyframes fall {
  from { transform: translateY(0); }
  to { transform: translateY(280px); }
}

@media (max-width: 800px) {
  .character-grid,
  .outfit-grid,
  .theme-grid {
    grid-template-columns: 1fr 1fr;
  }

  .teacher {
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .character-grid,
  .outfit-grid,
  .theme-grid,
  .stage-head {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .shop-btn {
    width: 100%;
  }
}
