:root {
  --bg: #0a0a0a;
  --bg-2: #111;
  --bg-3: #161616;
  --fg: #f4f4f0;
  --fg-dim: #888;
  --fg-dim-2: #555;
  --accent: #C8FF00;
  --accent-2: #ff2d6e;
  --line: #1f1f1f;
  --line-2: #2a2a2a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.display {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 0.85;
  text-transform: uppercase;
}
.display.medium { font-size: clamp(48px, 11vw, 76px); }

.accent { color: var(--accent); }
.dim { color: var(--fg-dim); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ SCREENS ============ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  animation: fadein 0.35s ease;
}
.screen.active { display: flex; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ LOADING ============ */
#screen-loading {
  align-items: center;
  justify-content: center;
}
.loading-pulse {
  width: 16px;
  height: 16px;
  background: var(--accent);
  margin-bottom: 16px;
  animation: pulse 1.2s ease-in-out infinite;
}
.loading-text {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--fg-dim);
}

/* ============ TOPBAR ============ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-shrink: 0;
  min-height: 60px;
}

.logo {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--accent);
  display: inline-block;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.badge {
  font-size: 9px;
  letter-spacing: 0.25em;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 4px 8px;
  border-radius: 100px;
  text-transform: uppercase;
}

.iconbtn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.iconbtn:active { transform: scale(0.92); background: var(--bg-3); }
.iconbtn.muted { color: var(--fg-dim-2); }
.iconbtn.muted #mute-wave { display: none; }

/* ============ INTRO ============ */
.intro-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 24px 24px;
  overflow-y: auto;
}

.intro-tag {
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin-bottom: 14px;
}

.intro-title {
  font-size: clamp(48px, 12vw, 88px);
  margin-bottom: 28px;
}

.intro-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 32px;
}

.meta-block {
  background: var(--bg);
  padding: 14px 12px;
}

.meta-label {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.meta-val {
  font-size: 13px;
  color: var(--fg);
  font-weight: 500;
  line-height: 1.3;
  word-break: break-word;
}

.intro-rules {
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rule {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.5;
}

.rule-num {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 900;
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  min-width: 28px;
}

/* ============ ERROR ============ */
.error-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
}

.error-num {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 900;
  font-size: 96px;
  line-height: 1;
  color: var(--accent-2);
  margin-bottom: 24px;
  letter-spacing: -0.04em;
}

/* ============ FORM / BUTTONS ============ */
.lead {
  font-size: 15px;
  color: var(--fg-dim);
  line-height: 1.6;
  margin-bottom: 28px;
  max-width: 460px;
}

.btn {
  padding: 16px 24px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:active {
  transform: translateY(2px);
}

.btn-block {
  width: 100%;
}

.btn .arrow { transition: transform 0.2s; }
.btn:active .arrow { transform: translateX(4px); }

.hint {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 14px;
  line-height: 1.6;
  text-align: center;
}

.footer-mini {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-dim-2);
  text-align: center;
  padding: 14px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ============ VOTE / DECK ============ */
.vote-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 20px 16px;
  overflow: hidden;
}

.vote-progress {
  flex: 1;
  margin: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#vote-progress-text {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 2px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.deck {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0 24px;
  perspective: 1000px;
}

.card {
  position: absolute;
  width: min(85vw, 360px);
  max-width: 360px;
  aspect-ratio: 3/4;
  max-height: calc(100% - 4px);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease, box-shadow 0.4s ease, border-color 0.4s ease;
  cursor: grab;
  touch-action: none;
  will-change: transform;
}
.card:active { cursor: grabbing; }

.card.swiping { transition: none; }

.card.top {
  z-index: 3;
  border-color: var(--accent);
  box-shadow: 0 24px 60px rgba(200, 255, 0, 0.08);
}
.card.second {
  z-index: 2;
  transform: scale(0.94) translateY(12px);
  opacity: 0.6;
}
.card.third {
  z-index: 1;
  transform: scale(0.88) translateY(24px);
  opacity: 0.3;
}
.card.hidden {
  z-index: 0;
  opacity: 0;
  transform: scale(0.85) translateY(40px);
  pointer-events: none;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  text-transform: uppercase;
}

.card-id { color: var(--accent); }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 20px 0;
}

.waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 120px;
  width: 100%;
}

.waveform .bar {
  flex: 1;
  max-width: 5px;
  background: var(--fg-dim-2);
  border-radius: 2px;
  height: 30%;
  transition: background 0.2s, height 0.1s;
}

.card.top .waveform .bar { background: var(--fg); }
.card.top.playing .waveform .bar { background: var(--accent); }

.card-time {
  margin-top: 16px;
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.15em;
  font-variant-numeric: tabular-nums;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.05em;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.card-meta .label {
  color: var(--fg-dim);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.2em;
  margin-bottom: 4px;
}

/* swipe hint overlays on top card */
.card-overlay {
  position: absolute;
  top: 24px;
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 900;
  font-size: 36px;
  letter-spacing: 0.04em;
  padding: 6px 14px;
  border: 3px solid;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.card-overlay.like {
  right: 24px;
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(12deg);
}
.card-overlay.skip {
  left: 24px;
  color: var(--accent-2);
  border-color: var(--accent-2);
  transform: rotate(-12deg);
}

/* ============ ACTIONS ============ */
.actions {
  display: flex;
  gap: 18px;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.action-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--fg);
  flex-shrink: 0;
}
.action-btn svg { width: 22px; height: 22px; }
.action-btn.play {
  width: 72px;
  height: 72px;
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.action-btn.play svg { width: 28px; height: 28px; }
.action-btn.no { color: var(--accent-2); }
.action-btn.no:active { background: var(--accent-2); color: var(--bg); border-color: var(--accent-2); transform: scale(0.92); }
.action-btn.yes { color: var(--accent); }
.action-btn.yes:active { background: var(--accent); color: var(--bg); border-color: var(--accent); transform: scale(0.92); }
.action-btn.play:active { transform: scale(0.92); }

.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.hint-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-dim-2);
  text-transform: uppercase;
  padding: 0 8px;
  flex-shrink: 0;
}

/* ============ DONE ============ */
.done-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
}

.done-mark {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
  font-weight: 900;
  animation: doneIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.done-mark.dim {
  background: var(--bg-2);
  color: var(--fg-dim);
  border: 1px solid var(--line);
}

@keyframes doneIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.receipt {
  margin: 32px 0;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.receipt-row:last-child { border-bottom: none; }
.receipt-row span:first-child {
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 10px;
}
.receipt-row span:last-child {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* ============ RESPONSIVE ============ */
@media (min-width: 600px) {
  .vote-main { padding: 16px 32px 24px; }
  .intro-main { padding: 40px 40px 32px; max-width: 640px; margin: 0 auto; width: 100%; }
  .done-main, .error-main { max-width: 640px; margin: 0 auto; width: 100%; }
}

@media (max-height: 700px) {
  .intro-rules { gap: 8px; margin-bottom: 20px; }
  .rule { padding: 10px 14px; }
  .intro-title { margin-bottom: 18px; }
  .intro-meta { margin-bottom: 18px; }
}

/* ===== PRELOAD BAR (intro screen) ===== */
.preload-bar-wrap {
  margin-top: 16px;
}
.preload-bar-track {
  width: 100%;
  height: 3px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 8px;
}
.preload-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.preload-status {
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.15em;
  text-align: center;
}
.preload-error {
  color: var(--accent-2);
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

/* ===== PER-CLIP LOADING BAR (vote screen) ===== */
.clip-loading-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 32px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.clip-loading-bar.hidden { display: none; }
.clip-loading-fill {
  flex: 1;
  height: 3px;
  background: var(--accent);
  animation: loadpulse 1s ease-in-out infinite;
  border-radius: 2px;
}
.clip-loading-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  text-transform: uppercase;
  white-space: nowrap;
}
@keyframes loadpulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* disabled start button */
.btn-primary:disabled {
  background: var(--bg-3);
  color: var(--fg-dim);
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ===== REVEAL SCREEN ===== */
.reveal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 24px 24px;
  overflow-y: auto;
}

.reveal-results {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.reveal-row {
  background: var(--bg-2);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 16px;
  align-items: center;
}

.reveal-rank {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 900;
  font-size: 36px;
  color: var(--accent);
  line-height: 1;
}

.reveal-clip-id {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.reveal-dj-name {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 900;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1;
  margin-bottom: 6px;
}

.reveal-meta {
  font-size: 11px;
  color: var(--fg-dim);
}

.reveal-pct {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 900;
  font-size: 32px;
  color: var(--fg);
  line-height: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.reveal-votes {
  font-size: 10px;
  color: var(--fg-dim);
  text-align: right;
  margin-top: 4px;
}

@media (min-width: 600px) {
  .reveal-main { max-width: 640px; margin: 0 auto; width: 100%; }
}
