:root {
  --ink: #eadcc6;
  --ink-dim: rgba(234, 220, 198, 0.55);
  --glass: rgba(22, 15, 10, 0.42);
  --edge: rgba(255, 222, 180, 0.09);
  --serif: "Iowan Old Style", "Palatino", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0705;
  color: var(--ink);
  font-family: var(--serif);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

body { position: fixed; inset: 0; }

#scene {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  touch-action: manipulation;
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--edge);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 235, 210, 0.06);
}

/* ------------------------------------------------ header */
.top {
  position: fixed;
  top: calc(var(--sat) + 18px);
  left: calc(var(--sal) + 24px);
  right: calc(var(--sar) + 24px);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.top > * { pointer-events: auto; }

.brand { display: flex; flex-direction: column; gap: 4px; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8); }
.title {
  font-size: 26px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-weight: 500;
  color: #f1e3cb;
}
.sub {
  font-size: 15px;
  font-style: italic;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  transition: opacity 0.4s;
}

.actions { display: flex; gap: 12px; }
.icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: transform 0.15s ease, background 0.2s;
}
.icon:active { transform: scale(0.92); background: rgba(40, 28, 18, 0.6); }
.icon svg { width: 22px; height: 22px; }
#soundBtn .mute { display: none; }
#soundBtn.off .on { display: none; }
#soundBtn.off .mute { display: block; }

/* ------------------------------------------------ heat slider */
.heat {
  --v: 0.62;
  position: fixed;
  right: calc(var(--sar) + 22px);
  top: 50%;
  transform: translateY(-50%);
  width: 58px;
  padding: 14px 0 12px;
  border-radius: 29px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  touch-action: none;
  outline: none;
}
.heat .flame {
  width: 22px;
  height: 22px;
  color: hsl(calc(10 + var(--v) * 32), 95%, calc(42% + var(--v) * 20%));
  filter: drop-shadow(0 0 calc(var(--v) * 10px) rgba(255, 120, 30, 0.8));
}
.heat .track {
  position: relative;
  width: 8px;
  height: min(230px, 30vh);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}
.heat .fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--v) * 100%);
  border-radius: 4px;
  background: linear-gradient(to top, #6b1606, #e0480c 45%, #ffb347 85%, #fff1c9);
  box-shadow: 0 0 14px rgba(255, 110, 30, calc(var(--v) * 0.8));
}
.heat .knob {
  position: absolute;
  left: 50%;
  bottom: calc(var(--v) * 100%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  transform: translate(-50%, 50%);
  background: radial-gradient(circle at 35% 30%, #5a4a3e, #1d1612 70%);
  border: 1px solid rgba(255, 220, 180, 0.2);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}
.heat .cap {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding-left: 0.22em;
}

/* ------------------------------------------------ ingredient shelf */
.shelf {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sab) + 18px);
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 10px 14px 8px;
  border-radius: 24px;
}
.vial {
  width: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  touch-action: none;
  transition: transform 0.18s ease, opacity 0.2s;
}
.vial svg { width: 46px; height: 70px; overflow: visible; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5)); }
.vial span {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  white-space: nowrap;
}
.vial:active, .vial.lifted { transform: translateY(-4px); }
.vial.lifted svg { opacity: 0.25; }

.ghost {
  position: fixed;
  left: 0; top: 0;
  width: 60px;
  height: 92px;
  pointer-events: none;
  z-index: 20;
  transition: transform 0.06s linear;
  filter: drop-shadow(0 18px 14px rgba(0, 0, 0, 0.55));
}
.ghost svg { width: 100%; height: 100%; overflow: visible; }
.ghost.pour { transition: transform 0.25s cubic-bezier(.3, 1.4, .5, 1); }

/* ------------------------------------------------ hint */
.hint {
  position: fixed;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.8);
  transition: opacity 1.2s ease, transform 1.2s ease;
  animation: breathe 3.2s ease-in-out infinite;
}
.hint .big {
  margin: 0 0 8px;
  font-size: 34px;
  font-style: italic;
  letter-spacing: 0.04em;
  color: #f6ead6;
}
.hint .small { margin: 0; font-size: 15px; line-height: 1.5; color: rgba(246, 234, 214, 0.75); }
.hint.gone { opacity: 0; transform: translate(-50%, -60%); animation: none; }
@keyframes breathe { 50% { opacity: 0.7; } }

.fallback {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 40px;
  font-size: 20px;
  background: #0a0705;
  z-index: 50;
}
.fallback .detail { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--ink-dim); white-space: pre-wrap; max-width: 80ch; text-align: left; }
.fallback[hidden] { display: none; }

/* small screens / portrait phones: tighten the shelf */
@media (max-width: 640px) {
  .vial { width: 52px; }
  .vial span { display: none; }
  .title { font-size: 20px; }
  .heat { right: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .hint { animation: none; }
}
