/* ClueBell Studio WebGL page. One stylesheet, no framework.
   Brand: orange #FF8000, gradient #FF512F -> #FF8000 -> #FDC830, background #0E0B14,
   surface #1A1524, text #FFFFFF / muted #B8B0C8. Headings Baloo 2, body Inter. */

:root {
  --cb-bg: #0E0B14;
  --cb-surface: #1A1524;
  --cb-surface-2: #241D31;
  --cb-line: rgba(255, 255, 255, 0.08);
  --cb-text: #FFFFFF;
  --cb-muted: #B8B0C8;
  --cb-primary: #FF8000;
  --cb-grad: linear-gradient(90deg, #FF512F 0%, #FF8000 50%, #FDC830 100%);
  --cb-radius: 22px;
  --cb-bar-h: 56px;
  --cb-vh: 1vh;
  --cb-font-head: "Baloo 2", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cb-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--cb-bg);
  color: var(--cb-text);
  font-family: var(--cb-font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  height: calc(var(--cb-vh) * 100);
  height: 100dvh;
}

[hidden] { display: none !important; }

a { color: inherit; }

/* ── Backdrop ─────────────────────────────────────────────────────────── */

.cb-backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.cb-backdrop-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120vmax;
  height: 120vmax;
  transform: translate(-50%, -50%);
  object-fit: cover;
  filter: blur(80px) saturate(1.4);
  opacity: 0.28;
}

.cb-glow {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.30;
}

.cb-glow.g1 { left: -25vmax; top: -30vmax; background: radial-gradient(circle, #FF512F 0%, transparent 65%); }
.cb-glow.g2 { right: -25vmax; bottom: -30vmax; background: radial-gradient(circle, #FDC830 0%, transparent 65%); }

.cb-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(14, 11, 20, 0.15) 0%, rgba(14, 11, 20, 0.85) 75%);
}

/* ── Top bar (desktop) ────────────────────────────────────────────────── */

.cb-bar {
  position: relative;
  z-index: 2;
  height: var(--cb-bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.cb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--cb-font-head);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.2px;
}

.cb-brand img { height: 28px; width: auto; }

.cb-brand .cb-brand-name span {
  background: var(--cb-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cb-actions { display: flex; align-items: center; gap: 10px; }

.cb-btn {
  appearance: none;
  border: 1px solid var(--cb-line);
  background: rgba(26, 21, 36, 0.75);
  color: var(--cb-text);
  font: 600 14px/1 var(--cb-font-body);
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cb-btn:hover { background: var(--cb-surface-2); border-color: rgba(255, 255, 255, 0.18); }
.cb-btn:active { transform: scale(0.97); }
.cb-btn:focus-visible { outline: 2px solid var(--cb-primary); outline-offset: 2px; }
.cb-btn svg { width: 18px; height: 18px; }

.cb-btn.cb-primary {
  border: 0;
  background: var(--cb-grad);
  color: #1A0E00;
  font-weight: 700;
}

.cb-btn.cb-primary:hover { filter: brightness(1.06); }

/* ── Shell and stage ──────────────────────────────────────────────────── */

.cb-shell {
  position: relative;
  z-index: 1;
  height: calc(100% - var(--cb-bar-h));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 0 16px 20px;
}

.cb-stage {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(100%, calc((100vw - 32px) * 16 / 9));
  max-width: calc(100vw - 32px);
  border-radius: var(--cb-radius);
  overflow: hidden;
  background: #000;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  isolation: isolate;
}

#unity-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  outline: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.cb-stage:fullscreen { border-radius: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; }
.cb-stage:-webkit-full-screen { border-radius: 0; width: 100%; height: 100%; max-width: none; }

/* Side cards: only where there is room beside the stage. */
.cb-side {
  width: 300px;
  flex: 0 0 300px;
  display: none;
  flex-direction: column;
  gap: 16px;
  align-self: center;
}

.cb-card {
  background: rgba(26, 21, 36, 0.78);
  border: 1px solid var(--cb-line);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cb-card h2 {
  font: 700 20px/1.15 var(--cb-font-head);
  margin: 0 0 6px;
}

.cb-card p { margin: 0 0 14px; color: var(--cb-muted); font-size: 14px; line-height: 1.45; }

.cb-store-links { display: flex; flex-direction: column; gap: 10px; }
.cb-store-links .cb-btn { justify-content: center; height: 44px; }

.cb-ad-slot { min-height: 250px; display: flex; align-items: center; justify-content: center; }

/* Both columns show whenever either has content, so the stage stays centred. */
@media (min-width: 1100px) {
  .cb-shell.cb-sides .cb-side { display: flex; }
}

/* ── Loader ───────────────────────────────────────────────────────────── */

.cb-loader {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 28px calc(32px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 128, 0, 0.18) 0%, transparent 60%),
    radial-gradient(120% 60% at 50% 100%, rgba(253, 200, 48, 0.10) 0%, transparent 60%),
    var(--cb-bg);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.cb-loader.cb-done { opacity: 0; visibility: hidden; pointer-events: none; }

.cb-studio {
  position: absolute;
  top: calc(24px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  text-align: center;
  font: 700 15px/1 var(--cb-font-head);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--cb-muted);
}

.cb-studio b {
  background: var(--cb-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cb-icon-wrap {
  position: relative;
  width: min(34%, 168px);
  aspect-ratio: 1;
  margin-bottom: 22px;
}

.cb-icon-wrap::before {
  content: "";
  position: absolute;
  inset: -14%;
  border-radius: 32%;
  background: var(--cb-grad);
  filter: blur(26px);
  opacity: 0.55;
  animation: cb-breathe 2.4s ease-in-out infinite;
}

.cb-icon {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 23%;
  object-fit: cover;
  background: var(--cb-surface);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.cb-game-name {
  font: 800 clamp(26px, 4.4vh, 40px)/1.05 var(--cb-font-head);
  margin: 0 0 26px;
  text-align: center;
}

.cb-progress {
  width: min(78%, 340px);
  height: 12px;
  border-radius: 999px;
  background: var(--cb-surface-2);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--cb-line);
}

.cb-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--cb-grad);
  background-size: 200% 100%;
  animation: cb-shimmer 1.8s linear infinite;
}

.cb-progress-row {
  width: min(78%, 340px);
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 13px;
  color: var(--cb-muted);
  font-variant-numeric: tabular-nums;
}

.cb-progress-row b { color: var(--cb-text); font-weight: 600; }

.cb-tip {
  min-height: 2.8em;
  max-width: 320px;
  margin-top: 22px;
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
  color: var(--cb-muted);
  transition: opacity 0.35s ease;
}

.cb-play {
  margin-top: 26px;
  height: 56px;
  padding: 0 44px;
  font-size: 20px;
  font-family: var(--cb-font-head);
  letter-spacing: 1px;
  box-shadow: 0 10px 30px rgba(255, 81, 47, 0.35);
  animation: cb-pop 0.35s ease-out;
}

@keyframes cb-shimmer { 0% { background-position: 0% 0; } 100% { background-position: -200% 0; } }
@keyframes cb-breathe { 0%, 100% { opacity: 0.4; transform: scale(0.96); } 50% { opacity: 0.7; transform: scale(1.04); } }
@keyframes cb-pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .cb-progress-fill, .cb-icon-wrap::before, .cb-play { animation: none; }
}

/* ── Overlays: error, get-the-app sheet, unsupported ──────────────────── */

.cb-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(14, 11, 20, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cb-overlay .cb-card { width: min(100%, 360px); text-align: center; }
.cb-overlay .cb-card img { width: 88px; height: 88px; border-radius: 22%; margin-bottom: 12px; }
.cb-overlay .cb-store-links { margin-bottom: 10px; }
.cb-overlay pre {
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow: auto;
  font-size: 11px;
  color: var(--cb-muted);
  background: var(--cb-bg);
  border-radius: 10px;
  padding: 10px;
  margin: 0 0 14px;
}

.cb-page-overlay { position: fixed; }

.cb-link-btn {
  background: none;
  border: 0;
  color: var(--cb-muted);
  font: 500 14px var(--cb-font-body);
  cursor: pointer;
  padding: 8px;
}

/* ── Phones: full-bleed ───────────────────────────────────────────────── */

@media (max-width: 700px), (pointer: coarse) and (max-width: 1024px) and (orientation: portrait) {
  .cb-bar, .cb-side { display: none !important; }
  .cb-shell { height: 100%; padding: 0; }
  .cb-stage {
    position: fixed;
    inset: 0;
    height: 100%;
    width: 100%;
    max-width: none;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Phone held sideways: keep the portrait frame, full height. */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 600px) {
  .cb-bar { display: none !important; }
  .cb-shell { height: 100%; padding: 0; }
  .cb-stage { height: 100%; border-radius: 0; }
}
