/*
  style.css - TuneDrop
*/

:root {
  --bg-deep: #0D0616;
  --bg-mid: #1E0F35;
  --magenta: #FF3E9A;
  --cyan: #2EE6D6;
  --gold: #FFC94A;
  --ink: #F4EFFB;
  --ink-dim: #B6A9CF;
  --danger: #FF5C5C;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius-lg: 22px;
  --tap-min: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: radial-gradient(120% 90% at 50% -10%, var(--bg-mid), var(--bg-deep) 60%);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(38vh 38vh at 12% 18%, rgba(255,62,154,0.20), transparent 70%),
    radial-gradient(42vh 42vh at 88% 78%, rgba(46,230,214,0.16), transparent 70%);
}

#app {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

[hidden] {
  display: none !important;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(28px + var(--safe-top)) 22px calc(28px + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  animation: screen-in 320ms cubic-bezier(.2,.8,.2,1);
}

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

@media (prefers-reduced-motion: reduce) {
  .screen, .bg-glow, .waveform i, .waiting-pulse { animation: none !important; transition: none !important; }
}

.brand {
  margin-top: 8vh;
  text-align: center;
}

.brand-eq {
  display: inline-flex;
  gap: 5px;
  align-items: flex-end;
  height: 26px;
  margin-bottom: 14px;
}
.brand-eq i {
  width: 5px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--cyan), var(--magenta));
  animation: eq-bounce 1.1s ease-in-out infinite;
}
.brand-eq i:nth-child(1) { height: 40%; animation-delay: 0s; }
.brand-eq i:nth-child(2) { height: 100%; animation-delay: .15s; }
.brand-eq i:nth-child(3) { height: 65%; animation-delay: .3s; }
.brand-eq i:nth-child(4) { height: 85%; animation-delay: .45s; }
@keyframes eq-bounce {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

.brand h1 {
  font-size: 44px;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 700;
  line-height: 1;
}
.brand h1 span {
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  color: var(--ink-dim);
  font-size: 16px;
  margin-top: 10px;
}

.home-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: auto;
  margin-bottom: 28px;
}

.account-pill {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 12px;
  color: var(--ink);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.account-form, .profile-section { width: 100%; }
.auth-tabs { display: flex; width: 100%; margin-bottom: 22px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; overflow: hidden; }
.profile-screen { align-items: stretch; }
.profile-heading { display: flex; align-items: center; gap: 16px; margin: 6px 0 22px; }
.profile-heading h2 { margin: 0 0 4px; }
.profile-email { margin: 0; text-align: left; overflow-wrap: anywhere; }
.profile-section { margin: 22px 0 4px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1); }
.profile-section h3 { margin: 0 0 13px; font-size: 16px; }
.account-avatar, .player-avatar, .profile-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  overflow: hidden;
  object-fit: cover;
  border-radius: 50%;
  background: rgba(255,255,255,.09);
}
.account-avatar { width: 28px; height: 28px; font-size: 18px; }
.player-avatar { width: 32px; height: 32px; font-size: 20px; }
.profile-avatar { width: 76px; height: 76px; font-size: 44px; border: 2px solid rgba(46,230,214,.5); }
.avatar-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 13px; }
.avatar-choice { min-height: 58px; color: var(--ink); background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.12); border-radius: 13px; font-size: 27px; cursor: pointer; }
.avatar-choice.selected { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(46,230,214,.18); }
.upload-label { display: flex; align-items: center; justify-content: center; width: 100%; cursor: pointer; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.stats-grid > div { display: grid; gap: 3px; padding: 13px; text-align: center; background: rgba(255,255,255,.05); border-radius: 12px; }
.stats-grid strong { color: var(--gold); font-size: 22px; }
.stats-grid span, .history-list { color: var(--ink-dim); font-size: 13px; }
.history-list { display: grid; gap: 7px; margin: 13px 0 20px; }
.history-row { padding: 10px 12px; background: rgba(255,255,255,.035); border-radius: 10px; }
.account-actions { display: grid; gap: 10px; }
.btn-danger { color: #ffe8e8; background: rgba(255,92,92,.14); border: 1px solid rgba(255,92,92,.45); }
.danger-zone { margin: 8px 0; padding: 14px; border: 1px solid rgba(255,92,92,.3); border-radius: 14px; }
.danger-zone summary { color: #ffaaaa; font-weight: 650; cursor: pointer; }
.danger-zone form { margin-top: 18px; }

.footnote {
  color: var(--ink-dim);
  font-size: 13px;
  text-align: center;
  max-width: 320px;
}

.btn {
  min-height: var(--tap-min);
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  padding: 0 22px;
  transition: transform 120ms ease, filter 120ms ease;
  color: var(--ink);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-huge { width: 100%; }

.btn-primary {
  background: linear-gradient(90deg, var(--magenta), #FF6FB8);
  box-shadow: 0 8px 24px rgba(255,62,154,0.35);
}
.btn-primary:active:not(:disabled) { filter: brightness(1.08); }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.18);
}

.btn-back {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--ink);
  font-size: 24px;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  cursor: pointer;
}

h2 { font-size: 24px; margin: 6px 0 20px; }
h3.players-heading { font-size: 15px; color: var(--ink-dim); margin: 22px 0 10px; font-weight: 500; }

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 18px;
}
.field span { font-size: 14px; color: var(--ink-dim); }
.field small, .locked-profile-name small { color: var(--ink-dim); font-size: 12px; }
.field input {
  min-height: var(--tap-min);
  border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  font-family: inherit;
  font-size: 20px;
  padding: 0 16px;
}
.field input:focus {
  outline: none;
  border-color: var(--cyan);
}
.password-wrap { position: relative; display: block; width: 100%; }
.password-wrap input { width: 100%; padding-right: 58px; }
.password-toggle { position: absolute; top: 0; right: 0; width: 54px; height: 100%; padding: 0; color: var(--ink); background: transparent; border: 0; font-size: 19px; cursor: pointer; }
.password-strength { display: grid; gap: 6px; width: 100%; margin: -8px 0 17px; }
.password-strength::before { content: ''; height: 5px; width: calc(var(--strength, 0) * 20%); border-radius: 5px; background: var(--danger); transition: width .2s ease, background .2s ease; }
.password-strength[data-score="1"] { --strength: 1; }
.password-strength[data-score="2"] { --strength: 2; }
.password-strength[data-score="3"] { --strength: 3; }
.password-strength[data-score="4"] { --strength: 4; }
.password-strength[data-score="5"] { --strength: 5; }
.password-strength[data-score="3"]::before { background: var(--gold); }
.password-strength[data-score="4"]::before, .password-strength[data-score="5"]::before { background: var(--cyan); }
.password-strength small { color: var(--ink-dim); }
.locked-profile-name { display: grid; gap: 6px; width: 100%; padding: 15px 16px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; }
.locked-profile-name > span { color: var(--ink-dim); font-size: 13px; }
.locked-profile-name strong { font-size: 18px; }
.code-input {
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
}

.error-text {
  color: var(--danger);
  font-size: 14px;
  margin: -8px 0 14px;
}

.room-code-box {
  width: 100%;
  text-align: center;
  padding: 26px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(255,62,154,0.16), rgba(46,230,214,0.10));
  border: 1.5px solid rgba(255,255,255,0.14);
  margin-bottom: 22px;
}
.room-code-label { display: block; font-size: 13px; color: var(--ink-dim); }
.room-code {
  display: block;
  font-size: 52px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 6px 0;
  background: linear-gradient(90deg, var(--gold), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.room-code-hint { font-size: 13px; color: var(--ink-dim); }

.settings-panel { width: 100%; }
.setting-group { margin-bottom: 18px; }
.setting-label { display: block; font-size: 14px; color: var(--ink-dim); margin-bottom: 8px; }

.setting-select {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0 16px;
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
}
.setting-select:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.setting-select option { background: var(--bg-mid); color: var(--ink); }

.toggle-row {
  display: flex;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.12);
  overflow: hidden;
}
.toggle-btn {
  flex: 1;
  min-height: var(--tap-min);
  border: none;
  background: none;
  color: var(--ink-dim);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.toggle-btn.active {
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  color: #12081F;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--magenta);
  height: var(--tap-min);
}

.players-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.players-list li {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 15px;
}
.players-list .player-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.avatar-report { width: 30px; height: 30px; padding: 0; color: var(--ink-dim); background: transparent; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; cursor: pointer; }
.players-list li.offline { opacity: 0.4; text-decoration: line-through; }
.players-list .player-score { color: var(--gold); font-weight: 700; }

.joined-as { color: var(--ink-dim); font-size: 14px; }
.waiting-pulse {
  width: 90px; height: 90px;
  margin: 26px 0 18px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--magenta), transparent 70%);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 1; }
}

#audio-unlock-box {
  width: 100%;
  text-align: center;
  background: rgba(255,201,74,0.10);
  border: 1.5px solid rgba(255,201,74,0.35);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 12px 0;
}
#audio-unlock-box p { margin: 0 0 12px; font-size: 14px; color: var(--ink-dim); }

.round-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--ink-dim);
  margin-bottom: 14px;
}
.my-score b { color: var(--gold); font-size: 16px; }

.timer-track {
  width: 100%;
  height: 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  margin-bottom: 18px;
}
.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  transform-origin: left;
  transition: width 100ms linear;
}
.timer-fill.urgent { background: linear-gradient(90deg, var(--gold), var(--danger)); }

.round-status {
  text-align: center;
  color: var(--ink-dim);
  font-size: 15px;
  min-height: 22px;
}

.cover-art {
  width: 150px;
  height: 150px;
  border-radius: 18px;
  object-fit: cover;
  margin: 8px 0 18px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}

.waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 60px;
  margin-bottom: 24px;
}
.waveform i {
  width: 6px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--cyan), var(--magenta));
  height: 15%;
  animation: wave 1.3s ease-in-out infinite;
}
.waveform i:nth-child(odd) { animation-duration: 0.9s; }
.waveform i:nth-child(3n) { animation-duration: 1.1s; }
.waveform.playing i { animation-name: wave; }
.waveform:not(.playing) i { height: 15% !important; animation: none; }
@keyframes wave {
  0%, 100% { height: 15%; }
  50% { height: 90%; }
}
.waveform i:nth-child(1){animation-delay:0s}.waveform i:nth-child(2){animation-delay:.1s}
.waveform i:nth-child(3){animation-delay:.2s}.waveform i:nth-child(4){animation-delay:.3s}
.waveform i:nth-child(5){animation-delay:.15s}.waveform i:nth-child(6){animation-delay:.25s}
.waveform i:nth-child(7){animation-delay:.05s}.waveform i:nth-child(8){animation-delay:.35s}
.waveform i:nth-child(9){animation-delay:.2s}.waveform i:nth-child(10){animation-delay:.1s}

.answer-progress {
  margin-top: 20px;
  padding: 10px 18px;
  border-radius: 30px;
  background: rgba(255,255,255,0.06);
  font-size: 14px;
  color: var(--ink-dim);
}

.stage-indicator {
  text-align: center;
  font-size: 15px;
  color: var(--ink-dim);
  margin: 0 0 14px;
}
.stage-indicator b {
  color: var(--gold);
  font-size: 17px;
}

.hint-controls {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}
.hint-controls .btn {
  font-size: 14px;
  padding: 0 10px;
}
#btn-next-hint { grid-column: span 2; }
#btn-next-hint:disabled { opacity: 0.35; }

.options-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}
#host-options { margin-top: 18px; }
#host-options:empty { display: none; }
.option-btn {
  min-height: 84px;
  border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.25;
  padding: 12px;
  cursor: pointer;
  clip-path: polygon(6% 0, 100% 0, 94% 100%, 0 100%);
  transition: transform 120ms ease, background 120ms ease;
}
.option-btn:active { transform: scale(0.96); }
.option-btn.selected {
  background: linear-gradient(135deg, var(--magenta), var(--cyan));
  color: #12081F;
  border-color: transparent;
}
.option-btn.correct { background: linear-gradient(135deg, #3CE68A, var(--cyan)); color: #05261A; }
.option-btn.wrong { background: rgba(255,92,92,0.25); border-color: var(--danger); }
.option-btn:disabled { cursor: default; }

.locked-msg {
  text-align: center;
  margin-top: 18px;
  color: var(--cyan);
  font-weight: 600;
}

.correct-song {
  font-size: 19px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 18px;
}

.fastest-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}
.fastest-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255,201,74,0.08);
}
.fastest-item .medal { margin-right: 8px; }

.scoreboard {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scoreboard li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.scoreboard .rank { color: var(--ink-dim); width: 22px; font-weight: 700; }
.scoreboard .sb-name { flex: 1; font-weight: 500; }
.scoreboard .sb-gained { color: var(--cyan); font-size: 13px; }
.scoreboard .sb-score { color: var(--gold); font-weight: 700; }
.scoreboard li.me { border-color: var(--magenta); }

#btn-finish-game { margin-top: 12px; }

.gameover-title {
  font-size: 34px;
  text-align: center;
  margin: 8px 0 20px;
  background: linear-gradient(90deg, var(--gold), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 8px;
  min-height: 150px;
}
.podium-step {
  flex: 1;
  max-width: 110px;
  border-radius: 12px 12px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 6px;
  color: #12081F;
  font-weight: 700;
  text-align: center;
  font-size: 13px;
}
.podium-step .p-name { margin-bottom: 4px; word-break: break-word; }
.podium-step.gold { height: 150px; background: linear-gradient(180deg, var(--gold), #C9922B); order: 2; }
.podium-step.silver { height: 115px; background: linear-gradient(180deg, #E4E4E4, #9B9B9B); order: 1; }
.podium-step.bronze { height: 90px; background: linear-gradient(180deg, #E1A16B, #9A6335); order: 3; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #22132F;
  border: 1.5px solid var(--magenta);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

html, body, #app, .screen { max-width: 100vw; }
