/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --border: #2a2a2a;
  --border-light: #363636;
  --text: #f0f0f0;
  --text-dim: #777;
  --text-muted: #4a4a4a;
  --accent: #1db954;
  --accent-dim: rgba(29, 185, 84, 0.15);
  --accent-glow: rgba(29, 185, 84, 0.3);
  --wrong: #e8443a;
  --wrong-dim: rgba(232, 68, 58, 0.15);
  --artist: #e8a117;
  --artist-dim: rgba(232, 161, 23, 0.15);
  --skip: #555;
  --skip-dim: rgba(85, 85, 85, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  height: -webkit-fill-available;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Subtle noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  pointer-events: none;
  z-index: 0;
}

/* ===== App Layout ===== */
#app {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  position: relative;
  z-index: 1;
}

/* ===== Header ===== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

#logo-icon {
  color: var(--accent);
  flex-shrink: 0;
}

header h1 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-dim) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#stats-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
}

#stats-btn:hover {
  color: var(--text);
  background: var(--surface);
}

/* ===== Day Nav ===== */
#day-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#day-nav button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  width: 32px;
  height: 32px;
}

#day-nav button:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-light);
}

#day-nav button:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

#day-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  min-width: 100px;
  text-align: center;
}

/* ===== Main Content ===== */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 16px 0;
  overflow-y: auto;
  padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px));
}

main.game-over {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

/* ===== Player ===== */
#player {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

/* Timeline */
#timeline {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#timeline-track {
  position: relative;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

#timeline-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px var(--accent-glow);
}

#timeline-labels {
  position: relative;
  height: 1.1em;
  padding: 0 2px;
}

.timeline-label {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  transition: color 0.3s;
}

.timeline-label.active {
  color: var(--accent);
}

.timeline-label.past {
  color: var(--text-dim);
}

/* Play Button */
#play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 50px;
  padding: 12px 28px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 12px var(--accent-glow);
}

#play-btn:active:not(:disabled) {
  transform: scale(0.96);
}

#play-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  box-shadow: none;
}

#play-icon {
  display: flex;
  align-items: center;
}

/* ===== Guesses ===== */
#guesses {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
  font-size: 0.85rem;
  transition: all 0.3s ease;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.guess-row.active {
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

.guess-row.future {
  opacity: 0.25;
}

.guess-row.skip {
  border-left-color: var(--skip);
  background: var(--skip-dim);
  color: var(--text-dim);
}

.guess-row.wrong {
  border-left-color: var(--wrong);
  background: var(--wrong-dim);
}

.guess-row.artist {
  border-left-color: var(--artist);
  background: var(--artist-dim);
}

.guess-row.correct {
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

.guess-row .icon {
  font-size: 0.95rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.guess-row .guess-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guess-row .clip-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.guess-row.active .clip-label {
  color: var(--accent);
}

/* ===== Result ===== */
#result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  animation: fadeUp 0.4s ease-out;
}

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

#result-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

#result-art {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  flex-shrink: 0;
}

#result-info {
  min-width: 0;
}

#result-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#result-artist {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 2px;
}

#result-message {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}

#share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

#share-btn:hover {
  background: var(--border);
  border-color: var(--border-light);
}

/* ===== Input Area (Fixed Bottom) ===== */
#input-area {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 420px;
  padding: 14px 16px calc(20px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  /* Frosted glass effect */
  background: rgba(10, 10, 10, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

#search-wrapper {
  position: static; /* let results position relative to input-area instead */
}

#search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
}

#search-input {
  width: 100%;
  padding: 13px 14px 13px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px; /* prevents iOS zoom */
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

#search-input::placeholder {
  color: var(--text-muted);
}

#search-input:focus {
  border-color: var(--accent);
  background: var(--surface-2);
}

/* No special input styling needed - dropdown now floats above entire input area */

#search-input:focus ~ .search-icon,
#search-field:focus-within .search-icon {
  color: var(--accent);
}

#search-input:disabled {
  opacity: 0.35;
}

/* Search Results - positioned above entire input area (search + buttons) */
#search-results {
  position: absolute;
  bottom: 100%;
  left: 16px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 290px; /* overridden by JS when keyboard is open */
  overflow-y: auto;
  z-index: 60;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.5);
  overscroll-behavior: contain;
}

.search-item {
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px; /* 48px+ touch target */
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.search-item:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:active {
  background: var(--surface-2);
}

@media (hover: hover) {
  .search-item:hover {
    background: var(--surface-2);
  }
}

.search-item img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface-2);
}

.search-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.search-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-artist {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action Buttons */
#action-buttons {
  display: flex;
  gap: 8px;
}

#action-buttons button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 12px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  border: none;
  min-height: 48px;
}

#action-buttons button:active:not(:disabled) {
  transform: scale(0.97);
}

#action-buttons button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#skip-btn {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

#submit-btn {
  background: var(--accent);
  color: #000;
}

/* ===== Stats Modal ===== */
#stats-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

#stats-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#stats-content {
  position: relative;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-bottom: none;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

#stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

#stats-content h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#stats-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

#stats-close:hover {
  color: var(--text);
}

#stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-item {
  text-align: center;
  padding: 14px 8px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ===== Header Actions ===== */
#header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

#header-actions button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
}

#header-actions button:hover {
  color: var(--text);
  background: var(--surface);
}

#auth-btn.logged-in {
  color: var(--accent);
}

/* ===== Generic Modal ===== */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(16px + var(--safe-bottom));
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-bottom: none;
  animation: slideUp 0.3s ease-out;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-content::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin: 0 auto 12px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  position: sticky;
  top: -20px;
  background: var(--surface);
  padding: 16px 0 8px;
  z-index: 1;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.modal-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

#auth-modal, #profile-modal, #leaderboard-modal, #account-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

/* ===== Auth Forms ===== */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  min-height: 44px;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.auth-switch {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
}

.auth-error {
  color: var(--wrong);
  font-size: 0.82rem;
  text-align: center;
}

.auth-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
}

/* ===== Profile Form ===== */
#profile-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#profile-form label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}

.required {
  color: var(--wrong);
}

.optional {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 0.75rem;
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: -4px 0 2px;
  line-height: 1.3;
}

#profile-form input,
#profile-form select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

#profile-form input:focus,
#profile-form select:focus {
  border-color: var(--accent);
}

.birthday-fields {
  display: flex;
  gap: 8px;
}

.birthday-fields select {
  flex: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23777' stroke-width='1.5'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* Favorite songs chips */
#fav-songs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fav-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 50px;
  padding: 5px 8px;
  font-size: 0.72rem;
  color: var(--text);
  max-width: 100%;
}

.fav-chip span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-chip button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

#fav-search-wrapper {
  position: relative;
}

#fav-search-results {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  max-height: 200px;
  overflow-y: auto;
  z-index: 210;
  overscroll-behavior: contain;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
}

#fav-search-results .search-item {
  padding: 10px 12px;
  min-height: 44px;
}

#fav-search-results .search-item img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
}

/* ===== Account Modal ===== */
#account-email {
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 4px;
}

#account-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#account-form label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}

#account-form input,
#account-form select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

#account-form input:focus,
#account-form select:focus {
  border-color: var(--accent);
}

#account-fav-search-wrapper {
  position: relative;
}

#account-fav-search-results {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  max-height: 200px;
  overflow-y: auto;
  z-index: 210;
  overscroll-behavior: contain;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
}

#account-fav-search-results .search-item {
  padding: 10px 12px;
  min-height: 44px;
}

#account-fav-search-results .search-item img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
}

.btn-signout {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--wrong);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  min-height: 44px;
}

.btn-signout:hover {
  background: var(--wrong-dim);
  border-color: var(--wrong);
}

/* ===== Leaderboard ===== */
#leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.lb-row.top-1 { border-left: 3px solid #ffd700; }
.lb-row.top-2 { border-left: 3px solid #c0c0c0; }
.lb-row.top-3 { border-left: 3px solid #cd7f32; }

.lb-rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-dim);
  min-width: 28px;
  text-align: center;
}

.lb-row.top-1 .lb-rank { color: #ffd700; }
.lb-row.top-2 .lb-rank { color: #c0c0c0; }
.lb-row.top-3 .lb-rank { color: #cd7f32; }

.lb-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-score {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
}

.lb-details {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.lb-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 24px;
  font-size: 0.85rem;
}

/* ===== Responsive ===== */
@media (min-width: 480px) {
  #stats-modal,
  #auth-modal,
  #profile-modal,
  #leaderboard-modal,
  #account-modal {
    align-items: center;
  }

  #stats-content,
  .modal-content {
    border-radius: 16px;
    border-bottom: 1px solid var(--border);
    max-width: 380px;
    animation: fadeUp 0.3s ease-out;
  }

  #search-results {
    max-height: 320px;
  }
}

/* When keyboard is likely open - shrink results */
@media (max-height: 500px) {
  #search-results {
    max-height: 160px;
  }

  main {
    padding-bottom: 120px;
  }

  .modal-content {
    max-height: 80vh;
    max-height: 80dvh;
  }
}

/* ===== Throwback Thursday Theme ===== */
body.throwback {
  --bg: #1a0a2e;
  --surface: #241248;
  --surface-2: #2e1a5c;
  --border: #4a2870;
  --border-light: #5c3490;
  --accent: #ff6ec7;
  --accent-dim: rgba(255, 110, 199, 0.15);
  --accent-glow: rgba(255, 110, 199, 0.35);
}

body.throwback::before {
  opacity: 0.05;
}

body.throwback #timeline-fill {
  background: linear-gradient(90deg, #ff6ec7, #7b2ff7);
}

body.throwback #play-btn {
  background: linear-gradient(135deg, #ff6ec7, #7b2ff7);
  box-shadow: 0 2px 16px rgba(255, 110, 199, 0.4);
}

body.throwback header h1 {
  background: linear-gradient(135deg, #ff6ec7 0%, #7b2ff7 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

body.throwback #throwback-badge {
  display: inline-flex;
}

#throwback-badge {
  display: none;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ff6ec7;
  background: rgba(255, 110, 199, 0.12);
  border: 1px solid rgba(255, 110, 199, 0.25);
  border-radius: 50px;
  padding: 3px 10px;
  margin-left: 8px;
  white-space: nowrap;
}

/* Very small phones */
@media (max-width: 350px) {
  header h1 {
    font-size: 0.9rem;
    letter-spacing: 0.08em;
  }

  .guess-row {
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  #play-btn {
    padding: 10px 24px;
    font-size: 0.85rem;
  }
}
