*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #00b5c8;
  --accent-dim: #008fa0;
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --text: #e0e0e0;
  --text-dim: #888;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --radius: 10px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px 16px 60px;
}

header {
  text-align: center;
  margin-bottom: 28px;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent);
}

header p {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 4px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 800px;
  margin: 0 auto 16px;
}

.save-indicator {
  font-size: 0.8rem;
  color: var(--text-dim);
  transition: color 0.3s;
}

.save-indicator.flash {
  color: var(--accent);
}

button.reset-btn {
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.2s, color 0.2s;
}

button.reset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#ranking-list {
  list-style: none;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
}

.entry {
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--surface2);
  border-radius: 0;
  transition: background 0.15s, transform 0.15s;
  cursor: default;
}

#ranking-list > li:first-child { border-radius: var(--radius) var(--radius) 0 0; }
#ranking-list > li:last-child  { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }

.entry:last-child {
  border-bottom: none;
}

.entry:hover {
  background: color-mix(in srgb, var(--surface) 85%, var(--accent) 15%);
}

.entry.dragging {
  opacity: 0 !important;
}


.entry-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  user-select: none;
  cursor: grab;
}


.drag-handle {
  color: var(--text-dim);
  font-size: 1.1rem;
  flex-shrink: 0;
  line-height: 1;
  padding: 4px 8px;
  touch-action: none;
}

.rank {
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  padding: 3px 6px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface2);
  color: var(--text-dim);
}

.rank.gold   { background: var(--gold);   color: #1a1a1a; }
.rank.silver { background: var(--silver); color: #1a1a1a; }
.rank.bronze { background: var(--bronze); color: #1a1a1a; }

.flag {
  width: 36px;
  height: 24px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.country {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.artist-song .song-title {
  color: var(--accent);
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

button.yt-btn,
button.notes-btn {
  background: transparent;
  border: 1px solid var(--surface2);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

button.yt-btn:hover:not(:disabled),
button.notes-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
}

button.yt-btn.no-video {
  opacity: 0.3;
  cursor: not-allowed;
}

button.yt-btn.playing {
  border-color: #ff4444;
  color: #ff4444;
  background: rgba(255,68,68,0.1);
}

button.notes-btn.has-notes {
  border-color: rgba(0,181,200,0.4);
  color: var(--accent);
}

/* Fixed YouTube player — bottom right */
.yt-player {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 100;
  overflow: hidden;
}

.yt-player.hidden { display: none; }

.yt-player-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface2);
}

.yt-player-title {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yt-player-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

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

#yt-iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
}

.notes-panel {
  display: none;
  padding: 0 14px 12px 14px;
}

.notes-panel.open {
  display: block;
}

.notes-panel textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 10px;
  resize: vertical;
  min-height: 70px;
  outline: none;
  transition: border-color 0.15s;
}

.notes-panel textarea:focus {
  border-color: var(--accent);
}

.notes-panel textarea::placeholder {
  color: var(--text-dim);
}


.entry.unranked {
  opacity: 0.5;
}

.entry.unranked:hover {
  opacity: 0.8;
}

.rank.unranked-badge {
  color: var(--text-dim);
  background: transparent;
  border: 1px dashed var(--surface2);
}

/* Divider row */
.divider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  border: none;
  border-top: 1px dashed rgba(0,181,200,0.4);
  border-bottom: 1px dashed rgba(0,181,200,0.4);
  background: rgba(0,181,200,0.04);
  user-select: none;
}

.divider-row.drag-over-divider {
  border-color: var(--accent);
  background: rgba(0,181,200,0.12);
}

.divider-label {
  flex: 1;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.divider-label strong {
  color: var(--accent);
}

.divider-btn {
  background: transparent;
  border: 1px solid var(--surface2);
  color: var(--text-dim);
  border-radius: 5px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.divider-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.divider-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

@media (max-width: 520px) {
  .entry-main { gap: 8px; padding: 10px 10px; }
}
