:root {
  --fg: #f4f1ea;
  --muted: rgba(244, 241, 234, 0.55);
  --accent: #ff5b3a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0a0c;
  color: var(--fg);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  cursor: default;
  touch-action: none; /* stop the page from panning while you drag the cigarette */
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Soft cinematic vignette painted over the canvas. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 42%, rgba(0, 0, 0, 0.55) 100%);
  z-index: 2;
}

#ui {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none; /* let clicks fall through to the canvas, except on real buttons */
}

/* ---- Title ---- */
#titlebar {
  position: absolute;
  top: clamp(18px, 4vh, 44px);
  left: 0;
  right: 0;
  text-align: center;
  user-select: none;
}
#titlebar h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 68px);
  font-weight: 800;
  letter-spacing: 0.42em;
  text-indent: 0.42em; /* balance the letter-spacing so it stays centered */
  background: linear-gradient(180deg, #fff 0%, #b9b3a6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 24px rgba(0, 0, 0, 0.5));
}
#titlebar .tag {
  margin: 6px 0 0;
  font-size: clamp(11px, 1.6vw, 14px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- Bottom hint (fades away after the first snap) ---- */
.hint {
  position: absolute;
  bottom: clamp(22px, 6vh, 60px);
  left: 0;
  right: 0;
  text-align: center;
  transition: opacity 0.6s ease;
}
.hint-inner {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(6px);
  font-size: clamp(11px, 1.5vw, 13px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  animation: breathe 2.6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.hint.gone { opacity: 0; }

/* ---- Snap counter ---- */
.counter {
  position: absolute;
  top: clamp(16px, 3.5vh, 34px);
  right: clamp(18px, 3vw, 40px);
  text-align: right;
  user-select: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.counter.show { opacity: 1; }
#count-num {
  display: block;
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 800;
  line-height: 1;
  color: var(--fg);
}
.count-label {
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}
.counter.bump #count-num { animation: bump 0.32s ease; }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); color: var(--accent); }
  100% { transform: scale(1); }
}

/* ---- Buttons ---- */
#controls {
  position: absolute;
  bottom: clamp(16px, 3vh, 30px);
  right: clamp(16px, 3vw, 34px);
  display: flex;
  gap: 10px;
  pointer-events: auto;
}
.ctl {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease, transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ctl:hover { background: rgba(255, 255, 255, 0.14); }
.ctl:active { transform: scale(0.92); }

/* ---- Fatal error card ---- */
.fatal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none; /* shown only when JS removes [hidden] */
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 12, 0.9);
}
.fatal:not([hidden]) { display: flex; }
.fatal-box {
  max-width: 420px;
  padding: 28px 32px;
  border-radius: 14px;
  background: #17171b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}
.fatal-box h2 { margin: 0 0 10px; font-size: 20px; }
.fatal-box p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Cursor feedback while dragging is toggled from JS via this class on <body>. */
body.grabbing { cursor: grabbing; }
body.grab-ready { cursor: grab; }
