:root {
  /* ============================================================
     1) WARNA BACKGROUND HALAMAN — solid, netral, biar 3 warna
     utama (biru/pink/kuning) di tombol & lane yang menonjol.
     ============================================================ */
  --bg-color-1: #F4F6FA;
  --bg-color-2: #F4F6FA;
  --bg-color-3: #F4F6FA;
  --bg-angle: 160deg;

  /* ============================================================
     2) WARNA KARTU & JUDUL
     ============================================================ */
  --card-bg: rgba(255,255,255,0.95);
  --card-border: #0066BC;
  --title-color: #0066BC;
  --text-dark: #17273B;

  /* ============================================================
     3) WARNA TOMBOL BESAR (Mulai Main, Simpan Skor, dll) — solid
     ============================================================ */
  --btn-color-1: #D5265C;
  --btn-color-2: #D5265C;
  --btn-angle: 135deg;

  /* ============================================================
     4) WARNA 4 LANE — dari 3 warna yang diminta (biru, pink, kuning)
     + 1 turunan biru gelap solid buat lane ke-4 (bukan gradasi,
     cuma warna beda) biar tiap lane tetap gampang dibedain.
     ============================================================ */
  --lane-up: #D5265C;
  --lane-left: #0066BC;
  --lane-down: #FAD817;
  --lane-right: #003C73;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
  background: linear-gradient(var(--bg-angle), var(--bg-color-1) 0%, var(--bg-color-2) 55%, var(--bg-color-3) 100%);
  color: var(--text-dark);
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

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

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.screen.active { display: flex; }

/* ---------- Scalloped "ice cream" background — menu screen only ---------- */
#menuScreen {
  overflow: hidden;
  background: #fff;
}
#menuScreen::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 58%;
  background: var(--btn-color-1);
  z-index: 0;
}
#menuScreen::after {
  content: "";
  position: absolute;
  top: 58%; left: 0; right: 0;
  height: 32px;
  transform: translateY(-16px);
  background-image: radial-gradient(circle at 16px 16px, var(--btn-color-1) 16px, transparent 17px);
  background-size: 32px 32px;
  background-repeat: repeat-x;
  z-index: 0;
}
#menuScreen .menuCard {
  position: relative;
  z-index: 1;
}

/* ---------- Menu / Result / Leaderboard card ---------- */
.menuCard {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: 24px;
  padding: 36px 30px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(120,100,160,0.18);
  backdrop-filter: blur(4px);
}

.titleText {
  font-size: 40px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--title-color);
  -webkit-text-stroke: 0.6px #222;
  paint-order: stroke fill;
}
.titleText.small { font-size: 30px; }

.logoImage {
  max-width: 280px;
  width: 65%;
  height: auto;
  margin: 0 auto 6px;
  display: block;
}

.subtitle { font-size: 14px; opacity: 0.75; margin: 0 0 20px; }

.songStatus {
  font-size: 13px;
  background: rgba(255,255,255,0.6);
  border-radius: 30px;
  padding: 8px 16px;
  margin-bottom: 18px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
}
.songStatus .marqueeText {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 9s linear infinite;
}
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

.bigBtn {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  font-weight: 800;
  font-family: inherit;
  border: none;
  border-radius: 40px;
  background: linear-gradient(var(--btn-angle), var(--btn-color-1), var(--btn-color-2));
  color: #fff;
  cursor: pointer;
  margin-bottom: 10px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.12);
  transition: transform 0.1s;
}
.bigBtn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.12); }
.bigBtn:disabled { opacity: 0.5; cursor: not-allowed; }

.ghostBtn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  border: 2px solid var(--title-color);
  border-radius: 40px;
  background: rgba(255,255,255,0.4);
  color: var(--text-dark);
  cursor: pointer;
  margin-top: 4px;
}
.ghostBtn:active { transform: scale(0.97); }

/* ---------- Countdown ---------- */
#countdownNum {
  font-size: 120px;
  font-weight: 800;
  color: #fff;
  -webkit-text-stroke: 2px var(--title-color);
  paint-order: stroke fill;
  animation: pop 1s ease;
}
@keyframes pop { 0%{ transform: scale(0.4); opacity:0; } 60%{ transform: scale(1.15); opacity:1;} 100%{ transform: scale(1);} }

/* ---------- Game screen ---------- */
#gameScreen { padding: 0; justify-content: flex-start; }

.hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  box-sizing: border-box;
  z-index: 10;
}

.hudPauseBtn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.6);
  color: var(--text-dark);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.hudPauseBtn:active { transform: scale(0.9); }

.hudCenter { flex-shrink: 0; }
.hudLogo { height: 34px; width: auto; display: block; }

.hudRight {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}
.hudScoreVal { font-size: 20px; font-weight: 800; color: var(--text-dark); line-height: 1.1; }
.hudAccVal { font-size: 12px; font-weight: 700; opacity: 0.65; }

.judgeText {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
  font-weight: 800;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  color: var(--text-dark);
  -webkit-text-stroke: 0.5px #222;
  paint-order: stroke fill;
}
.judgeText.show { animation: judgePop 0.45s ease forwards; }
@keyframes judgePop {
  0% { opacity: 0; transform: translate(-50%,-40%) scale(0.7); }
  30% { opacity: 1; transform: translate(-50%,-50%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%,-55%) scale(1); }
}
.judgeText.perfect { color: var(--lane-down); }
.judgeText.good { color: var(--lane-left); }
.judgeText.bad { color: var(--lane-up); }
.judgeText.miss { color: #8F1A3D; }

.lanesWrap {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  padding: 0 14px;
  box-sizing: border-box;
  background: rgba(255,255,255,0.32);
  border-radius: 34px;
  position: relative;
}

.lane {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
}
.lane:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 12%;
  bottom: 12%;
  right: 0;
  width: 1px;
  background: rgba(58,51,80,0.12);
}

.laneTrack {
  position: relative;
  width: 100%;
  height: 100%;
}

.laneBtn {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 rgba(0,0,0,0.15), 0 0 0 6px rgba(255,255,255,0.55);
  z-index: 6;
  transition: transform 0.08s;
}
.laneBtn:active, .laneBtn.pressed { transform: translateX(-50%) scale(0.88); filter: brightness(0.9); }
.laneBtn.pressed { animation: btnPulse 0.32s ease-out; }
@keyframes btnPulse {
  0% { box-shadow: 0 4px 0 rgba(0,0,0,0.15), 0 0 0 5px rgba(255,255,255,0.55); }
  40% { box-shadow: 0 4px 0 rgba(0,0,0,0.15), 0 0 0 14px rgba(255,255,255,0.28); }
  100% { box-shadow: 0 4px 0 rgba(0,0,0,0.15), 0 0 0 5px rgba(255,255,255,0.55); }
}
.lane[data-lane="up"] .laneBtn    { background: var(--lane-up); }
.lane[data-lane="left"] .laneBtn  { background: var(--lane-left); }
.lane[data-lane="down"] .laneBtn  { background: var(--lane-down); }
.lane[data-lane="right"] .laneBtn { background: var(--lane-right); }

.lane { transition: background-color 0.18s ease; border-radius: 24px; }
.lane.flash[data-lane="up"]    { background-color: color-mix(in srgb, var(--lane-up) 35%, transparent); }
.lane.flash[data-lane="left"]  { background-color: color-mix(in srgb, var(--lane-left) 35%, transparent); }
.lane.flash[data-lane="down"]  { background-color: color-mix(in srgb, var(--lane-down) 35%, transparent); }
.lane.flash[data-lane="right"] { background-color: color-mix(in srgb, var(--lane-right) 35%, transparent); }

.note {
  position: absolute;
  left: 50%;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 3px 6px rgba(0,0,0,0.18), 0 0 0 4px rgba(255,255,255,0.55);
  z-index: 4;
}
.lane[data-lane="up"] .note    { background: var(--lane-up); }
.lane[data-lane="left"] .note  { background: var(--lane-left); }
.lane[data-lane="down"] .note  { background: var(--lane-down); }
.lane[data-lane="right"] .note { background: var(--lane-right); }

.songProgressWrap {
  width: 100%;
  height: 5px;
  background: rgba(255,255,255,0.4);
}
.songProgressBar {
  height: 100%;
  width: 0%;
  background: var(--lane-left);
}

.pauseOverlay {
  position: absolute; inset: 0;
  background: rgba(58,51,80,0.45);
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
}
.pauseOverlay.show { display: flex; }
.pauseOverlayCard {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 26px 30px;
  text-align: center;
}
.pauseOverlayCard .titleText { font-size: 24px; margin-bottom: 14px; }

/* ---------- Result screen ---------- */
.resultGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.resultBox {
  background: rgba(255,255,255,0.5);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.resultBox.judgeCounts { grid-column: 1 / -1; }
.resultLabel { font-size: 11px; font-weight: 700; opacity: 0.65; }
.resultVal { font-size: 20px; font-weight: 800; }
.resultVal.big { font-size: 32px; color: var(--title-color); -webkit-text-stroke: 0.5px #222; paint-order: stroke fill; }
.resultVal.small { font-size: 16px; }

.saveScoreWrap { display: flex; gap: 8px; margin-bottom: 6px; }
.nameInput {
  flex: 1;
  padding: 12px 14px;
  border-radius: 30px;
  border: 2px solid var(--title-color);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  background: rgba(255,255,255,0.7);
  color: var(--text-dark);
  min-width: 0;
}
.nameInput:focus { outline: none; border-color: var(--lane-up); }
.saveScoreWrap .bigBtn { width: auto; padding: 12px 18px; margin-bottom: 0; white-space: nowrap; }
.saveStatus { font-size: 13px; font-weight: 700; min-height: 18px; margin-bottom: 12px; }
.saveStatus.ok { color: #4C8C5A; }
.saveStatus.err { color: #C25B5B; }

/* ---------- Leaderboard ---------- */
.leaderboardList {
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lbLoading { padding: 20px; opacity: 0.6; font-weight: 600; }
.lbRow {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.5);
  border-radius: 12px;
  padding: 8px 12px;
  text-align: left;
}
.lbRank {
  width: 26px;
  font-weight: 800;
  color: var(--title-color);
  flex-shrink: 0;
}
.lbRow.top1 .lbRank { color: #E0A020; }
.lbRow.top2 .lbRank { color: #9AA5B1; }
.lbRow.top3 .lbRank { color: #C2794B; }
.lbName { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbScore { font-weight: 800; color: var(--lane-left); }

@media (max-width: 380px) {
  .titleText { font-size: 30px; }
  .laneBtn { width: 68px; height: 68px; font-size: 24px; }
  .note { width: 50px; height: 50px; }
  #countdownNum { font-size: 90px; }
}
