/* K-Pop Xylophone */
:root {
  --bg-deep: #0a0a1a;
  --bg-card: #111128;
  --neon-cyan: #00f0ff;
  --neon-pink: #ff2d78;
  --neon-purple: #b24dff;
  --neon-gold: #ffd700;
  --text-primary: #e8e8f0;
  --text-secondary: #9090b0;
  --font-main: 'Space Grotesk', system-ui, sans-serif;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
html, body { min-height: 100%; overflow-x: hidden; }

body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.5;
}

/* ─── Topbar ─── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: .75rem 1.5rem;
  background: rgba(10, 10, 26, .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #1e1e3a;
}

.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: color .2s;
}
.back-link:hover { color: var(--neon-cyan); }

/* ─── App ─── */
.xylo-app {
  padding: calc(3rem + 48px) 1.5rem 3rem;
  max-width: 720px;
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: .35rem;
  text-transform: uppercase;
}

.subtitle {
  font-size: .95rem;
  color: var(--text-secondary);
}

/* ─── Song picker ─── */
.song-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.song-label {
  font-size: .85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.song-select {
  flex: 1;
  min-width: 200px;
  padding: .6rem 1rem;
  font-family: var(--font-main);
  font-size: .95rem;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid #2a2a4a;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.song-select:hover,
.song-select:focus {
  border-color: var(--neon-cyan);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 240, 255, .2);
}

.btn {
  padding: .6rem 1rem;
  font-family: var(--font-main);
  font-size: .9rem;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .2s, background .2s;
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid #2a2a4a;
}
.btn-ghost:hover {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}
.btn-play {
  background: var(--neon-cyan);
  color: var(--bg-deep);
  border: none;
}
.btn-play:hover {
  filter: brightness(1.15);
}
.btn-play:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.btn[hidden] { display: none; }

.speed-control {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.speed-label {
  font-size: .85rem;
  color: var(--text-secondary);
}
.speed-option {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .9rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.speed-option input { cursor: pointer; }
.speed-option:hover { color: var(--text-primary); }

/* ─── Instruction box ─── */
.instruction-box {
  background: var(--bg-card);
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  min-height: 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .5rem;
}

.instruction-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.instruction-text.highlight {
  color: var(--neon-cyan);
  text-shadow: 0 0 20px rgba(0, 240, 255, .4);
}

.instruction-progress {
  font-size: .85rem;
  color: var(--text-secondary);
}
.instruction-progress[hidden] { display: none; }

/* ─── Xylophone keys ─── */
.xylo-keys {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: stretch;
  gap: 6px;
  margin-bottom: .75rem;
  padding: 1rem 0;
}

.xylo-key {
  flex: 1;
  min-width: 36px;
  max-width: 72px;
  min-height: 140px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: .9rem;
  color: rgba(255,255,255,.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: .75rem;
  transition: transform .1s var(--ease-out), box-shadow .2s, filter .2s;
  -webkit-tap-highlight-color: transparent;
}

.xylo-key:hover {
  transform: scale(1.02);
  filter: brightness(1.15);
}

.xylo-key:active {
  transform: scale(0.98);
}

.xylo-key.hint {
  box-shadow: 0 0 0 3px var(--neon-cyan), 0 0 24px rgba(0, 240, 255, .35);
  animation: pulse-hint 1s var(--ease-out) infinite;
}

@keyframes pulse-hint {
  0%, 100% { box-shadow: 0 0 0 3px var(--neon-cyan), 0 0 24px rgba(0, 240, 255, .35); }
  50% { box-shadow: 0 0 0 4px var(--neon-cyan), 0 0 32px rgba(0, 240, 255, .5); }
}

/* Key colors (rainbow / xylophone style) */
.xylo-key[data-note="0"] { background: linear-gradient(180deg, #e63946 0%, #c1121f 100%); }
.xylo-key[data-note="1"] { background: linear-gradient(180deg, #f77f00 0%, #d62828 100%); }
.xylo-key[data-note="2"] { background: linear-gradient(180deg, #fcbf49 0%, #e76f51 100%); }
.xylo-key[data-note="3"] { background: linear-gradient(180deg, #2a9d8f 0%, #264653 100%); }
.xylo-key[data-note="4"] { background: linear-gradient(180deg, #06d6a0 0%, #118ab2 100%); }
.xylo-key[data-note="5"] { background: linear-gradient(180deg, #4361ee 0%, #3a0ca3 100%); }
.xylo-key[data-note="6"] { background: linear-gradient(180deg, #7209b7 0%, #560bad 100%); }
.xylo-key[data-note="7"] { background: linear-gradient(180deg, #f72585 0%, #b5179e 100%); }

.key-legend {
  text-align: center;
  font-size: .8rem;
  color: var(--text-secondary);
  letter-spacing: .2em;
}

.footer {
  flex-shrink: 0;
  text-align: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid #1e1e3a;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.footer a { color: var(--text-secondary); text-decoration: none; }

.footer a:hover { color: var(--neon-cyan); }

@media (max-width: 520px) {
  .xylo-app { padding-left: 1rem; padding-right: 1rem; }
  .xylo-key { min-width: 28px; min-height: 120px; font-size: .75rem; }
}

/* Vote widget */
.vote-widget {
  font: inherit;
  background: transparent;
  padding: 0.75rem 1.25rem;
  text-align: right;
  margin-left: auto;
  width: fit-content;
}
.vote-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary, #9090b0);
  margin-bottom: 0.25rem;
}
.vote-nums {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  font-size: 0.95rem;
}
.vote-num {
  cursor: pointer;
  color: var(--text-secondary, #9090b0);
  transition: color 0.15s;
  min-width: 1.2em;
  text-align: center;
}
.vote-num:hover {
  color: var(--neon-pink, #ff2d78);
}
.vote-num.vote-selected {
  color: var(--neon-pink, #ff2d78);
}
.vote-num.vote-grey {
  color: var(--text-secondary, #666);
}
.vote-thanks {
  font-size: 0.75rem;
  color: var(--text-secondary, #666);
  margin-left: 0.5rem;
}
