:root {
  --background-image: none;
  --image-overlay: rgba(18, 18, 19, .86);

  --background: #121213;
  --text: #ffffff;
  --muted-text: #818384;
  --border: #3a3a3c;
  --border-active: #565758;
  --key-gray: #818384;
  --key-gray-text: #ffffff;
  --wrong-gray: #3a3a3c;
  --correct-green: #538d4e;
  --main-button: #ffffff;
  --main-button-text: #121213;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  font-family: 'Libre Franklin', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(var(--image-overlay), var(--image-overlay)),
    var(--background-image) center top / cover no-repeat,
    var(--background);
}

.hidden { display: none !important; }
.centered { text-align: center; }

.site-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 6px 14px;
  background: rgba(0, 0, 0, .65);
  border-bottom: 1px solid var(--border);
}

.site-title {
  margin: 0;
  font-family: 'Roboto Slab', Georgia, serif;
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1.2;
  letter-spacing: .01em;
  text-align: center;
}

.site-quip {
  margin: 2px 0 0;
  color: var(--muted-text);
  font-size: 11px;
  text-align: center;
}
.site-quip:empty { display: none; }

.site-footer {
  margin-top: 10px;
  padding: 12px 16px 16px;
  background: rgba(0, 0, 0, .65);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted-text);
  font-size: 11px;
}

.game {
  flex: 1;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}

.puzzle-number {
  margin-bottom: 8px;
  text-align: center;
  color: var(--muted-text);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 380px;
  margin: 0 auto 14px;
}

.guess-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  padding: 0 14px;
  border: 2px solid var(--border);
  background: rgba(0, 0, 0, .4);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.guess-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guess-seconds {
  flex: none;
  margin-left: 10px;
  color: var(--muted-text);
  font-size: .7rem;
  font-weight: 600;
}

.guess-row.active { border-color: var(--border-active); }

.guess-row.wrong,
.guess-row.skipped {
  background: var(--wrong-gray);
  border-color: var(--wrong-gray);
  color: #fff;
}
.guess-row.skipped .guess-text { opacity: .6; }

.guess-row.correct {
  background: var(--correct-green);
  border-color: var(--correct-green);
  color: #fff;
}

.guess-row.wrong .guess-seconds,
.guess-row.skipped .guess-seconds,
.guess-row.correct .guess-seconds {
  color: inherit;
  opacity: .7;
}

.guess-row.flip { animation: flip .5s ease; }
@keyframes flip {
  0%   { transform: rotateX(0); }
  50%  { transform: rotateX(-90deg); }
  100% { transform: rotateX(0); }
}

.progress-bar {
  position: relative;
  max-width: 380px;
  height: 4px;
  margin: 0 auto 12px;
  background: var(--border);
}
.progress-fill {
  width: 0;
  height: 100%;
  background: var(--text);
}
.progress-marks { position: absolute; inset: 0; }
.progress-marks i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--background);
}

.pill-button {
  height: 46px;
  padding: 0 28px;
  border: 0;
  border-radius: 26px;
  background: var(--main-button);
  color: var(--main-button-text);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.pill-button.green {
  background: var(--correct-green);
  color: #fff;
}

.key-button {
  flex: 1;
  height: 46px;
  border: 0;
  border-radius: 4px;
  background: var(--key-gray);
  color: var(--key-gray-text);
  font: inherit;
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  cursor: pointer;
}
.key-button.dark {
  background: var(--wrong-gray);
  color: #fff;
}

.pill-button:hover,
.key-button:hover { filter: brightness(.93); }

.button-row {
  display: flex;
  gap: 8px;
  max-width: 380px;
  margin: 0 auto;
}

.play-area { margin-bottom: 18px; }

.search-field {
  position: relative;
  max-width: 380px;
  margin: 0 auto 10px;
}

.search-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: rgba(0, 0, 0, .6);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  outline: none;
}
.search-input:focus { border-color: var(--border-active); }
.search-input::placeholder { color: var(--muted-text); font-weight: 600; }

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  max-height: 250px;
  margin: 0;
  padding: 4px;
  overflow: auto;
  list-style: none;
  background: var(--background);
  border: 2px solid var(--border-active);
  border-radius: 4px;
}
.suggestions li {
  padding: 10px;
  border-radius: 3px;
  font-weight: 600;
  font-size: .93rem;
  cursor: pointer;
}
.suggestions li small {
  margin-left: 6px;
  color: var(--muted-text);
  font-weight: 600;
}
.suggestions li.highlighted,
.suggestions li:hover { background: var(--border); }

.countdown {
  margin: 12px 0 0;
  text-align: center;
  color: var(--muted-text);
  font-size: .85rem;
  font-weight: 600;
}
.countdown b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.results {
  position: fixed;
  top: 78px;
  left: 50%;
  z-index: 100;
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 4px;
  background: var(--text);
  color: var(--background);
  font-weight: 700;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.results.show { opacity: 1; }

.popup {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.popup.open {
  opacity: 1;
  pointer-events: auto;
}

.popup-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  padding: 26px 26px 24px;
  overflow: auto;
  text-align: center;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.close-button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.close-button:hover { background: var(--border); }
.close-button svg { width: 26px; height: 26px; fill: currentColor; }

.popup-title {
  margin: 0 0 12px;
  font-size: 1.5rem;
  font-weight: 800;
}

.section-heading {
  margin: 18px 0 12px;
  font-size: .95rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.album-cover {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 10px;
  object-fit: cover;
  background: var(--border);
  border-radius: 4px;
}
.song-info b { display: block; font-size: 1.05rem; }
.song-info small { color: var(--muted-text); font-weight: 600; }

.preview-player {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
}
.play-circle {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--key-gray);
  color: var(--key-gray-text);
  font-size: .95rem;
  cursor: pointer;
}
.preview-time {
  flex: none;
  min-width: 74px;
  text-align: right;
  color: var(--muted-text);
  font-size: .75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.preview-seek {
  flex: 1;
  min-width: 0;
  height: 4px;
  background: var(--border);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.preview-seek::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  -webkit-appearance: none;
}
.preview-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
.preview-note {
  margin: 6px 0 4px;
  color: var(--muted-text);
  font-size: .74rem;
  font-weight: 600;
}
.deezer-link {
  color: var(--text);
  font-size: .82rem;
  font-weight: 700;
}

.stats-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.stat { flex: 1; }
.stat-number {
  font-size: 2.2rem;
  font-weight: 400;
  line-height: 1.1;
}
.stat-label {
  font-size: .68rem;
  line-height: 1.2;
}

.popup-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 20px;
}
.next-label {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.next-time {
  font-size: 2.1rem;
  font-weight: 400;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.footer-divider {
  align-self: stretch;
  width: 1px;
  background: var(--border);
}

@media (max-width: 420px) {
  .site-title { font-size: 1.55rem; }
}
