:root {
  --bg: #0b0b0d;
  --panel: #17171a;
  --panel-2: #1f1f23;
  --accent: #22c55e;
  --accent-dim: #16a34a;
  --accent-rgb: 34, 197, 94;
  --green: #22c55e;
  --medium: #d4a017;
  --red: #e5484d;
  --purple: #a970ff;
  --text: #f2f2f2;
  --text-dim: #9a9aa0;
  --border: #2b2b30;
}

* { box-sizing: border-box; }

/* Author styles below (e.g. .screen{display:flex}, .app{display:grid}) would
   otherwise beat the UA's default [hidden]{display:none} in the cascade —
   force it explicitly so screen/panel toggling via the `hidden` attribute
   always works. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ---------------------------------------------------------------- screens */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  max-width: 440px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px;
}

.login-card h1 {
  margin: 0 0 12px;
  font-size: 28px;
}

.subtitle {
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 24px;
  font-size: 14px;
}

.error-text {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 20px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---------------------------------------------------------------- buttons */
.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #17170a;
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-dark {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  padding: 10px 16px;
}
.btn-dark:hover { background: #26262b; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12px;
}

/* ---------------------------------------------------------------- layout */
.app {
  display: grid;
  grid-template-columns: 220px minmax(320px, 560px) 240px;
  gap: 24px;
  justify-content: center;
  align-items: start;
  padding: 48px 24px;
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.panel-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: space-between;
  min-height: 320px;
}

.panel-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 24px;
}

.panel-right {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ------------------------------------------------------------- ad slot */
.ad-slot {
  max-width: 728px;
  margin: 0 auto 32px;
  padding: 12px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 60px;
}

.ad-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* --------------------------------------------------------- difficulty list */
.difficulty-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.difficulty-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  letter-spacing: 0.2px;
}

.difficulty-btn.current {
  background: var(--accent);
  color: #17170a;
}

.difficulty-btn.cleared {
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--green);
}

.difficulty-btn.failed {
  background: rgba(229, 72, 77, 0.18);
  color: var(--red);
}

.account-btn {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reroll-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.no-login-note {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

.settings-hint {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
}

/* Live "X online" badge -- see public/presence.js. Hidden by default and
   only revealed once a real count comes back (i.e. the site is actually
   deployed on Netlify with the heartbeat function available). */
.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}
.online-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.9);
}

/* -------------------------------------------------------------- round pills */
.round-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.round-pill {
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  background: var(--panel-2);
  color: var(--text-dim);
}

.round-pill.easy.current { background: var(--green); color: #06210c; }
.round-pill.medium.current { background: var(--medium); color: #17170a; }
.round-pill.hard.current { background: #ff9f43; color: #2a1400; }
.round-pill.expert.current { background: var(--red); color: #2a0607; }
.round-pill.impossible.current { background: var(--purple); color: #1c0a33; }

.round-pill.cleared { background: rgba(var(--accent-rgb), 0.18); color: var(--green); }

/* -------------------------------------------------------- segmented progress */
.segmented-progress {
  display: flex;
  gap: 4px;
  width: 100%;
}

.segment {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--panel-2);
  overflow: hidden;
  position: relative;
}

.segment .fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
}

.segment.filled .fill { transform: scaleX(1); }
.segment.active .fill { background: var(--accent); animation: fillstage linear forwards; }
.segment.wrong .fill { background: var(--red); transform: scaleX(1); }

@keyframes fillstage {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* -------------------------------------------------------------------- play */
.play-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* A plain circular play button. Audio plays through a hidden <audio>
   element (see audioPlayer.js) that is never attached to the page visibly —
   there's no video anywhere, so nothing to hide: just this button. */
.play-circle {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  background: rgba(var(--accent-rgb), 0.88);
  color: #17170a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.25);
}
.play-circle:hover { background: rgba(var(--accent-rgb), 0.96); }
.play-circle:active { transform: scale(0.94); }
.play-circle:disabled { opacity: 0.5; cursor: not-allowed; }

/* Play/pause/loading icons are all stacked on top of each other and cross-
   fade + morph between states (instead of an instant hidden/visible swap)
   whenever the button's state class changes. */
.play-circle .btn-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5) rotate(-15deg);
  transition: opacity 0.16s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.play-circle #play-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

.play-circle.is-playing #play-icon {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5) rotate(15deg);
}
.play-circle.is-playing #pause-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

.play-circle.loading #play-icon,
.play-circle.loading #pause-icon {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5) rotate(-15deg);
}
.play-circle.loading #loading-icon {
  opacity: 1;
  animation: spinCentered 0.8s linear infinite;
}

/* Same rotation as .spinner's `spin`, but keeps the icon's own
   translate(-50%, -50%) centering (an animated `transform` fully replaces
   the static one, so the centering has to be baked into the keyframes too). */
@keyframes spinCentered {
  from { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  to { transform: translate(-50%, -50%) scale(1) rotate(360deg); }
}

.elapsed-time {
  font-weight: 700;
  color: var(--text-dim);
  font-size: 14px;
}

/* -------------------------------------------------------------- reveal panel */
/* Shown once a run ends (win or lose): the answer's cover art, title and
   artist, with a soft color glow sampled from the artwork itself, plus a
   little pop-in animation -- and a WON!/LOST! pill (green / red). */
.reveal-panel {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0 2px;
  animation: revealPop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes revealPop {
  from { opacity: 0; transform: translateY(10px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.reveal-glow {
  position: absolute;
  inset: -36px -24px auto -24px;
  height: 200px;
  filter: blur(34px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
}

.reveal-cover {
  position: relative;
  z-index: 1;
  width: 112px;
  height: 112px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  margin-bottom: 2px;
}

.reveal-label {
  position: relative;
  z-index: 1;
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.reveal-title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
}

.reveal-subtitle {
  position: relative;
  z-index: 1;
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.reveal-pill {
  position: relative;
  z-index: 1;
  border: 2px solid var(--red);
  color: var(--red);
  border-radius: 999px;
  padding: 6px 22px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.6px;
}

.reveal-pill.win {
  border-color: var(--green);
  color: var(--green);
}

/* ------------------------------------------------------------------ search */
.search-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.search-box {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  gap: 8px;
}

.search-icon { color: var(--text-dim); flex-shrink: 0; }

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
  z-index: 10;
}

.suggestion-item {
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.suggestion-item:hover { background: #2a2a30; }
.suggestion-item .s-title { font-weight: 600; }
.suggestion-item .s-artist { color: var(--text-dim); font-size: 12px; }

.postgame { width: 100%; display: flex; justify-content: center; }

/* -------------------------------------------------------------- right panel */
.settings-group h3 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.pill-toggle {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pill {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.pill-active {
  background: var(--accent);
  color: #17170a;
}

/* Fixed, non-editable stage durations, shown as a wrapping grid of pills
   (not a picker -- clicking them does nothing, by design: see README). */
.stage-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-chip {
  background: var(--accent);
  color: #17170a;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  flex: 1 1 calc(33.333% - 6px);
  text-align: center;
}

.slider {
  width: 100%;
  accent-color: var(--accent);
}

/* ------------------------------------------------------------------ mobile */
@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    max-width: 480px;
    margin: 0 auto;
  }
  .panel-left { flex-direction: row; flex-wrap: wrap; }
  .difficulty-list { flex-direction: row; flex-wrap: wrap; }
}
