*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --bg: #09090a;
  --surface: #141210;
  --surface2: #1e1b17;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f5f0e8;
  --muted: rgba(245, 240, 232, 0.38);
  --amber: #e8a020;
  --green: #5cb85c;
  --red: #d95f5f;
  --mono: "Space Mono", monospace;
  --serif: "Playfair Display", serif;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px 64px;
  -webkit-tap-highlight-color: transparent;
}
.wrap {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.hidden {
  display: none !important;
}

.logo {
  text-align: center;
  position: relative;
}
.logo-disc {
  font-size: 28px;
  color: var(--amber);
  display: block;
  margin-bottom: 8px;
}
.logo h1 {
  font-family: var(--serif);
  font-size: 34px;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}
.logo p {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.btn-header {
  position: absolute;
  top: 4px;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.btn-header:hover {
  border-color: var(--amber);
  color: var(--amber);
}
.btn-help {
  left: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
}
.btn-stats {
  right: 0;
}

.mode-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.mode-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}
.mode-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text);
}
.mode-btn.active {
  background: var(--amber);
  color: #0a0908;
  border-color: var(--amber);
  font-weight: 700;
}

.loader {
  text-align: center;
  padding: 40px 0;
}
.spinner {
  width: 38px;
  height: 38px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loader-msg {
  font-size: 12px;
  color: var(--muted);
}

.error-card {
  background: var(--surface);
  border: 1px solid rgba(217, 95, 95, 0.3);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
}
.error-card h2 {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--red);
  margin-bottom: 10px;
}
.error-card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 20px;
}
.btn-retry {
  background: var(--amber);
  color: #0a0908;
  border: none;
  border-radius: 9px;
  padding: 12px 28px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-retry:hover {
  opacity: 0.88;
}

#view-game {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cover-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.cover-frame {
  width: 280px;
  height: 280px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9);
  flex-shrink: 0;
}
.cover-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 1.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.cover-frame.won {
  animation: coverPulse 0.6s ease;
}
@keyframes coverPulse {
  0% {
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9);
  }
  50% {
    box-shadow:
      0 0 40px rgba(232, 160, 32, 0.5),
      0 24px 60px rgba(0, 0, 0, 0.9);
  }
  100% {
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9);
  }
}
.cover-scan {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.13) 3px,
    rgba(0, 0, 0, 0.13) 4px
  );
  pointer-events: none;
  transition: opacity 0.6s;
}

.pips {
  display: flex;
  gap: 8px;
}
.pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition:
    background 0.5s,
    transform 0.3s;
}
.pip.pop {
  animation: pipPop 0.4s ease;
}
@keyframes pipPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.8);
  }
  100% {
    transform: scale(1);
  }
}

.player {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.player-top {
  display: flex;
  align-items: center;
  gap: 14px;
}
.btn-play {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--amber);
  border: none;
  cursor: pointer;
  font-size: 17px;
  color: #0a0908;
  font-weight: bold;
  flex-shrink: 0;
  transition:
    transform 0.15s,
    opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-play:hover:not(:disabled) {
  transform: scale(1.06);
}
.btn-play:active:not(:disabled) {
  transform: scale(0.95);
}
.btn-play:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.player-info .round-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}
.player-info .dur-label {
  font-size: 13px;
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.volume-icon {
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s;
}
.volume-icon:hover {
  color: var(--text);
}
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 60px;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
}
.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--amber);
  border: none;
  cursor: pointer;
}

.progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--amber);
  border-radius: 99px;
  width: 0%;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.guess-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
  font-size: 13px;
  overflow: hidden;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.guess-icon {
  min-width: 18px;
}
.guess-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guess-row-artist {
  border-color: rgba(232, 160, 32, 0.25);
  background: rgba(232, 160, 32, 0.06);
}

.btn-see-result {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  padding: 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-see-result:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.input-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.input-wrap {
  position: relative;
}
.ginput {
  width: 100%;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 13px 16px;
  outline: none;
  transition: border-color 0.2s;
}
.ginput:focus {
  border-color: var(--amber);
}
.ginput::placeholder {
  color: rgba(245, 240, 232, 0.22);
}
.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #1c1a16;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  overflow: hidden;
  z-index: 50;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.75);
}
.sug-item {
  padding: 11px 16px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sug-item:last-child {
  border-bottom: none;
}
.sug-item:hover,
.sug-item.active {
  background: rgba(232, 160, 32, 0.14);
}
.sug-album {
  color: var(--amber);
}
.sug-artist {
  color: rgba(245, 240, 232, 0.4);
  margin-left: 8px;
}
.sug-loading {
  padding: 12px 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-skip {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(245, 240, 232, 0.45);
  font-family: var(--mono);
  font-size: 12px;
  padding: 10px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-skip:hover {
  border-color: rgba(255, 255, 255, 0.36);
  color: var(--text);
}
.att-left {
  font-size: 11px;
  color: rgba(245, 240, 232, 0.26);
  margin-left: auto;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fi 0.25s ease;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 30px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: su 0.3s ease;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-cover {
  width: 130px;
  height: 130px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin: 0 auto 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}
.modal-title {
  font-family: var(--serif);
  font-size: 26px;
  margin-bottom: 10px;
}
.modal-album {
  font-size: 16px;
  margin-bottom: 4px;
}
.modal-artist {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.modal-track {
  font-size: 11px;
  color: rgba(245, 240, 232, 0.25);
  font-style: italic;
  margin-bottom: 20px;
}
.modal-won {
  font-size: 12px;
  color: var(--amber);
  margin-bottom: 6px;
}
.modal-countdown {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 20px;
}
.btn-share {
  display: block;
  width: 100%;
  background: var(--amber);
  color: #0a0908;
  border: none;
  border-radius: 9px;
  padding: 13px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 10px;
  transition: opacity 0.2s;
}
.btn-share:hover {
  opacity: 0.85;
}
.btn-close {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-close:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.24);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.stat-box {
  text-align: center;
}
.stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.stat-label {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
}
.dist-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  text-align: left;
}
.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 12px;
}
.dist-label {
  width: 14px;
  text-align: right;
  color: var(--muted);
  flex-shrink: 0;
}
.dist-bar {
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  min-width: 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6px;
  font-size: 10px;
  color: var(--bg);
  font-weight: 700;
  transition: width 0.6s ease;
}
.dist-bar.highlight {
  background: var(--amber);
}

@keyframes fi {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes su {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.help-content {
  text-align: left;
  font-size: 13px;
  line-height: 1.7;
  color: rgba(245, 240, 232, 0.75);
}
.help-content strong {
  color: var(--text);
}
.help-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.help-step {
  display: flex;
  align-items: center;
  gap: 12px;
}
.help-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--amber);
  color: #0a0908;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.help-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}
.help-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.help-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.help-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
}
.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  top: -10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 10px 20px;
  border-radius: 8px;
  z-index: 300;
  animation:
    toastIn 0.3s ease,
    toastOut 0.3s ease 1.4s forwards;
  pointer-events: none;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
@keyframes toastOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
