@font-face { font-family: "Zen Maru Gothic"; font-weight: 500; font-display: swap; src: url(fonts/zen-maru-500.woff2) format("woff2"); }
@font-face { font-family: "Zen Maru Gothic"; font-weight: 700; font-display: swap; src: url(fonts/zen-maru-700.woff2) format("woff2"); }
@font-face { font-family: "Klee One"; font-weight: 600; font-display: swap; src: url(fonts/klee-one-600.woff2) format("woff2"); }

:root {
  --cream: #f4ecdc;
  --paper: #fbf6ea;
  --frost: #9cc0dc;
  --frost-deep: #3d6a92;
  --pine: #4f7a5a;
  --pine-deep: #3b5e45;
  --berry: #b8324a;
  --berry-deep: #94253b;
  --gold: #d9a93f;
  --graphite: #3f3935;
  --blush: #e79aa6;
  --wood: #b98f68;
  --shadow: 0 10px 28px rgba(70, 45, 25, .22), 0 2px 6px rgba(70, 45, 25, .18);
  --hand: "Klee One", "Zen Maru Gothic", system-ui, sans-serif;
  --round: "Zen Maru Gothic", system-ui, sans-serif;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .36  0 0 0 0 .25  0 0 0 .16 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  touch-action: manipulation;
  font-family: var(--round);
  color: var(--graphite);
  background: var(--wood);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body[data-screen="play"] { overflow: hidden; overscroll-behavior: none; }
.desk { position: fixed; inset: 0; background: #c49c76 url(assets/desk-wide.webp) center / cover no-repeat; z-index: -2; }
@media (orientation: portrait) { .desk { background-image: url(assets/desk-tall.webp); } }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--frost-deep); outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.primary, .ghost {
  border: 0; border-radius: 999px; padding: .7em 1.4em; font-weight: 700; font-size: 1rem; min-height: 44px;
  transition: transform .12s ease, box-shadow .12s ease, background .2s;
}
.primary { background: var(--berry); color: #fff8ee; box-shadow: 0 3px 0 var(--berry-deep), 0 6px 14px rgba(148, 37, 59, .3); }
.primary:hover:not(:disabled) { transform: translateY(-1px); }
.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--berry-deep); }
.primary:disabled { background: #c9b9a6; box-shadow: 0 3px 0 #ad9c88; color: #f7efe2; }
.primary.big { font-size: 1.12rem; padding: .8em 1.8em; }
.ghost { background: rgba(255, 250, 240, .85); color: var(--graphite); box-shadow: inset 0 0 0 2px rgba(63, 57, 53, .18); }
.ghost:hover:not(:disabled) { background: #fff; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: rgba(255, 250, 240, .9);
  box-shadow: 0 2px 6px rgba(70, 45, 25, .2); font-size: 1.35rem; line-height: 1; display: grid; place-items: center;
}
.icon-btn:disabled { opacity: .4; }
.icon-btn.muted { opacity: .55; text-decoration: line-through; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.hint { font-size: .95rem; line-height: 1.5; color: #6a5d52; margin: .3rem 0; }
.small { font-family: var(--hand); font-size: .95rem; color: var(--berry); margin: 0; }
.letter {
  display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; padding: 0 .2em; border-radius: .35em;
  background: var(--berry); color: #fff8ee; font-family: var(--round); font-weight: 700; transform: rotate(-3deg); margin: 0 .1em;
}
.notecard {
  background: var(--paper) var(--grain); border-radius: 6px; box-shadow: var(--shadow); position: relative; padding: 1.4rem 1.5rem;
}
.notecard::before, .envelope::before {
  content: ""; position: absolute; top: -12px; left: 50%; width: 110px; height: 26px; transform: translateX(-50%) rotate(-2deg);
  background: repeating-linear-gradient(90deg, rgba(156, 192, 220, .85) 0 10px, rgba(255, 255, 255, .7) 10px 14px); opacity: .9;
}

/* ---------- Title ---------- */
.screen { min-height: 100%; }
.intro {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); text-align: center;
}
.logo { margin: 0; width: min(640px, 92vw); }
.logo img { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 12px rgba(255, 250, 235, .85)) drop-shadow(0 0 2px rgba(255, 250, 235, .9)); }
.tagline { font-family: var(--hand); font-size: 1.3rem; margin: -.4rem 0 .2rem; color: var(--graphite); background: rgba(251, 246, 234, .82); padding: .1em .8em; border-radius: 999px; }
.mode-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 260px)); gap: 16px; width: min(560px, 100%); margin-top: 22px; }
.mode-card {
  background: var(--paper) var(--grain); border: 0; border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; transition: transform .15s ease;
}
.mode-card:nth-child(1) { transform: rotate(-1.2deg); }
.mode-card:nth-child(2) { transform: rotate(1.2deg); }
.mode-card:hover { transform: rotate(0) translateY(-3px); }
.mode-card img { width: 64%; height: auto; margin-top: -40px; filter: drop-shadow(0 4px 6px rgba(70, 45, 25, .25)); }
.mode-name { font-weight: 700; font-size: 1.2rem; color: var(--berry-deep); }
.mode-card:nth-child(2) .mode-name { color: var(--pine-deep); }
.mode-note { font-size: .88rem; line-height: 1.4; color: #6a5d52; }
.length { border: 0; display: flex; gap: 8px; padding: 0; margin: .2rem 0 0; flex-wrap: wrap; justify-content: center; }
.length legend { font-family: var(--hand); width: 100%; margin-bottom: .3rem; background: rgba(251, 246, 234, .8); border-radius: 999px; padding: 0 .6em; }
.length label { position: relative; }
.length input { position: absolute; opacity: 0; inset: 0; }
.length span { display: inline-block; padding: .45em 1em; border-radius: 999px; background: rgba(251, 246, 234, .9); box-shadow: inset 0 0 0 2px rgba(63, 57, 53, .15); font-weight: 700; font-size: .92rem; min-height: 40px; line-height: 1.6; cursor: pointer; }
.length input:checked + span { background: var(--pine); color: #fff8ee; box-shadow: none; }
.length input:focus-visible + span { outline: 3px solid var(--frost-deep); outline-offset: 2px; }
.how { background: rgba(251, 246, 234, .92); border-radius: 10px; padding: .5rem 1rem; max-width: 520px; text-align: left; box-shadow: 0 2px 8px rgba(70, 45, 25, .12); }
.how summary { cursor: pointer; font-weight: 700; text-align: center; min-height: 32px; line-height: 32px; }
.how ol { margin: .4rem 0 .6rem; padding-left: 1.3rem; line-height: 1.55; font-size: .95rem; }
.intro-foot { display: flex; flex-direction: column; gap: .4rem; align-items: center; max-width: 560px; }
.intro-measurement { background: rgba(251, 246, 234, .9); border-radius: 10px; padding: .4rem .8rem; font-size: .85rem; }
.intro-measurement p { margin: .2rem 0; }
.intro-measurement button, nav [data-measurement] button { background: none; border: 0; text-decoration: underline; color: var(--frost-deep); padding: .3rem; min-height: 36px; }
.policies { font-size: .85rem; background: rgba(251, 246, 234, .8); border-radius: 999px; padding: .2rem .9rem; margin: 0; }
.policies a { color: var(--graphite); }
.brand { font-weight: 700; } .brand b { color: #FF4D8D; }

/* ---------- Players and curtain ---------- */
.card-screen { display: grid; place-items: center; padding: 24px 16px; min-height: 100vh; min-height: 100dvh; }
.players-card { width: min(440px, 100%); }
.players-card h2, .envelope h2 { margin: 0 0 .3rem; font-size: 1.6rem; }
.player-list { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .5rem; counter-reset: p; }
.player-list li { display: flex; gap: .5rem; align-items: center; counter-increment: p; }
.player-list li::before { content: counter(p); font-family: var(--hand); color: var(--berry); width: 1.2em; }
.player-list input, .field input {
  flex: 1; font: inherit; font-size: 1.1rem; padding: .6em .8em; border-radius: 8px; border: 2px solid rgba(63, 57, 53, .2);
  background: #fffdf7; color: var(--graphite); min-height: 46px; width: 100%;
}
.envelope {
  position: relative; width: min(500px, 100%); text-align: center; padding: 2rem 1.6rem 1.8rem; border-radius: 8px;
  background: #e2c9a2 var(--grain); box-shadow: var(--shadow);
  background-image: linear-gradient(160deg, transparent 49.5%, rgba(120, 80, 40, .18) 50%, transparent 50.5%), linear-gradient(20deg, transparent 49.5%, rgba(120, 80, 40, .18) 50%, transparent 50.5%), var(--grain);
}
.envelope .primary { margin-top: 1rem; }
.curtain-flurry { position: absolute; width: 120px; height: auto; top: -84px; right: 14px; transform: rotate(8deg); filter: drop-shadow(0 4px 6px rgba(70, 45, 25, .3)); }
.envelope h2 { margin-top: .6rem; }

/* ---------- Play ---------- */
.play {
  height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); gap: 6px; width: 100%; overflow: hidden;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.topbar { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.chainbar {
  display: flex; align-items: center; gap: 8px; background: rgba(251, 246, 234, .92); border-radius: 999px; padding: 5px 10px;
  box-shadow: 0 2px 8px rgba(70, 45, 25, .18); min-width: 0;
}
.stamp {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 6px; border: 2px dashed var(--pine);
  color: var(--pine-deep); font-weight: 700; font-size: 1.15rem; transform: rotate(-4deg); background: #fffdf7;
}
.stamp.end { border-color: var(--berry); color: var(--berry-deep); transform: rotate(4deg); }
.stamp-wrap { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.stamp-wrap small { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--pine-deep); line-height: 1; }
.stamp-wrap:last-child small { color: var(--berry-deep); }
.top-right { display: flex; gap: 6px; }
.letter.start { background: var(--pine); }
.letter.end { background: var(--berry); box-shadow: 0 0 0 2px #fffdf7, 0 0 0 4px var(--berry); }
.must { color: var(--berry-deep); letter-spacing: .03em; }
.prompt-goal { margin: .15rem 0 0; font-size: .86rem; color: #6a5d52; line-height: 1.5; }
.prompt-goal .letter { min-width: 1.35em; height: 1.35em; font-size: .85rem; }
.bonus { font-size: .78rem; font-weight: 700; color: #8a6514; background: #fbefcf; border-radius: 999px; padding: .05em .6em; margin: 2px 0; }
.rules ol { margin: .4rem 0 .8rem; padding-left: 1.2rem; line-height: 1.55; }
.rules-goal { margin: .5rem 0 .6rem; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.rules-goal .tile { margin: 0; padding: .5rem .4rem .6rem; border-radius: 8px; background: rgba(251, 246, 234, .9); box-shadow: inset 0 0 0 2px rgba(63, 57, 53, .12); display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: .35rem; text-align: center; line-height: 1.35; font-size: .92rem; text-wrap: balance; }
.rules-goal .tile .letter { font-size: 1.5rem; min-width: 1.5em; height: 1.5em; }
.rules-goal .rg-n { grid-column: 1 / -1; margin: 0; text-align: center; font-size: .9rem; color: #6a5d52; }
.curtain-goal { margin: .6rem 0 0; font-weight: 700; line-height: 1.8; }
.rules-score { list-style: none; padding: 0; margin: .3rem 0 0; }
.rules-score li { display: flex; justify-content: space-between; padding: .25rem 0; border-bottom: 1px dashed rgba(63, 57, 53, .2); }
.rules .credit { font-size: .78rem; color: var(--ink-soft, #5f5750); margin: .6rem 0 0; line-height: 1.35; }
.rules .credit a { color: inherit; }
.beads { list-style: none; display: flex; align-items: center; gap: 0; margin: 0; padding: 0; }
.beads li { width: 16px; height: 16px; border-radius: 50%; background: #fffdf7; border: 2px solid #c9b9a6; position: relative; margin: 0 6px; }
.beads li + li::before { content: ""; position: absolute; right: 100%; top: 50%; width: 12px; height: 2px; background: var(--berry); opacity: .5; margin-right: 0; }
.beads li.done { background: var(--frost); border-color: var(--frost-deep); }
.beads li.now { background: var(--gold); border-color: #b8862a; transform: scale(1.25); }
.stage { position: relative; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.book { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; position: relative; }
.prompt {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: rgba(251, 246, 234, .95) var(--grain); border-radius: 8px; padding: .35rem 1rem; box-shadow: 0 2px 8px rgba(70, 45, 25, .16);
  max-width: min(640px, 100%); order: -1;
}
.prompt-flurry { display: none; margin: .15rem 0 0; font-family: var(--hand); font-size: .88rem; color: var(--pine-deep); line-height: 1.35; }
body:not(.landscape) .prompt-flurry:not([hidden]) { display: block; }
body:not(.landscape) .flurry-note { display: none; }
.prompt-who { margin: 0; font-family: var(--hand); color: var(--berry); font-size: .95rem; }
.prompt-text { margin: 0; font-weight: 700; font-size: clamp(1rem, 2.6vw, 1.3rem); line-height: 1.45; }
.page {
  position: relative; background: var(--paper) var(--grain); border-radius: 4px; touch-action: none;
  box-shadow: 0 1px 0 #e9dfcc, 0 2px 0 #e2d6c0, 0 3px 0 #dccfb8, 0 14px 30px rgba(70, 45, 25, .3);
  cursor: crosshair;
}
.page::after {
  content: ""; position: absolute; top: -10px; left: 8%; right: 8%; height: 20px; pointer-events: none;
  background: radial-gradient(circle at 10px 10px, #8f8a85 0 4px, #d8d2ca 4px 6px, transparent 6.5px) 0 0 / 28px 20px repeat-x;
}
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 4px; touch-action: none; }
.page-veil { position: absolute; inset: 0; background: rgba(251, 246, 234, .0); outline: 4px dashed rgba(184, 50, 74, .5); outline-offset: -8px; border-radius: 4px; pointer-events: none; }
.play[data-look] .page { cursor: default; }
.polaroid {
  position: absolute; z-index: 3; border: 0; background: #fffdf7; padding: 6px 6px 4px; box-shadow: var(--shadow);
  transform: rotate(-5deg); display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.polaroid canvas { width: 92px; height: 92px; background: var(--paper); display: block; }
.polaroid span { font-family: var(--hand); font-size: .72rem; color: #7a6b5e; }
.polaroid::before { content: ""; position: absolute; top: -9px; left: 50%; width: 52px; height: 16px; transform: translateX(-50%) rotate(3deg); background: rgba(231, 154, 166, .75); }

.tools {
  position: relative;
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: nowrap;
  background: rgba(251, 246, 234, .9); border-radius: 14px; padding: 6px 10px; box-shadow: 0 2px 10px rgba(70, 45, 25, .2);
  overflow-x: auto; scrollbar-width: none; transition: opacity .2s; max-width: 100%; flex: none;
}
.tools.disabled { opacity: .45; }
.tool-tin { display: flex; gap: 2px; align-items: flex-end; background: linear-gradient(#cfd8d4, #aebbb6); border-radius: 10px; padding: 4px 6px 0; height: 62px; overflow: hidden; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .08); }
.tool { border: 0; background: none; padding: 0; width: 44px; height: 80px; display: flex; align-items: flex-start; justify-content: center; transform: translateY(26px); transition: transform .15s ease; }
.tool img { height: 76px; width: auto; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); pointer-events: none; }
.tool[aria-checked="true"] { transform: translateY(2px); }
.swatches { display: grid; grid-template-columns: repeat(4, 44px); gap: 2px; }
.swatch { width: 44px; height: 44px; border: 0; background: none; padding: 0; display: grid; place-items: center; }
.swatch::before {
  content: ""; width: 30px; height: 30px; border-radius: 50% 46% 52% 44%; background: var(--c);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15), 0 1px 2px rgba(0, 0, 0, .2); transition: transform .12s ease;
}
.swatch[aria-checked="true"]::before { transform: scale(1.18); box-shadow: 0 0 0 3px #fffdf7, 0 0 0 5px var(--c); }
.sizes { display: flex; gap: 0; align-items: center; }
.size { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; }
.size i { display: block; border-radius: 50%; background: var(--c, var(--graphite)); }
.size[data-size="0"] i { width: 3px; height: 3px; }
.size[data-size="1"] i { width: 6px; height: 6px; }
.size[data-size="2"] i { width: 12px; height: 12px; }
.size[data-size="3"] i { width: 20px; height: 20px; }
.size[data-size="4"] i { width: 29px; height: 29px; }
.size[aria-checked="true"] { box-shadow: inset 0 0 0 2px rgba(63, 57, 53, .35); background: #fffdf7; }
.history { display: flex; gap: 6px; }
.history .icon-btn { width: 44px; height: 44px; font-size: 1.15rem; box-shadow: inset 0 0 0 2px rgba(63, 57, 53, .14); }
.finger { border: 0; border-radius: 999px; background: #fffdf7; padding: .3em .8em; font-size: .78rem; box-shadow: inset 0 0 0 2px rgba(63, 57, 53, .14); min-height: 36px; white-space: nowrap; }
.finger[aria-pressed="true"] { background: var(--frost); }

.flurry { position: absolute; right: -6px; bottom: 0; width: clamp(92px, 20vw, 150px); pointer-events: none; z-index: 4; transition: transform .45s cubic-bezier(.3, 1.4, .5, 1); }
.flurry.away { transform: translateY(130%); }
.flurry-face { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 8px rgba(70, 45, 25, .3)); transform-origin: 50% 100%; }
.flurry-face.bob { animation: bob .5s ease; }
@keyframes bob { 0% { transform: translateY(8px) scale(.97); } 60% { transform: translateY(-4px) scale(1.02); } 100% { transform: none; } }
.flurry-note {
  position: absolute; bottom: 100%; right: 30%; width: max-content; max-width: min(240px, 60vw);
  background: #fffdf7 var(--grain); padding: .55rem .8rem; border-radius: 6px; box-shadow: var(--shadow); transform: rotate(-2deg);
  font-family: var(--hand); font-size: .95rem; line-height: 1.4; animation: pop .3s ease;
}
.flurry-note::after { content: ""; position: absolute; right: 18px; bottom: -8px; border: 8px solid transparent; border-top-color: #fffdf7; border-bottom: 0; }
.flurry-note p { margin: 0; }
@keyframes pop { from { transform: rotate(-2deg) scale(.85); opacity: 0; } }
.actions { display: flex; justify-content: center; align-items: center; gap: 10px; padding-bottom: 2px; }
.actions .history { gap: 4px; }
.mitten { position: absolute; left: 0; top: 0; z-index: 6; height: auto; transform-origin: 0 100%; pointer-events: none; filter: drop-shadow(0 6px 6px rgba(70, 45, 25, .3)); will-change: transform; }

/* Portrait (phones, iPad upright): prompt, page, then tools; Flurry peeks in at the top right. */
body:not(.landscape) .tools { order: 2; flex-wrap: wrap; justify-content: center; overflow: visible; row-gap: 6px; }
body:not(.landscape) .swatches { order: -1; }
body:not(.landscape) .polaroid { top: 0; left: 0; }
body:not(.landscape) .polaroid canvas { width: 64px; height: 64px; }
body:not(.landscape) .prompt { margin-left: 74px; margin-right: clamp(78px, 20vw, 120px); min-height: 60px; justify-content: center; align-self: stretch; max-width: none; }
body:not(.landscape) .flurry { top: -6px; bottom: auto; right: -4px; width: clamp(80px, 20vw, 124px); }
body:not(.landscape) .flurry.away { transform: translateX(130%); }
body:not(.landscape) .flurry-note { bottom: auto; top: 88%; right: 18%; max-width: min(260px, 62vw); }
body:not(.landscape) .flurry-note::after { bottom: auto; top: -8px; border-top: 0; border-bottom: 8px solid #fffdf7; }
@media (max-width: 520px) {
  .beads li { width: 12px; height: 12px; margin: 0 2.5px; flex-shrink: 0; }
  .beads li + li::before { width: 5px; }
  .topbar { gap: 6px; }
  .top-right { gap: 4px; flex-shrink: 0; }
  .stamp { width: 28px; height: 28px; font-size: 1rem; }
  .chainbar { gap: 5px; padding: 4px 8px; }
  .tools { gap: 6px 8px; padding: 6px 8px; }
  .swatches { grid-template-columns: repeat(8, 44px); gap: 0; }
  .swatch::before { width: 26px; height: 26px; }
  .mode-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .mode-note { display: none; }
  .mode-card img { margin-top: -26px; }
}
/* Landscape (iPad sideways, laptops, desktops): tools column left, page centre, Flurry right. */
body.landscape .stage { flex-direction: row; align-items: stretch; }
body.landscape .tools { flex-direction: column; justify-content: center; width: 236px; flex: none; overflow: visible; padding: 10px 8px; align-self: center; }
body.landscape .swatches { grid-template-columns: repeat(4, 44px); gap: 2px; }
body.landscape .history { flex-wrap: wrap; justify-content: center; }
body.landscape .book { padding-right: clamp(110px, 16vw, 210px); }
body.landscape .flurry { width: clamp(120px, 15vw, 210px); right: 0; }
body.landscape .polaroid { left: 0; top: 0; }
body.landscape .flurry-note { right: 20%; }

/* ---------- Secret card dialog ---------- */
.secret {
  margin-top: max(6vh, 16px);
  border: 0; padding: 1.4rem 1.5rem 1.2rem; border-radius: 8px; width: min(460px, calc(100vw - 32px)); color: var(--graphite);
  background: #fffdf7 var(--grain); box-shadow: 0 20px 50px rgba(40, 25, 10, .45);
  background-image: repeating-linear-gradient(transparent 0 33px, rgba(111, 156, 196, .25) 33px 34px), var(--grain);
}
.secret::backdrop { background: rgba(48, 36, 26, .55); backdrop-filter: blur(3px); }
.secret h2 { margin: .1rem 0 .3rem; font-size: 1.5rem; }
.field { display: block; margin-top: .6rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: .6rem; min-height: 4px; }
.chip { border: 0; border-radius: 999px; padding: .4em .9em; background: #eef4f8; box-shadow: inset 0 0 0 2px rgba(95, 141, 181, .35); font-size: .95rem; min-height: 38px; }
.check { min-height: 1.4em; font-size: .92rem; color: var(--berry-deep); margin: .6rem 0 0; line-height: 1.45; }
.check.good { color: var(--pine-deep); }
.small-dialog { width: min(360px, calc(100vw - 32px)); }

/* ---------- Reveal ---------- */
.reveal { overflow-x: clip; padding: max(18px, env(safe-area-inset-top)) 16px 120px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.reveal-head { text-align: center; background: rgba(251, 246, 234, .94) var(--grain); border-radius: 10px; padding: .6rem 1.4rem; box-shadow: var(--shadow); }
.reveal-head h2 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.2rem); color: var(--berry-deep); }
.chain { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 28px 22px; width: min(1180px, 100%); }
.link-card { display: flex; flex-direction: column; align-items: center; gap: 6px; transition: opacity .4s ease, transform .5s cubic-bezier(.3, 1.3, .5, 1); }
.link-card.hidden-card { opacity: .0; transform: translateY(16px) rotate(-2deg) scale(.96); pointer-events: none; }
.link-card.shown .card { animation: flip .6s ease; }
@keyframes flip { 0% { transform: rotateY(80deg); } 100% { transform: none; } }
.knot { display: inline-flex; gap: .5em; align-items: center; padding: .25em .9em; border-radius: 999px; font-weight: 700; font-size: .95rem; background: #fffdf7; box-shadow: 0 2px 6px rgba(70, 45, 25, .2); }
.knot.ok { color: var(--pine-deep); box-shadow: inset 0 0 0 2px var(--pine), 0 2px 6px rgba(70, 45, 25, .2); }
.knot.snap { color: var(--berry-deep); box-shadow: inset 0 0 0 2px var(--berry), 0 2px 6px rgba(70, 45, 25, .2); }
.card { margin: 0; background: #fffdf7; padding: 10px 10px 12px; box-shadow: var(--shadow); width: 100%; border-radius: 3px; }
.link-card:nth-child(odd) .card { transform: rotate(-1deg); }
.link-card:nth-child(even) .card { transform: rotate(1deg); }
.card canvas { width: 100%; aspect-ratio: 1; display: block; background: var(--paper); }
.card figcaption { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 8px; text-align: center; }
.who { font-family: var(--hand); color: #7a6b5e; font-size: .9rem; }
.word { font-weight: 700; font-size: 1.35rem; color: var(--graphite); text-transform: capitalize; }
.seen { font-size: .92rem; color: #6a5d52; }
.seen b { text-transform: capitalize; }
.seen.yes { color: var(--pine-deep); }
.quip { margin: 0; font-family: var(--hand); font-size: .95rem; text-align: center; background: rgba(251, 246, 234, .92); border-radius: 8px; padding: .3rem .7rem; max-width: 100%; }
.finish { justify-content: center; }
.finish-text { background: rgba(251, 246, 234, .94); border-radius: 10px; padding: 1rem; text-align: center; font-weight: 700; box-shadow: var(--shadow); margin: 0; line-height: 1.6; }
.reveal-controls { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; justify-content: center; align-items: center; padding: 12px 16px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(80, 55, 35, .35)); flex-wrap: wrap; }
.summary { width: min(520px, 100%); text-align: center; margin-top: 70px; padding-top: 4.4rem; }
.summary-flurry { width: 130px; height: auto; position: absolute; top: -70px; left: 50%; transform: translateX(-50%); filter: drop-shadow(0 6px 8px rgba(70, 45, 25, .3)); }
.summary h3 { margin: .4rem 0 0; font-size: 1.7rem; color: var(--berry-deep); }
.summary-score { font-size: 1.15rem; margin: .3rem 0 .6rem; }
.summary-score b { font-size: 2.6rem; color: var(--frost-deep); vertical-align: -.1em; }
.summary-score .of-max { font-size: .95rem; color: #6a5d52; }
.summary-list { list-style: none; padding: 0; margin: 0 auto; max-width: 340px; text-align: left; }
.summary-list li { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px dashed rgba(63, 57, 53, .2); }
#steam-slot .steam-interest { margin-top: 1rem; font-size: .85rem; }
#steam-slot button { border: 0; border-radius: 999px; padding: .5em 1em; background: #eef4f8; min-height: 40px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Final refinement: timer, shapes, bucket, bonus, personal best ---------- */
.settings { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; justify-content: center; align-items: flex-start; max-width: 620px; }
.settings .length { margin: .2rem 0 0; }
.length span { white-space: nowrap; }
.timer-set input:checked + span { background: var(--berry); }
.mode-best { font-family: var(--hand); font-size: .85rem; color: var(--berry-deep); min-height: 1.2em; line-height: 1.3; }
.mode-best:empty { display: none; }
.prompt { position: relative; }
.prompt-top { display: flex; align-items: center; justify-content: center; }
.prompt-rule { margin: .1rem 0 0; font-family: var(--hand); font-size: .84rem; color: var(--berry-deep); line-height: 1.4; }
.clock { position: absolute; left: 50%; bottom: -17px; transform: translateX(-50%) rotate(-1.5deg); z-index: 3; white-space: nowrap; display: inline-flex; align-items: center; gap: .35em; background: #fffdf7; border-radius: 999px; padding: 0 .7em 0 .25em; box-shadow: inset 0 0 0 2px rgba(63, 57, 53, .16); height: 30px; font-weight: 700; color: var(--pine-deep); }
.clock svg { width: 24px; height: 24px; transform: rotate(-90deg); flex: none; }
.clock circle { fill: none; stroke-width: 5; }
.clock-track { stroke: #e3d8c5; }
.clock-arc { stroke: var(--pine); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; }
.clock b { font-variant-numeric: tabular-nums; min-width: 2.4ch; text-align: left; font-size: 1rem; }
.clock-tag { font-family: var(--hand); font-size: .8rem; color: var(--berry-deep); }
.clock.mid .clock-arc { stroke: var(--gold); } .clock.mid { color: #8a6514; }
.clock.low { color: var(--berry-deep); box-shadow: inset 0 0 0 2px var(--berry); }
.clock.low .clock-arc { stroke: var(--berry); }
.clock.low { animation: tock 1s ease-in-out infinite; }
@keyframes tock { 50% { transform: translateX(-50%) scale(1.08) rotate(1.5deg); } }
.clock-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(63, 57, 53, .08); border-radius: 0 0 8px 8px; overflow: hidden; }
.clock-bar i { display: block; height: 100%; background: var(--pine); transform-origin: 0 50%; }
.clock-bar.mid i { background: var(--gold); } .clock-bar.low i { background: var(--berry); }
.timesup { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%) rotate(-6deg); z-index: 5; pointer-events: none; font-family: var(--hand); font-weight: 600; font-size: clamp(1.8rem, 9vw, 3.2rem); color: var(--berry-deep); border: 4px solid var(--berry); border-radius: 14px; padding: .1em .6em; background: rgba(255, 253, 247, .92); box-shadow: var(--shadow); animation: stamp .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-6deg) scale(1.8); opacity: 0; } }
.extras { display: flex; gap: 4px; }
.extra { width: 54px; height: 56px; border: 0; border-radius: 10px; background: #fffdf7; box-shadow: inset 0 0 0 2px rgba(63, 57, 53, .16); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--graphite); padding: 0; font-size: .7rem; font-weight: 700; line-height: 1.1; }
.extra svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.extra svg .drop { fill: var(--pick, var(--graphite)); stroke: none; }
.extra svg .swatch-bar { stroke: var(--pick, var(--graphite)); stroke-width: 3; }
.extra[aria-pressed="true"] { background: var(--frost); box-shadow: inset 0 0 0 2px var(--frost-deep); }
.shape-pop { position: absolute; z-index: 20; display: grid; grid-template-columns: repeat(4, 56px); gap: 4px; padding: 8px; background: #fffdf7 var(--grain); border-radius: 12px; box-shadow: var(--shadow); animation: fade-in .18s ease; }
body:not(.landscape) .shape-pop { bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); }
body.landscape .shape-pop { left: calc(100% + 8px); top: 50%; transform: translateY(-50%); }
.shape-opt { height: 58px; border: 0; border-radius: 10px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; font-weight: 700; color: var(--graphite); padding: 0; }
.shape-opt svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shape-opt[aria-checked="true"] { background: var(--frost); box-shadow: inset 0 0 0 2px var(--frost-deep); }
.tools.shape-live .page { cursor: crosshair; }
.best-line { margin: .2rem 0 .6rem; font-family: var(--hand); font-size: 1.05rem; color: var(--pine-deep); }
.best-line.new { color: var(--berry-deep); font-weight: 600; font-size: 1.25rem; animation: bob .7s ease; }
.bonus-line b { color: #8a6514; }
.card.sparkle { position: relative; box-shadow: 0 0 0 3px var(--gold), 0 0 28px 6px rgba(217, 169, 63, .55), var(--shadow); }
.bonus.surprise { display: inline-block; font-size: .95rem; background: linear-gradient(100deg, #fbefcf, #fff8de, #fbefcf); box-shadow: 0 0 0 2px var(--gold); animation: pop-star .7s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pop-star { from { transform: scale(.2) rotate(-20deg); opacity: 0; } }
.sparkles { position: absolute; inset: -14px; pointer-events: none; overflow: visible; }
.sparkles i { position: absolute; left: 50%; top: 40%; width: 14px; height: 14px; color: var(--gold); animation: fly 1.2s ease-out forwards; }
.sparkles i::before { content: "✦"; font-style: normal; font-size: 18px; line-height: 1; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) scale(.3) rotate(120deg); opacity: 0; } }
@media (max-width: 520px) {
  .shape-opt, .extra { font-size: .68rem; }
}
@media (max-width: 400px) {
  .beads li { width: 9px; height: 9px; margin: 0 1.5px; border-width: 1.5px; }
  .beads li + li::before { width: 3px; }
  .stamp { width: 24px; height: 24px; font-size: .9rem; }
  .stamp-wrap small { font-size: .52rem; }
  .chainbar { gap: 3px; padding: 3px 6px; }
  .topbar { gap: 4px; }
  .top-right { gap: 2px; }
  .topbar .icon-btn { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .clock.low, .timesup { animation: none !important; }
  .sparkles { display: none; }
}
.prompt-sub { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 1em; }
.prompt-sub p { margin: .1rem 0 0; }
body.landscape .clock { left: auto; right: 8px; top: 5px; bottom: auto; transform: rotate(1.5deg); }
body.landscape .clock.low { animation-name: tock-l; }
@keyframes tock-l { 50% { transform: scale(1.08) rotate(-1.5deg); } }
@keyframes fade-in { from { opacity: 0; } }
.linkish { background: rgba(251, 246, 234, .85); border: 0; border-radius: 999px; padding: .3rem .9rem; min-height: 36px; font-size: .82rem; text-decoration: underline; color: var(--frost-deep); }
/* Very small phones (320 px wide): the tray wraps its swatches, Flurry's prompt line steps aside and the page keeps what room is left. */
@media (max-width: 360px) {
  .swatches { grid-template-columns: repeat(8, 36px) !important; justify-content: center; }
  .swatch { width: 36px; height: 44px; }
  .swatch::before { width: 24px; height: 24px; }
  .book { justify-content: flex-start; }
  body.flurry-mode .prompt-who { display: none; }
  .extra { width: 46px; }
  body:not(.landscape) .prompt-flurry { display: none !important; }
  body:not(.landscape) .prompt { min-height: 0; padding: .2rem .5rem; }
  .prompt-text { font-size: .98rem; line-height: 1.35; }
  .prompt-goal, .prompt-rule { font-size: .78rem; }
  .primary.big { font-size: 1rem; padding: .7em 1.1em; }
  .actions .history .icon-btn { width: 44px; }
  .tools { padding: 4px; gap: 4px 4px; }
  .tool-tin { padding: 4px 3px 0; gap: 0; }
  body:not(.landscape) .prompt { margin-left: 54px; margin-right: 62px; }
  body:not(.landscape) .polaroid canvas { width: 46px; height: 46px; }
  body:not(.landscape) .flurry { width: 62px; }
  body:not(.landscape) .flurry-note { display: none; }
}
body.timed:not(.landscape) .prompt { padding-bottom: 21px; }
.best-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; font-size: .82rem; background: rgba(251, 246, 234, .85); border-radius: 14px; padding: .25rem .8rem; }
.best-controls label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; }
.best-controls input { width: 22px; height: 22px; accent-color: var(--pine); }
.best-controls .linkish { background: none; min-height: 44px; padding: 0 .4rem; }
.best-controls a { color: var(--frost-deep); min-height: 44px; display: inline-flex; align-items: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
