/* ========================
   CSS Variables & Reset
======================== */
:root {
  --primary: hsl(215, 90%, 58%);
  --primary-dark: hsl(215, 85%, 45%);
  --primary-glow: hsl(215, 90%, 70%);
  --accent: hsl(340, 85%, 60%);
  --accent-dark: hsl(340, 80%, 48%);
  --accent-glow: hsl(340, 85%, 75%);
  --gold: hsl(45, 95%, 58%);
  --gold-dark: hsl(45, 90%, 45%);
  --success: hsl(145, 70%, 52%);
  --danger: hsl(5, 85%, 60%);
  
  --bg-dark: hsl(220, 25%, 8%);
  --bg-card: hsl(220, 20%, 13%);
  --bg-card2: hsl(220, 18%, 18%);
  --border: hsl(220, 15%, 25%);
  --text-primary: hsl(220, 20%, 95%);
  --text-secondary: hsl(220, 15%, 65%);
  --text-muted: hsl(220, 12%, 45%);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);
  --shadow-primary: 0 8px 32px hsla(215, 90%, 58%, 0.35);
  --shadow-accent: 0 8px 32px hsla(340, 85%, 60%, 0.35);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans JP', 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ========================
   Background Animation
======================== */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.wave {
  position: absolute;
  width: 200%;
  height: 200%;
  border-radius: 40%;
  opacity: 0.04;
  animation: wave-rotate linear infinite;
}

.wave1 {
  top: -60%;
  left: -50%;
  background: radial-gradient(ellipse, var(--primary), transparent 70%);
  animation-duration: 20s;
}

.wave2 {
  top: -30%;
  right: -60%;
  background: radial-gradient(ellipse, var(--accent), transparent 70%);
  animation-duration: 28s;
  animation-direction: reverse;
}

.wave3 {
  bottom: -70%;
  left: -20%;
  background: radial-gradient(ellipse, var(--primary-dark), transparent 70%);
  animation-duration: 35s;
}

@keyframes wave-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.particles {
  position: absolute;
  inset: 0;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0;
  animation: particle-float linear infinite;
}

@keyframes particle-float {
  0% { opacity: 0; transform: translateY(100vh) scale(0); }
  10% { opacity: 0.6; }
  90% { opacity: 0.3; }
  100% { opacity: 0; transform: translateY(-20vh) scale(1.5); }
}

/* ========================
   Screen Management
======================== */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start; /* flex-start + margin:auto on children = centers when fits, scrolls from top when tall */
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  overflow-y: auto;
  padding: 24px 20px;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ========================
   Home Screen
======================== */
.home-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin: auto; /* vertically centers when content fits viewport */
  animation: slide-up 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo-area {
  text-align: center;
}

.logo-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: white;
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  padding: 8px 20px;
  border-radius: 100px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-accent);
}

.title-main {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--text-primary), var(--primary-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  margin-bottom: 8px;
}

.title-sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 300;
}

.home-stats {
  display: flex;
  gap: 16px;
  width: 100%;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-num {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.settings-panel {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-row label {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}

.select-styled {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.select-styled:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px hsla(215, 90%, 58%, 0.2);
}

.reset-row {
  margin-top: 6px;
}

.btn-reset-history {
  width: 100%;
  padding: 10px 14px;
  background: hsla(5, 85%, 60%, 0.12);
  border: 1px dashed var(--danger);
  color: var(--danger);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reset-history:hover {
  background: var(--danger);
  color: white;
}

/* ========================
   Buttons
======================== */
.btn-primary {
  width: 100%;
  padding: 18px 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-xl);
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-primary);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px hsla(215, 90%, 58%, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  flex: 1;
  padding: 14px 24px;
  background: var(--bg-card2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.btn-secondary:hover {
  background: var(--border);
  transform: translateY(-2px);
}

.btn-icon {
  font-size: 1.3rem;
}

.glow-effect {
  animation: glow-pulse 2.5s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: var(--shadow-primary); }
  50% { box-shadow: 0 12px 48px hsla(215, 90%, 58%, 0.7); }
}

/* ========================
   Quiz Screen
======================== */
.quiz-container {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: auto; /* vertically centers when content fits viewport */
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.q-num {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--primary);
}

.q-total {
  font-size: 1rem;
  color: var(--text-muted);
  margin-left: 4px;
}

.score-display {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 16px;
}

.score-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.score-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gold);
}

.streak-display {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  min-width: 64px;
  justify-content: center;
}

.streak-fire {
  font-size: 1rem;
}

#streak-count {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
}

.progress-bar-wrap {
  height: 4px;
  background: var(--bg-card2);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 100px;
  transition: width 0.5s ease;
  width: 0%;
}

/* ========================
   Player Card
======================== */
.player-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

.player-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at center, hsla(215, 90%, 58%, 0.05), transparent 60%);
  pointer-events: none;
}

.player-visual {
  display: flex;
  align-items: center;
  gap: 24px;
}

/* Vinyl Record */
.vinyl-record {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #2a2a2a 25%, #1a1a1a 25%, #1a1a1a 30%, #333 30%, #333 35%, #1a1a1a 35%, #1a1a1a 40%, #333 40%, #333 45%, #1a1a1a 45%, #1a1a1a 50%, #333 50%);
  position: relative;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  flex-shrink: 0;
  transition: animation 0.3s;
}

.vinyl-record.spinning {
  animation: vinyl-spin 1.5s linear infinite;
}

@keyframes vinyl-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.vinyl-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
}

.vinyl-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bg-dark);
}

/* Sound Waves */
.sound-waves {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
}

.wave-bar {
  width: 5px;
  background: linear-gradient(to top, var(--primary), var(--primary-glow));
  border-radius: 100px;
  height: 8px;
  transition: height 0.1s ease;
}

.sound-waves.playing .wave-bar {
  animation: wave-dance 0.8s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0.0s; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.0s; }
.wave-bar:nth-child(5) { animation-delay: 0.15s; }
.wave-bar:nth-child(6) { animation-delay: 0.05s; }
.wave-bar:nth-child(7) { animation-delay: 0.25s; }

@keyframes wave-dance {
  0%, 100% { height: 8px; }
  50% { height: 40px; }
}

/* Timer Ring */
.timer-ring-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.timer-ring {
  width: 80px;
  height: 80px;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: var(--bg-card2);
  stroke-width: 8;
}

.timer-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.3;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s;
}

.timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* Play Button */
.btn-play {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  color: white;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.btn-play:not(:disabled):hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px hsla(215, 90%, 58%, 0.6);
}

.btn-play:not(:disabled):active {
  transform: scale(0.95);
}

.btn-play:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-play::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn-play:not(:disabled):hover::after {
  opacity: 1;
}

.play-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* ========================
   Choices Grid
======================== */
.choices-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.choices-grid.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.choice-btn {
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text-primary);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
  word-break: break-all;
  line-height: 1.4;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: hsla(215, 90%, 58%, 0.1);
  transform: translateX(4px);
}

.choice-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.choice-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-card2);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.choice-btn:hover:not(:disabled) .choice-label {
  background: var(--primary);
  color: white;
}

.choice-btn.correct {
  border-color: var(--success);
  background: hsla(145, 70%, 52%, 0.15);
  animation: correct-pulse 0.4s ease;
}

.choice-btn.correct .choice-label {
  background: var(--success);
  color: white;
}

.choice-btn.wrong {
  border-color: var(--danger);
  background: hsla(5, 85%, 60%, 0.15);
  animation: wrong-shake 0.4s ease;
}

.choice-btn.wrong .choice-label {
  background: var(--danger);
  color: white;
}

.choice-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

@keyframes correct-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ========================
   Feedback Overlay
======================== */
.feedback-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.feedback-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.feedback-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.feedback-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.1s;
}

@keyframes bounce-in {
  from { opacity: 0; transform: scale(0.3) translateY(-20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.feedback-text {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.feedback-answer {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.feedback-score-add {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
}

.feedback-audio-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
  align-items: center;
}

.btn-listen {
  flex: 1;
  padding: 10px 14px;
  background: hsla(215, 90%, 58%, 0.15);
  border: 1px solid var(--primary);
  color: var(--primary-light);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

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

.btn-next-q {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  color: white;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-primary);
}

.btn-next-q:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px hsla(215, 90%, 58%, 0.5);
}

/* ========================
   Result Screen
======================== */
.result-container {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: auto; /* vertically centers when content fits viewport */
  animation: slide-up 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.result-header {
  text-align: center;
}

.result-emoji {
  font-size: 4rem;
  display: block;
  margin-bottom: 8px;
  animation: bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.result-title {
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--text-primary), var(--primary-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-score-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
}

.final-score-wrap {
  text-align: center;
  margin-bottom: 24px;
}

.final-score-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.final-score {
  font-size: 4rem;
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 30px hsla(45, 95%, 58%, 0.5);
}

.final-score-max {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.res-stat {
  background: var(--bg-card2);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.res-stat-icon {
  font-size: 1.3rem;
}

.res-stat-val {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.res-stat-lab {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.new-record {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold);
  background: hsla(45, 95%, 58%, 0.1);
  border: 2px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 14px;
  animation: glow-pulse 1.5s ease-in-out infinite;
}

.missed-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.missed-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.missed-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.missed-item {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* .missed-item::before removed - icon injected via JS (.song-result-icon) */

.missed-item-title {
  flex: 1;
}

.btn-missed-play {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-missed-play:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

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

.result-actions .btn-primary {
  flex: 1;
}

/* ========================
   Scrollbar
======================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-card2);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ========================
   Responsive
======================== */
@media (max-width: 480px) {
  .quiz-container,
  .home-container,
  .result-container {
    gap: 12px;
  }
  
  .player-card {
    padding: 20px 16px;
  }
  
  .choices-grid.cols-2 {
    grid-template-columns: 1fr;
  }
  
  .final-score {
    font-size: 3rem;
  }
}

/* ========================
   Loading state
======================== */
.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========================
   入力式モード
======================== */
.input-answer-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.answer-input {
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-card2);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.answer-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px hsla(215, 90%, 58%, 0.2);
  background: var(--bg-card);
}

.answer-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.answer-input.input-correct {
  border-color: var(--success);
  background: hsla(145, 70%, 52%, 0.1);
  box-shadow: 0 0 0 3px hsla(145, 70%, 52%, 0.2);
}

.answer-input.input-wrong {
  border-color: var(--danger);
  background: hsla(5, 85%, 60%, 0.1);
  box-shadow: 0 0 0 3px hsla(5, 85%, 60%, 0.2);
}

.answer-suggestions {
  display: none;
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}

.suggestion-item {
  padding: 12px 20px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}

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

.suggestion-item:hover {
  background: var(--primary);
  color: #fff;
}

.btn-submit-answer {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: var(--shadow-primary);
}

.btn-submit-answer:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 12px 36px hsla(215, 90%, 58%, 0.45);
}

.btn-submit-answer:active:not(:disabled) {
  transform: translateY(0);
}

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

/* 揺れアニメーション（入力ミス時） */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}

.shake {
  animation: shake 0.45s ease;
}

/* 全出題曲の正解アイコン */
.song-result-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-right: 4px;
}

/* スキップボタン */
.btn-skip-answer {
  width: 100%;
  padding: 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-skip-answer:hover:not(:disabled) {
  background: hsla(5, 85%, 60%, 0.12);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-skip-answer:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* 入力式モードでの answer-suggestions - choices-grid 内で正しく重なるよう調整 */
.choices-grid {
  position: relative;
}

/* ========================
   途中終了ボタン
======================== */
.btn-quit {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-quit:hover {
  background: hsla(5, 85%, 60%, 0.12);
  border-color: var(--danger);
  color: var(--danger);
}

/* ==========================
   全曲一覧ボタン（ホーム）
========================== */
.btn-songlist {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 340px;
  margin: 0.75rem auto 0;
  padding: 0.85rem 2rem;
  background: hsla(215, 90%, 58%, 0.1);
  border: 1.5px solid hsla(215, 90%, 58%, 0.35);
  border-radius: var(--radius-xl);
  color: var(--primary-glow);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}
.btn-songlist:hover {
  background: hsla(215, 90%, 58%, 0.2);
  border-color: var(--primary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px hsla(215, 90%, 58%, 0.3);
}

/* ==========================
   全曲一覧画面
========================== */
#screen-songlist {
  overflow: hidden;
}

.songlist-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 680px;
  margin: 0 auto;
  padding: 0;
}

.songlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.9rem;
  background: linear-gradient(135deg, hsl(220,25%,10%) 0%, hsl(220,20%,14%) 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-songlist-back {
  background: hsla(220, 15%, 25%, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-family: inherit;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-songlist-back:hover {
  background: hsla(215, 90%, 58%, 0.15);
  border-color: var(--primary);
  color: var(--primary-glow);
}

.songlist-header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.songlist-logo-badge {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
}

.songlist-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.songlist-total {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* 検索バー */
.songlist-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: hsl(220, 22%, 10%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.songlist-search-icon {
  font-size: 0.95rem;
  opacity: 0.5;
  flex-shrink: 0;
}

.songlist-search {
  flex: 1;
  background: hsla(220, 20%, 20%, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0.55rem 0.9rem;
  outline: none;
  transition: all 0.2s;
}
.songlist-search:focus {
  border-color: var(--primary);
  background: hsla(215, 90%, 58%, 0.06);
  box-shadow: 0 0 0 3px hsla(215, 90%, 58%, 0.12);
}
.songlist-search::placeholder {
  color: var(--text-muted);
}

.songlist-search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.songlist-search-clear:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* カウントバー */
.songlist-count-bar {
  padding: 0.4rem 1.2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: hsl(220, 22%, 10%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* 曲リスト */
.songlist-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0 2rem;
}
.songlist-items::-webkit-scrollbar {
  width: 4px;
}
.songlist-items::-webkit-scrollbar-track {
  background: transparent;
}
.songlist-items::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* 各曲アイテム */
.songlist-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsla(220, 15%, 25%, 0.4);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  position: relative;
}
.songlist-item:hover {
  background: hsla(215, 90%, 58%, 0.06);
}
.songlist-item:active {
  transform: scale(0.995);
}
.songlist-item.sl-playing {
  background: hsla(215, 90%, 58%, 0.1);
  border-bottom-color: hsla(215, 90%, 58%, 0.25);
}
.songlist-item.sl-playing::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--primary), var(--accent));
  border-radius: 0 2px 2px 0;
}

.sl-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.songlist-item.sl-playing .sl-num {
  color: var(--primary);
}

.sl-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-all;
}
.songlist-item.sl-playing .sl-title {
  color: var(--primary-glow);
  font-weight: 600;
}

/* 再生中ウェーブアニメーション */
.sl-wave-icon {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  flex-shrink: 0;
}
.songlist-item.sl-playing .sl-wave-icon {
  display: flex;
}
.sl-wave-icon span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--primary);
  animation: sl-wave 0.8s ease-in-out infinite alternate;
}
.sl-wave-icon span:nth-child(1) { height: 8px; animation-delay: 0s; }
.sl-wave-icon span:nth-child(2) { height: 14px; animation-delay: 0.2s; }
.sl-wave-icon span:nth-child(3) { height: 8px; animation-delay: 0.4s; }

@keyframes sl-wave {
  from { transform: scaleY(0.4); opacity: 0.6; }
  to   { transform: scaleY(1);   opacity: 1; }
}

/* 再生ボタン */
.sl-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-card2);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sl-play-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 12px hsla(215, 90%, 58%, 0.4);
  transform: scale(1.08);
}
.songlist-item.sl-playing .sl-play-btn {
  background: hsla(215, 90%, 58%, 0.2);
  border-color: var(--primary);
  color: var(--primary-glow);
}

/* 検索結果なし */
.sl-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}
