* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #050505;
  --text: rgba(255, 255, 255, 0.88);
  --text-dim: rgba(255, 255, 255, 0.5);
  --blood: #8a0303;
  --blood-glow: rgba(200, 10, 10, 0.45);
  --fire: #ff7a1a;
  --fire-glow: rgba(255, 140, 40, 0.45);
  /* One look for every control, matching the cover and print pages:
     soft burgundy glass, cream text, deep red for the main action, no outlines */
  --glass: rgba(58, 10, 8, 0.72);
  --cream: #f6eee2;
  --accent: #8a0303;
  /* camera page, from the owner's design: wine, bronze filigree, old paper */
  --wine: #4a0f0c;
  --bronze: #b48a52;
  --ink-brown: #3a1a12;
}

/* Ornate panel: bronze double rule with corner curls (9-slice), star on top */
.ornate {
  border: 18px solid transparent;
  border-image: url(assets/orn-frame.svg) 34 / 18px stretch;
  background-clip: padding-box;
}
.ornate::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -16px;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  background: url(assets/orn-star.svg) center / contain no-repeat;
}
.ornate--paper { background: url(assets/parchment.svg) center / 100% 100%; color: var(--ink-brown); background-clip: border-box; }

/* A fine rule with a small star in the middle */
.orn-rule {
  position: relative;
  height: 1px;
  margin: 10px auto;
  width: 80%;
  background: linear-gradient(90deg, transparent, var(--bronze) 20%, var(--bronze) 80%, transparent);
}
.orn-rule::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: url(assets/orn-star.svg) center / contain no-repeat;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font-family: inherit; color: inherit; }

/* ─── Screens ──────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
}
.screen.is-active { display: block; }

/* ─── Start screen: opening → home ───────────────────────────────── */
/* Burgundy, the same as the print page (owner, 30 Oct), with cream text */
#startScreen {
  --paper: #4f1410;
  --ink-dark: #f3ece0;
  --curtain-w: clamp(40px, 11vw, 250px);
  --lace-h: clamp(36px, 7vw, 110px);
  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  background: var(--paper);
  color: var(--ink-dark);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Curtains (cropped illustration, transparent background).
   Phones: the whole drape squeezed narrow, in front (see @media).
   Wide screens: the whole drape, in front, inner edge lined up (see @media). */
.home-curtain {
  position: fixed;
  z-index: 0;
  top: 0;
  bottom: 0;
  width: var(--curtain-w);
  background: url(assets/curtain.webp) no-repeat left top / auto 100%;
  pointer-events: none;
  transition: transform 1.1s var(--ease);
}
.home-curtain--left { left: 0; }
.home-curtain--right { right: 0; transform: scaleX(-1); }
.is-intro .home-curtain--left { transform: translateX(-105%); }
.is-intro .home-curtain--right { transform: scaleX(-1) translateX(-105%); }

.home-lace {
  position: fixed;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  height: var(--lace-h);
  background: url(assets/lace.webp) repeat-x center top / auto 100%;
  pointer-events: none;
  transition: transform 1s var(--ease) 0.15s;
}
.is-intro .home-lace { transform: translateY(-105%); }

/* Sound toggle, top right */
.home-sound {
  position: fixed;
  z-index: 5;
  top: calc(20px + env(safe-area-inset-top));
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.3);
  color: #f3ece0;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.home-sound .mute { display: none; }
.home-sound.is-muted .wave { display: none; }
.home-sound.is-muted .mute { display: inline; }
/* (shown on the opening and the home page — the sound button is on every page) */

/* Layout (owner's mock-up): booth on the left, fully in view; title, ink
   choices and credit on the right. Phones: booth on top, the rest below. */
.home-layout {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: calc(var(--lace-h) * 0.8) calc(var(--curtain-w) * 0.55 + 12px) 24px;
}
.home-stage { flex: none; }

.home-booth {
  display: block;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.is-ready .home-booth { opacity: 1; }
.home-booth img { display: block; width: min(96vw, 46vh, 520px); height: auto; }
.is-intro .home-booth img { width: min(92vw, calc(78vh * 1225 / 1284)); }

.home-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 520px;
  animation: homeIn 0.9s ease 0.5s both;
}
.is-intro .home-content { display: none; }
@keyframes homeIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* Title with a fine rule and a star either side */
.home-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: clamp(38px, 4.4vw, 68px);
  line-height: 1;
  white-space: nowrap;
  color: #f3ece0;
}
.orn {
  position: relative;
  display: block;
  width: clamp(28px, 4vw, 64px);
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}
.orn::before {
  content: '✦';
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translate(-50%, -52%);
  font-size: 0.32em;
  line-height: 1;
  opacity: 1;
}
.orn--r::before { left: auto; right: -2px; transform: translate(50%, -52%); }
.home-title .orn::before { font-size: 18px; }

.home-sub {
  margin-top: 12px;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: clamp(17px, 1.6vw, 22px);
  line-height: 1.3;
  color: rgba(243, 236, 224, 0.88);
}

.home-byline {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: clamp(17px, 1.5vw, 20px);
  color: #f3ece0;
}
.home-byline .orn { width: 40px; }
/* on the opening the credit sits under the booth and fades in with it */
.home-byline--intro { justify-content: center; margin-top: 8px; opacity: 0; transition: opacity 1.2s ease 0.4s; }
.is-ready .home-byline--intro { opacity: 1; }
.is-home .home-byline--intro { display: none; }
.home-byline .orn::before { font-size: 11px; }

/* Ink choices: just the painting in an arched window, the name and a line
   of text underneath — kept small and quiet, no frames or ornaments */
.mode-cards {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 22px);
  width: 100%;
  max-width: 440px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  color: #f3ece0;
  cursor: pointer;
}
.mode-pic {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 3.8;
  border-radius: 999px 999px 4px 4px;   /* arched, like a mirror */
  background: var(--card-bg) var(--card-pos, center) / cover no-repeat;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease, box-shadow 0.3s ease;
}
.mode-card:hover .mode-pic { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45); }
.mode-card:active .mode-pic { transform: scale(0.98); }
.mode-pic--blood { --card-bg: url(assets/card-blood.webp); --card-pos: 18% center; }
.mode-pic--fire  { --card-bg: url(assets/card-fire.webp);  --card-pos: 8% center; }
.mode-pic--gold  { --card-bg: url(assets/card-gold.webp);  --card-pos: 48% center; }
.mode-name {
  margin-top: 8px;
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-size: clamp(22px, 2vw, 28px);
  line-height: 1;
}
.mode-desc { font-size: clamp(11px, 0.9vw, 13px); line-height: 1.3; color: rgba(243, 236, 224, 0.72); }
/* Phones: the whole drape (swag + tassels), squeezed narrow, in front at
   both edges like the desktop — not a flat strip of its outer edge, which
   read as two walls (owner, 30 Oct) */
@media (max-width: 600px) {
  #startScreen { --curtain-w: 22vw; }
  .home-curtain { z-index: 3; background-size: 100% 100%; }
  #startScreen.is-home .home-layout { padding-left: 16vw; padding-right: 16vw; }
  .home-title { font-size: 34px; gap: 10px; }
  .home-title .orn { width: 18px; }
  .mode-cards { max-width: 280px; gap: 10px; }
  .mode-desc { font-size: 10.5px; }
}

@media (min-width: 860px) and (min-aspect-ratio: 1/1) {
  /* The whole drape, always pinned to the screen edge: the box is exactly as
     wide as the curtain image at full height (410 × 1536 px), so it can't be
     cut off whatever the window size */
  #startScreen { --curtain-w: calc(100vh * 410 / 1536); }
  .home-curtain { z-index: 3; background-position: left top; }
  .is-home .home-layout {
    flex-direction: row;
    justify-content: center;
    gap: clamp(24px, 4vw, 72px);
    padding: calc(var(--lace-h) * 0.7) calc(var(--curtain-w) * 0.8 + 12px) 24px;
  }
  /* big, as in the mock-up; the picture's empty paper margins may overlap */
  .is-home .home-booth img { width: min(calc(80vh * 1225 / 1284), 46vw, 820px); }
  .is-home .home-stage { margin: 0 -4vw; }
  .home-content { flex: 0 1 520px; }
}

/* ─── Mirror screen ────────────────────────────────────────────────── */
#mirrorScreen { touch-action: none; }

#video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#mirrorScreen > canvas {   /* the layers only, not the booth thumbnails */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#cameraCanvas { z-index: 1; }
#bloodCanvas, #goldCanvas { z-index: 2; }
/* Fire adds light to the camera image rather than painting over it */
#fireCanvas   { z-index: 3; mix-blend-mode: screen; }
#inkCanvas    { z-index: 4; }
#fxCanvas     { z-index: 5; }

#cursor {
  position: absolute;
  z-index: 10;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, background 0.1s, box-shadow 0.1s;
}
#cursor.is-visible { opacity: 1; }
.has-wand #cursor { display: none; }
#cursor.is-writing {
  background: var(--ink, #fff);
  border-color: var(--ink, #fff);
  box-shadow: 0 0 16px var(--ink, #fff);
}

/* ─── Camera page controls (sit on the frame, not on the glass) ───── */
.frame-layer {
  position: absolute;
  z-index: 6;
  inset: 0;
  pointer-events: none;
}
.frame-layer svg { display: block; width: 100%; height: 100%; }
.svg-defs { position: absolute; width: 0; height: 0; }

.cam-top {
  position: absolute;
  z-index: 20;
  top: calc(14px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 6px;
}
.cam-top--left { left: 12px; gap: 10px; }
.cam-top--right { right: 12px; }

.cam-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #6a1814, var(--wine));
  color: #f1dfbf;
  box-shadow: 0 0 0 1.5px var(--bronze), 0 3px 10px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.cam-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cam-icon .dot { fill: currentColor; stroke: none; }
.cam-icon[aria-expanded="true"] { background: var(--accent); box-shadow: 0 0 0 2px #e2bd7d, 0 3px 10px rgba(0, 0, 0, 0.45); }
.cam-icon .mute { display: none; }
.cam-icon.is-muted .wave { display: none; }
.cam-icon.is-muted .mute { display: inline; }

@media (max-width: 400px) {
  .cam-top--right { gap: 4px; }
  .cam-icon { width: 36px; height: 36px; }
  .ink-dot { width: 30px; height: 30px; }
  .ink-dots { gap: 6px !important; }
}

/* Thickness popover (under the top-right icons) */
.size-pop {
  position: absolute;
  z-index: 25;
  top: calc(64px + env(safe-area-inset-top));
  right: 12px;
  width: min(280px, calc(100% - 24px));
  padding: 4px 6px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.size-pop[hidden] { display: none; }
.size-head { display: flex; justify-content: space-between; font-family: 'Instrument Serif', Georgia, serif; font-size: 20px; }
.size-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.size-end { flex: none; width: 14px; height: 14px; background: url(assets/orn-star.svg) center / contain no-repeat; }
/* Slider: a wine bar in a bronze outline, the filled part darker, a wine bead for the thumb */
.size-row input {
  flex: 1;
  height: 28px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.size-row input::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  border: 1px solid var(--bronze);
  background: linear-gradient(90deg, #6b1410 var(--fill, 33%), #f6eedd var(--fill, 33%));
}
.size-row input::-moz-range-track { height: 8px; border-radius: 4px; border: 1px solid var(--bronze); background: #f6eedd; }
.size-row input::-moz-range-progress { height: 8px; border-radius: 4px; background: #6b1410; }
.size-row input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  border: 2px solid var(--bronze);
  background: radial-gradient(circle at 40% 35%, #a02018, #5a0f0b);
}
.size-row input::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--bronze); background: #7a1510; }
.size-preview { height: 56px; display: grid; place-items: center; margin-top: 6px; }
#sizeDot {
  display: block;
  border-radius: 999px;
  background: var(--ink, #b0121c);
  box-shadow: 0 0 10px var(--ink, #b0121c);
}

.ink-dots { display: flex; gap: 14px; margin-left: 6px; }
.ink-dot {
  width: 34px;
  height: 34px;
  position: relative;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--wine), 0 0 0 4.5px var(--bronze), 0 3px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s;
}
/* the chosen ink: a little bigger, with a small cream dot underneath */
.ink-dot.is-active { transform: scale(1.12); }
.ink-dot.is-active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -17px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: url(assets/orn-star.svg) center / contain no-repeat;
}
.ink-dot--blood { background: #8a0a12; }
.ink-dot--gold  { background: #c9a14a; }
.ink-dot--fire  { background: #e8742a; }

.cam-bottom {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: calc(var(--win-bottom, 0px) + 14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  pointer-events: none;
}
.cam-bottom > * { pointer-events: auto; }

.shutter {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 40% 35%, #8a1a14, #5a0f0b);
  color: #f1dfbf;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 0 3px #5a0f0b, 0 0 0 5px var(--bronze), 0 6px 18px rgba(30, 0, 0, 0.5);
}
.shutter-wrap { position: relative; }
.shutter-orn { position: absolute; width: 24px; height: 24px; pointer-events: none; }
.shutter-orn--l { left: -30px; top: 50%; margin-top: -12px; }
.shutter-orn--r { right: -30px; top: 50%; margin-top: -12px; }
.shutter-orn--b { left: 50%; bottom: -26px; margin-left: -12px; width: 18px; height: 18px; }
.shutter svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.shutter:active { transform: scale(0.94); }


@media (min-width: 600px) {
  .cam-bottom { flex-direction: row; justify-content: center; }
  .cam-top--left { left: 20px; }
  .cam-top--right { right: 20px; }
  .shutter { width: 84px; height: 84px; }
  .shutter svg { width: 34px; height: 34px; }
  .cam-icon { width: 48px; height: 48px; }
  .cam-icon svg { width: 24px; height: 24px; }
  .cam-top--right { gap: 12px; }
  .ink-dot { width: 40px; height: 40px; }
  /* (#mirrorScreen: these rules come before the base ones in the file) */
  #mirrorScreen .hint { padding: 14px 44px 12px; }
  #mirrorScreen .hint-hand { width: 64px; height: 64px; }
  #mirrorScreen .hint-title { font-size: 38px; }
  #mirrorScreen .hint-sub { font-size: 21px; }
  #mirrorScreen .status { font-size: 21px; bottom: calc(var(--win-bottom, 0px) + 118px + env(safe-area-inset-bottom)); }
  #mirrorScreen .size-pop { width: 330px; top: calc(80px + env(safe-area-inset-top)); }
}

.ui-btn {
  min-height: 40px;
  padding: 8px 18px;
  font-size: 14px;
  border-radius: 999px;
  border: none;
  background: var(--glass);
  color: var(--cream);
  cursor: pointer;
}
.ui-btn:active { transform: scale(0.97); }
.ui-btn--icon { width: 40px; padding: 0; font-size: 17px; letter-spacing: 0; }
.ui-btn--primary { background: var(--accent); }

/* Camera-shutter flash */
.flash {
  position: absolute;
  z-index: 40;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.flash.is-on { animation: flash 0.45s ease-out; }
@keyframes flash { from { opacity: 0.85; } to { opacity: 0; } }

/* Photo booth while shooting: hide the normal controls */
.in-booth .size-pop,
.in-booth .cam-top,
.in-booth .cam-bottom,
.in-booth .status,
.in-booth .hint { visibility: hidden; }
/* …but the sound button stays, also over the layout picker */
.in-booth .cam-top--right,
.picker-open .cam-top--right { visibility: visible; z-index: 40; }
.in-booth .cam-top--right > :not(#soundBtn),
.picker-open .cam-top--right > :not(#soundBtn) { visibility: hidden; }

.booth {
  position: absolute;
  z-index: 30;
  inset: 0;
  pointer-events: none;
}
.booth[hidden] { display: none; }
.booth-cancel {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  pointer-events: auto;
}
.booth-count {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: clamp(120px, 32vmin, 240px);
  line-height: 1;
  color: var(--cream);
  text-shadow: 0 0 40px rgba(0, 0, 0, 0.8), 0 0 12px rgba(255, 80, 40, 0.6);
}
.booth-count.is-tick { animation: tick 1s ease-out; }
@keyframes tick {
  from { transform: translate(-50%, -50%) scale(1.35); opacity: 0; }
  20%  { opacity: 1; }
  to   { transform: translate(-50%, -50%) scale(0.9); opacity: 0.85; }
}
.booth-label {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(24px + env(safe-area-inset-top));
  text-align: center;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 20px;
  color: var(--cream);
  text-shadow: 0 1px 6px rgba(30, 0, 0, 0.8);
}
.booth-thumbs {
  position: absolute;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.booth-thumb {
  flex: 0 0 64px;
  min-width: 0;          /* don't let the full-size shot inside stretch it */
  width: 64px;
  height: 64px;
  border-radius: 6px;
  border: none;
  background: var(--glass);
  overflow: hidden;
}
/* Frame picker */
.frame-picker {
  position: absolute;
  z-index: 35;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}
.frame-picker[hidden] { display: none; }
.picker-card {
  position: relative;
  width: min(360px, 100%);
  padding: 24px 20px 20px;
  border-radius: 18px;
  background: #4f1410;   /* the print page's burgundy */
  color: var(--cream);
  box-shadow: 0 20px 50px rgba(20, 0, 0, 0.5);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.picker-title { font-family: 'Instrument Serif', Georgia, serif; font-size: 28px; }
.picker-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}
.picker-close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.picker-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.picker-start { min-width: 160px; font-size: 15px; }
.picker-options { display: flex; gap: 12px; width: 100%; }
.frame-opt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 6px 12px;
  border-radius: 12px;
  border: none;
  background: rgba(0, 0, 0, 0.18);
  font-size: 18px;
  cursor: pointer;
}
.frame-opt.is-selected { border-color: #b41010; box-shadow: 0 0 18px rgba(180, 16, 16, 0.4); }
[data-mode="gold"] .frame-opt.is-selected { border-color: #e0ad3e; box-shadow: 0 0 18px rgba(224, 173, 62, 0.4); }
[data-mode="fire"] .frame-opt.is-selected { border-color: #ff8a2a; box-shadow: 0 0 18px rgba(255, 138, 42, 0.4); }
.frame-icon {
  display: grid;
  gap: 3px;
  padding: 4px 4px 4px;
  border-radius: 2px;
  background: #fbf9f4;
}
.frame-icon i { display: block; background: #b9b2a8; border-radius: 1px; }
.frame-icon--2 { width: 34px; grid-template-rows: 18px 18px; padding-bottom: 10px; }
.frame-icon--3 { width: 20px; grid-template-rows: 14px 14px 14px; padding-bottom: 9px; }
.frame-icon--4 { width: 36px; grid-template-columns: 1fr 1fr; grid-template-rows: 20px 20px; }

.booth-thumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }

/* The print: burgundy room, the booth, and the photo sticking out of it */
.print-screen {
  position: absolute;
  z-index: 45;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background: #4f1410;
  color: #f3ece0;
  overflow-y: auto;
}
.print-screen[hidden] { display: none; }
.print-stage { position: relative; flex: none; }
/* sized by width so the element box matches the drawn booth (the photo is placed relative to it) */
.print-booth { display: block; width: min(92vw, calc(60vh * 0.954), 610px); height: auto; }
.print-slot {
  position: absolute;
  left: var(--pl, 44%);
  top: var(--pt, 25%);
  width: var(--pw, 60%);
  height: var(--ph, 60%);
  transform: rotate(var(--pa, 6deg));
  transform-origin: top left;
  /* hide only what's above the top edge — the shadow can still spill out */
  clip-path: inset(0 -80px -80px -80px);
}
.print-photo {
  display: block;
  width: 100%;
  height: 100%;
  background: #fbf9f4;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.3);
}
/* Slides out of the slot in one smooth go */
.print-photo.is-printing { animation: printOut 1.4s cubic-bezier(0.22, 0.7, 0.3, 1) both; }
@keyframes printOut {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}
/* Phones: smaller booth, nudged left, so the photo sticking out stays on screen */
@media (max-width: 600px) {
  .print-booth { width: min(78vw, calc(62vh * 0.954)); }
  .print-stage { margin-right: 12vw; }
}
.print-byline { font-family: 'Instrument Serif', Georgia, serif; font-size: 20px; }

.print-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: opacity 0.5s;
}
.print-actions[hidden] { display: flex; visibility: hidden; opacity: 0; }
.print-filters { display: flex; gap: 8px; }
.print-filter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  color: #f3ece0;
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.print-filter canvas {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  object-fit: cover;
}
.print-filter.is-active canvas { border-color: #fff4dc; box-shadow: 0 0 0 3px rgba(255, 244, 220, 0.25); }
/* The two saves side by side (main actions), Share underneath as a plain outline */
.print-buttons { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.print-save { display: flex; justify-content: center; gap: 10px; }
.print-buttons .ui-btn { min-width: 132px; }
.print-buttons .ui-btn--outline { min-width: 274px; }
.ui-btn--outline { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(243, 236, 224, 0.85); }
.ui-btn--share { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.ui-btn--share svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 400px) {
  .print-buttons .ui-btn { min-width: 128px; }
  .print-buttons .ui-btn--outline { min-width: 266px; }
}

.hint {
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 26px 6px;
  background-color: rgba(74, 15, 12, 0.9);
  background-clip: border-box;   /* fill right out to the bronze rule */
  color: #f1dfbf;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.6s;
}
.hint.is-hidden { opacity: 0; }
.hint-hand {
  width: 48px;
  height: 48px;
  fill: none;
  stroke: #f1dfbf;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: pinch 1.4s ease-in-out infinite;
}
.hint-title { margin-top: 6px; font-family: 'Instrument Serif', Georgia, serif; font-size: 28px; line-height: 1.1; white-space: nowrap; }
.hint .orn-rule { margin: 10px auto 8px; }
.hint-sub { font-family: 'Instrument Serif', Georgia, serif; font-size: 17px; opacity: 0.9; white-space: nowrap; }

@keyframes pinch {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.82); }
}

.status {
  position: absolute;
  z-index: 20;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--win-bottom, 0px) + 100px + env(safe-area-inset-bottom));   /* just above the shutter */
  max-width: calc(100% - 64px);
  padding: 0 14px;
  border: 10px solid transparent;
  border-image: url(assets/orn-frame.svg) 34 / 10px stretch;
  background: url(assets/parchment.svg) center / 100% 100%;
  color: var(--ink-brown);
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 17px;
  line-height: 1.6;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
.status::before, .status::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  background: url(assets/orn-star.svg) center / contain no-repeat;
}
.status::before { left: -22px; }
.status::after { right: -22px; }
.status:empty { display: none; }
/* On short screens the hint card and the status label would overlap — while
   the hint is up, it says enough on its own */
@media (max-height: 640px) {
  .hint:not(.is-hidden) ~ .status { display: none; }
}

.error-box {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.85);
  line-height: 1.6;
}
.error-box[hidden] { display: none; }

.boot-error {
  position: fixed;
  z-index: 100;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 12px 16px;
  border-radius: 10px;
  background: #3a0000;
  border: 1px solid #a00000;
  font-size: 13px;
  line-height: 1.5;
}
.boot-error[hidden] { display: none; }
