/* The shared frame for the games: top row · prompt bar · page zone · bottom bar.
   The leftover paper around the page is just notebook; nothing else goes there. */
.room {
  height: 100dvh; min-height: 0;
  padding-bottom: calc(var(--safe-bottom) + 16px);
}
.top-row { flex: none; height: 44px; display: flex; align-items: center; gap: 8px; }
.prompt-bar {
  flex: none; height: 60px; margin-top: 12px; display: flex; align-items: flex-end; gap: 12px;
}
.prompt-bar .pb-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.prompt-bar .prompt {
  font: 40px/1 var(--display); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; align-self: flex-start; padding: 0 4px 2px 2px;
}
.prompt-bar .prompt.struck { position: relative; }
.prompt-bar .prompt .strike {
  position: absolute; left: -2px; width: calc(100% + 4px); top: 52%; height: 2px; overflow: visible; color: var(--ink);
}
.prompt-bar .note { flex: none; max-width: 150px; text-align: right; font-size: 13px; line-height: 1.3; color: var(--ink-3); padding-bottom: 4px; }
.prompt-bar.changing .prompt { animation: dd-prompt-out .12s ease-in both; }
@keyframes dd-prompt-out { to { opacity: 0; transform: translateY(-8px) } }

.page-zone { flex: 1; min-height: 0; margin: 12px 0; display: flex; align-items: center; justify-content: center; }
.page {
  position: relative; background: var(--page); box-shadow: 4px 5px 0 0 var(--rule); flex: none;
}
.page > svg.line rect { stroke: var(--ink); fill: none; }
.page canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; position: relative; }
.page .hint {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font: 26px/1.1 var(--display); color: var(--ink-disabled); transform: rotate(-4deg); text-align: center; padding: 0 20px;
  transition: opacity .2s;
}
@media (prefers-color-scheme: dark) { .page .hint { color: #aeb6c8; } }
.page-zone.leaving .page { animation: dd-page-out .15s ease-in both; }
@keyframes dd-page-out { to { opacity: 0; transform: translateX(-24px) } }

.bottom-bar { flex: none; height: 48px; display: flex; align-items: center; gap: 12px; }
.bottom-bar .btn.flex { flex: 1; height: 48px; font-size: 16px; }
.bottom-bar .swatch { flex: none; width: 48px; height: 48px; overflow: visible; }
.bottom-bar .swatch .fill { transition: y .12s linear; }
.bottom-bar.swap { animation: dd-fade .2s var(--ease) both; }

/* Colour strip: grey column, hue ramp, light to dark. Always light, in every mode. */
.strip {
  position: relative; flex: 1; min-width: 0; height: 44px; touch-action: none; cursor: pointer;
  margin: -8px 0; padding: 8px 0; box-sizing: content-box; /* +8px touch target above and below */
}
.strip canvas { display: block; width: 100%; height: 44px; border-radius: var(--r-md); }
.strip > svg.line { top: 9px; height: 42px; }
.strip > svg.line rect { stroke: var(--ink); }
.strip .probe {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); pointer-events: none;
}
.strip.off { opacity: .35; pointer-events: none; transition: opacity .3s; }
.magnifier {
  position: absolute; bottom: calc(100% + 4px); width: 64px; height: 76px; margin-left: -32px; z-index: 30;
  pointer-events: none; filter: drop-shadow(0 6px 12px rgba(30, 42, 74, .22)); overflow: visible;
}

/* Next / Finish nudge when out of ink (proposal P3): a yellow highlighter ring around it. */
.nudge { position: relative; }
.nudge::after {
  content: ""; position: absolute; inset: -6px; border-radius: 14px; border: 6px solid var(--hl-yellow);
  mix-blend-mode: var(--hl-blend); transform-origin: left; animation: dd-ring .3s var(--ease) both; pointer-events: none;
}
@keyframes dd-ring { from { clip-path: inset(0 100% 0 0) } to { clip-path: inset(0 0 0 0) } }

/* --- People chips ---------------------------------------------------------------- */
.chips {
  list-style: none; margin: 0; padding: 0 24px 0 0; flex: 1; min-width: 0; display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  position: relative; flex: none; width: 92px; height: 44px; padding: 8px 10px 0;
  display: flex; flex-direction: column; gap: 7px;
}
.chip .line rect { fill: var(--card); }
.chip > :not(.line) { position: relative; }
.chip .who { display: flex; align-items: center; gap: 6px; font: 700 13px/1 var(--body); }
.chip .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; border: 1.5px solid var(--ink-3); }
.chip.online .dot { background: var(--online); border-color: var(--online); }
.chip:not(.online) .who { color: var(--ink-3); }
.gauge { height: 4px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.gauge i { display: block; height: 100%; transition: width .12s linear; }
.gauge.low i { animation: dd-pulse 1s infinite; }
.gauge.dry { background: none; outline: 1.5px dashed var(--ink-disabled); outline-offset: -1px; }
.ticks { display: flex; gap: 4px; height: 5px; align-items: center; }
.ticks i { width: 14px; height: 5px; border-radius: 2px; background: var(--rule); }
.ticks svg { width: 16px; height: 16px; color: var(--pass); margin-top: -6px; }

/* --- Waiting for a friend (creator only) ----------------------------------------------- */
.waiting {
  position: fixed; inset: 0; z-index: 50; overflow: hidden;
  background: var(--paper) repeating-linear-gradient(0deg, var(--rule) 0 1px, transparent 1px 28px);
}
.waiting .frame { height: 100dvh; }
.waiting .ripple { align-self: center; margin-top: auto; }
.waiting h2 { margin-top: 32px; text-align: center; }
.waiting .lead { text-align: center; max-width: 280px; align-self: center; margin-top: 8px; }
.waiting .actions { margin-top: auto; display: grid; gap: 14px; text-align: center; padding-bottom: 12px; }
.waiting.leaving { animation: dd-fade .2s reverse both; }

/* --- Challenge: all three in, the reveal ------------------------------------------------- */
.ch-wait { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: 12px; }
.ch-wait .lead { margin-top: 6px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.mini { margin: 0; min-width: 0; }
.mini .sheet { position: relative; aspect-ratio: 2 / 3; background: var(--page); box-shadow: 3px 4px 0 0 var(--rule); }
.mini .sheet canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mini .sheet > svg.line rect { stroke: var(--ink); }
.mini figcaption { margin-top: 6px; font-size: 12px; line-height: 1.3; color: var(--ink-2); }
.mini figcaption.name { display: flex; align-items: center; gap: 6px; font: 700 13px/1 var(--body); color: var(--ink); }
.mini figcaption.name i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ch-wait .ripple { align-self: center; margin: auto 0; }
.ch-wait .meta { text-align: center; }

.reveal { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 12px; }
.reveal .scroll {
  flex: 1; min-height: 0; overflow-y: auto; padding: 0 2px 140px; margin: 0 -2px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 140px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 140px), transparent);
}
.reveal h2 { margin: 0 0 18px; align-self: flex-start; }
.round-block + .round-block { margin-top: 28px; }
.round-block .display-s { margin: 4px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 12px; }
.grid.tight { gap: 8px; }
.reveal .end { text-align: center; margin-top: 28px; color: var(--ink-3); }
.reveal .bottom-bar { margin-top: 0; }
/* Reveal motion: each mini page's outline draws itself, then its drawing fades in. */
.mini.waiting-to-reveal .sheet > svg.line rect { stroke-dasharray: 100; stroke-dashoffset: 100; }
.mini.waiting-to-reveal canvas { opacity: 0; }
.mini.revealing .sheet > svg.line rect { stroke-dasharray: 100; stroke-dashoffset: 100; animation: dd-draw .4s ease-out forwards; animation-delay: var(--d, 0s); }
.mini.revealing canvas { opacity: 0; animation: dd-fade .2s ease-out forwards; animation-delay: calc(var(--d, 0s) + .4s); }
@media (prefers-reduced-motion: reduce) {
  .mini.revealing .sheet > svg.line rect, .mini.waiting-to-reveal .sheet > svg.line rect { stroke-dasharray: none; stroke-dashoffset: 0; animation: none; }
  .mini.revealing canvas { animation: dd-fade .2s both; animation-delay: 0s; }
}

/* --- Daily ---------------------------------------------------------------------------- */
.daily .top-row { justify-content: space-between; }
.daily .inkpot { display: flex; align-items: center; gap: 8px; }
.daily .inkpot svg { width: 22px; height: 24px; overflow: visible; }
.daily .inkpot .gauge { width: 64px; }
.daily-result { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.daily-result .page { width: 224px; height: 336px; margin-top: 16px; }
.daily-result .page canvas { position: absolute; inset: 0; }
.daily-result .bubble { position: absolute; right: -58px; top: -46px; width: 150px; height: 96px; color: var(--ink); z-index: 3; animation: dd-pop-in .2s var(--ease) both; transform-origin: 15% 90%; }
.daily-result .bubble svg { width: 100%; height: 100%; overflow: visible; }
.daily-result .bubble .dots circle { animation: dd-dots 1.2s infinite; transform-box: fill-box; }
.daily-result .bubble .dots circle:nth-child(2) { animation-delay: .2s; }
.daily-result .bubble .dots circle:nth-child(3) { animation-delay: .4s; }
.daily-result .bubble.asleep { color: var(--ink-disabled); }
.daily-result .bubble.popping { animation: dd-pop-out .15s ease-in both; }
@keyframes dd-pop-out { to { opacity: 0; transform: scale(.8) } }
.daily-result .verdict { margin-top: 22px; min-height: 76px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.daily-result .verdict .display-m { max-width: 330px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.daily-result .countdown { margin-top: 14px; }
.daily-result .countdown b { font-weight: 700; color: var(--ink); background: var(--hl-pink); padding: 1px 4px; border-radius: 3px; }
.daily-result .actions { margin-top: auto; width: 100%; display: grid; gap: 10px; }
.daily-result .actions .text-link { display: none; }
.daily-result > .rise-in:nth-child(3) { animation-delay: .06s; } .daily-result > .rise-in:nth-child(4) { animation-delay: .12s; }
@media (prefers-color-scheme: dark) { .daily .inkpot svg path { stroke: var(--ink); } }

/* --- Small phones -------------------------------------------------------------------------- */
@media (max-height: 700px) {
  .room { padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: calc(max(14px, env(safe-area-inset-bottom)) + 10px); }
  .prompt-bar { height: 52px; margin-top: 8px; }
  .prompt-bar .prompt { font-size: 34px; }
  .prompt-bar .hl > .swipe { height: 14px; }
  .page-zone { margin: 10px 0; }
  .daily-result .page { width: 156px; height: 234px; }
  .daily-result .bubble { width: 120px; height: 77px; right: -50px; top: -38px; }
  .daily-result .verdict { margin-top: 14px; }
  .daily-result .verdict .display-m { font-size: 28px; }
  .daily-result .countdown .tomorrow { display: none; }
  .daily-result .actions .btn.secondary { display: none; }
  .daily-result .actions .text-link { display: inline-block; justify-self: center; }
  .daily-result .actions .btn.primary { height: 52px; }
  .waiting .frame { padding-top: max(24px, env(safe-area-inset-top)); }
}

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* The page's ballpoint outline sits on top of the white canvas. */
.page > svg.line, .mini .sheet > svg.line { z-index: 2; }
/* "Past words →" under today's Daily result, always shown (also on small phones). */
.daily-result .actions .text-link.past { display: inline-block; justify-self: center; padding-top: 2px; }
.daily-result .actions .result-links { display: flex; justify-content: center; gap: 4px; }

/* --- Challenge Round: the AI's verdict ----------------------------------------------- */
.verdict-banner { margin: -6px 0 18px; display: grid; gap: 4px; justify-items: start; min-height: 24px; }
.verdict-banner .champ { margin-top: 2px; }
.verdict-banner .btn.small { width: auto; padding: 0 16px; margin-top: 6px; }
.judge-pending { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 700; font-size: 15px; }
.judge-pending .dots { display: inline-flex; gap: 4px; }
.judge-pending .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); animation: dd-dots 1.2s infinite; }
.judge-pending .dots i:nth-child(2) { animation-delay: .2s; } .judge-pending .dots i:nth-child(3) { animation-delay: .4s; }
.ai-note { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); font-style: italic; min-height: 0; }
.ai-note:empty { display: none; }
.mini .sheet { container-type: inline-size; }
.stamp.sticker { width: 88%; top: 50%; z-index: 4; }
.stamp.sticker .word { font-size: 19cqw; }
.stamp.sticker.win { color: #1f8a4c; }
.stamp.sticker.lose { color: #d62839; transform: translate(-50%, -50%) rotate(6deg); }
.stamp.sticker.lose.slam { animation-name: dd-stamp-r; }
@keyframes dd-stamp-r {
  0% { transform: translate(-50%, -50%) rotate(20deg) scale(1.8); opacity: 0 }
  60% { transform: translate(-50%, -50%) rotate(6deg) scale(.96); opacity: 1 }
  100% { transform: translate(-50%, -50%) rotate(6deg) scale(1) }
}

/* --- Trash talk -------------------------------------------------------------------------- */
.trash { flex: none; margin: 4px 0 10px; display: grid; gap: 8px; }
.trash-head { display: flex; justify-content: space-between; align-items: center; }
.trash-head .label { color: var(--ink); }
.trash-time { font: 700 13px/1 var(--body); color: var(--on-ink); background: var(--fail); padding: 4px 8px; border-radius: var(--r-pill); min-width: 40px; text-align: center; }
.trash.closed .trash-time { background: var(--rule); color: var(--ink-2); }
.trash-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 96px; overflow-y: auto; }
.trash-list:empty { display: none; }
.trash-list li { align-self: flex-start; max-width: 85%; background: var(--card); border: 1.5px solid var(--rule); border-radius: 12px 12px 12px 4px; padding: 5px 10px; font-size: 14px; line-height: 1.3; animation: dd-rise .15s var(--ease) both; }
.trash-list li.mine { align-self: flex-end; border-radius: 12px 12px 4px 12px; background: var(--hl-yellow); border-color: transparent; }
.trash-list li b { font-size: 12px; margin-right: 6px; }
.trash.closed .trash-list { max-height: 64px; }
.trash-quick { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.trash-quick::-webkit-scrollbar { display: none; }
.trash-quick .quick {
  flex: none; font: 700 13px/1 var(--body); color: var(--ink); background: var(--card); cursor: pointer;
  border: 1.5px solid var(--ink); border-radius: var(--r-pill); padding: 8px 12px; touch-action: manipulation;
}
.trash-quick .quick:active { transform: scale(.94); background: var(--rule); }
.trash-say { display: flex; gap: 8px; align-items: center; }
.trash-say .field { flex: 1; height: 44px; }
.trash-say .field input { font-size: 16px; font-weight: 400; }
/* Trash talk sits in the results, right under "that's the lot." */
.reveal .scroll .trash { margin: 18px 0 0; }
.reveal .scroll .trash .trash-list { max-height: 180px; }
