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

/* ── Themes ───────────────────────────────────────── */
:root {
  --bg:            #0a0a0f;
  --bg-surface:    #0f0f1a;
  --bg-bar:        #1a1a2e;
  --accent:        #6c63ff;
  --accent-hover:  #7d75ff;
  --accent-start:  #5a53dd;
  --accent-alpha:  #6c63ff44;
  --on-accent:     #fff;
  --text:          #e0e0e0;
  --text-typed:    #f0f0f0;
  --tab-inactive:  #666;
  --tab-hover:     #ccc;
  --border:        #252535;
  --border-hover:  #555;
  --label:         #444;
  --dot:           #222232;
  --punct:         #252535;
  --reveal:        #3d3d55;
  --idle-msg:      #333;
  --eye:           #2e2e45;
  --eye-hover:     #666;
  --eye-active:    #888;
  --reset-color:   #555;
  --reset-hover:   #999;
}

[data-theme="warm-midnight"] {
  --bg:            #0f0d0a;
  --bg-surface:    #130f0b;
  --bg-bar:        #1e1810;
  --accent:        #e8a020;
  --accent-hover:  #f0aa28;
  --accent-start:  #c47d10;
  --accent-alpha:  #e8a02044;
  --on-accent:     #0f0d0a;
  --text:          #e8dfd0;
  --text-typed:    #f0e8d8;
  --tab-inactive:  #7a6a55;
  --tab-hover:     #c8b090;
  --border:        #2e2418;
  --border-hover:  #5a4a35;
  --label:         #4a3c2a;
  --dot:           #231e14;
  --punct:         #26201a;
  --reveal:        #4a3c28;
  --idle-msg:      #3a2e20;
  --eye:           #2e2418;
  --eye-hover:     #7a6040;
  --eye-active:    #a07840;
  --reset-color:   #6a5a45;
  --reset-hover:   #a08060;
}

[data-theme="deep-ocean"] {
  --bg:            #080f12;
  --bg-surface:    #091318;
  --bg-bar:        #0a1e2a;
  --accent:        #0ea5e9;
  --accent-hover:  #38bdf8;
  --accent-start:  #0284c7;
  --accent-alpha:  #0ea5e944;
  --on-accent:     #080f12;
  --text:          #c8e0ea;
  --text-typed:    #e0f0f8;
  --tab-inactive:  #3d6a80;
  --tab-hover:     #7ab8d0;
  --border:        #0d2535;
  --border-hover:  #1a4a60;
  --label:         #1a3a4a;
  --dot:           #0d1f28;
  --punct:         #0f2230;
  --reveal:        #1a3a4a;
  --idle-msg:      #152530;
  --eye:           #0d2535;
  --eye-hover:     #3d7a98;
  --eye-active:    #5a9ab8;
  --reset-color:   #3d6a80;
  --reset-hover:   #7ab8d0;
}

/* ── Base ─────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem 4rem;
}

/* ── Header ───────────────────────────────────────── */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.song-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.song-tab {
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: transparent;
  color: var(--tab-inactive);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.song-tab:hover:not(:disabled) {
  border-color: var(--border-hover);
  color: var(--tab-hover);
}

.song-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.song-tab:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Theme switcher ───────────────────────────────── */
.theme-switcher {
  display: flex;
  gap: 0.45rem;
  justify-content: center;
  margin-bottom: 0.25rem;
}

.theme-swatch {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
}

.theme-swatch:hover {
  transform: scale(1.3);
}

.theme-swatch.active {
  transform: scale(1.2);
  border-color: var(--text);
  outline: 2px solid transparent;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px currentColor;
}

/* ── Verse tabs ───────────────────────────────────── */
.verse-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1.5rem;
  max-width: 640px;
}

.verse-tab {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: transparent;
  color: var(--tab-inactive);
  cursor: pointer;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.verse-tab:hover:not(:disabled) {
  border-color: var(--border-hover);
  color: var(--tab-hover);
}

.verse-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.verse-tab:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Progress bar ─────────────────────────────────── */
.progress-bar {
  width: 100%;
  max-width: 640px;
  height: 2px;
  background: var(--bg-bar);
  border-radius: 2px;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

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

/* ── Lyrics display ───────────────────────────────── */
.display-wrapper {
  width: 100%;
  max-width: 640px;
  position: relative;
}

.btn-view-lyrics {
  position: absolute;
  top: 0.75rem;
  right: 0.85rem;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--eye);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-view-lyrics:hover  { color: var(--eye-hover); }
.btn-view-lyrics.active { color: var(--eye-active); }

.btn-view-lyrics svg {
  width: 100%;
  height: 100%;
}

.verse-label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label);
  margin-bottom: 0.75rem;
}

.lyrics-display {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--bg-bar);
  border-radius: 14px;
  padding: 2rem 2.25rem;
  font-size: 1.15rem;
  line-height: 1.95;
  min-height: 180px;
  cursor: text;
  transition: border-color 0.4s;
  word-break: break-word;
}

.lyrics-display.complete { border-color: var(--accent-alpha); }

.idle-msg {
  color: var(--idle-msg);
  font-style: italic;
}

/* ── Character spans ──────────────────────────────── */
.c-typed  { color: var(--text-typed); }
.c-hint   { color: var(--accent); }
.c-cursor {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 3px;
  padding: 0 2px;
  margin: 0 1px;
  animation: blink 1.1s step-end infinite;
}
.c-dot    { color: var(--dot); }
.c-punct  { color: var(--punct); }
.c-reveal { color: var(--reveal); }

@keyframes blink { 50% { opacity: 0; } }

/* ── Controls area ────────────────────────────────── */
.controls-area {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1.5rem;
}

.hint-status {
  font-size: 0.82rem;
  color: var(--label);
  height: 1.1em;
  transition: color 0.2s;
  letter-spacing: 0.02em;
}

.hint-status.hinting { color: var(--accent); }

.buttons {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.btn {
  padding: 0.55rem 1.8rem;
  border: none;
  border-radius: 2rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: transform 0.1s, background 0.15s, color 0.15s;
}

.btn:active { transform: scale(0.97); }

.btn-start {
  background: var(--accent);
  color: var(--on-accent);
}

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

.btn-next {
  background: #22c55e;
  color: #fff;
}

.btn-next:hover { background: #16a34a; }

.btn-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--reset-color);
  padding: 0.55rem 1.4rem;
}

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

.stats {
  font-size: 0.8rem;
  color: var(--label);
  display: flex;
  gap: 2rem;
  margin-top: 0.25rem;
}

.stats span { display: flex; align-items: center; gap: 0.35rem; }

/* ── Shake animation ──────────────────────────────── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-5px); }
  60%      { transform: translateX(5px); }
}

.shake { animation: shake 0.25s ease; }

/* ── Hidden capture input ─────────────────────────── */
#capture {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}
