.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}
.screen[hidden] { display: none; }

.modal-screen {
  z-index: 30;
  background: rgba(3, 4, 12, 0.82);
  backdrop-filter: blur(6px);
}
.modal-panel {
  width: 100%;
  max-width: 340px;
  background: linear-gradient(180deg, rgba(20, 24, 48, 0.96), rgba(10, 12, 26, 0.98));
  border: 1px solid rgba(139, 91, 255, 0.35);
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: 0 0 40px rgba(139, 91, 255, 0.18);
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 88dvh;
  overflow-y: auto;
}

/* ---------------- menu ---------------- */
#menu-screen { gap: 20px; }
.logo {
  font-size: 48px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #eafcff, var(--cyan) 60%, var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(40, 240, 255, 0.35);
  margin-bottom: 4px;
}
.menu-hint {
  font-size: 13px;
  color: rgba(244, 248, 255, 0.55);
  letter-spacing: 0.08em;
}
.menu-stats {
  display: flex;
  gap: 22px;
  font-size: 12px;
  color: rgba(244, 248, 255, 0.7);
  letter-spacing: 0.06em;
}
.menu-stats span { display: block; font-size: 16px; font-weight: 800; color: var(--cyan); }

/* ---------------- buttons ---------------- */
.btn-primary {
  min-width: 200px;
  padding: 16px 32px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #05060f;
  background: linear-gradient(180deg, #eafcff, var(--cyan));
  border-radius: 999px;
  box-shadow: 0 0 24px rgba(40, 240, 255, 0.55), 0 6px 0 rgba(11, 130, 145, 0.9);
  transition: transform 0.08s ease;
}
.btn-primary:active { transform: translateY(3px); box-shadow: 0 0 24px rgba(40, 240, 255, 0.55), 0 3px 0 rgba(11, 130, 145, 0.9); }

.btn-secondary {
  min-width: 200px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--cyan);
  background: rgba(40, 240, 255, 0.08);
  border: 1px solid rgba(40, 240, 255, 0.35);
  border-radius: 999px;
}
.btn-secondary:active { background: rgba(40, 240, 255, 0.18); }

.btn-ghost {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(244, 248, 255, 0.75);
  border: 1px solid rgba(244, 248, 255, 0.25);
  border-radius: 999px;
}

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------------- pause ---------------- */
#pause-screen .modal-panel { align-items: center; }
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 14px;
  padding: 6px 2px;
}
.toggle-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--cyan); }

/* ---------------- result ---------------- */
#result-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 210, 63, 0.5);
}
.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  width: 100%;
  font-size: 13px;
  color: rgba(244, 248, 255, 0.7);
  text-align: left;
}
.result-stats b { display: block; font-size: 18px; color: var(--cyan); }

.nickname-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
#nickname-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(139, 91, 255, 0.4);
  background: rgba(5, 6, 15, 0.7);
  color: #fff;
  font-size: 14px;
}
/* .btn-secondary's min-width:200px (sized for the full-width menu buttons)
   would squeeze this inline input down to a sliver — override for this one
   compact, inline use (caught via screenshot review: the placeholder text
   was visibly clipped). */
#btn-submit-score {
  min-width: auto;
  flex: 0 0 auto;
  padding: 10px 14px;
  font-size: 12px;
  white-space: nowrap;
}
#nickname-error {
  min-height: 16px;
  font-size: 12px;
  color: var(--danger);
}
.submitted-line {
  font-size: 13px;
  color: rgba(244, 248, 255, 0.75);
}
#submitted-rank { color: var(--gold); font-weight: 800; }

/* ---------------- leaderboard ---------------- */
.lb-tabs { display: flex; gap: 6px; }
.lb-tabs button {
  flex: 1;
  padding: 7px 0;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  background: rgba(139, 91, 255, 0.08);
  color: rgba(244, 248, 255, 0.6);
}
.lb-tabs button.active { background: var(--violet); color: #fff; }

#leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 44dvh;
  overflow-y: auto;
  text-align: left;
}
.lb-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.03);
}
.lb-row:nth-child(1) { color: var(--gold); }
.lb-row:nth-child(2) { color: #d8dce8; }
.lb-row:nth-child(3) { color: #cd9a5b; }
.lb-rank { font-weight: 800; opacity: 0.8; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; }
#leaderboard-your-rank {
  font-size: 12px;
  font-weight: 800;
  color: var(--cyan);
  text-align: center;
}
#leaderboard-loading, #leaderboard-empty {
  font-size: 13px;
  color: rgba(244, 248, 255, 0.5);
  padding: 12px 0;
}

/* ---------------- how to play ---------------- */
#how-to-play-screen .modal-panel { text-align: left; }
#how-to-play-screen h3 { color: var(--cyan); font-size: 15px; margin-top: 4px; }
#how-to-play-screen p, #how-to-play-screen li { font-size: 13px; color: rgba(244, 248, 255, 0.78); line-height: 1.5; }
#how-to-play-screen ul { padding-left: 18px; list-style: disc; }

.close-x {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  font-size: 16px;
}

@media (max-width: 380px) {
  .logo { font-size: 40px; }
  .btn-primary { min-width: 170px; padding: 14px 24px; font-size: 18px; }
  .btn-secondary { min-width: 170px; }
}
