:root {
  --bg-void: #090a0d;
  --bg-deck: #111318;
  --bg-well: #060709;
  --surface-card: #161820;
  --surface-raised: #1e202b;
  --border-hairline: rgba(255, 255, 255, 0.08);
  --border-bevel: rgba(255, 255, 255, 0.14);
  --text-ink: #f4f4f6;
  --text-body: #d1d3dc;
  --text-muted: #8e92a4;
  --amber-alert: #f59e0b;
  --danger: #ef4444;
  --room-accent: #f59e0b;

  --r-outer: 14px;
  --r-inner: 8px;
  --r-pill: 999px;

  --ease-hardware: cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: "Alumni Sans", "Plus Jakarta Sans", sans-serif;
  --font-heading: "Plus Jakarta Sans", "Albert Sans", sans-serif;
  --font-body: "Albert Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-void);
  color: var(--text-ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.mono-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Tactile SVG film grain */
.grain-svg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 90;
  opacity: 0.04;
}

.yt-host-hidden {
  position: fixed;
  right: 4px;
  bottom: 4px;
  width: 200px;
  height: 200px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.001;
  z-index: -1;
}

.yt-host-hidden:not(.is-room-visible) .yt-monitor-bar,
.yt-host-hidden.is-room-visible.is-minimized .yt-monitor-bar,
.app-shell.is-keyboard-open ~ .yt-host-hidden.is-room-visible .yt-monitor-bar {
  display: none;
}

.yt-host-hidden.is-room-visible {
  opacity: 1;
  pointer-events: auto;
  z-index: 35;
  right: 20px;
  top: 172px;
  bottom: auto;
  width: 202px;
  height: auto;
  background: var(--bg-deck);
  border: 1px solid var(--border-bevel);
  border-radius: var(--r-inner);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}

.yt-host-hidden.is-room-visible.is-minimized,
.app-shell.is-keyboard-open ~ .yt-host-hidden.is-room-visible {
  opacity: 0.001;
  pointer-events: none;
  z-index: -1;
  right: 4px;
  bottom: 4px;
  top: auto;
  width: 200px;
  height: 200px;
  border: none;
  box-shadow: none;
}

.yt-monitor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-hairline);
}

.yt-monitor-title {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

.yt-monitor-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.yt-monitor-link {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--amber-alert);
  text-decoration: none;
}

.yt-monitor-link:hover {
  text-decoration: underline;
}

.yt-monitor-close {
  width: 20px;
  height: 20px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--border-bevel);
  background: var(--bg-well);
  color: var(--text-ink);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.yt-monitor-close:hover {
  background: var(--surface-raised);
}

.yt-monitor-screen {
  width: 200px;
  height: 200px;
  background: #000;
  overflow: hidden;
  line-height: 0;
}

.yt-monitor-screen iframe {
  display: block;
  width: 200px;
  height: 200px;
  border: 0;
}

/* Main hardware shell */
.app-shell {
  min-height: 100dvh;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

.app-shell.is-room-active {
  height: 100dvh;
  max-height: 100dvh;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}

.app-shell.is-final-ten::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  border: 2px solid rgba(245, 158, 11, 0.55);
  box-shadow: inset 0 0 42px rgba(245, 158, 11, 0.16);
  z-index: 60;
  animation: amberPerimeterPulse 1s var(--ease-hardware) infinite alternate;
}

@keyframes amberPerimeterPulse {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

/* Header */
.deck-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-deck);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-outer);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-spool {
  color: var(--amber-alert);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text-ink);
}

.brand-code {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.header-telemetry {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.live-counter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--text-body);
}

.counter-label {
  color: var(--text-muted);
}

.led-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}

.led-live {
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.65);
}

/* Tactile Buttons */
.icon-keycap,
.btn-hardware,
.btn-primary-amber,
.btn-rewind,
.btn-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-inner);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 150ms var(--ease-hardware), background-color 150ms var(--ease-hardware), border-color 150ms var(--ease-hardware), opacity 150ms var(--ease-hardware);
}

.icon-keycap:focus-visible,
.btn-hardware:focus-visible,
.btn-primary-amber:focus-visible,
.btn-rewind:focus-visible,
.btn-send:focus-visible,
.tape-card:focus-visible,
.chat-bubble-btn:focus-visible {
  outline: 2px solid var(--amber-alert);
  outline-offset: 2px;
}

.icon-keycap {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--surface-card);
  color: var(--text-ink);
  border: 1px solid var(--border-bevel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.icon-keycap:hover,
.btn-hardware:hover {
  background: var(--surface-raised);
  border-color: rgba(255, 255, 255, 0.24);
}

.icon-keycap:active,
.btn-hardware:active,
.btn-primary-amber:active,
.btn-rewind:active,
.btn-send:active {
  transform: translateY(1px);
}

.btn-hardware {
  padding: 10px 16px;
  background: var(--surface-card);
  color: var(--text-ink);
  border: 1px solid var(--border-bevel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.btn-small {
  padding: 7px 12px;
  font-size: 12px;
}

.btn-ambience.is-active {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.14);
  color: #fde68a;
}

.btn-danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.28);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.5);
}

.btn-primary-amber {
  padding: 11px 18px;
  background: var(--amber-alert);
  color: #0b0b0e;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary-amber:hover {
  background: #fbbf24;
}

/* View 1: Deck Landing */
.stage-deck {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-top: 12px;
}

.hero-statement {
  max-width: 72ch;
}

.hero-statement h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.85rem, 6vw, 4.6rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
  text-wrap: balance;
  color: var(--text-ink);
}

.hero-lead {
  margin: 0;
  color: var(--text-body);
  font-size: 1rem;
  line-height: 1.6;
  text-wrap: pretty;
}

/* Quick Match Bar */
.quick-match-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(17, 19, 24, 0.96));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--r-outer);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.quick-match-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.quick-match-badge {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--amber-alert);
  font-weight: 500;
}

.quick-match-text {
  margin: 0;
  font-size: 14px;
  color: var(--text-ink);
  text-wrap: pretty;
}

.btn-quick-match {
  flex-shrink: 0;
  padding: 12px 20px;
  font-size: 14px;
}

.cooldown-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.36);
  border-radius: var(--r-inner);
  color: #fde68a;
  font-size: 13px;
}

.section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.section-meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* 6 Cassette Rack */
.tape-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.tape-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  text-align: left;
  padding: 18px;
  background: var(--bg-deck);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-outer);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--text-ink);
  cursor: pointer;
  transition: transform 170ms var(--ease-hardware), border-color 170ms var(--ease-hardware), background-color 170ms var(--ease-hardware);
}

.tape-card:hover {
  transform: translateY(-2px);
  background: var(--surface-card);
  border-color: var(--tape-accent, var(--border-bevel));
}

.tape-card:active {
  transform: translateY(1px);
}

.tape-card.is-waiting-ready {
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 1px rgba(245, 158, 11, 0.14);
}

.tape-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tape-waiting-badge,
.tape-midnight-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.tape-waiting-badge {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.42);
  color: #fde68a;
}

.tape-midnight-badge {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.34);
  color: #bae6fd;
}

.tape-midnight-badge.is-night-active {
  background: rgba(56, 189, 248, 0.22);
  border-color: rgba(56, 189, 248, 0.65);
  color: #e0f2fe;
}

.tape-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tape-code-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tape-diode {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tape-accent);
}

.tape-code {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.tape-window {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-pill);
}

.tape-window-spool {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
}

.tape-window-bridge {
  width: 14px;
  height: 2px;
  background: var(--tape-accent);
  opacity: 0.75;
}

.tape-body h2 {
  margin: 0 0 6px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.tape-artists {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  text-wrap: pretty;
}

.tape-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
  font-size: 12px;
  color: var(--text-body);
}

.tape-listeners {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tape-listeners .led-dot {
  width: 6px;
  height: 6px;
}

.tape-action-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--tape-accent);
}

.deck-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
  color: var(--text-muted);
  font-size: 13px;
}

.deck-footer p {
  margin: 0;
  text-wrap: pretty;
}

.deck-footer-links {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.deck-footer-links a {
  color: var(--text-body);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  padding-bottom: 1px;
  transition: color 150ms var(--ease-hardware), border-color 150ms var(--ease-hardware);
}

.deck-footer-links a:hover {
  color: var(--amber-alert);
  border-color: var(--amber-alert);
}

/* View 2: Queue / Matchmaking */
.stage-queue {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}

.queue-hardware-well {
  width: 100%;
  max-width: 460px;
  padding: 32px 24px;
  background: var(--bg-deck);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-outer);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
}

.cassette-mechanism {
  width: 240px;
}

.cassette-svg {
  width: 100%;
  height: auto;
  display: block;
}

.spool-left,
.spool-right {
  transform-box: fill-box;
  transform-origin: center;
  animation: spinSlow 2.6s linear infinite;
}

.spinning {
  animation: spinSlow 3.4s linear infinite;
}

@keyframes spinSlow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.queue-status-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.queue-code {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--room-accent);
}

.queue-status-block h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.queue-message {
  margin: 4px 0 0;
  color: var(--text-ink);
  font-weight: 500;
}

.queue-subtext {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  text-wrap: pretty;
}

.queue-preview-status {
  margin: 6px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber-alert);
}

.queue-actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

/* View 3: Chat Room */
.stage-room {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-deck);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-outer);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.room-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-hairline);
}

.room-track-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mini-spool {
  color: var(--room-accent);
  flex-shrink: 0;
}

.track-titles {
  min-width: 0;
}

.track-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.room-yt-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber-alert);
  text-decoration: none;
  white-space: nowrap;
}

.room-yt-link:hover {
  text-decoration: underline;
}

.tape-pill,
.extension-pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.extension-pill {
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}

.track-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.timer-readout {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 4px 10px;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-inner);
}

.timer-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  line-height: 1.1;
}

.timer-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-ink);
  line-height: 1.25;
}

.is-final-ten .timer-value {
  color: var(--amber-alert);
}

.progress-rail {
  width: 100%;
  height: 3px;
  background: var(--bg-well);
  overflow: hidden;
}

.progress-fill {
  width: 100%;
  height: 100%;
  background: var(--room-accent);
  transform-origin: left center;
  transform: scaleX(1);
  will-change: transform;
}

.is-final-ten .progress-fill {
  background: var(--amber-alert);
}

/* Mobile Autoplay Unlock Bar */
.audio-unlock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(245, 158, 11, 0.12);
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
}

.audio-unlock-copy {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-ink);
  min-width: 0;
}

.led-amber {
  background: var(--amber-alert);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
}

/* Chat feed */
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  overflow-anchor: none;
  touch-action: pan-y;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-well);
}

.icebreaker-bar {
  align-self: center;
  width: 100%;
  max-width: 60ch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.icebreaker-note {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-inner);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  text-wrap: pretty;
}

.btn-icebreaker-dice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-hairline);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: color 150ms var(--ease-hardware), border-color 150ms var(--ease-hardware), background-color 150ms var(--ease-hardware);
}

.btn-icebreaker-dice:hover {
  color: var(--text-ink);
  border-color: var(--border-bevel);
  background: var(--surface-card);
}

.system-banner {
  align-self: center;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
  font-size: 12px;
  text-align: center;
}

.chat-messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 600ms var(--ease-hardware), transform 600ms var(--ease-hardware);
}

.chat-messages.is-dissolving {
  opacity: 0;
  transform: translateY(-18px) scale(0.98);
}

.chat-row {
  display: flex;
  flex-direction: column;
  max-width: min(76%, 540px);
}

.chat-row.is-self {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-row.is-partner {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-bubble-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-card);
  color: var(--text-ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.48;
  cursor: pointer;
  transition: border-color 150ms var(--ease-hardware), background-color 150ms var(--ease-hardware);
}

.chat-row.is-self .chat-bubble-btn {
  background: #1c202c;
  border-color: rgba(255, 255, 255, 0.14);
}

.chat-bubble-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.chat-bubble-btn.is-pinned {
  border-color: var(--amber-alert);
  background: rgba(245, 158, 11, 0.1);
}

.chat-bubble-btn.is-pending {
  opacity: 0.72;
  border-style: dashed;
}

.chat-bubble-btn.is-failed {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.1);
}

.chat-bubble-btn.is-failed .chat-meta {
  color: #fca5a5;
}

.chat-text {
  word-break: break-word;
  text-wrap: pretty;
}

.chat-text.is-masked {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber-alert);
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.pin-tag {
  color: var(--amber-alert);
  font-weight: 600;
}

/* Last 10 seconds Rewind Panel */
.rewind-panel {
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.12);
  border-top: 1px solid rgba(245, 158, 11, 0.38);
}

.rewind-panel-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.rewind-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rewind-tag {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--amber-alert);
}

.rewind-copy p {
  margin: 0;
  font-size: 13px;
  color: var(--text-ink);
  text-wrap: pretty;
}

.btn-rewind {
  padding: 11px 18px;
  background: var(--amber-alert);
  color: #0b0b0e;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.btn-rewind:hover {
  background: #fbbf24;
}

.btn-rewind[disabled] {
  opacity: 0.72;
  cursor: default;
}

.rewind-candidates {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(245, 158, 11, 0.25);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rewind-candidates-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #fde68a;
}

.rewind-candidate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.rewind-candidate-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 8px 10px;
  border-radius: var(--r-inner);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: var(--bg-deck);
  color: var(--text-ink);
  font-family: var(--font-body);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms var(--ease-hardware), background-color 150ms var(--ease-hardware);
}

.rewind-candidate-btn:hover {
  border-color: var(--amber-alert);
  background: var(--surface-card);
}

.rewind-candidate-btn.is-selected {
  border-color: var(--amber-alert);
  background: rgba(245, 158, 11, 0.18);
}

.rewind-candidate-btn.is-partner::after {
  content: "Yabancının seçimi";
  font-family: var(--font-mono);
  font-size: 10px;
  color: #fde68a;
}

.rewind-candidate-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* Composer & Live Pulse Waveform */
.chat-composer-wrap {
  padding: 10px 16px 14px;
  background: var(--bg-deck);
  border-top: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pulse-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 18px;
}

.pulse-wave {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 16px;
  opacity: 0.35;
  transition: opacity 150ms var(--ease-hardware);
}

.pulse-wave span {
  display: block;
  width: 2px;
  height: 12px;
  border-radius: 2px;
  background: var(--room-accent);
  transform: scaleY(0.22);
  transition: transform 140ms var(--ease-hardware);
}

.pulse-wave.is-pulsing {
  opacity: 1;
}

.pulse-wave.is-pulsing span:nth-child(3n) {
  transform: scaleY(0.95);
}

.pulse-wave.is-pulsing span:nth-child(3n + 1) {
  transform: scaleY(0.55);
}

.pulse-wave.is-pulsing span:nth-child(3n + 2) {
  transform: scaleY(0.78);
}

.filter-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.filter-hint.is-open {
  color: var(--amber-alert);
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  background: var(--bg-well);
  color: var(--text-ink);
  border: 1px solid var(--border-bevel);
  border-radius: var(--r-inner);
  font-family: var(--font-body);
  font-size: 15px;
}

.chat-form input::placeholder {
  color: var(--text-muted);
}

.chat-form input:focus {
  outline: none;
  border-color: var(--room-accent);
}

.btn-send {
  width: 42px;
  height: 42px;
  padding: 0;
  background: var(--surface-raised);
  color: var(--text-ink);
  border: 1px solid var(--border-bevel);
}

.btn-send:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

/* View 4: Dark Ending */
.stage-ended {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ended-card {
  max-width: 520px;
  width: 100%;
  padding: 36px 28px;
  background: #050507;
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-outer);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.ended-code {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.ended-card h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1.25;
  text-wrap: balance;
}

.ended-subtext {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 14px;
  text-wrap: pretty;
}

.ended-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* Receipt Dialog */
.receipt-dialog {
  padding: 0;
  border: none;
  background: transparent;
  max-width: min(440px, calc(100vw - 24px));
  width: 100%;
  color: var(--text-ink);
}

.receipt-dialog::backdrop {
  background: rgba(4, 5, 8, 0.84);
  backdrop-filter: blur(6px);
}

.receipt-dialog-surface {
  background: var(--bg-deck);
  border: 1px solid var(--border-bevel);
  border-radius: var(--r-outer);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.receipt-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.receipt-dialog-header h3 {
  margin: 2px 0 0;
  font-family: var(--font-heading);
  font-size: 1.25rem;
}

.receipt-theme-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-inner);
}

.receipt-theme-btn {
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease-hardware), color 150ms var(--ease-hardware);
}

.receipt-theme-btn.is-active {
  background: var(--surface-raised);
  color: var(--text-ink);
}

.receipt-quote-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.receipt-quote-picker select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-well);
  color: var(--text-ink);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-inner);
  font-family: var(--font-body);
  font-size: 13px;
}

.receipt-canvas-well {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-inner);
  overflow: auto;
}

#receipt-canvas {
  width: 100%;
  max-width: 340px;
  height: auto;
  display: block;
}

#receipt-canvas.is-story {
  max-width: 260px;
}

.receipt-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.receipt-dialog-actions > button {
  flex: 1;
}

/* Custom Track & Open Waiting Songs */
.waiting-songs-section,
.custom-deck-panel {
  display: flex;
  flex-direction: column;
}

.waiting-songs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.waiting-song-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-deck);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-outer);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.waiting-song-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.waiting-song-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.waiting-song-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.waiting-song-count .led-dot {
  width: 6px;
  height: 6px;
  background: var(--amber-alert);
}

.custom-track-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg-deck);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-outer);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.custom-select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-well);
  color: var(--text-ink);
  border: 1px solid var(--border-bevel);
  border-radius: var(--r-inner);
  font-family: var(--font-body);
  font-size: 14px;
}

.custom-select:focus {
  outline: none;
  border-color: var(--amber-alert);
}

.custom-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-input-row input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  background: var(--bg-well);
  color: var(--text-ink);
  border: 1px solid var(--border-bevel);
  border-radius: var(--r-inner);
  font-family: var(--font-body);
  font-size: 14px;
}

.custom-input-row input::placeholder {
  color: var(--text-muted);
}

.custom-input-row input:focus {
  outline: none;
  border-color: var(--amber-alert);
}

.custom-track-error {
  margin: 0;
  font-size: 13px;
  color: #fca5a5;
}

/* Legal / Copyright Page */
.legal-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.legal-card {
  background: var(--bg-deck);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-outer);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.legal-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-hairline);
}

.legal-badge {
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--amber-alert);
}

.legal-header h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-ink);
}

.legal-lead {
  margin: 0;
  color: var(--text-body);
  font-size: 15px;
  text-wrap: pretty;
}

.legal-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legal-section h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-ink);
}

.legal-section p {
  margin: 0;
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.65;
  text-wrap: pretty;
}

.legal-section a {
  color: var(--amber-alert);
  text-decoration: none;
  border-bottom: 1px solid rgba(245, 158, 11, 0.38);
}

.legal-section a:hover {
  border-color: var(--amber-alert);
}

.legal-list {
  margin: 4px 0 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.6;
}

.legal-notice-box {
  padding: 16px 18px;
  background: var(--bg-well);
  border: 1px solid var(--border-bevel);
  border-left: 3px solid var(--amber-alert);
  border-radius: var(--r-inner);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legal-notice-box strong {
  color: var(--text-ink);
  font-size: 14px;
}

.legal-notice-box code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber-alert);
}

.legal-back-link {
  text-decoration: none;
}

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .tape-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body.is-room-locked {
    overflow: hidden;
    overscroll-behavior: none;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  .app-shell {
    padding: 12px 14px 18px;
    gap: 14px;
  }

  .app-shell.is-room-active {
    position: fixed;
    top: var(--vvt, 0px);
    left: 0;
    right: 0;
    width: 100%;
    height: var(--vvh, 100dvh);
    max-height: var(--vvh, 100dvh);
    padding: 0;
    gap: 0;
    overflow: hidden;
    z-index: 20;
  }

  .app-shell.is-room-active .deck-header {
    display: none;
  }

  .app-shell.is-room-active .stage-room {
    height: 100%;
    min-height: 0;
    border: none;
    border-radius: 0;
  }

  .quick-match-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    gap: 12px;
  }

  .btn-quick-match {
    width: 100%;
    justify-content: center;
  }

  .deck-header {
    padding: 10px 12px;
  }

  .counter-label {
    display: none;
  }

  .tape-grid {
    grid-template-columns: 1fr;
  }

  .waiting-songs-grid {
    grid-template-columns: 1fr;
  }

  .waiting-song-card {
    flex-direction: column;
    align-items: stretch;
  }

  .custom-input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-form input,
  .custom-input-row input,
  .custom-select {
    font-size: 16px;
  }

  .section-bar {
    flex-direction: column;
    gap: 2px;
  }

  .room-top-bar {
    flex-shrink: 0;
    flex-wrap: nowrap;
    padding: 8px 10px;
    gap: 8px;
  }

  .room-controls {
    gap: 6px;
  }

  .timer-readout {
    padding: 3px 8px;
  }

  .btn-label-desktop {
    display: none;
  }

  .rewind-panel-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .audio-unlock-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-scroll {
    padding: 10px 12px;
    gap: 10px;
  }

  .chat-row {
    max-width: 88%;
  }

  .chat-composer-wrap {
    flex-shrink: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--surface-card);
    gap: 6px;
  }

  .chat-form {
    gap: 8px;
  }

  .chat-form input {
    min-height: 42px;
    height: 42px;
    padding: 9px 14px;
    border-radius: 20px;
    font-size: 16px;
    line-height: 1.3;
  }

  .btn-send {
    flex-shrink: 0;
    border-radius: 999px;
  }

  .filter-hint {
    font-size: 11px;
  }

  .app-shell.is-keyboard-open .pulse-strip {
    display: none;
  }

  .rewind-candidate-grid {
    grid-template-columns: 1fr;
  }

  .app-shell.is-keyboard-open .chat-scroll {
    padding: 10px 12px;
    gap: 8px;
  }

  .app-shell.is-keyboard-open .chat-composer-wrap {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 0;
  }

  .yt-host-hidden.is-room-visible {
    top: calc(64px + var(--vvt, 0px));
    right: 10px;
  }

  .app-shell.has-unlock-bar ~ .yt-host-hidden.is-room-visible {
    top: calc(148px + var(--vvt, 0px));
  }

  .legal-card {
    padding: 20px 16px;
  }
}

/* Matchmaking Engine v2 — Queue Live Radar & Flexible Controls */
.queue-live-radar {
  width: 100%;
  max-width: 520px;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-inner);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-radar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.queue-radar-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.queue-radar-note {
  font-size: 12px;
  color: var(--amber-alert);
}

.queue-radar-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.queue-radar-chip {
  appearance: none;
  background: var(--surface-card);
  color: var(--text-ink);
  border: 1px solid var(--border-bevel);
  border-radius: var(--r-inner);
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 140ms var(--ease-hardware), background-color 140ms var(--ease-hardware);
}

.queue-radar-chip:hover,
.queue-radar-chip:focus-visible {
  border-color: var(--amber-alert);
  background: var(--surface-raised);
  outline: none;
}

.queue-radar-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--amber-alert);
}

.btn-hardware.is-active {
  border-color: var(--amber-alert);
  color: var(--amber-alert);
  background: rgba(245, 158, 11, 0.08);
}

.queue-flexible-hint {
  color: var(--amber-alert);
}

#btn-skip-room[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

#btn-skip-room.is-active {
  border-color: var(--amber-alert);
  color: var(--amber-alert);
  background: rgba(245, 158, 11, 0.1);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
