:root {
  --bg: #0a0b0d;
  --panel: #121317;
  --border: #23252b;
  --text: #eef0f3;
  --text-dim: #8a8d96;
  --accent: #ff7a3d;
  --accent-2: #ffcf5c;
  --accent-dim: #5c3a24;
  --danger: #ff6b6b;
  --good: #6bffa0;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  min-height: 100vh;
}

code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255,255,255,0.06);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}

.back-link, .topbar-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.back-link:hover, .topbar-link:hover { color: var(--text); }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

/* ── Stage layout ── */
.stage {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  padding: 20px 28px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; }
}

.viewer {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}

.video-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  transform: scaleX(-1); /* mirror for a natural "looking in a mirror" feel */
  background: #050505;
}

@media (max-width: 900px) {
  /* no sibling panel height to match once columns stack, so fall back to a fixed ratio */
  .video-wrap { height: auto; aspect-ratio: 7 / 5; }
}

#video, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* keep HUD/overlay text readable — un-mirror them */
.viewer-overlay, .hud, .roast-overlay {
  transform: scaleX(-1);
}

/* ── Easter egg: rating flash ── */
.roast-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.roast-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255,122,61,0.5), rgba(255,122,61,0) 70%);
  opacity: 0;
}

.roast-text {
  position: relative;
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-shadow: 0 0 24px rgba(255,122,61,0.9), 0 2px 14px rgba(0,0,0,0.7);
  opacity: 0;
}

.roast-overlay.is-active .roast-flash { animation: roast-flash 1.1s ease-out; }
.roast-overlay.is-active .roast-text { animation: roast-text-pop 1.5s cubic-bezier(.2,.9,.3,1); }

@keyframes roast-flash {
  0% { opacity: 0; }
  10% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes roast-text-pop {
  0% { opacity: 0; transform: scale(0.7) translateY(10px); }
  18% { opacity: 1; transform: scale(1.08) translateY(0); }
  28% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(1) translateY(-6px); }
}

.viewer.is-shaking { animation: viewer-shake 0.45s ease-in-out; }

@keyframes viewer-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-10px, 4px) rotate(-1deg); }
  40% { transform: translate(8px, -6px) rotate(1deg); }
  60% { transform: translate(-6px, 6px) rotate(-0.6deg); }
  80% { transform: translate(6px, -3px) rotate(0.6deg); }
}

.viewer-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,11,13,0.75), rgba(10,11,13,0.96));
  text-align: center;
  padding: 20px;
}
.viewer-overlay[hidden] { display: none; }

.start-card {
  max-width: 380px;
}

.start-icon { font-size: 2.4rem; margin-bottom: 6px; }

.start-card h1 {
  font-size: 1.3rem;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.start-card p {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 20px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #1a0a02;
  border: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 26px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary:disabled {
  background: var(--accent-dim);
  color: var(--text-dim);
  cursor: default;
}

.start-note {
  margin: 14px 0 0 !important;
  font-size: 0.78rem !important;
  color: var(--danger) !important;
}

/* ── HUD ── */
.hud {
  position: absolute;
  display: flex;
  gap: 8px;
  z-index: 5;
}
.hud[hidden] { display: none; }
.hud-top { top: 14px; left: 14px; right: 14px; justify-content: space-between; }

.hud-pill {
  background: rgba(10,11,13,0.72);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 999px;
}

.hud-btn {
  cursor: pointer;
  transition: background 0.2s;
}
.hud-btn:hover { background: rgba(255,107,107,0.25); }

/* ── Side panel ── */
.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.panel-section h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0 0 14px;
}

.panel-note p {
  font-size: 0.83rem;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0;
}

/* ── Score readout ── */
.score-readout {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.score-number {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.score-max {
  font-size: 1.1rem;
  color: var(--text-dim);
}

.score-label {
  margin-top: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-2);
  min-height: 1.3em;
}

.norwood-badge {
  display: inline-block;
  margin-top: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}
.norwood-badge[hidden] { display: none; }

.confidence-track {
  height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s ease-out;
}

.confidence-label {
  margin-top: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.tips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.83rem;
  line-height: 1.4;
  color: var(--text-dim);
}

.tips li { display: flex; align-items: flex-start; gap: 8px; }
.tips .emoji { font-size: 1rem; flex-shrink: 0; }
