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

:root {
  --display-hue: 205;
  --display-deepest: hsl(var(--display-hue), 55%, 7%);
  --display-deep: hsl(var(--display-hue), 50%, 11%);
  --display-panel: hsl(var(--display-hue), 45%, 16%);
  --display-card: hsl(var(--display-hue), 40%, 22%);
  --display-border: hsl(var(--display-hue), 35%, 28%);
  --display-accent: hsl(var(--display-hue), 85%, 58%);
  --display-text: #f8fafc;
  --display-muted: #cbd5e1;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #000;
  color: var(--display-text);
}

[hidden] {
  display: none !important;
}

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 0.35rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #0f172a;
  background: #fbbf24;
}

.ad-diag {
  position: fixed;
  right: 0.5rem;
  bottom: 0.5rem;
  z-index: 60;
  margin: 0;
  max-width: min(42vw, 28rem);
  max-height: 40vh;
  overflow: auto;
  padding: 0.4rem 0.55rem;
  font: 11px/1.35 ui-monospace, Consolas, monospace;
  color: #e2e8f0;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.35);
  white-space: pre-wrap;
}

.display-setup {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: #f5f7fa;
  color: #1a1a1a;
}

.pair-code {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: 0.35em;
  margin: 1rem 0;
  font-variant-numeric: tabular-nums;
}

.pair-refresh {
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  border: 0;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.display-stage {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.display-root {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  display: grid;
  grid-template-columns: minmax(0, 85%) minmax(0, 15%);
  background: var(--display-deepest);
  overflow: hidden;
}

.ad-column {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--display-border);
}

.display-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 0.55rem 1rem 0.45rem;
  background: linear-gradient(
    90deg,
    hsl(var(--display-hue), 70%, 22%),
    hsl(var(--display-hue), 55%, 14%)
  );
  border-bottom: 1px solid var(--display-border);
}

.display-business {
  margin: 0;
  font-size: clamp(0.875rem, 1.75vh, 1.1875rem);
  color: var(--display-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.display-screen {
  margin: 0.1rem 0 0;
  font-size: clamp(1.25rem, 3vh, 2rem);
  font-weight: 700;
}

.display-clock {
  margin: 0;
  font-size: clamp(1.25rem, 3vh, 2rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  opacity: 0.9;
  white-space: nowrap;
  color: var(--display-text);
}

.ad-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--display-deep);
}

.ad-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

.ad-image,
.ad-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.ad-media[hidden] {
  display: none !important;
}

/* Lobby ads: no browser chrome (big play, cast/PiP, scrubbers). */
.ad-stage video {
  background: #000;
  pointer-events: none;
}

.ad-stage video.ad-video-pending {
  opacity: 0;
}

.ad-stage video::-webkit-media-controls,
.ad-stage video::-webkit-media-controls-enclosure,
.ad-stage video::-webkit-media-controls-panel,
.ad-stage video::-webkit-media-controls-overlay-enclosure,
.ad-stage video::-webkit-media-controls-overlay-play-button,
.ad-stage video::-webkit-media-controls-start-playback-button,
.ad-stage video::-webkit-media-controls-play-button {
  display: none !important;
  -webkit-appearance: none !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
}

.ad-placeholder {
  margin: 0;
  color: var(--display-muted);
  font-size: clamp(1.25rem, 2.75vh, 1.75rem);
}

.ad-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
}

.ad-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--display-accent);
  transition: width 0.1s linear;
}

.ad-sponsor {
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: clamp(0.9375rem, 2vh, 1.25rem);
  color: var(--display-muted);
  background: var(--display-panel);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--display-panel);
}

.product-heading {
  margin: 0;
  padding: 0.55rem 0.75rem 0.4rem;
  font-size: clamp(1.0625rem, 2.25vh, 1.4375rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--display-border);
}

.product-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.product-track {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.6rem 0.65rem 1rem;
  will-change: transform;
  transform: translateY(0);
}

.product-set {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex-shrink: 0;
}

.product-card {
  background: var(--display-card);
  border: 1px solid var(--display-border);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.product-card-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 8px;
  object-fit: cover;
  background: hsl(var(--display-hue), 20%, 18%);
}

.product-card-body {
  min-width: 0;
}

.product-card-title {
  margin: 0;
  font-size: clamp(1.0625rem, 2.375vh, 1.4375rem);
  font-weight: 700;
}

.product-card-price {
  margin: 0.25rem 0 0;
  font-size: clamp(1.125rem, 2.5vh, 1.5rem);
  color: var(--display-accent);
  font-weight: 700;
}

.product-card-offer {
  margin: 0.2rem 0 0;
  font-size: clamp(0.875rem, 1.875vh, 1.1875rem);
  color: #fde68a;
}

.ticker-bar {
  overflow: hidden;
  border-top: 1px solid var(--display-border);
  background: hsl(var(--display-hue), 55%, 10%);
  padding: 0.55rem 0;
}

.ticker-track {
  display: flex;
  width: max-content;
  will-change: transform;
  font-size: clamp(1.7rem, 3.8vh, 2.3rem);
  font-weight: 600;
  animation: ticker-scroll linear infinite;
}

.ticker-set {
  flex: 0 0 auto;
  white-space: nowrap;
  padding-right: 4rem;
}

.ticker-track.is-paused {
  animation: none;
  transform: none;
  width: 100%;
  justify-content: flex-start;
  padding-left: 1rem;
}

.ticker-track.is-paused .ticker-set:last-child {
  display: none;
}

@keyframes ticker-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@media (max-width: 700px) {
  .display-root {
    grid-template-columns: 1fr;
    grid-template-rows: 62% 38%;
  }

  .ad-column {
    border-right: 0;
    border-bottom: 1px solid var(--display-border);
  }
}
