:root {
  --bg: #101114;
  --card: #191b20;
  --card-hover: #20232b;
  --border: #2a2d36;
  --primary: #7c5cff;
  --primary-hover: #9377ff;
  --day: #f5b942;
  --night: #536dfe;
  --success: #2ecc71;
  --danger: #e74c3c;
  --text: #f2f2f5;
  --text-dim: #a6a8b3;
  --radius: 16px;
  --radius-sm: 10px;
  --sticky-height: 76px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  padding-bottom: calc(var(--sticky-height) + 16px);
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 8px;
}

p {
  margin: 0 0 12px;
  color: var(--text-dim);
}

a {
  color: var(--primary);
}

button {
  font: inherit;
  cursor: pointer;
}

.deadline-banner {
  position: sticky;
  top: 0;
  z-index: 45;
  background: var(--day);
  color: #1a1300;
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 16px;
}

.site-header {
  padding: 20px 16px 8px;
  text-align: center;
}

.site-header .brand-logo {
  width: 96px;
  height: 96px;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 24px;
}

.hero h1 {
  font-size: 1.9rem;
  text-align: center;
}

.hero-note {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.subtitle {
  text-align: center;
  font-size: 1.05rem;
}

.rules-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.rules-box p {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 0.95rem;
}

.rules-box p:last-child {
  margin-bottom: 0;
}

.rules-box .rules-note {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-left: 24px;
}

.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input {
  flex: 1 1 100%;
  min-width: 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
  min-height: 48px;
}

.search-bar input:focus {
  outline: 2px solid var(--primary);
}

.search-bar select {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.95rem;
  min-height: 48px;
}

.search-bar select:focus {
  outline: 2px solid var(--primary);
}

.search-bar button {
  flex: 1;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  min-height: 48px;
  min-width: 88px;
}

@media (min-width: 560px) {
  .search-bar input {
    flex: 1 1 auto;
  }

  .search-bar select {
    flex: 0 1 160px;
  }

  .search-bar button {
    flex: 0 0 auto;
  }
}

.search-bar button:hover {
  background: var(--primary-hover);
}

.search-bar button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#search-status {
  min-height: 24px;
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

@media (min-width: 560px) {
  .results-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.track-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.track-card:hover {
  background: var(--card-hover);
}

.track-art {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  background: #26293280 center/cover no-repeat;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-title {
  font-weight: 700;
  font-size: 1rem;
  overflow-wrap: break-word;
  word-break: break-word;
}

.track-artist {
  color: var(--text-dim);
  font-size: 0.9rem;
  overflow-wrap: break-word;
  word-break: break-word;
}

.track-meta {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 2px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.btn-add {
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  min-height: 40px;
}

.btn-add:hover {
  background: var(--primary-hover);
}

.btn-add:disabled {
  background: #3a3c45;
  color: var(--text-dim);
  cursor: not-allowed;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-dim);
}

.empty-state strong {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

/* Sticky counter bar */
.counter-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--sticky-height);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  z-index: 40;
}

.counter-bar .counters {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  overflow-x: auto;
}

.counter-bar .counter {
  white-space: nowrap;
}

.counter-bar .counter b {
  color: var(--text);
}

.btn-secondary {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 700;
  min-height: 44px;
  white-space: nowrap;
}

.btn-primary {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  min-height: 48px;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  background: #3a3c45;
  color: var(--text-dim);
  cursor: not-allowed;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 10px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: #000000a0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
}

@media (min-width: 560px) {
  .modal {
    align-items: center;
  }
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 28px;
  width: 100%;
  max-width: 420px;
}

@media (min-width: 560px) {
  .modal-content {
    border-radius: var(--radius);
  }
}

.modal-content h2 {
  text-align: center;
}

#modal-song-info {
  text-align: center;
  margin-bottom: 20px;
}

.btn-day,
.btn-night {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 10px;
  min-height: 56px;
}

.btn-day {
  background: var(--day);
  color: #1a1300;
}

.btn-night {
  background: var(--night);
  color: #fff;
}

.btn-day:disabled,
.btn-night:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Full-screen overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  overflow-y: auto;
  padding: 16px;
}

.overlay-content {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 32px;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-weight: 700;
  padding: 10px 0;
  margin-bottom: 8px;
}

.playlist-section {
  margin-bottom: 24px;
}

.playlist-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-day {
  color: var(--day);
}

.badge-night {
  color: var(--night);
}

.song-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.song-row .track-art {
  width: 48px;
  height: 48px;
  font-size: 1.1rem;
}

.song-row-info {
  flex: 1;
  min-width: 0;
}

.song-row-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-row-artist {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-row-reason {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 2px;
  white-space: normal;
}

.song-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  min-height: 36px;
}

.icon-btn.danger {
  color: var(--danger);
  border-color: var(--danger);
}

.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.form-field .optional {
  color: var(--text-dim);
  font-weight: 400;
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
}

.form-field textarea {
  min-height: 80px;
  resize: vertical;
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 4px;
}

.summary-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-around;
  text-align: center;
}

.summary-box .stat b {
  display: block;
  font-size: 1.4rem;
}

.summary-box .stat span {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.confirmation {
  text-align: center;
  padding-top: 40px;
}

.confirmation .emoji {
  font-size: 3rem;
}

.reference-box {
  background: var(--card);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--primary);
}

.toast {
  position: fixed;
  bottom: calc(var(--sticky-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  z-index: 80;
  max-width: 90%;
  text-align: center;
  font-size: 0.9rem;
}

.toast.success {
  background: var(--success);
}

.status-check-link {
  text-align: center;
  font-size: 0.85rem;
  margin: -8px 0 20px;
}

.status-back-link {
  margin-top: 20px;
}

.status-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.status-pill.pending {
  color: var(--text-dim);
}

.status-pill.under_review {
  color: var(--primary);
  border-color: var(--primary);
}

.status-pill.partially_approved {
  color: var(--day);
  border-color: var(--day);
}

.status-pill.approved {
  color: var(--success);
  border-color: var(--success);
}

.status-pill.rejected {
  color: var(--danger);
  border-color: var(--danger);
}

.status-hero {
  text-align: center;
  margin-bottom: 20px;
}

.status-hero .status-pill {
  font-size: 1rem;
  padding: 8px 20px;
  margin-top: 8px;
}

.status-submitted-at {
  text-align: center;
  font-size: 0.85rem;
}

.song-row .status-pill {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 4px 10px;
}

.confirmation .btn-secondary {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  margin-top: 10px;
}

.limit-note {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 6px;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-dim);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- BeepBop the drone ---- */
.beepbop {
  /* Tablet and up only — on phones he'd cover too much of a cramped screen. */
  position: fixed;
  right: 16px;
  bottom: calc(var(--sticky-height) + 16px);
  z-index: 55;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

@media (min-width: 768px) {
  .beepbop {
    display: flex;
  }
}

.beepbop-bubble {
  position: relative;
  max-width: min(240px, 62vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 30px 10px 12px;
  font-size: 0.85rem;
  box-shadow: 0 6px 20px #00000040;
  animation: beepbop-bubble-in 0.25s ease-out;
}

.beepbop-bubble::after {
  content: '';
  position: absolute;
  right: 22px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--card);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}

.beepbop-bubble p {
  margin: 0;
  color: var(--text);
}

.beepbop-bubble-close {
  position: absolute;
  top: 2px;
  right: 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
}

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

.beepbop-drone {
  position: relative;
  width: 64px;
  height: 64px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  animation: beepbop-float 3.2s ease-in-out infinite;
}

.beepbop-antenna {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 12px;
  background: var(--text-dim);
  transform: translateX(-50%);
}

.beepbop-antenna::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  transform: translateX(-50%);
  box-shadow: 0 0 6px var(--primary);
}

.beepbop-rotor {
  position: absolute;
  top: 10px;
  width: 22px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  opacity: 0.6;
  animation: beepbop-rotor-blur 0.15s linear infinite;
}

.beepbop-rotor-left {
  left: -10px;
}

.beepbop-rotor-right {
  right: -10px;
}

.beepbop-body {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 14px;
  bottom: 4px;
  background: linear-gradient(180deg, #3a3c45, #23252d);
  border: 2px solid var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px #00000060;
}

.beepbop-eye {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--night);
  box-shadow: 0 0 6px var(--night);
  animation: beepbop-blink 4s ease-in-out infinite;
}

.beepbop-smile {
  position: absolute;
  bottom: 8px;
  left: 50%;
  width: 16px;
  height: 6px;
  border-bottom: 2px solid var(--day);
  border-radius: 0 0 10px 10px;
  transform: translateX(-50%);
}

@keyframes beepbop-float {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-10px) rotate(2deg);
  }
}

@keyframes beepbop-rotor-blur {
  0%,
  100% {
    transform: scaleX(1);
    opacity: 0.5;
  }
  50% {
    transform: scaleX(0.7);
    opacity: 0.8;
  }
}

@keyframes beepbop-blink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  96% {
    transform: scaleY(0.1);
  }
}

@keyframes beepbop-bubble-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Double-clicked/double-tapped: droop, whimper, and fly off. */
.beepbop-sad .beepbop-drone {
  animation: beepbop-sink 1.1s ease-in forwards;
  cursor: default;
}

.beepbop-sad .beepbop-rotor {
  animation: none;
  opacity: 0.2;
  transform: scaleX(0.4);
}

.beepbop-sad .beepbop-antenna::after {
  background: var(--text-dim);
  box-shadow: none;
}

.beepbop-sad .beepbop-body {
  border-color: var(--text-dim);
}

.beepbop-sad .beepbop-eye {
  animation: none;
  height: 4px;
  border-radius: 4px;
  background: var(--text-dim);
  box-shadow: none;
  transform: translateY(2px);
}

.beepbop-sad .beepbop-smile {
  border-bottom: none;
  border-top: 2px solid var(--text-dim);
  border-radius: 10px 10px 0 0;
  bottom: 6px;
}

@keyframes beepbop-sink {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  30% {
    transform: translateY(-4px) rotate(-6deg);
    opacity: 1;
  }
  100% {
    transform: translateY(50px) rotate(14deg);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .beepbop-drone,
  .beepbop-rotor,
  .beepbop-eye {
    animation: none;
  }

  .beepbop-sad .beepbop-drone {
    animation: beepbop-fade-out 0.3s ease-in forwards;
  }

  @keyframes beepbop-fade-out {
    to {
      opacity: 0;
    }
  }
}

/* ---- Flappy BeepBop (hidden mini-game: click the logo 5 times) ---- */
.flappy-overlay {
  position: fixed;
  inset: 0;
  background: #000000b0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.flappy-panel {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  width: 100%;
  max-width: min(720px, 94vw);
  user-select: none;
}

.flappy-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
}

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

.flappy-scorebar {
  display: flex;
  justify-content: space-around;
  font-size: 0.9rem;
  margin-bottom: 10px;
  padding-right: 24px;
}

.flappy-field {
  position: relative;
  width: 100%;
  height: min(480px, 70vh);
  background: linear-gradient(180deg, #1a1c22, #101114);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: manipulation;
  cursor: pointer;
}

.flappy-bird {
  position: absolute;
  top: 0;
  left: 0;
  width: 64px;
  height: 64px;
  z-index: 2;
  will-change: transform;
}

.flappy-gates {
  position: absolute;
  inset: 0;
}

.flappy-gate {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 46px;
}

.flappy-gate-top,
.flappy-gate-bottom {
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 6px;
}

.flappy-gate-top {
  top: 0;
}

.flappy-gate-bottom {
  bottom: 0;
}

.flappy-gate-day .flappy-gate-top,
.flappy-gate-day .flappy-gate-bottom {
  background: linear-gradient(180deg, var(--day), #c98f1f);
}

.flappy-gate-night .flappy-gate-top,
.flappy-gate-night .flappy-gate-bottom {
  background: linear-gradient(180deg, var(--night), #2c3d9e);
}

.flappy-gate-icon {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.1rem;
}

.flappy-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
  background: #101114cc;
  z-index: 3;
}

.flappy-message strong {
  font-size: 1.2rem;
  color: var(--text);
}

.flappy-message p {
  color: var(--text-dim);
}

.flappy-message .btn-primary {
  width: auto;
  padding: 10px 24px;
}

.flappy-countdown strong {
  font-size: 3.5rem;
  color: var(--primary);
  animation: flappy-countdown-pulse 0.7s ease-out;
}

@keyframes flappy-countdown-pulse {
  from {
    transform: scale(1.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
