@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Press Start 2P', cursive;
  background: #1a0a2e;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}
/* ── LOADING SCREEN ── */
.loading-notes {
  display: flex; gap: 10px; margin-bottom: 20px;
  font-size: 32px; filter: drop-shadow(0 0 8px rgba(255,255,255,0.5));
}
.loading-notes span { animation: float-note 1.5s ease-in-out infinite alternate; }
.loading-notes span:nth-child(2) { animation-delay: 0.3s; }
.loading-notes span:nth-child(3) { animation-delay: 0.6s; }
.loading-notes span:nth-child(4) { animation-delay: 0.9s; }
.loading-notes span:nth-child(5) { animation-delay: 1.2s; }

@keyframes float-note {
  0% { transform: translateY(10px) scale(0.8); filter: brightness(0.8); }
  100% { transform: translateY(-10px) scale(1.2); filter: brightness(1.5) drop-shadow(0 0 10px currentColor); }
}

.loader-bar {
  width: 240px; height: 48px;
  display: grid;
  grid-template-columns: repeat(3, 8px) repeat(10, 12px 8px) repeat(2, 8px);
  grid-template-rows: repeat(6, 8px);
}
.block-border { background-color: #fff; }
.block-meter.c1 { background-color: #ef4444; }
.block-meter.c2 { background-color: #eab308; }
.block-meter.c3 { background-color: #ec4899; }
.block-meter.c4 { background-color: #22c55e; }
.block-meter.c5 { background-color: #3b82f6; }
.block-meter.c6 { background-color: #8b5cf6; }

.block-border:nth-of-type(1) { grid-row: 1; grid-column: 3/-3; }
.block-border:nth-of-type(2) { grid-row: -2; grid-column: 3/-3; }
.block-border:nth-of-type(3) { grid-row: 3/5; grid-column: 1; }
.block-border:nth-of-type(4) { grid-row: 3/5; grid-column: -2; }
.block-border:nth-of-type(5) { grid-row: 2; grid-column: 2; }
.block-border:nth-of-type(6) { grid-row: 2; grid-column: -3; }
.block-border:nth-of-type(7) { grid-row: 5; grid-column: 2; }
.block-border:nth-of-type(8) { grid-row: 5; grid-column: -3; }

.block-meter:nth-of-type(9) { grid-row: 3/5; grid-column: 4; }
.block-meter:nth-of-type(10) { grid-row: 3/5; grid-column: 6; }
.block-meter:nth-of-type(11) { grid-row: 3/5; grid-column: 8; }
.block-meter:nth-of-type(12) { grid-row: 3/5; grid-column: 10; }
.block-meter:nth-of-type(13) { grid-row: 3/5; grid-column: 12; opacity:0; animation: blinky1 1s linear forwards; }
.block-meter:nth-of-type(14) { grid-row: 3/5; grid-column: 14; opacity:0; animation: blinky1 1s 1s linear forwards; }
.block-meter:nth-of-type(15) { grid-row: 3/5; grid-column: 16; opacity:0; animation: blinky1 1s 2s linear forwards; }
.block-meter:nth-of-type(16) { grid-row: 3/5; grid-column: 18; opacity:0; animation: blinky2 1.5s 3s linear infinite; }

@keyframes blinky1 { 99% {opacity: 0;} 100% {opacity: 1;} }
@keyframes blinky2 { 49% {opacity: 0;} 50% {opacity: 1;} 90% {opacity: 1;} }

/* ── MOBILE WRAPPER ── */
#game-wrapper {
  position: relative;
  width: 390px;
  height: 100vh;
  max-height: 844px;
  overflow: hidden;
  border-left: 3px solid #7c3aed;
  border-right: 3px solid #7c3aed;
  background: #1a0a2e;
}
@media (max-width: 420px) {
  #game-wrapper { width: 100vw; max-height: 100vh; border: none; }
}

/* ── PIXEL BUTTON ── */
.pixel-btn {
  color: #fff;
  padding: 12px 30px;
  margin: 8px;
  font-size: 12px;
  font-family: "Press Start 2P", system-ui;
  border: 0;
  cursor: pointer;
  box-shadow: 0px 5px black, 0px -5px black, 5px 0px black, -5px 0px black,
              0px 10px #00000038, 5px 5px #00000038, -5px 5px #00000038,
              inset 0px 5px #ffffff36;
  transition: transform .05s;
}
.pixel-btn:active {
  transform: translateY(5px);
  box-shadow: 0px 5px black, 0px -5px black, 5px 0px black, -5px 0px black,
              inset 0px 5px #00000038;
}
.pixel-btn.green { background-color: #6abc3a; }
.pixel-btn.red { background-color: #d83434; }
.pixel-btn.blue { background-color: #38667f; }
.pixel-btn.purple { background-color: #9f7db1; }
.pixel-btn.orange { background-color: #FF5722; }
.pixel-btn.teal { background-color: #009688; }

/* ── MAIN MENU ── */
#main-menu {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 100;
  background-size: cover;
  background-position: center;
}
#main-menu::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(26,10,46,.4) 0%, rgba(26,10,46,.85) 100%);
  z-index: -1;
}

#main-menu h1 {
  color: #fff; font-size: 26px;
  text-shadow: 3px 3px 0 #7c3aed, -1px -1px 0 #a855f7;
  margin-bottom: 6px; letter-spacing: 2px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.05)} }

#main-menu .subtitle { color: #c084fc; font-size: 9px; margin-bottom: 30px; text-transform: uppercase; }

.menu-buttons { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 20px; }

.skin-label { color: #7c3aed; font-size: 7px; text-align: center; margin-top: 4px; }

.powered-by { position: absolute; bottom: 12px; color: #7c3aed; font-size: 7px; text-transform: uppercase; }

/* Trophy icon button */
.trophy-btn {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; cursor: pointer;
  font-size: 28px; filter: drop-shadow(2px 2px 0 black);
}

/* Info icon button */
.info-btn {
  position: absolute; top: 12px; left: 12px;
  background: rgba(124,58,237,.8); border: 2px solid #1a0a2e; 
  cursor: pointer; color: #fff;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 20px; font-weight: bold; font-family: serif; font-style: italic;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 2px 2px 0px #1a0a2e;
}

/* ── CHARACTER SELECT ── */
#char-select {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 100;
  background-size: cover; background-position: center;
}
#char-select::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(26,10,46,.5) 0%, rgba(26,10,46,.9) 100%);
  z-index: -1;
}

#char-select .question {
  color: #c084fc; font-size: 10px; text-transform: uppercase; margin-bottom: 14px;
}

.carousel-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

.carousel-btn {
  background-color: #38667f; color: #fff;
  font-family: "Press Start 2P", system-ui;
  font-size: 14px; width: 36px; height: 36px;
  border: 0; cursor: pointer;
  box-shadow: 0px 4px black, 0px -4px black, 4px 0px black, -4px 0px black,
              inset 0px 4px #ffffff36;
  display: flex; align-items: center; justify-content: center;
}
.carousel-btn:active { transform: translateY(4px);
  box-shadow: 0px 4px black, 0px -4px black, 4px 0px black, -4px 0px black, inset 0px 4px #00000038; }

.char-display {
  width: 160px; height: 220px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(124,58,237,.12);
  border: 2px solid #7c3aed; border-radius: 6px;
}
.char-display img {
  width: 110px; height: 150px; object-fit: contain;
  animation: charFloat 2.5s ease-in-out infinite;
}
@keyframes charFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

.char-display .char-name {
  color: #fff; font-size: 11px; margin-top: 4px;
  text-transform: uppercase; letter-spacing: 2px;
  text-shadow: 2px 2px 0 #7c3aed;
}

/* Song wave text */
.wave-text {
  display: inline-block;
  font-size: 14px;
  color: #fbbf24;
  text-shadow: 2px 2px 0px #d83434;
  white-space: nowrap;
}
.wave-text span {
  display: inline-block;
  animation: wave 1.2s ease-in-out infinite;
}

@keyframes wave {
  0%, 100% { transform: translateY(0); color: #fbbf24; text-shadow: 2px 2px 0px #d83434; }
  50% { transform: translateY(-4px); color: #fff; text-shadow: 2px 2px 0px #7c3aed; }
}

.glow-effect {
  animation: glowPop 0.4s ease-out;
}
@keyframes glowPop {
  0% { transform: scale(1.1); filter: brightness(1.5); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* ── GAME SCREEN ── */
#game-screen { position: absolute; inset: 0; display: none; z-index: 50; }
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between;
  align-items: flex-start; padding: 10px 12px;
  pointer-events: none; z-index: 60;
}
.hud-left { display: flex; flex-direction: column; gap: 4px; }
#score-display { color: #fff; font-size: 14px; text-shadow: 2px 2px 0 #000; }
.coin-row { display: flex; align-items: center; gap: 4px; }
.coin-row img { width: 18px; height: 18px; image-rendering: auto; }
#coin-display { color: #fbbf24; font-size: 10px; text-shadow: 2px 2px 0 #000; }
.hud-right { pointer-events: all; }

/* Small pause pixel button */
.pause-pixel {
  background-color: #d83434; color: #fff;
  font-family: "Press Start 2P", system-ui;
  font-size: 10px; border: 0; cursor: pointer;
  padding: 8px 10px;
  box-shadow: 0px 4px black, 0px -4px black, 4px 0px black, -4px 0px black,
              inset 0px 4px #ffffff36;
}
.pause-pixel:active {
  transform: translateY(4px);
  box-shadow: 0px 4px black, 0px -4px black, 4px 0px black, -4px 0px black, inset 0px 4px #00000038;
}

/* ── OVERLAY (white transparent popup) ── */
#overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.8);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 70;
}
.overlay-card {
  background: rgba(255,255,255,.98);
  border: 4px solid #1a0a2e;
  border-radius: 12px;
  padding: 24px 28px;
  display: flex; flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.5), 0px 6px black, 0px -6px black, 6px 0px black, -6px 0px black;
  max-width: 320px; width: 85%;
}
.overlay-card h2 {
  color: #000; font-size: 18px; margin-bottom: 12px;
  font-weight: 900; text-shadow: none;
}

.overlay-stats {
  background: rgba(124,58,237,.1); border: 2px solid #000;
  border-radius: 8px;
  padding: 12px 20px; margin-bottom: 14px; width: 100%;
}
.stat-row {
  color: #000; font-size: 10px; line-height: 2.4; font-weight: bold;
  display: flex; justify-content: space-between; gap: 16px;
}
.stat-row .val { color: #5b21b6; font-weight: 900; }
.stat-row.gold-row .val { color: #166534; }

.overlay-buttons { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }

/* ── LEADERBOARD OVERLAY (white popup) ── */
#leaderboard-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.8);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 110;
}
.lb-card {
  background: rgba(255,255,255,.98);
  border: 4px solid #1a0a2e;
  border-radius: 12px;
  padding: 20px 16px;
  display: flex; flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.5), 0px 6px black, 0px -6px black, 6px 0px black, -6px 0px black;
  max-width: 340px; width: 90%;
  max-height: 80vh; overflow-y: auto;
}
.lb-card h2 {
  color: #000; font-size: 16px; margin-bottom: 14px;
  font-weight: 900; text-shadow: none;
}

.lb-podium { display: flex; align-items: flex-end; gap: 6px; margin-bottom: 12px; }
.lb-step {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(124,58,237,.1); border: 2px solid #000;
  border-radius: 6px;
  padding: 6px 6px; min-width: 65px;
}
.lb-step.gold { border-color: #d97706; background: rgba(251,191,36,.2); }
.lb-step.silver { border-color: #475569; background: rgba(148,163,184,.2); }
.lb-step.bronze { border-color: #9a3412; background: rgba(205,127,50,.2); }
.lb-step .rank { font-size: 16px; margin-bottom: 2px; }
.lb-step .lb-name { color: #000; font-size: 7px; font-weight: bold; }
.lb-step .lb-score { color: #5b21b6; font-size: 10px; font-weight: 900; margin-top: 2px; }
.lb-step img { width: 28px; height: 28px; object-fit: contain; margin-bottom: 2px; }

.lb-list { width: 100%; max-height: 200px; overflow-y: auto; }
.lb-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; border-bottom: 2px solid #e2e8f0;
  color: #000; font-size: 9px; font-weight: bold;
}
.lb-row .lb-rank { color: #5b21b6; width: 22px; font-weight: 900; }
.lb-row img { width: 18px; height: 18px; object-fit: contain; margin: 0 4px; }
.lb-row .lb-n { flex: 1; }
.lb-row .lb-s { color: #5b21b6; font-weight: 900; }

.lb-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.lb-tab {
  color: #000; font-family: "Press Start 2P", system-ui;
  font-size: 7px; padding: 5px 12px; cursor: pointer;
  background: rgba(124,58,237,.1); border: 2px solid #000;
  border-radius: 4px; font-weight: bold;
}
.lb-tab.active { border-color: #166534; color: #166534; background: rgba(34,197,94,.2); }
