:root {
  --bg: #090c12;
  --card: #111722;
  --accent: #40d6a0;
  --text: #eef2f7;
  --muted: #9eaabd;
  --danger: #ff5d5d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at top, #152033 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

.tv-layout {
  width: 100vw;
  height: 100vh;
  padding: 1.2rem;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 1rem;
  transition: filter 0.6s ease, opacity 0.6s ease;
}

.tv-layout.dimmed {
  filter: blur(12px) brightness(0.35);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}

.brand-logo-shell {
  background: #f4f5f7;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  padding: 0.4rem 0.55rem;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.03);
}

.brand-logo {
  height: clamp(52px, 6vw, 88px);
  width: auto;
  object-fit: contain;
  display: block;
}

.status-wrap {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: clamp(0.85rem, 1.4vw, 1.15rem);
  color: var(--muted);
}

.badge {
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-weight: 700;
}

.badge.online {
  background: rgba(64, 214, 160, 0.2);
  color: #8ef2cd;
}

.badge.offline {
  background: rgba(255, 93, 93, 0.18);
  color: #ffb1b1;
}

.global-controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: clamp(0.95rem, 1.5vw, 1.2rem);
}

.ad-countdown {
  margin-left: auto;
  color: var(--muted);
  font-size: clamp(0.75rem, 1.1vw, 0.95rem);
  opacity: 0.85;
}

.range-buttons {
  display: inline-flex;
  gap: 0.4rem;
}

.range-buttons button {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #1a2230;
  color: var(--text);
  border-radius: 9px;
  padding: 0.35rem 0.7rem;
  font-size: clamp(0.9rem, 1.3vw, 1.1rem);
  cursor: pointer;
}

.range-buttons button.active {
  background: rgba(64, 214, 160, 0.2);
  border-color: rgba(64, 214, 160, 0.7);
}

.cards-grid {
  display: grid;
  gap: 1rem;
  min-height: 0;
}

.metal-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-head h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 2.1rem);
}

.price {
  margin: 0.4rem 0;
  font-size: clamp(2.2rem, 6.2vw, 6rem);
  line-height: 1;
  font-weight: 800;
  color: #f8fffb;
  font-variant-numeric: tabular-nums;
}

.time-label {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.3vw, 1.15rem);
}

.chart-wrap {
  margin-top: 0.6rem;
  flex: 1;
  min-height: 220px;
  position: relative;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.ad-scene {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  background: #000;
  overflow: hidden;
}

.ad-scene.hidden {
  display: none;
}

.ad-content {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.ad-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.9s ease-in-out;
  pointer-events: none;
}

.ad-slide.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

.ad-slide.leaving {
  opacity: 0;
  z-index: 1;
}

.ad-slide img,
.ad-slide video {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  object-fit: cover;
  object-position: center;
}

.ad-slide img {
  animation: adKenBurns 12s ease-out forwards;
}

@keyframes adKenBurns {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.ad-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at 50% 40%, #1a1a2e 0%, #090c12 70%);
  padding: 2rem;
}

.ad-fallback .fallback-logo {
  height: clamp(80px, 18vh, 160px);
  margin-bottom: 2rem;
}

.ad-fallback h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 5vw, 4.5rem);
  color: #ffd45b;
}

.ad-fallback p {
  margin: 0;
  font-size: clamp(1rem, 2.5vw, 2rem);
  color: var(--muted);
}

.ad-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ad-footer img {
  height: 42px;
}

.ad-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.1rem;
}

.ad-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}
