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

:root {
  --bg-deep: #0f0e1a;
  --bg-purple: #1a1630;
  --bg-card: rgba(245, 240, 225, 0.08);
  --cream: #f5f0e1;
  --warm-cream: #e8dcc8;
  --coral: #ff6b6b;
  --coral-light: #ff8e8e;
  --cyan: #48dbfb;
  --cyan-dark: #0abde3;
  --gold: #ffd93d;
  --gold-dark: #f0c929;
  --green: #6bcb77;
  --text: #f0ebe3;
  --text-dim: #a09888;
  --shadow: rgba(0, 0, 0, 0.4);
  --radius: 18px;
  --radius-sm: 10px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.screen.hidden {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* Loading Screen */
#loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1630 0%, #0f0e1a 70%);
  z-index: 100;
}

.loading-content {
  text-align: center;
}

.title-hand {
  font-family: 'Fredoka One', cursive;
  font-size: 3.5rem;
  color: var(--gold);
  text-shadow: 0 4px 20px rgba(255, 217, 61, 0.3), 0 2px 0 var(--gold-dark);
  letter-spacing: 4px;
  transform: rotate(-1.5deg);
  margin-bottom: 8px;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--cyan);
  transform: rotate(0.5deg);
  margin-bottom: 40px;
  font-weight: 600;
}

.loader {
  width: 60px;
  height: 60px;
  margin: 0 auto 20px;
  border: 4px solid rgba(255, 217, 61, 0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text-dim);
  font-size: 0.95rem;
  animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Hub Screen */
#hub-screen {
  background: radial-gradient(ellipse at 30% 20%, #1a1630 0%, #0f0e1a 100%);
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

.hub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 12px;
  border-bottom: 2px dashed rgba(255, 217, 61, 0.2);
}

.station-name {
  display: flex;
  align-items: center;
  gap: 12px;
}

.station-name h1 {
  font-family: 'Fredoka One', cursive;
  font-size: 1.6rem;
  color: var(--gold);
  transform: rotate(-1deg);
  text-shadow: 0 2px 10px rgba(255, 217, 61, 0.2);
}

.level-badge {
  background: var(--cyan);
  color: var(--bg-deep);
  padding: 2px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 800;
  transform: rotate(1deg);
  box-shadow: 0 2px 8px rgba(72, 219, 251, 0.3);
}

.hub-stats {
  display: flex;
  gap: 16px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 1.1rem;
  backdrop-filter: blur(4px);
}

.stat-icon {
  font-size: 1.2rem;
}

/* Station View */
.station-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 20px 4px;
  flex: 1;
}

.room {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  position: relative;
  backdrop-filter: blur(4px);
  min-height: 130px;
}

.room:hover {
  border-color: var(--gold);
  background: rgba(255, 217, 61, 0.08);
  transform: translateY(-2px);
}

.room:active {
  transform: scale(0.97);
}

.room[data-room="stage"] {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.1), rgba(255, 217, 61, 0.08));
  border-color: rgba(255, 107, 107, 0.3);
  min-height: 150px;
}

.room[data-room="stage"]:hover {
  border-color: var(--coral);
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(255, 217, 61, 0.15));
}

.room[data-room="defense"] {
  background: linear-gradient(135deg, rgba(72, 219, 251, 0.1), rgba(15, 14, 26, 0.2));
  border-color: rgba(72, 219, 251, 0.3);
}

.room[data-room="defense"]:hover {
  border-color: var(--cyan);
  background: linear-gradient(135deg, rgba(72, 219, 251, 0.2), rgba(15, 14, 26, 0.3));
}

.room[data-room="colorsurge"] {
  background: linear-gradient(135deg, rgba(166, 108, 255, 0.1), rgba(15, 14, 26, 0.2));
  border-color: rgba(166, 108, 255, 0.3);
}

.room[data-room="colorsurge"]:hover {
  border-color: #a66cff;
  background: linear-gradient(135deg, rgba(166, 108, 255, 0.2), rgba(15, 14, 26, 0.3));
}

.room[data-room="neonfrenzy"] {
  background: linear-gradient(135deg, rgba(255, 159, 243, 0.1), rgba(15, 14, 26, 0.2));
  border-color: rgba(255, 159, 243, 0.3);
}

.room[data-room="neonfrenzy"]:hover {
  border-color: #ff9ff3;
  background: linear-gradient(135deg, rgba(255, 159, 243, 0.2), rgba(15, 14, 26, 0.3));
}

.room[data-room="voice"] {
  background: linear-gradient(135deg, rgba(107, 203, 119, 0.1), rgba(15, 14, 26, 0.2));
  border-color: rgba(107, 203, 119, 0.3);
}

.room[data-room="voice"]:hover {
  border-color: var(--green);
  background: linear-gradient(135deg, rgba(107, 203, 119, 0.2), rgba(15, 14, 26, 0.3));
}

.room[data-room="cosmicduality"] {
  background: linear-gradient(135deg, rgba(255, 217, 61, 0.1), rgba(15, 14, 26, 0.2));
  border-color: rgba(255, 217, 61, 0.3);
}

.room[data-room="cosmicduality"]:hover {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(255, 217, 61, 0.2), rgba(15, 14, 26, 0.3));
}

.room[data-room="voicestudio"] {
  background: linear-gradient(135deg, rgba(255, 159, 243, 0.1), rgba(15, 14, 26, 0.2));
  border-color: rgba(255, 159, 243, 0.3);
}

.room[data-room="voicestudio"]:hover {
  border-color: #ff9ff3;
  background: linear-gradient(135deg, rgba(255, 159, 243, 0.2), rgba(15, 14, 26, 0.3));
}

.animal-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px 0 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 10px;
}

.animal-btn {
  background: rgba(255,255,255,0.05);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  flex: 1;
  min-width: 60px;
}

.animal-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

.animal-btn.selected {
  border-color: var(--gold);
  background: rgba(255, 217, 61, 0.15);
}

.animal-btn .animal-emoji {
  font-size: 1.6rem;
  display: block;
}

.animal-btn .animal-name {
  font-size: 0.7rem;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
}

.room-icon {
  font-size: 2.2rem;
}

.room-name {
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}

.room-level {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.play-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-5deg);
  font-family: 'Fredoka One', cursive;
  font-size: 3.5rem;
  color: var(--gold);
  opacity: 0;
  transition: opacity 0.3s ease;
  text-shadow: 0 0 30px rgba(255, 217, 61, 0.5);
  pointer-events: none;
}

.room[data-room="stage"]:hover .play-hint {
  opacity: 0.7;
}

/* Level Select (minigames) */
.level-select {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  backdrop-filter: blur(4px);
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.level-select.open {
  display: block;
}

.level-select h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--cyan);
}

#level-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.level-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.level-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 217, 61, 0.3);
}

.level-item.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.level-item.locked:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
}

.level-item .level-stars {
  color: var(--gold);
  font-size: 0.9rem;
}

/* Mini-game Screen */
#minigame-screen {
  background: var(--bg-deep);
}

#minigame-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#minigame-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#minigame-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  pointer-events: auto;
}

#mg-level-name {
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

#mg-score {
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  color: var(--gold);
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
  min-width: 60px;
  text-align: right;
}

/* Song Select */
.song-select {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  backdrop-filter: blur(4px);
  max-height: 250px;
  overflow-y: auto;
}

.song-select h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--cyan);
}

#song-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.song-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.song-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 217, 61, 0.3);
}

.song-item.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.song-item.locked:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
}

.song-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.song-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.song-artist {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.song-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.song-stars {
  color: var(--gold);
}

/* Hub Footer */
.hub-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  border-top: 2px dashed rgba(255, 217, 61, 0.15);
}

.progress-bar {
  flex: 1;
  height: 10px;
  background: var(--bg-card);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--gold));
  border-radius: 10px;
  transition: width 0.5s ease;
  width: 0%;
}

/* Buttons */
.btn-hand {
  background: var(--bg-card);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.btn-hand:hover {
  border-color: var(--gold);
  color: var(--gold);
  transform: translateY(-1px);
}

.btn-hand:active {
  transform: scale(0.97);
}

.btn-hand.primary {
  background: var(--gold);
  color: var(--bg-deep);
  border-color: var(--gold);
}

.btn-hand.primary:hover {
  background: var(--gold-dark);
  border-color: var(--gold-dark);
  color: var(--bg-deep);
}

/* Game Screen */
#game-screen {
  background: var(--bg-deep);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#game-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  pointer-events: auto;
}

.btn-back {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-exit {
  background: rgba(255, 80, 80, 0.15);
  border: none;
  color: #ff6b6b;
  font-size: 1.3rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  margin-right: 4px;
}

.btn-exit:hover {
  background: rgba(255, 80, 80, 0.3);
}

#song-name-display {
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

#score-display {
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  color: var(--gold);
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
  min-width: 60px;
  text-align: right;
}

#combo-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Fredoka One', cursive;
  font-size: 3rem;
  color: var(--cyan);
  text-shadow: 0 0 30px rgba(72, 219, 251, 0.5);
  pointer-events: none;
}

#feedback-display {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Fredoka One', cursive;
  font-size: 1.8rem;
  pointer-events: none;
  text-align: center;
}

#progress-bar-container {
  position: absolute;
  bottom: 30px;
  left: 20px;
  right: 20px;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  overflow: hidden;
}

#song-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--gold));
  border-radius: 6px;
  width: 0%;
  transition: width 0.1s linear;
}

/* Pause Overlay */
#pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 14, 26, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  z-index: 10;
}

.pause-menu {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pause-menu h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: var(--gold);
  margin-bottom: 12px;
}

/* Result Screen */
#result-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1630 0%, #0f0e1a 70%);
}

.result-content {
  text-align: center;
  max-width: 380px;
  padding: 24px;
}

#result-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  margin-bottom: 16px;
  color: var(--gold);
  transform: rotate(-1deg);
}

.stars-display {
  font-size: 3rem;
  margin-bottom: 20px;
  letter-spacing: 8px;
}

.star-earned {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 217, 61, 0.5);
}

.star-empty {
  color: rgba(255, 255, 255, 0.15);
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.result-stat {
  background: var(--bg-card);
  padding: 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-stat span:first-child {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.result-stat span:last-child {
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  color: var(--cyan);
}

.result-breakdown {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  font-weight: 600;
}

.perfect-badge { color: var(--cyan); }
.good-badge { color: var(--green); }
.miss-badge { color: var(--coral); }

.result-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Scrollbar */
.song-select::-webkit-scrollbar {
  width: 4px;
}

.song-select::-webkit-scrollbar-track {
  background: transparent;
}

.song-select::-webkit-scrollbar-thumb {
  background: rgba(255, 217, 61, 0.3);
  border-radius: 4px;
}

/* Responsive */
@media (min-width: 600px) {
  .station-view {
    grid-template-columns: repeat(4, 1fr);
    max-width: 700px;
    margin: 0 auto;
  }

  .room[data-room="stage"] {
    grid-column: 1 / -1;
  }

  .hub-header, .hub-footer {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
  }

  .song-select {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }
}
