@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-card: rgba(255,255,255,0.06);
  --bg-card-hover: rgba(255,255,255,0.10);
  --accent-green: #1DB954;
  --accent-purple: #8B5CF6;
  --accent-pink: #EC4899;
  --accent-blue: #3B82F6;
  --text-primary: #FFFFFF;
  --text-secondary: #A0A0C0;
  --text-muted: #606080;
  --border-subtle: rgba(255,255,255,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: 'Outfit', sans-serif;
}

html, body {
  width: 100%; height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
}
body {
  background: linear-gradient(135deg, var(--bg-primary) 0%, #0f0f2e 50%, #1a0a2e 100%);
  min-height: 100vh;
}

/* === Background Animation === */
.bg-animation {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.bg-orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.15;
  animation: float 20s ease-in-out infinite;
}
.bg-orb:nth-child(1) { width: 400px; height: 400px; background: var(--accent-purple); top: 10%; left: 10%; }
.bg-orb:nth-child(2) { width: 300px; height: 300px; background: var(--accent-green); top: 60%; right: 10%; animation-delay: -7s; }
.bg-orb:nth-child(3) { width: 350px; height: 350px; background: var(--accent-pink); bottom: 10%; left: 40%; animation-delay: -14s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* === Screens === */
.screen { display: none; position: relative; z-index: 1; min-height: 100vh; padding: 40px 20px; }
.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* === Background Art Tiles === */
.art-tiles-bg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  overflow: hidden; z-index: 0; opacity: 0.12; pointer-events: none;
}
.art-tiles-row {
  display: flex; gap: 8px; margin-bottom: 8px;
  width: max-content;
}
.art-tiles-row:nth-child(odd) { animation: scroll-left 60s linear infinite; }
.art-tiles-row:nth-child(even) { animation: scroll-right 55s linear infinite; }
@keyframes scroll-left {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
@keyframes scroll-right {
  0% { transform: translateX(-50%); }
  100% { transform: translateX(0); }
}
.art-tile {
  width: 80px; height: 80px; border-radius: 8px; flex-shrink: 0;
  overflow: hidden; background: rgba(255,255,255,0.05);
}
.art-tile img { width: 100%; height: 100%; object-fit: cover; }

/* === Loading Overlay === */
.loading-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(10,10,26,0.85); z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; backdrop-filter: blur(10px);
}
.loading-spinner {
  width: 48px; height: 48px; border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-purple); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: 1rem; color: var(--text-secondary); letter-spacing: 1px;
}

/* === Title Screen === */
.title-screen { position: relative; overflow: hidden; }
.title-screen .logo-container { text-align: center; margin-bottom: 48px; position: relative; z-index: 2; }
.title-screen .logo-icon {
  font-size: 72px; margin-bottom: 16px;
  animation: pulse-glow 3s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(139,92,246,0.5)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 30px rgba(139,92,246,0.8)); transform: scale(1.05); }
}
.title-screen h1 {
  font-size: 3.5rem; font-weight: 800;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink), var(--accent-green));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: -1px;
}
.title-screen .subtitle {
  font-size: 1.1rem; color: var(--text-secondary); margin-top: 8px; font-weight: 300;
}
.rules-box {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px); border-radius: var(--radius-lg);
  padding: 24px 32px; max-width: 480px; margin-bottom: 40px;
  position: relative; z-index: 2;
}
.rules-box h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 2px; color: var(--accent-purple); margin-bottom: 16px; }
.rules-box ol { padding-left: 20px; }
.rules-box li { color: var(--text-secondary); margin-bottom: 8px; font-size: 0.95rem; line-height: 1.5; }

/* === Year Range Slider === */
.year-slider-container {
  max-width: 480px; width: 100%; margin-bottom: 20px; text-align: center;
}
.year-slider-label {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px;
  color: var(--accent-blue); margin-bottom: 8px;
}
.year-slider-row {
  display: flex; align-items: center; gap: 12px; justify-content: center;
}
.year-slider-row input[type="range"] {
  flex: 1; max-width: 160px; accent-color: var(--accent-purple);
  height: 6px; cursor: pointer;
}
.year-slider-value {
  font-size: 1rem; font-weight: 700; color: var(--accent-purple);
  min-width: 48px; text-align: center;
}
.year-slider-value.muted { color: var(--text-muted); font-weight: 400; }

/* === Buttons === */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: white; border: none; padding: 16px 48px; border-radius: 50px;
  font-family: var(--font); font-size: 1.1rem; font-weight: 600;
  cursor: pointer; transition: all 0.3s ease; position: relative; overflow: hidden;
  box-shadow: 0 4px 20px rgba(139,92,246,0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(139,92,246,0.6); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border-subtle); padding: 12px 32px;
  border-radius: 50px; font-family: var(--font); font-size: 1rem;
  font-weight: 500; cursor: pointer; transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--accent-purple); }

.btn-icon {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  width: 36px; height: 36px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; cursor: pointer;
  transition: all 0.3s ease; color: var(--text-primary); font-size: 0.85rem;
}
.btn-icon:hover { background: var(--accent-purple); border-color: var(--accent-purple); }

/* === Listen Phase === */
.listen-screen .phase-header { text-align: center; margin-bottom: 32px; }
.listen-screen .phase-label {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 3px;
  color: var(--accent-green); margin-bottom: 8px;
}
.listen-screen .phase-title { font-size: 1.8rem; font-weight: 700; }

.progress-bar-container {
  display: flex; gap: 8px; margin-bottom: 40px; width: 100%; max-width: 400px;
}
.progress-dot {
  flex: 1; height: 4px; border-radius: 2px; background: var(--border-subtle);
  transition: background 0.5s ease;
}
.progress-dot.completed { background: var(--accent-green); }
.progress-dot.current { background: var(--accent-purple); animation: dot-pulse 1.5s ease-in-out infinite; }
@keyframes dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.song-card-listen {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px); border-radius: var(--radius-xl);
  padding: 32px; width: 100%; max-width: 400px; text-align: center;
}
.song-card-listen .song-number {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 3px;
  color: var(--text-muted); margin-bottom: 24px;
}
.song-card-listen .album-art-placeholder {
  width: 200px; height: 200px; margin: 0 auto 24px;
  background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(236,72,153,0.2));
  border-radius: var(--radius-lg); display: flex; align-items: center;
  justify-content: center; font-size: 64px; overflow: hidden;
  animation: art-pulse 2s ease-in-out infinite;
}
@keyframes art-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(139,92,246,0); }
  50% { box-shadow: 0 0 40px rgba(139,92,246,0.3); }
}
.song-card-listen .song-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 4px; }
.song-card-listen .song-artist { font-size: 1rem; color: var(--text-secondary); margin-bottom: 24px; }

/* Spotify Embed Container */
.spotify-embed-container {
  width: 100%; max-width: 400px; margin: 16px auto;
  border-radius: var(--radius-md); overflow: hidden;
}
.spotify-embed-container iframe { border-radius: var(--radius-md); }

/* Custom Audio Player */
.custom-audio-player {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.05); border-radius: 50px;
  padding: 8px 16px; margin-top: 16px;
}
.audio-progress {
  flex: 1; height: 4px; background: var(--border-subtle);
  border-radius: 2px; overflow: hidden; cursor: pointer;
}
.audio-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent-purple), var(--accent-green));
  border-radius: 2px; width: 0%; transition: width 0.1s linear;
}
.audio-time { font-size: 0.75rem; color: var(--text-muted); min-width: 36px; }
.listen-controls { margin-top: 24px; display: flex; gap: 12px; }

/* === Sort Phase — VERTICAL layout === */
.sort-screen .phase-header { text-align: center; margin-bottom: 16px; }
.sort-screen .phase-label {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 3px;
  color: var(--accent-pink); margin-bottom: 8px;
}
.sort-screen .phase-title { font-size: 1.8rem; font-weight: 700; }
.sort-screen .phase-subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-top: 4px; }

.timeline-container {
  width: 100%; max-width: 500px; position: relative; margin-bottom: 24px;
}
.timeline-label {
  display: flex; justify-content: space-between; padding: 0 8px;
  margin-bottom: 12px;
}
.timeline-label span {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 2px;
  color: var(--text-muted);
}

/* Vertical card container */
.sort-cards-container {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; max-width: 500px; position: relative; z-index: 1;
  align-items: center; min-height: 260px; margin: 0 auto;
}

/* === Draggable Song Card — Horizontal bar (Vertical stack) === */
.song-card {
  display: flex; flex-direction: row; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px); border-radius: var(--radius-lg);
  padding: 10px 16px; cursor: grab; transition: all 0.25s ease;
  user-select: none; position: relative;
  width: 100%; box-sizing: border-box; flex-shrink: 0;
}
.song-card:hover { background: var(--bg-card-hover); border-color: rgba(139,92,246,0.3); }
.song-card:active { cursor: grabbing; }

.song-card.dragging {
  opacity: 0.9; transform: scale(1.02);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 20px rgba(139,92,246,0.3);
  border-color: var(--accent-purple); z-index: 100;
}
.song-card.drag-over {
  border-color: var(--accent-green);
  box-shadow: 0 0 15px rgba(29,185,84,0.2);
}

.song-card .card-number {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.song-card .card-art {
  width: 60px; height: 60px; border-radius: var(--radius-md);
  overflow: hidden; background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(236,72,153,0.2));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.song-card .card-art img {
  width: 100%; height: 100%; object-fit: cover;
}
.song-card .card-info {
  text-align: left; flex: 1; min-width: 0;
}
.song-card .card-title {
  font-size: 0.8rem; font-weight: 600; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.song-card .card-artist {
  font-size: 0.7rem; color: var(--text-secondary); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-card .card-play-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.1); color: var(--text-primary);
  border: 1px solid var(--border-subtle); cursor: pointer;
  margin-left: auto; flex-shrink: 0; font-size: 0.8rem;
  transition: all 0.2s ease;
}
.song-card .card-play-btn:hover { background: rgba(139,92,246,0.3); }
.song-card .drag-handle {
  color: var(--text-muted); font-size: 1.2rem;
  padding-left: 8px; cursor: grab; flex-shrink: 0;
}

.drop-placeholder {
  height: 60px; border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md); background: rgba(255,255,255,0.05);
}

/* SortableJS ドラッグ時のスタイル */
.sortable-ghost {
  opacity: 0.4; background: rgba(139,92,246,0.1) !important;
  border: 2px dashed var(--accent-purple) !important;
}
.sortable-drag {
  opacity: 1 !important; box-shadow: 0 10px 20px rgba(0,0,0,0.5) !important;
  cursor: grabbing !important;
}

.sort-actions { margin-top: 8px; }

/* === Result Screen === */
.result-screen .phase-header { text-align: center; margin-bottom: 32px; }
.result-screen .score-display {
  font-size: 5rem; line-height: 1.2;
}
.result-screen .score-label {
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 3px;
  color: var(--text-muted); margin-top: 4px;
}
.result-screen .score-message {
  font-size: 1.3rem; margin-top: 12px; font-weight: 500;
}

.result-cards-container {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; max-width: 500px; margin-bottom: 32px;
  justify-content: center; align-items: center; margin-left: auto; margin-right: auto;
}

.result-card {
  display: flex; flex-direction: row; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px); border-radius: var(--radius-lg);
  padding: 10px 16px; transition: all 0.3s ease;
  width: 100%; box-sizing: border-box;
}
.result-card.correct { border-color: rgba(29,185,84,0.4); background: rgba(29,185,84,0.08); }
.result-card.incorrect { border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08); }

.result-card .result-icon { font-size: 1.5rem; flex-shrink: 0; width: 32px; text-align: center; }

/* ===== Global Navigation Button ===== */
.btn-global-home {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px);
  border-radius: 50px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
  font-family: var(--font);
}

.btn-global-home:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  transform: translateY(-2px);
  border-color: var(--accent-purple);
}

/* ===== Global Volume Control ===== */
.global-volume {
  position: fixed;
  top: 16px;
  left: 170px; /* メニューに戻るボタンの右側 */
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px);
  border-radius: 50px;
  padding: 6px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}
.global-volume:hover { border-color: var(--accent-purple); }
.global-volume input[type="range"] {
  width: 80px;
  accent-color: var(--accent-purple);
  cursor: pointer;
}

@media (max-width: 600px) {
  .global-volume {
    top: auto;
    bottom: 16px;
    left: 16px;
  }
}

.result-card .result-position {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  position: absolute; top: -8px; left: -8px;
}
.result-card { position: relative; }
.result-card.correct .result-position { background: rgba(29,185,84,0.2); color: var(--accent-green); }
.result-card.incorrect .result-position { background: rgba(239,68,68,0.2); color: #EF4444; }
.result-card .result-art {
  width: 60px; height: 60px; border-radius: var(--radius-md);
  overflow: hidden; background: rgba(139,92,246,0.1);
  flex-shrink: 0;
}
.result-card .result-art img { width: 100%; height: 100%; object-fit: cover; }
.result-card .result-info { text-align: left; flex: 1; min-width: 0; }
.result-card .result-title { 
  font-size: 0.8rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-card .result-artist { 
  font-size: 0.7rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-card .result-year {
  font-size: 1.1rem; font-weight: 700;
  color: var(--accent-purple); margin-top: 4px;
}
.result-card .result-date {
  font-size: 0.7rem; color: var(--text-muted);
}
.result-card .result-your-pos {
  font-size: 0.65rem; color: var(--text-muted); margin-top: 2px;
}

.result-actions { display: flex; gap: 12px; }

/* === Animations === */
.fade-in { animation: fadeIn 0.5s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.slide-up { animation: slideUp 0.4s ease forwards; }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }

.card-enter { animation: cardEnter 0.3s ease forwards; }
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }

/* === Difficulty Badge === */
.difficulty-badge {
  position: fixed; top: 16px; right: 16px; z-index: 50;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px); border-radius: 50px;
  padding: 6px 16px; font-size: 0.85rem; font-weight: 600;
  color: var(--text-secondary); letter-spacing: 1px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* === Drum Roll Shake === */
.drumroll-shake .song-card {
  animation: cardShake 0.08s ease-in-out infinite alternate;
}
.drumroll-shake .song-card:nth-child(2) { animation-delay: 0.02s; }
.drumroll-shake .song-card:nth-child(3) { animation-delay: 0.04s; }
.drumroll-shake .song-card:nth-child(4) { animation-delay: 0.01s; }
.drumroll-shake .song-card:nth-child(5) { animation-delay: 0.03s; }

@keyframes cardShake {
  0% { transform: translateX(-2px) rotate(-0.5deg); }
  25% { transform: translateY(-2px) rotate(0.3deg); }
  50% { transform: translateX(2px) rotate(0.5deg); }
  75% { transform: translateY(2px) rotate(-0.3deg); }
  100% { transform: translateX(1px) translateY(-1px) rotate(0.2deg); }
}
