:root {
  --ink: #1c1420;
  --paper: #f3e6c8;
  --paper-deep: #e8d4a8;
  --gold: #e09a3a;
  --ember: #c45c1a;
  --indigo: #1a2744;
  --midnight: #0e1524;
  --leaf: #4a6a3a;
  --cream: #fff6e4;
  --frame: #b8893a;
  --shadow: rgba(14, 12, 8, 0.55);
}

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

html, body {
  height: 100%;
  background: var(--midnight);
  color: var(--cream);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  min-height: 100dvh;
}

#app {
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  background: var(--indigo);
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* Paper grain */
.grain::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* Title */
#title {
  background: #12182a;
}
#title .hero {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#title .hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  filter: saturate(1.05) contrast(1.05);
}
#title .veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(12,16,28,0.15) 20%, rgba(12,16,28,0.82) 72%, #0e1524 100%);
}
#title .copy {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 22px 28px;
  z-index: 2;
}
#title .eyebrow {
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 8px;
}
#title h1 {
  font-size: 34px;
  line-height: 1.05;
  font-weight: 600;
  text-shadow: 0 2px 18px rgba(0,0,0,.55);
}
#title h1 em {
  font-style: italic;
  color: #f0c56a;
}
#title .tag {
  margin-top: 10px;
  font-size: 15px;
  color: #f0e2c4;
  opacity: 0.88;
}
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  background: var(--gold);
  color: var(--ink);
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(224, 154, 58, 0.28);
}
.btn.ghost {
  background: transparent;
  color: var(--cream);
  box-shadow: none;
  border: 1px solid rgba(243, 230, 200, 0.28);
}
.btn.wide { width: 100%; margin-top: 16px; }
.btn:active { transform: scale(0.98); }
.row { display: flex; gap: 10px; }

/* Gallery */
#gallery { background: #10182a; }
#gallery .stage {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#gallery .stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% 40%;
}
#gallery .hud {
  position: absolute;
  left: 14px; right: 14px; top: calc(12px + env(safe-area-inset-top));
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.plaque {
  background: rgba(16, 18, 28, 0.72);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(232, 196, 120, 0.28);
  padding: 10px 12px;
  border-radius: 12px;
  max-width: 72%;
}
.plaque strong { display: block; font-size: 15px; }
.plaque span { font-size: 12px; color: #e8d7b0; opacity: 0.85; }

.frames {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.frame-hit {
  position: absolute;
  border: 2px solid rgba(240, 197, 106, 0.0);
  border-radius: 6px;
  background: rgba(240, 197, 106, 0.0);
}
.frame-hit:active { background: rgba(240, 197, 106, 0.12); }
.frame-hit.locked { filter: grayscale(0.35); }
.frame-hit .label {
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translate(-50%, 100%);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(14,21,36,0.8);
  padding: 3px 6px;
  border-radius: 6px;
  white-space: nowrap;
}
.frame-hit.ready { box-shadow: 0 0 0 2px rgba(240,197,106,0.55), 0 0 18px rgba(224,154,58,0.35); }

.rail {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 4;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, rgba(8,12,22,0.88) 36%);
  -webkit-overflow-scrolling: touch;
}
.thumb {
  flex: 0 0 92px;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--cream);
  font-family: inherit;
  text-align: left;
}
.thumb img {
  width: 92px;
  height: 64px;
  object-fit: cover;
  border: 3px solid #c49a4a;
  border-radius: 3px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  display: block;
}
.thumb.locked img { filter: grayscale(0.5) brightness(0.65); }
.thumb figcaption {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 5px;
  opacity: 0.85;
}

/* Scene */
#scene { background: #0c1018; }
#scene .canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#scene .canvas-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.6s ease;
}
#scene.light-gold .canvas-wrap img { filter: saturate(1.08) brightness(1.05) sepia(0.08); }
#scene.light-moon .canvas-wrap img { filter: saturate(0.72) brightness(0.92) hue-rotate(198deg) contrast(1.08); }
#scene.light-gutter .canvas-wrap img { filter: saturate(0.85) brightness(0.7) contrast(1.15); }
#scene.wind-on .canvas-wrap img { animation: sway 4.6s ease-in-out infinite; }
@keyframes sway {
  0%,100% { transform: scale(1.04) translateX(0); }
  50% { transform: scale(1.06) translateX(-1.4%); }
}

.hotspot {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(243,230,200,0.55);
  background: rgba(243,230,200,0.12);
  box-shadow: 0 0 0 6px rgba(243,230,200,0.05);
  animation: pulse 2.4s ease-in-out infinite;
}
.hotspot.used {
  opacity: 0.35;
  animation: none;
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.scene-top {
  position: absolute;
  left: 12px; right: 12px;
  top: calc(10px + env(safe-area-inset-top));
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.act-chip {
  background: rgba(12,16,24,0.7);
  border: 1px solid rgba(232,196,120,0.3);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  letter-spacing: 0.06em;
}
.icon-btn {
  background: rgba(12,16,24,0.7);
  border: 1px solid rgba(232,196,120,0.3);
  color: var(--cream);
  border-radius: 999px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 12px;
}

.script {
  position: relative;
  background: linear-gradient(180deg, #f6ead0, #ead6ae);
  color: var(--ink);
  padding: 14px 16px 18px;
  min-height: 168px;
  max-height: 42%;
  overflow: auto;
  box-shadow: 0 -12px 30px rgba(0,0,0,0.35);
}
.script .who {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8a4a16;
  margin-bottom: 4px;
}
.script .line {
  font-size: 16px;
  line-height: 1.35;
}
.script .choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.choice {
  text-align: left;
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(28,20,32,0.16);
  background: rgba(255,246,228,0.7);
  color: var(--ink);
}
.choice:active { background: #f0c56a; }

.direct {
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px;
  background: #ead6ae;
}
.direct button {
  flex: 1;
  font-family: inherit;
  font-size: 12px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid rgba(28,20,32,0.14);
  background: #f6ead0;
  color: var(--ink);
}
.direct button.on {
  background: #c45c1a;
  color: #fff6e4;
  border-color: transparent;
}

/* Ending / cards */
.card-screen {
  background:
    radial-gradient(120% 80% at 50% -10%, #3a2a18 0%, #12182a 48%, #0b1020 100%);
  padding: 28px 22px calc(24px + env(safe-area-inset-bottom));
  justify-content: flex-end;
}
.card-screen h2 {
  font-size: 28px;
  line-height: 1.15;
  margin-bottom: 10px;
}
.card-screen p {
  font-size: 16px;
  line-height: 1.45;
  color: #f0e2c4;
  margin-bottom: 12px;
}
.fine {
  font-size: 13px;
  opacity: 0.75;
}

.name-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.name-row input {
  flex: 1;
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(28,20,32,0.2);
  background: #fff6e4;
  color: var(--ink);
}

/* Web additions */
.studio-line { margin-top: 14px; font-size: 11.5px; letter-spacing: .04em; color: #e8d7b0; opacity: .75; text-align: center; }
.studio-line a { color: #f0c56a; text-decoration: none; }
.patron { margin: 6px 0 4px; padding: 14px 14px 12px; border-radius: 14px; background: rgba(243,230,200,.07); border: 1px solid rgba(232,196,120,.28); }
.patron strong { display: block; font-size: 15px; color: #f0c56a; margin-bottom: 4px; }
.patron span { display: block; font-size: 13.5px; line-height: 1.4; color: #f0e2c4; opacity: .9; }
.patron .btn { margin-top: 10px; padding: 10px 16px; font-size: 14px; }
.patron em { display: block; font-style: normal; font-size: 12px; margin-top: 8px; color: #e8d7b0; opacity: .8; }
.card-screen { overflow-y: auto; }
.hotspot { cursor: pointer; }
.hotspot:focus-visible, .btn:focus-visible, .choice:focus-visible { outline: 2px solid #f0c56a; outline-offset: 2px; }
@media (min-width: 700px) {
  body { background: radial-gradient(120% 90% at 50% 0%, #25324f 0%, #0e1524 60%); }
  #app { box-shadow: 0 0 0 1px rgba(232,196,120,.18), 0 30px 80px rgba(0,0,0,.5); }
}
.card-screen { justify-content: flex-start; }
.card-screen > :first-child { margin-top: auto; }
.hotspot { border: 2px solid rgba(255,244,214,.9); background: rgba(255,236,190,.18); box-shadow: 0 0 0 3px rgba(20,14,10,.28), 0 0 18px rgba(255,210,120,.35); }
.hotspot.used { opacity: .45; }

/* Patron ticket */
.linkish { background: none; border: 0; padding: 4px 6px; color: #f0c56a; font: inherit; font-size: 12px; letter-spacing: .04em; text-decoration: underline; cursor: pointer; }
.patron-badge { display: inline-block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #1c1420; background: linear-gradient(135deg, #f4d27c, #c8923a); padding: 5px 10px; border-radius: 999px; font-weight: 700; }
.patron .patron-badge { margin-bottom: 8px; }
.eyebrow-s { letter-spacing: .22em; text-transform: uppercase; color: #e09a3a; font-size: 11px; margin-bottom: 10px; }
#patron h2 { margin-top: 0; }
.pt-list { margin: 0 0 12px 18px; color: #f0e2c4; font-size: 15px; line-height: 1.45; }
.pt-box { margin: 10px 0; padding: 14px; border-radius: 14px; background: rgba(243,230,200,.07); border: 1px solid rgba(232,196,120,.24); }
.pt-box img { width: 100%; height: auto; border-radius: 8px; border: 4px solid #c49a4a; margin: 10px 0; display: block; }
.pt-box .btn.wide { margin-top: 0; }
.pt-box .btn[disabled] { opacity: .6; cursor: not-allowed; box-shadow: none; }
.pt-box .fine { margin: 8px 0 0; }
.pt-box a { color: #f0c56a; }
.pt-note { font-style: italic; }
.pt-label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 6px; color: #fff6e4; }
.pt-row { display: flex; gap: 8px; min-width: 0; }
.pt-row input { flex: 1 1 auto; min-width: 0; font-family: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(232,196,120,.35); background: #fff6e4; color: #1c1420; }
.pt-go { flex: 0 0 auto; }
#ptCode { word-break: break-all; color: #f0c56a; font-size: 13px; }
#app, .screen { max-width: 100%; }
@media (prefers-reduced-motion: reduce) { .hotspot { animation: none; } #scene.wind-on .canvas-wrap img { animation: none; } }
[hidden] { display: none !important; }
.patron span.patron-badge { display: inline-block; width: auto; color: #1c1420; font-size: 11px; line-height: 1.2; opacity: 1; margin: 0 0 8px; }
