/*
 * Lưu ý tương thích: trang Receiver chạy trên trình duyệt Smart TV rất cũ
 * (Chromium 38–76). Mọi thuộc tính hiện đại (clamp, aspect-ratio, gap, var())
 * ở các class dùng cho index.html đều phải có dòng fallback đứng TRƯỚC nó.
 */
:root {
  color-scheme: dark;
  --bg: #05060a;
  --surface: #11141d;
  --surface-2: #191d2a;
  --border: #262c3b;
  --text: #f2f4f8;
  --muted: #99a2b8;
  --accent: #4f7cff;
  --ok: #2ecc8f;
  --warn: #ffb020;
  --err: #ff5a5f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05060a;
  background: var(--bg);
  color: #f2f4f8;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  padding: clamp(16px, 3vw, 48px);
}

.shell { width: min(1100px, 100%); }

.card {
  background: #11141d;
  background: var(--surface);
  border: 1px solid #262c3b;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  padding: clamp(20px, 3vw, 40px);
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-size: clamp(22px, 3.2vw, 38px);
  letter-spacing: -0.02em;
}

.sub { margin: 0 0 28px; color: #99a2b8; color: var(--muted); font-size: 16px; font-size: clamp(14px, 1.4vw, 18px); }

.pair-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.pair-grid > div:first-child { flex: 1 1 340px; margin-right: 40px; }
.pair-grid .qr-wrap { flex: 1 1 240px; }

@media (max-width: 760px) {
  .pair-grid > div:first-child { margin-right: 0; }
}

.step { display: flex; gap: 14px; margin-bottom: 22px; }
.step-num {
  flex: 0 0 30px; height: 30px; border-radius: 50%;
  background: #191d2a; background: var(--surface-2);
  border: 1px solid #262c3b; border: 1px solid var(--border);
  text-align: center; line-height: 28px; font-size: 14px;
  color: #99a2b8; color: var(--muted);
}
.step-body { flex: 1; }
.step-title { font-weight: 600; margin-bottom: 4px; }
.step-desc { color: var(--muted); font-size: 14px; line-height: 1.5; }

.pin { display: flex; margin: 10px 0 6px; }
.pin span {
  flex: 1; max-width: 76px; height: 96px;
  text-align: center; line-height: 96px;
  background: #191d2a; background: var(--surface-2);
  border: 1px solid #262c3b; border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 40px; font-size: clamp(26px, 4vw, 46px);
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.pin span + span { margin-left: 8px; }

.expiry { color: #99a2b8; color: var(--muted); font-size: 13px; }

.qr-wrap { text-align: center; }
.qr {
  background: #fff; border-radius: 18px; padding: 14px;
  max-width: 320px; width: 100%; margin: 0 auto;
}
.qr img, .qr svg { width: 100%; height: auto; display: block; }
.qr-hint { margin-top: 12px; color: #99a2b8; color: var(--muted); font-size: 14px; }

.status {
  display: inline-flex; align-items: center;
  padding: 6px 14px; border-radius: 999px;
  background: #191d2a; background: var(--surface-2);
  border: 1px solid #262c3b; border: 1px solid var(--border);
  font-size: 14px; margin-bottom: 18px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #99a2b8; background: var(--muted); margin-right: 8px; }
.status[data-tone='ok'] .dot { background: var(--ok); }
.status[data-tone='busy'] .dot { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.status[data-tone='err'] .dot { background: var(--err); }

@keyframes pulse { 50% { opacity: 0.25; } }

button {
  font: inherit; cursor: pointer; border-radius: 12px; padding: 12px 22px;
  border: 1px solid #262c3b; border: 1px solid var(--border);
  background: #191d2a; background: var(--surface-2);
  color: #f2f4f8; color: var(--text);
}
button.primary { background: #4f7cff; background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- màn hình đang phản chiếu ---- */
.stage { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: #000; display: none; }
.stage.active { display: block; }
/* Letterbox bằng "absolute centering" (CSS2, chạy mọi trình duyệt kể cả TV
   không hỗ trợ object-fit): 4 offset = 0 + margin auto căn giữa cả 2 chiều,
   max-width/height giới hạn trong khung, phần tử thay thế (video/img) tự dùng
   kích thước gốc rồi thu vừa -> đúng như contain, video dọc không tràn. */
.stage video, .stage img {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto;
  max-width: 100%; max-height: 100%; background: #000;
}
.stage-bar {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; align-items: center;
  background: rgba(10, 12, 18, 0.78); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px;
  opacity: 0; transition: opacity 0.25s; font-size: 14px;
}
.stage-bar > * + * { margin-left: 12px; }
.stage:hover .stage-bar, .stage-bar.show { opacity: 1; }
.stage-stats { color: #99a2b8; color: var(--muted); font-variant-numeric: tabular-nums; }

.hidden { display: none !important; }
.error { color: #ff5a5f; color: var(--err); font-size: 14px; margin-top: 12px; min-height: 20px; }
