:root {
  --ink: #120e0a;
  --ink-2: #1c1610;
  --ivory: #f4ebdd;
  --ivory-dim: #b9ad9b;
  --muted: #8a7f70;
  --blue: #3ba0da;
  --red: #e74415;
  --yellow: #fbb900;
  --green: #84b727;
  --display: "Pally", ui-rounded, system-ui, sans-serif;
  --text: "Switzer", system-ui, sans-serif;
  --cut: 34px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--ivory); overflow: hidden; }
body { font-family: var(--text); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }

/* Composed at 1920x1080 (landscape) or 1080x1920 (portrait) and scaled to fit the screen. */
.viewport { position: fixed; inset: 0; }
.stage {
  position: absolute; left: 50%; top: 50%; width: 1920px; height: 1080px;
  transform: translate(-50%, -50%) scale(var(--s, 1)); transform-origin: center;
  overflow: hidden; background: var(--ink);
}
.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.03); transition: filter 1.2s ease; }
.stage[data-mode="attract"] .bg { filter: brightness(.7) saturate(.85); }
.grain {
  position: absolute; inset: 0; opacity: .09; mix-blend-mode: overlay; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.brand { position: absolute; left: 96px; top: 64px; display: flex; align-items: center; gap: 22px; z-index: 3; }
.logo { height: 52px; width: auto; pointer-events: none; }
.event { font-size: 22px; font-weight: 500; color: var(--ivory-dim); padding-left: 22px; border-left: 1px solid rgb(244 235 221 / .22); line-height: 30px; }

.pagi { position: absolute; left: 150px; top: 100px; width: 760px; height: 963px; }

/* ---------- right column (landscape) ---------- */
.invite, .talk, .hint, .asks, .bye, .typer { position: absolute; left: 1000px; right: 110px; }

.invite { top: 160px; }
.hello { margin: 0; font: 700 112px/.94 var(--display); letter-spacing: -.02em; color: var(--ivory); }
.pitch { margin: 34px 0 0; max-width: 700px; font: 400 34px/1.3 var(--text); color: var(--ivory-dim); text-wrap: pretty; }
.start {
  position: relative; margin-top: 48px; display: flex; flex-direction: column; gap: 8px; text-align: left;
  padding: 30px 64px 30px 40px; background: var(--ivory); color: var(--ink);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), background-color .2s ease;
}
.start-main { font: 700 46px/1 var(--display); }
.start-sub { font: 500 22px/1.2 var(--text); color: #5c5246; }
.start:active { transform: scale(.97); background: #fff7ea; }
/* a slow breath on the call to action so the screen never looks dead */
.stage[data-mode="attract"] .start { animation: breathe 3.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: none; } 50% { transform: translateX(6px); } }

.talk {
  top: 200px; height: 430px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 28px;
  mask-image: linear-gradient(to bottom, transparent 0, #000 110px);
}
.turn { animation: rise .45s cubic-bezier(.2, .8, .2, 1); transition: opacity .6s ease; }
.turn:not(:nth-last-child(-n + 2)) { opacity: .3; }
.turn p { margin: 0; text-wrap: pretty; }
.turn.pagi-line p { font: 500 44px/1.22 var(--display); color: var(--ivory); }
.turn.pagi-line.long p { font-size: 36px; }
.turn.guest-line { padding-left: 26px; border-left: 3px solid rgb(244 235 221 / .18); }
.turn.guest-line p { font: 400 29px/1.3 var(--text); color: var(--ivory-dim); }
.turn.guest-line p:empty::before { content: "…"; }
@keyframes rise { from { transform: translateY(18px); opacity: .5; } to { transform: none; opacity: 1; } }

/* state line: four petals that breathe with the visitor's voice */
.hint { top: 664px; display: flex; align-items: center; gap: 22px; min-height: 64px; }
.meter { position: relative; width: 56px; height: 56px; flex: none; }
.meter .p { position: absolute; width: 26px; height: 26px; transition: transform .12s ease-out; transform-origin: center; }
.meter .p1 { left: 0; top: 0; fill: var(--blue); --r: 180deg; }
.meter .p2 { right: 0; top: 0; fill: var(--red); --r: -90deg; }
.meter .p3 { left: 0; bottom: 0; fill: var(--yellow); --r: 90deg; }
.meter .p4 { right: 0; bottom: 0; fill: var(--green); --r: 0deg; }
.meter .p { transform: rotate(var(--r)) scale(calc(.62 + var(--lv, 0) * .55)); }
.meter .p2 { transition-delay: .03s; } .meter .p3 { transition-delay: .06s; } .meter .p4 { transition-delay: .09s; }
.stage[data-state="thinking"] .meter { animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint-text { font: 500 30px/1.2 var(--text); color: var(--ivory); }
.end { margin-left: auto; font: 500 24px/1 var(--text); color: var(--ivory-dim); padding: 18px 4px 18px 24px; text-decoration: underline; text-decoration-color: rgb(244 235 221 / .3); text-underline-offset: 6px; }
.end:active { color: var(--ivory); }
.hold {
  font: 700 32px/1 var(--display); color: var(--ink); background: var(--yellow); padding: 26px 40px;
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
}
.hold.on { background: var(--green); transform: scale(.97); }

/* suggested questions */
.asks { bottom: 96px; }
.asks-label { margin: 0 0 10px; font: 500 21px/1 var(--text); color: var(--ivory-dim); letter-spacing: .02em; }
.ask-list { display: flex; flex-direction: column; }
.ask {
  display: flex; align-items: center; gap: 22px; width: 100%; text-align: left; padding: 15px 0;
  font: 500 30px/1.25 var(--text); color: var(--ivory);
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), color .2s ease;
}
.ask svg { width: 22px; height: 22px; flex: none; transition: transform .35s cubic-bezier(.3, 1.6, .4, 1); }
.ask:nth-child(4n + 1) svg { fill: var(--blue); transform: rotate(180deg); }
.ask:nth-child(4n + 2) svg { fill: var(--red); transform: rotate(-90deg); }
.ask:nth-child(4n + 3) svg { fill: var(--yellow); transform: rotate(90deg); }
.ask:nth-child(4n + 4) svg { fill: var(--green); }
.ask:active { transform: translateX(10px); color: #fff; }
.ask:active svg { transform: rotate(270deg) scale(1.25); }
.ask.new { animation: rise .5s cubic-bezier(.2, .8, .2, 1); }

.support { position: absolute; right: 110px; bottom: 44px; margin: 0; font: 400 20px/1 var(--text); color: var(--muted); }

/* goodbye card */
.bye {
  top: 250px; display: grid; grid-template-columns: 260px 1fr; gap: 44px; align-items: center;
  padding: 48px 56px 64px; background: var(--ivory); color: var(--ink);
  clip-path: polygon(0 0, calc(100% - 48px) 0, 100% 48px, 100% 100%, 48px 100%, 0 calc(100% - 48px));
  animation: rise .5s cubic-bezier(.2, .8, .2, 1);
}
.qr { width: 260px; height: 260px; display: block; }
.bye-title { margin: 0; font: 700 64px/1 var(--display); }
.bye-web { margin: 16px 0 22px; font: 700 36px/1 var(--display); color: var(--blue); }
.bye-line { margin: 10px 0 0; font: 400 24px/1.35 var(--text); color: #4a4036; }
.bye-timer { position: absolute; left: 56px; right: 56px; bottom: 26px; display: flex; gap: 6px; height: 6px; }
.bye-timer i { flex: 1; transform-origin: left; animation: drain var(--bye, 10s) linear forwards; }
.bye-timer i:nth-child(1) { background: var(--blue); } .bye-timer i:nth-child(2) { background: var(--red); }
.bye-timer i:nth-child(3) { background: var(--yellow); } .bye-timer i:nth-child(4) { background: var(--green); }
@keyframes drain { to { transform: scaleX(0); } }

.typer { bottom: 20px; z-index: 4; }
.typer input { width: 100%; font: 400 24px var(--text); color: var(--ivory); background: rgb(18 14 10 / .86); border: 1px solid rgb(244 235 221 / .25); border-radius: 12px; padding: 14px 18px; outline: none; user-select: text; }
.typer input:focus { border-color: var(--blue); }

/* ---------- what each mode shows ---------- */
.stage:not([data-mode="attract"]) .invite { display: none; }
.stage[data-mode="attract"] .talk, .stage[data-mode="attract"] .hint { display: none; }
.stage[data-mode="goodbye"] .talk, .stage[data-mode="goodbye"] .hint, .stage[data-mode="goodbye"] .asks { display: none; }
.stage[data-mode="connecting"] .end, .stage[data-mode="error"] .end { visibility: hidden; }
.stage[data-mode="attract"] .support, .stage[data-mode="goodbye"] .support { display: none; }
.stage[data-mode="live"] .asks { bottom: 96px; }
.stage[data-mode="live"] .ask { font-size: 26px; padding: 12px 0; }

/* ---------- maintenance ---------- */
.menu {
  position: absolute; left: 96px; top: 150px; z-index: 10; width: 620px; padding: 30px; display: flex; flex-direction: column; gap: 10px;
  background: rgb(18 14 10 / .95); border: 1px solid rgb(244 235 221 / .2); border-radius: 14px; font: 400 24px/1.3 var(--text);
}
.menu-title { margin: 0 0 8px; font-weight: 600; } .menu-title span { color: var(--muted); font-weight: 400; font-size: 20px; }
.menu > button, .menu-row button { text-align: left; padding: 12px 16px; background: rgb(244 235 221 / .07); border-radius: 8px; }
.menu-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; }
.menu b { color: var(--yellow); font-weight: 600; }
.debug { position: absolute; left: 24px; bottom: 16px; z-index: 9; margin: 0; font: 14px/1.4 ui-monospace, monospace; color: #cfc4b3; background: rgb(0 0 0 / .7); padding: 10px 12px; border-radius: 8px; white-space: pre; }

/* ---------- portrait totem: Pagi on top, words and questions below ---------- */
.stage.portrait { width: 1080px; height: calc(1920px + var(--extra, 0px)); }
.portrait .brand { left: 72px; top: 64px; }
.portrait .pagi { left: 170px; top: calc(130px + var(--extra, 0px) * .3); width: 740px; height: 937px; }
.portrait .invite, .portrait .talk, .portrait .hint, .portrait .asks, .portrait .bye, .portrait .typer { left: 72px; right: 72px; }
.portrait .invite { top: calc(1090px + var(--extra, 0px) * .5); }
.portrait .hello { font-size: 104px; }
.portrait .hello br { display: none; }
.portrait .pitch { margin-top: 22px; font-size: 32px; }
.portrait .start { margin-top: 34px; }
.portrait .talk { top: calc(1090px + var(--extra, 0px) * .5); height: 360px; }
.portrait .turn.pagi-line p { font-size: 46px; }
.portrait .turn.pagi-line.long p { font-size: 38px; }
.portrait .hint { top: calc(1470px + var(--extra, 0px) * .5); }
.portrait .asks { bottom: 104px; }
.portrait[data-mode="attract"] .asks { bottom: 96px; }
.portrait .support { right: auto; left: 72px; bottom: 48px; }
.portrait .bye { top: calc(1120px + var(--extra, 0px) * .5); grid-template-columns: 240px 1fr; padding: 44px 48px 60px; }
.portrait .qr { width: 240px; height: 240px; }

@media (prefers-reduced-motion: reduce) {
  .turn, .bye, .ask.new { animation: none; }
  .stage[data-mode="attract"] .start, .stage[data-state="thinking"] .meter { animation: none; }
}
