:root {
  --paper: #efe8da;
  --paper-2: #fbf8f2;
  --ink: #231f20;
  --ink1: #ff48b0;
  --ink2: #0078bf;
  --ink3: #ffe800;
  --sans: "Bricolage Grotesque", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
  --serif: "Instrument Serif", Georgia, serif;
  --panel-w: 380px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; color: var(--ink); font-family: var(--sans); font-size: 17px; background: var(--paper); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink2); outline-offset: 3px; }
::selection { background: var(--ink3); color: var(--ink); }

/* ---------- the app fills the window exactly ---------- */
.app {
  position: fixed; inset: 0; display: grid; overflow: hidden; background: var(--paper);
  grid-template-columns: var(--panel-w) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "bar bar" "panel stage";
}
.app::after { /* paper grain above the ink blobs */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  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='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .14 0 0 0 0 .12 0 0 0 0 .12 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* drifting riso ink blobs — the wow backdrop, tinted by the current poster */
.blobs { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blobs i { position: absolute; width: 58vmax; height: 58vmax; border-radius: 50%; filter: blur(70px); opacity: .42; mix-blend-mode: multiply; transition: background 1.2s ease; }
.blobs i:nth-child(1) { background: var(--ink1); left: 18%; top: -26vmax; animation: drift1 22s ease-in-out infinite alternate; }
.blobs i:nth-child(2) { background: var(--ink2); right: -22vmax; bottom: -30vmax; animation: drift2 26s ease-in-out infinite alternate; }
.blobs i:nth-child(3) { background: var(--ink3); left: 34%; bottom: -36vmax; width: 46vmax; height: 46vmax; opacity: .5; animation: drift3 19s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(14vw, 12vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vw, -10vh) scale(.9); } }
@keyframes drift3 { to { transform: translate(-12vw, -14vh) scale(1.2); } }

.bar, .panel, .stage { position: relative; z-index: 1; }

/* ---------- header ---------- */
.bar { grid-area: bar; display: flex; align-items: center; gap: 18px; padding: 14px 22px 10px; }
.logo { margin: 0; font: 800 38px/1 var(--sans); letter-spacing: -.03em; display: flex; white-space: nowrap; }
.logo span { display: inline-block; transform: translateY(var(--y)) rotate(var(--r)); margin-right: var(--ls); animation: drop .7s cubic-bezier(.3, 1.7, .5, 1) backwards; animation-delay: var(--d); }
.logo span:nth-child(3n+1) { color: var(--ink1); transition: color 1s; }
.logo span:nth-child(5n+2) { font-family: var(--serif); font-style: italic; font-weight: 400; }
.logo span:nth-child(4n+3) { color: var(--ink2); transition: color 1s; }
.logo span.sp { width: .28em; }
@keyframes drop { from { transform: translateY(-60px) rotate(30deg); opacity: 0; } }
.bar__tag { margin: 0; font: italic 22px/1 var(--serif); flex: 1; }
.help { border: 2px solid var(--ink); background: var(--paper-2); border-radius: 999px; padding: 10px 18px; font: 700 15px/1 var(--sans); box-shadow: 3px 3px 0 var(--ink); }
.help:hover { background: var(--ink3); }

/* ---------- left panel ---------- */
.panel {
  grid-area: panel; display: flex; flex-direction: column; min-height: 0; margin: 4px 0 18px 18px;
  background: rgba(251, 248, 242, .86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 2px solid var(--ink); border-radius: 24px; box-shadow: 6px 6px 0 var(--ink); overflow: hidden;
}
.panel__scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 18px 6px; display: grid; gap: 18px; align-content: start; scrollbar-width: thin; }
.step { display: grid; gap: 10px; }
.step__label { display: flex; align-items: center; gap: 10px; font: 800 20px/1.1 var(--sans); }
.num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; font: 700 15px/1 var(--mono); flex: none; }
.num--light { background: #fff; color: var(--ink); }
textarea, .extra input {
  width: 100%; border: 2px solid var(--ink); border-radius: 14px; background: #fff; padding: 12px 14px; color: var(--ink);
  font: 800 24px/1.15 var(--sans); resize: none;
}
.extra { display: grid; gap: 8px; }
.extra[hidden] { display: none; }
.extra input { font: 600 17px/1.2 var(--sans); padding: 11px 14px; }
textarea:focus, .extra input:focus { outline: none; border-color: var(--ink2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink2) 30%, transparent); }
.textlink { justify-self: start; border: 0; background: none; padding: 2px 0; font: 700 15px var(--sans); text-decoration: underline; text-underline-offset: 3px; opacity: .75; }
.textlink:hover { opacity: 1; }

.looks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.look { position: relative; border: 2px solid transparent; border-radius: 10px; padding: 0; background: none; transition: transform .2s cubic-bezier(.3, 1.7, .5, 1); }
.look canvas { display: block; width: 100%; aspect-ratio: 3 / 4; border-radius: 7px; box-shadow: 0 3px 8px -3px rgba(0, 0, 0, .35); }
.look:hover { transform: translateY(-3px) rotate(-2deg); }
.look.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink3), 3px 3px 0 4px var(--ink); }
.look.on::after { content: "✓"; position: absolute; top: -9px; right: -9px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font: 800 14px var(--sans); }

.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; border: 2px solid var(--ink); border-radius: 16px; padding: 14px 16px;
  font: 800 19px/1 var(--sans); box-shadow: 4px 4px 0 var(--ink); transition: transform .12s, box-shadow .12s, background .2s; }
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .4; cursor: default; box-shadow: 2px 2px 0 var(--ink); }
.btn--pink { background: var(--ink1); font-size: 22px; padding: 17px 16px; transition: transform .12s, box-shadow .12s, background 1s; }
.btn--soft { background: #fff; font-size: 17px; }
.btn--black { background: var(--ink); color: #fff; font-size: 20px; padding: 17px 16px; box-shadow: 4px 4px 0 var(--ink1); }
.btn--black:hover:not(:disabled) { box-shadow: 5px 5px 0 var(--ink1); }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel__end { padding: 14px 18px 14px; border-top: 2px dashed rgba(35, 31, 32, .25); display: grid; gap: 12px; }
.panel__end .step--play { padding-bottom: 4px; }
.minor { display: flex; justify-content: space-between; gap: 6px; }
.minor button { border: 0; background: none; padding: 4px 2px; font: 600 14px var(--sans); text-decoration: underline; text-underline-offset: 3px; opacity: .75; }
.minor button:hover { opacity: 1; }
.minor button.rec { color: #d0213a; opacity: 1; text-decoration: none; }

/* ---------- stage ---------- */
.stage { grid-area: stage; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 6px 24px 18px; min-height: 0; perspective: 1600px; }
.poster { position: relative; width: var(--pw, 420px); transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) rotate(-1.2deg); transition: transform .5s cubic-bezier(.2, .8, .3, 1); transform-style: preserve-3d; }
.poster canvas { display: block; width: 100%; aspect-ratio: 3 / 4; background: #f4efe6;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .1), 0 22px 34px -14px rgba(35, 31, 32, .5), 0 60px 90px -40px rgba(35, 31, 32, .45); }
.poster.slam { animation: slam .55s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes slam { 0% { transform: rotate(2deg) scale(.93); } 60% { transform: rotate(-2.2deg) scale(1.015); } 100% { transform: rotate(-1.2deg) scale(1); } }
.tape { position: absolute; z-index: 2; width: 110px; height: 32px; background: rgba(255, 250, 230, .62); box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
  clip-path: polygon(3% 0, 97% 4%, 100% 50%, 96% 100%, 4% 96%, 0 50%); }
.tape--a { top: -13px; left: -28px; transform: rotate(-32deg); }
.tape--b { top: -10px; right: -24px; transform: rotate(28deg); }
.stamp { position: absolute; z-index: 3; right: -34px; bottom: 14%; width: 108px; height: 108px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: var(--ink3); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); opacity: 0; pointer-events: none; transition: background .3s; }
.stamp::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; border: 2px dashed var(--ink); }
.stamp b { font: 800 38px/1 var(--sans); letter-spacing: -.03em; }
.stamp span { font: 700 10px/1.1 var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.stamp.in { animation: stamp .5s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.stamp.low { background: #f15060; color: #fff; }
@keyframes stamp { 0% { opacity: 0; transform: scale(2.4) rotate(-40deg); } 100% { opacity: 1; transform: scale(1) rotate(12deg); } }

.say { display: flex; align-items: center; gap: 12px; max-width: min(560px, 100%); min-height: 64px; padding: 10px 18px 10px 12px;
  background: rgba(251, 248, 242, .9); border: 2px solid var(--ink); border-radius: 20px; box-shadow: 4px 4px 0 var(--ink); }
.say__who { width: 30px; height: 56px; flex: none; overflow: visible; }
.who { display: none; } .say[data-who="0"] .who--0, .say[data-who="1"] .who--1, .say[data-who="2"] .who--2 { display: inline; }
.say:not([data-who]) .who--0 { display: inline; }
.say.talk .say__who { animation: talk .18s ease-in-out infinite alternate; }
@keyframes talk { to { transform: translateY(-3px) rotate(-4deg); } }
.say__text { display: grid; gap: 3px; min-width: 0; }
.say__text b { font: 700 12px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .04em; }
.say__text span { font: italic 21px/1.15 var(--serif); }

/* ---------- help + toast ---------- */
.help-sheet { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(35, 31, 32, .5); }
.help-sheet[hidden] { display: none; }
.help-sheet__card { position: relative; width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--paper-2); border: 3px solid var(--ink); border-radius: 24px;
  padding: 26px 26px 22px; box-shadow: 8px 8px 0 var(--ink1); animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.9) rotate(-3deg); opacity: 0; } }
.help-sheet__card h2 { margin: 0 0 12px; font: 800 30px/1.05 var(--sans); }
.help-sheet__card ol { padding-left: 22px; margin: 0 0 14px; display: grid; gap: 8px; font-size: 18px; line-height: 1.4; }
.help-sheet__small { font-size: 15px; line-height: 1.45; opacity: .75; margin: 0 0 16px; }
.help-sheet__x { position: absolute; top: 12px; right: 12px; width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--ink); background: var(--ink3); font-size: 24px; line-height: 1; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 30; transform: translate(-50%, 160%); background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 999px;
  font: 700 16px var(--sans); box-shadow: 4px 4px 0 var(--ink1); transition: transform .35s cubic-bezier(.3, 1.6, .5, 1); max-width: calc(100vw - 32px); text-align: center; }
.toast.in { transform: translate(-50%, 0); }

/* ---------- smaller laptops ---------- */
@media (max-height: 760px) and (min-width: 821px) {
  .panel__scroll { gap: 13px; padding-top: 14px; }
  textarea { font-size: 21px; padding: 10px 12px; }
  .btn--pink, .btn--black { padding: 14px 16px; }
  .say { min-height: 54px; } .say__text span { font-size: 18px; }
  .logo { font-size: 32px; }
  .bar { padding-top: 10px; padding-bottom: 6px; }
  .step { gap: 7px; } .step__label { font-size: 18px; }
  textarea { height: 64px; }
  .looks { grid-template-columns: repeat(4, 56px); gap: 8px 10px; }
  .panel__end { padding: 10px 18px 10px; gap: 9px; }
  .btn--pink, .btn--black { padding: 12px 16px; font-size: 18px; }
  .duo .btn { padding-top: 10px; padding-bottom: 10px; }
}

/* ---------- phones & narrow tablets: poster on top, controls below, still no page scroll ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "bar" "stage" "panel"; }
  .bar { padding: 10px 14px 4px; gap: 10px; }
  .logo { font-size: 27px; }
  .bar__tag { display: none; }
  .help { margin-left: auto; padding: 8px 13px; font-size: 14px; }
  .stage { padding: 6px 16px 8px; gap: 8px; }
  .say { min-height: 0; padding: 6px 12px 6px 8px; border-radius: 14px; }
  .say__who { width: 18px; height: 34px; }
  .say__text b { display: none; } .say__text span { font-size: 16px; }
  .stamp { width: 74px; height: 74px; right: -14px; } .stamp b { font-size: 26px; } .stamp span { font-size: 8px; }
  .tape { width: 70px; height: 24px; } .tape--a { left: -16px; } .tape--b { right: -14px; }
  .panel { margin: 0 10px calc(10px + env(safe-area-inset-bottom)); max-height: 46dvh; border-radius: 20px; box-shadow: 4px 4px 0 var(--ink); }
  .panel__scroll { padding: 12px 12px 4px; gap: 12px; }
  .step { gap: 7px; }
  .step__label { font-size: 16px; } .num { width: 24px; height: 24px; font-size: 12px; }
  textarea { font-size: 19px; padding: 9px 11px; }
  .looks { display: flex; overflow-x: auto; gap: 8px; padding: 4px 4px 8px; margin: 0 -4px; scroll-snap-type: x mandatory; }
  .look { flex: 0 0 64px; scroll-snap-align: start; }
  .btn { padding: 12px 10px; font-size: 16px; border-radius: 13px; }
  .btn--pink { font-size: 18px; padding: 13px 10px; }
  .btn--black { font-size: 17px; padding: 13px 10px; }
  .panel__end { padding: 8px 12px 10px; gap: 6px; }
  .minor button { font-size: 13px; }
  .minor { justify-content: flex-start; gap: 18px; padding-right: 56px; }
}
@media (max-width: 820px) {
  .say { display: none; }
  .stage .step--play { display: flex; gap: 8px; width: 100%; max-width: 460px; }
  .stage .step--play .step__label { display: none; }
  .stage .step--play .duo { display: contents; }
  .stage .step--play .btn { width: auto; flex: 0 0 auto; font-size: 15px; padding: 11px 12px; white-space: nowrap; }
  .stage .step--play #surprise { flex: 1 1 auto; font-size: 16px; }
  textarea { height: 52px; }
  .stage #undo { padding: 11px 14px; font-size: 18px; }
  .stage #undo .lbl { display: none; }
  .stage .step--play #surprise, .stage #newColours { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.duo .btn { white-space: nowrap; font-size: 16px; padding-left: 8px; padding-right: 8px; }
