/* ── Reset & base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --coral:   #FF6B6B;
  --teal:    #4ECDC4;
  --yellow:  #FFE66D;
  --purple:  #A855F7;
  --orange:  #FB923C;
  --green:   #4ADE80;
  --white:   #FFFFFF;
  --cream:   #FFFBF5;
  --dark:    #1E1B2E;
  --muted:   #7C6F8A;
  --shadow:  0 8px 32px rgba(0,0,0,.18);
  --radius:  24px;
  --radius-sm: 12px;
}

html, body {
  height: 100%;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  color: var(--dark);
  overflow-x: hidden;
}

body {
  background: linear-gradient(-45deg, #FF6B6B, #FF9A56, #4ECDC4, #A855F7);
  background-size: 400% 400%;
  animation: bgShift 14s ease infinite;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
}

@keyframes bgShift {
  0%   { background-position: 0%   50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0%   50%; }
}

/* ── App shell ──────────────────────────────────────────────────────────────── */
#app {
  width: 100%;
  max-width: 480px;
}

/* ── Screens ────────────────────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn .25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Logo / landing ─────────────────────────────────────────────────────────── */
.logo { text-align: center; }
.logo-notes {
  font-size: 2.4rem;
  letter-spacing: .2em;
  animation: bounce 1.6s ease infinite alternate;
}
@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-8px); }
}
.logo h1 {
  font-size: 2.6rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--coral), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  margin-top: 4px;
}
.tagline { color: var(--muted); font-size: 1.05rem; margin-top: 6px; font-weight: 700; }

/* ── Form elements ──────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 8px; }

.input {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
  background: #F0EBF8;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--dark);
  outline: none;
  transition: border-color .2s, background .2s;
}
.input:focus { border-color: var(--purple); background: white; }
.input::placeholder { color: #B0A8C0; font-weight: 400; }

.code-input {
  text-transform: uppercase;
  letter-spacing: .15em;
  font-size: 1.2rem;
}

.join-row {
  display: flex;
  gap: 10px;
}
.join-row .input { flex: 1; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: #E0D8F0;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, opacity .12s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--coral), var(--orange));
  color: white;
  box-shadow: 0 4px 16px rgba(255,107,107,.4);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(255,107,107,.55); transform: translateY(-1px); }

.btn-secondary {
  background: linear-gradient(135deg, var(--purple), #7C3AED);
  color: white;
  box-shadow: 0 4px 16px rgba(168,85,247,.4);
}
.btn-secondary:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(168,85,247,.55); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-size: .9rem;
}
.btn-ghost:hover { background: #F0EBF8; color: var(--dark); }

.btn-play {
  background: linear-gradient(135deg, var(--teal), #22D3EE);
  color: white;
  font-size: 1.1rem;
  padding: 16px 32px;
  box-shadow: 0 4px 16px rgba(78,205,196,.4);
  width: 100%;
}
.btn-play:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(78,205,196,.55); transform: translateY(-1px); }

.btn-large { width: 100%; font-size: 1.15rem; padding: 18px 24px; }
.btn-small { padding: 6px 12px; font-size: .85rem; }

.hidden { display: none !important; }

/* ── Small print ────────────────────────────────────────────────────────────── */
.small-print { text-align: center; color: var(--muted); font-size: .82rem; }
.muted-text  { color: var(--muted); font-size: .95rem; text-align: center; }

/* ── Toast / error ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--dark);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: 700;
  font-size: .95rem;
  z-index: 1000;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-overflow: ellipsis;
  overflow: hidden;
}
.toast.visible { transform: translateX(-50%) translateY(0); }

/* ── Round badge ────────────────────────────────────────────────────────────── */
.round-badge {
  align-self: center;
  background: linear-gradient(135deg, var(--purple), #7C3AED);
  color: white;
  padding: 6px 18px;
  border-radius: 50px;
  font-size: .85rem;
  font-weight: 800;
}

/* ── Lobby ──────────────────────────────────────────────────────────────────── */
.lobby-header { display: flex; flex-direction: column; gap: 10px; }
.lobby-header h2 { font-size: 1.6rem; font-weight: 900; }

.room-code-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #F0EBF8;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
}
.room-code-label { color: var(--muted); font-size: .85rem; font-weight: 700; }
.room-code-value {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: .15em;
  color: var(--purple);
  flex: 1;
}

.player-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 2px solid #E8E0F5;
  border-radius: 50px;
  padding: 8px 14px 8px 8px;
  font-weight: 700;
  font-size: .95rem;
  transition: border-color .2s;
}
.player-chip.mine { border-color: var(--purple); background: #F5F0FF; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  font-size: .9rem;
  flex-shrink: 0;
}

.host-badge {
  background: var(--yellow);
  color: #7A5C00;
  font-size: .7rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 50px;
}

.lobby-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ── Humming screen ─────────────────────────────────────────────────────────── */
.your-turn-header { text-align: center; }
.mic-icon { font-size: 3rem; margin-bottom: 4px; }
.your-turn-header h2 { font-size: 1.7rem; font-weight: 900; }

.song-card {
  background: linear-gradient(135deg, #FF6B6B, var(--orange));
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  color: white;
}
.song-card.compact { padding: 16px; }
.song-card-label { font-size: .8rem; font-weight: 800; opacity: .8; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.song-title-big  { font-size: 1.7rem; font-weight: 900; line-height: 1.2; }
.song-artist     { font-size: 1rem; opacity: .85; margin-top: 6px; font-weight: 700; }

.record-area { display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* Record button */
.record-btn {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--coral), var(--orange));
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 24px rgba(255,107,107,.45);
  transition: transform .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.record-btn:active { transform: scale(.94); }

.record-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid rgba(255,107,107,.4);
  animation: none;
}
.record-btn.recording .record-ring {
  animation: ripple 1.2s ease-out infinite;
}
.record-btn.recording {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  box-shadow: 0 0 0 0 rgba(239,68,68,.7);
  animation: pulse-btn 1.2s ease infinite;
}
@keyframes pulse-btn {
  0%   { box-shadow: 0 0 0  0   rgba(239,68,68,.7); }
  70%  { box-shadow: 0 0 0 20px rgba(239,68,68,0);  }
  100% { box-shadow: 0 0 0  0   rgba(239,68,68,0);  }
}
@keyframes ripple {
  0%   { transform: scale(1);   opacity: .8; }
  100% { transform: scale(1.4); opacity: 0;  }
}

.record-dot {
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
}
.record-btn.recording .record-dot {
  border-radius: 4px;
  width: 20px;
  height: 20px;
}
.record-label { color: white; font-weight: 900; font-size: .85rem; }

/* ── Waiting screen ─────────────────────────────────────────────────────────── */
.waiting-content { text-align: center; padding: 20px 0; }
.waiting-content h2 { font-size: 1.5rem; font-weight: 900; margin-bottom: 8px; }
.highlight-name { color: var(--coral); }

.floating-notes {
  font-size: 2rem;
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.floating-notes span { display: inline-block; }
.floating-notes span:nth-child(1) { animation: float 2.0s ease-in-out -.0s infinite alternate; }
.floating-notes span:nth-child(2) { animation: float 2.0s ease-in-out -.3s infinite alternate; color: var(--coral); }
.floating-notes span:nth-child(3) { animation: float 2.0s ease-in-out -.6s infinite alternate; color: var(--purple); }
.floating-notes span:nth-child(4) { animation: float 2.0s ease-in-out -.9s infinite alternate; color: var(--teal); }
.floating-notes span:nth-child(5) { animation: float 2.0s ease-in-out -1.2s infinite alternate; color: var(--orange); }
@keyframes float {
  from { transform: translateY(0)   rotate(-5deg); }
  to   { transform: translateY(-16px) rotate(5deg); }
}

/* ── Guessing screen ────────────────────────────────────────────────────────── */
.timer-area {
  display: flex;
  align-items: center;
  gap: 12px;
}
.timer-track {
  flex: 1;
  height: 12px;
  background: #E8E0F5;
  border-radius: 50px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #22D3EE);
  border-radius: 50px;
  transition: width 1s linear, background .5s;
  width: 100%;
}
.timer-number {
  font-size: 1.4rem;
  font-weight: 900;
  min-width: 44px;
  text-align: right;
  transition: color .3s;
}

.audio-area { display: flex; flex-direction: column; align-items: center; }

.guess-area { display: flex; gap: 10px; }
.guess-input { flex: 1; }

.guess-feedback {
  min-height: 24px;
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  transition: all .2s;
}
.guess-feedback.correct { color: var(--green); animation: popIn .3s cubic-bezier(.34,1.56,.64,1); }
.guess-feedback.wrong   { color: var(--coral); }

@keyframes popIn {
  from { transform: scale(.8); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

/* Shake animation for wrong guess */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.shake { animation: shake .4s ease; }

/* ── Guessers list ──────────────────────────────────────────────────────────── */
.guessers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.guess-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  animation: slideIn .3s cubic-bezier(.34,1.56,.64,1);
}
.guess-result.correct {
  background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
  color: #065F46;
}
@keyframes slideIn {
  from { transform: translateX(-20px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

.player-tag {
  font-weight: 900;
}

.points {
  margin-left: auto;
  background: var(--green);
  color: white;
  padding: 2px 10px;
  border-radius: 50px;
  font-size: .85rem;
  font-weight: 900;
}

/* ── Results screen ─────────────────────────────────────────────────────────── */
.song-reveal {
  background: linear-gradient(135deg, var(--purple), #7C3AED);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  color: white;
}
.song-reveal-label { font-size: .8rem; font-weight: 800; opacity: .8; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }

.scores-list { display: flex; flex-direction: column; gap: 8px; }

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: white;
  border: 2px solid #E8E0F5;
  font-weight: 700;
  animation: popIn .3s ease backwards;
}
.score-row.mine  { border-color: var(--purple); background: #F5F0FF; }
.score-row.winner {
  border-color: var(--yellow);
  background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
}
.score-row:nth-child(2) { animation-delay: .05s; }
.score-row:nth-child(3) { animation-delay: .10s; }
.score-row:nth-child(4) { animation-delay: .15s; }
.score-row:nth-child(5) { animation-delay: .20s; }

.rank { font-size: 1.1rem; min-width: 28px; font-weight: 900; }
.player-name { flex: 1; }
.score { font-size: 1.1rem; font-weight: 900; color: var(--purple); }
.score-row.winner .score { color: #92400E; }

.next-round-msg { margin-top: 4px; }

/* ── Game Over ──────────────────────────────────────────────────────────────── */
.trophy { text-align: center; font-size: 4rem; animation: bounce 1s ease infinite alternate; }
.gameover-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 8px; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 360px) {
  .card { padding: 24px 18px; }
  .logo h1 { font-size: 2.2rem; }
  .song-title-big { font-size: 1.4rem; }
  .record-btn { width: 100px; height: 100px; }
}

/* Settings panel */
.settings-panel {
  background: #F5F0FF;
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-label { font-weight: 700; font-size: .9rem; color: var(--dark); }

.seg-group { display: flex; gap: 4px; }
.seg-btn {
  padding: 8px 14px;
  border: 2px solid #D8D0F0;
  border-radius: 8px;
  background: white;
  font-family: inherit;
  font-weight: 800;
  font-size: .9rem;
  cursor: pointer;
  color: var(--muted);
  transition: all .15s;
}
.seg-btn.active { background: var(--purple); border-color: var(--purple); color: white; }
.seg-btn:disabled { cursor: not-allowed; opacity: .5; }
.seg-btn:not(:disabled):not(.active):hover { border-color: var(--purple); color: var(--purple); }

/* Autocomplete */
.ac-wrapper { position: relative; flex: 1; }
.ac-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: white;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  border: 2px solid #E8E0F5;
}
.ac-dropdown.open { display: block; animation: fadeIn .15s ease; }
.ac-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid #F0EBF8;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.ac-active { background: #F5F0FF; }
.ac-title { font-weight: 700; font-size: .95rem; }
.ac-artist { font-size: .78rem; color: var(--muted); }
.ac-item mark { background: var(--yellow); color: var(--dark); border-radius: 2px; padding: 0 1px; font-style: normal; }

/* Song choice buttons */
.song-choice-list { display: flex; flex-direction: column; gap: 10px; }

.song-choice-btn {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid #E8E0F5;
  border-radius: var(--radius-sm);
  background: white;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s, background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.song-choice-btn:hover { border-color: var(--purple); background: #F5F0FF; }
.song-choice-btn:active { transform: scale(.98); }
.song-choice-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.choice-title  { font-size: 1.05rem; font-weight: 900; color: var(--dark); }
.choice-artist { font-size: .82rem; font-weight: 700; color: var(--muted); }

/* Buy Me a Coffee */
.bmc-link-small {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  text-decoration: none;
  transition: color .15s;
}
.bmc-link-small:hover { color: #FBAB34; }

.bmc-btn {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: #FFDD00;
  color: #000000;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 900;
  font-size: 1rem;
  text-align: center;
  text-decoration: none;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 4px 16px rgba(251,171,52,.4);
}
.bmc-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(251,171,52,.55); }
.bmc-btn:active { transform: scale(.97); }

/* Wrong guess item */
.guess-result.wrong {
  background: linear-gradient(135deg, #FEE2E2, #FECACA);
  color: #991B1B;
}
