body[data-page="baccarat"],
html:has(body[data-page="baccarat"]) {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body[data-page="baccarat"] .app {
  min-height: 100vh;
  height: auto;
}

body[data-page="baccarat"] .main {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: visible;
}

body[data-page="baccarat"] .content {
  padding-bottom: 12px;
}

.baccarat-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: auto;
}

/* ── Hero ── */
.baccarat-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(16px, 2.5vw, 22px) clamp(18px, 3vw, 26px);
  border-radius: var(--radius-outer);
  border: 1px solid var(--tiff-line);
  background:
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(129, 216, 208, 0.12), transparent 55%),
    radial-gradient(ellipse 70% 50% at 0% 100%, rgba(201, 173, 106, 0.08), transparent 50%),
    var(--gradient-hero-rich);
  box-shadow: var(--shadow-luxe), var(--shadow-border-glow);
}

.baccarat-rays {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.baccarat-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, rgba(129, 216, 208, 0.05) 50%, transparent 60%);
  pointer-events: none;
}

.baccarat-hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
}

.baccarat-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 3.5vw, 38px);
  font-weight: 600;
  margin: 6px 0 8px;
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--text);
}

.baccarat-hero .lead {
  margin: 0;
  max-width: 48ch;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-dim);
}

.baccarat-hero .lead strong {
  color: var(--tiff-bright);
  font-weight: 500;
}

.baccarat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.baccarat-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text-dim);
}

.baccarat-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.baccarat-badge--player {
  border-color: rgba(96, 165, 250, 0.35);
  color: #93c5fd;
}

.baccarat-badge--banker {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.baccarat-badge--tiff {
  border-color: var(--tiff-line);
  color: var(--tiff-bright);
  background: var(--tiff-soft);
}

.baccarat-hero-mark {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-outer);
  display: grid;
  place-items: center;
  border: 1px solid var(--tiff-line);
  background:
    radial-gradient(circle at 30% 20%, rgba(129, 216, 208, 0.2), transparent 55%),
    linear-gradient(145deg, var(--bg-2), var(--bg-0));
  box-shadow: var(--shadow-luxe), 0 0 24px var(--tiff-glow);
}

.baccarat-hero-mark-inner {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--tiff-bright);
  letter-spacing: -0.02em;
}

/* ── Stage chrome ── */
.baccarat-stage {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius-outer);
  border: 1px solid var(--tiff-line);
  background: #030608;
  overflow: visible;
  box-shadow:
    var(--shadow-luxe),
    0 0 0 1px rgba(129, 216, 208, 0.06) inset,
    0 0 56px rgba(129, 216, 208, 0.07);
}

.baccarat-stage .baccarat-rays {
  opacity: 0.75;
}

.baccarat-stage-head {
  position: relative;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(129, 216, 208, 0.12);
  background: linear-gradient(180deg, rgba(12, 24, 28, 0.98), rgba(8, 18, 20, 0.92));
  backdrop-filter: blur(10px);
}

.baccarat-stage-head[hidden] {
  display: none !important;
}

.baccarat-stage-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.baccarat-live-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
  flex-shrink: 0;
  animation: baccarat-live 2s ease-in-out infinite;
}

@keyframes baccarat-live {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.92); }
}

.baccarat-stage-title {
  font-family: var(--font-mono, "Kanit", sans-serif);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tiff-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.baccarat-stage-head-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.baccarat-timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--gold-line);
  background: var(--gold-soft);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--gold-bright);
}

.baccarat-timer-pill svg {
  width: 14px;
  height: 14px;
  opacity: 0.9;
}

.baccarat-timer-pill.is-low {
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
}

.baccarat-timer-pill.is-critical {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
  animation: baccarat-pulse 1.2s ease-in-out infinite;
}

@keyframes baccarat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.baccarat-progress {
  width: 88px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--bg-2);
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.baccarat-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--tiff-deep), var(--tiff-bright));
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 0.6s ease, background 0.3s ease;
}

.baccarat-progress.is-low > span {
  background: linear-gradient(90deg, #b45309, #fbbf24);
}

.baccarat-progress.is-critical > span {
  background: linear-gradient(90deg, #b91c1c, #f87171);
}

.baccarat-fs-btn {
  min-height: 34px;
  padding: 0 14px;
  font-size: 12px;
}

.baccarat-iframe-scaler {
  position: relative;
  flex: 0 0 auto;
  z-index: 1;
  overflow: visible;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 6px 4px 10px;
  touch-action: pan-y;
}

.baccarat-page.is-immersive .baccarat-stage,
.baccarat-stage:fullscreen {
  flex: 1 1 auto;
  min-height: calc(100vh - 100px);
  overflow: hidden;
}

.baccarat-page.is-immersive .baccarat-iframe-scaler,
.baccarat-stage:fullscreen .baccarat-iframe-scaler {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(129, 216, 208, 0.35) transparent;
}

.baccarat-page.is-immersive .baccarat-iframe-scaler::-webkit-scrollbar,
.baccarat-stage:fullscreen .baccarat-iframe-scaler::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.baccarat-page.is-immersive .baccarat-iframe-scaler::-webkit-scrollbar-thumb,
.baccarat-stage:fullscreen .baccarat-iframe-scaler::-webkit-scrollbar-thumb {
  border-radius: var(--radius-pill);
  background: rgba(129, 216, 208, 0.35);
}

.baccarat-iframe-shell {
  flex-shrink: 0;
  overflow: visible;
  width: 100%;
  max-width: 1152px;
  margin: 0 auto;
  border-radius: var(--radius-inner);
}

.baccarat-stage iframe {
  display: block;
  width: 100%;
  max-width: 1152px;
  min-height: 1120px;
  height: var(--baca-height, 1120px);
  border: 0;
  background: #000;
  flex-shrink: 0;
}

.baccarat-stage.is-blocked .baccarat-iframe-scaler iframe {
  filter: grayscale(0.55) brightness(0.4) blur(1px);
  pointer-events: none;
}

.baccarat-page.is-immersive .baccarat-hero,
.baccarat-page.is-immersive .baccarat-tips {
  display: none;
}

.baccarat-page.is-immersive .baccarat-stage {
  min-height: calc(100vh - 100px);
}

.baccarat-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  border: 0;
}

.baccarat-stage:fullscreen .baccarat-iframe-scaler {
  flex: 1;
}

/* ── Loading & gate ── */
.baccarat-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(129, 216, 208, 0.1), rgba(0, 0, 0, 0.92) 70%);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.baccarat-loading.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.baccarat-loading[hidden] {
  display: none !important;
}

.baccarat-loading-card {
  text-align: center;
  padding: 24px;
}

.baccarat-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: var(--radius-pill);
  border: 3px solid rgba(129, 216, 208, 0.2);
  border-top-color: var(--tiff-bright);
  animation: baccarat-spin 0.9s linear infinite;
}

@keyframes baccarat-spin {
  to { transform: rotate(360deg); }
}

.baccarat-loading-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.baccarat-gate {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background: rgba(3, 6, 8, 0.88);
  backdrop-filter: blur(10px);
}

.baccarat-gate[hidden] {
  display: none !important;
}

.baccarat-gate-card {
  width: min(440px, 100%);
  padding: 32px 28px 28px;
  border-radius: var(--radius-outer);
  border: 1px solid var(--tiff-line);
  background:
    radial-gradient(circle at 50% 0%, rgba(129, 216, 208, 0.12), transparent 58%),
    var(--gradient-panel);
  text-align: center;
  box-shadow: var(--shadow-luxe);
}

.baccarat-gate-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
  font-size: 24px;
}

.baccarat-gate-card h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

.baccarat-gate-card p {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
}

.baccarat-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* ── Tips ── */
.baccarat-tips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  flex-shrink: 0;
}

.baccarat-tip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-outer);
  border: 1px solid var(--border);
  background: var(--gradient-panel);
  box-shadow: var(--shadow-luxe);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.baccarat-tip:hover {
  border-color: var(--tiff-line);
  transform: translateY(-1px);
}

.baccarat-tip-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--tiff-bright);
  background: var(--tiff-soft);
  border: 1px solid var(--tiff-line);
}

.baccarat-tip-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.baccarat-tip-txt {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}

@media (max-width: 900px) {
  .baccarat-page.is-immersive .baccarat-stage {
    min-height: calc(100vh - 88px);
  }

  .baccarat-stage iframe {
    min-height: 1000px;
    height: var(--baca-height, 1000px);
  }

  .baccarat-hero-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .baccarat-hero-mark {
    width: 52px;
    height: 52px;
    justify-self: start;
  }

  .baccarat-hero-mark-inner {
    font-size: 20px;
  }

  .baccarat-tips {
    grid-template-columns: 1fr;
  }

  .baccarat-stage-head {
    flex-direction: column;
    align-items: stretch;
  }

  .baccarat-stage-head-right {
    margin-left: 0;
    justify-content: space-between;
  }

  .baccarat-progress {
    flex: 1;
    min-width: 60px;
  }

  .baccarat-fs-btn {
    flex: 1;
    justify-content: center;
  }
}
