/* Plot Twist · PT07 Neon Mini Studio (docs/PLOT_TWIST_ART_BIBLE.md).
   The world is dark and glowing; player work (frames, canvas, captions) is light paper and never glows. */
:root {
  --night: #120f33; --indigo: #1d1856; --deep: #0a0820;
  --pink: #ff3fa4; --blue: #36c3ff; --citrus: #ffc23d; --mint: #4ef0b5;
  --paper: #fffaf0; --ink: #1b1738; --text: #f4f1ff; --muted: #b6b0e0;
  --frost: rgba(255,255,255,.08); --edge: rgba(255,255,255,.18);
  --glow-pink: 0 0 6px rgba(255,63,164,.9), 0 0 20px rgba(255,63,164,.55);
  --glow-blue: 0 0 6px rgba(54,195,255,.85), 0 0 18px rgba(54,195,255,.45);
  --glow-citrus: 0 0 10px rgba(255,194,61,.55);
  --radius: 20px; --tap: 48px;
  font-family: "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", system-ui, sans-serif; color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(120% 80% at 50% 0%, #2a2170 0%, var(--night) 55%, var(--deep) 100%) fixed; min-height: 100dvh; overscroll-behavior: none; }
main { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.proto-tag { position: fixed; bottom: 4px; left: 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); opacity: .6; pointer-events: none; z-index: 5; }
body.offline::after { content: "Reconnecting…"; position: fixed; left: 50%; top: 10px; transform: translateX(-50%); background: var(--pink); color: #fff; padding: 6px 14px; border-radius: 99px; font-weight: 700; z-index: 9; box-shadow: var(--glow-pink); }

/* frosted plastic panels */
.card { background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.05)); border: 1px solid var(--edge); border-radius: var(--radius); padding: 20px; width: min(520px, 100%); box-shadow: 0 18px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.18); display: flex; flex-direction: column; gap: 14px; align-items: stretch; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.entry { text-align: center; }
.mascot { width: 132px; height: 132px; align-self: center; object-fit: contain; filter: drop-shadow(0 0 14px rgba(255,63,164,.45)); }
.logo { font-size: 2.7rem; margin: 0; color: #fff; letter-spacing: .01em; text-shadow: 0 0 4px #fff, 0 0 14px var(--pink), 0 0 28px rgba(255,63,164,.6); }
.dev-note, .hint { color: var(--muted); margin: 0; font-size: .95rem; text-align: center; }
input, textarea { font: inherit; font-size: 1.15rem; border: 2px solid rgba(54,195,255,.45); border-radius: 14px; padding: 12px 14px; background: var(--paper); color: var(--ink); width: 100%; }
input:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--glow-blue); }
.code-input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 700; }
.row { display: flex; gap: 10px; }
.or { color: var(--muted); font-size: .9rem; }
.btn { font: inherit; font-weight: 700; min-height: var(--tap); min-width: var(--tap); border: 1px solid var(--edge); border-radius: 16px; padding: 10px 16px; background: var(--frost); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; touch-action: manipulation; box-shadow: inset 0 1px 0 rgba(255,255,255,.15); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible, .swatch:focus-visible, .width:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #ffd56a, var(--citrus)); color: #2a1b00; border-color: #ffe39a; box-shadow: var(--glow-citrus), inset 0 1px 0 rgba(255,255,255,.6); }
.btn.big { font-size: 1.2rem; min-height: 56px; }
.btn.ghost { background: transparent; border: 2px solid rgba(54,195,255,.55); box-shadow: 0 0 10px rgba(54,195,255,.18); }
.btn.on { border-color: var(--pink); box-shadow: var(--glow-pink); background: rgba(255,63,164,.16); }
.btn.round { border-radius: 50%; padding: 0; width: 56px; height: 56px; }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; display: block; }
#toast { position: fixed; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--indigo); border: 1px solid var(--pink); box-shadow: var(--glow-pink); color: #fff; padding: 10px 18px; border-radius: 14px; z-index: 10; max-width: 90vw; }
#toast[hidden] { display: none; }

/* player markers: glowing tokens, colour + shape */
.mark { display: inline-block; width: 22px; height: 22px; background: var(--mc); vertical-align: middle; filter: drop-shadow(0 0 4px var(--mc)); }
.shape-circle { border-radius: 50%; } .shape-square { border-radius: 4px; }
.shape-triangle { clip-path: polygon(50% 4%, 96% 92%, 4% 92%); }
.shape-star { clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.shape-diamond { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.shape-heart { clip-path: polygon(50% 95%, 5% 45%, 10% 15%, 30% 5%, 50% 22%, 70% 5%, 90% 15%, 95% 45%); }
.shape-hex { clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); }
.shape-moon { border-radius: 50%; box-shadow: inset -7px 0 0 0 var(--night); }

/* lobby */
.code-big { font-size: 3.4rem; font-weight: 800; letter-spacing: .25em; text-align: center; color: #fff; text-shadow: 0 0 6px var(--blue), 0 0 22px rgba(54,195,255,.6); }
.members { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.members li { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; padding: 8px 12px; background: var(--frost); border: 1px solid var(--edge); border-radius: 14px; }
.badge { margin-left: auto; font-size: .8rem; background: var(--pink); color: #fff; padding: 3px 9px; border-radius: 99px; box-shadow: var(--glow-pink); }
.modes { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tv-link { border-color: rgba(54,195,255,.6); }

/* creation stages */
.stage { width: min(720px, 100%); height: calc(100dvh - 24px); display: flex; flex-direction: column; gap: 10px; }
.stage-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.stage-pill { border: 2px solid var(--blue); box-shadow: var(--glow-blue); padding: 5px 12px; border-radius: 99px; font-weight: 700; font-size: .9rem; color: #e9f8ff; }
.task { margin: 0; font-size: 1.25rem; line-height: 1.2; color: #fff; }
.timer { font-weight: 800; font-size: 1.35rem; min-width: 3ch; text-align: right; color: #fff; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--pink); text-shadow: var(--glow-pink); }
.timer.count { font-size: 1rem; color: var(--mint); }
.input-card { background: var(--paper); color: var(--ink); border-radius: 16px; padding: 12px 16px; box-shadow: 0 0 0 2px rgba(54,195,255,.6), 0 10px 26px rgba(0,0,0,.4); }
.input-card.genre { text-align: center; background: transparent; box-shadow: none; padding: 4px; }
.genre-chip { display: inline-block; border: 2px solid var(--pink); color: #fff; font-weight: 800; padding: 6px 18px; border-radius: 99px; font-size: 1.15rem; box-shadow: var(--glow-pink); text-shadow: 0 0 6px rgba(255,63,164,.7); }
.input-card.missing { background: var(--frost); color: var(--text); text-align: center; display: flex; flex-direction: column; gap: 4px; box-shadow: none; border: 2px dashed rgba(255,255,255,.3); }
.story-text { font-size: 1.3rem; line-height: 1.35; margin: 0; overflow-wrap: anywhere; font-weight: 700; color: var(--ink); }
.input-card.draw { padding: 8px; align-self: center; }
.input-drawing { width: min(52vh, 100%); height: auto; aspect-ratio: 1; display: block; border-radius: 10px; }
.text-stage .input-card.draw { flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; }
.text-stage .input-drawing { width: auto; height: 100%; max-height: 52vh; }
.text-wrap { background: var(--frost); border: 1px solid var(--edge); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.text-wrap textarea { resize: none; }
.meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; }
.meta .count { margin-left: auto; font-variant-numeric: tabular-nums; }
.save-status { color: var(--mint); font-size: .9rem; min-width: 6ch; }
.done { width: 100%; }
.prompt-row .input-card { padding: 10px 14px; }
.prompt-row .story-text { font-size: 1.1rem; }
.pad-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.pad { touch-action: none; background: var(--paper); border-radius: 12px; box-shadow: 0 0 0 3px rgba(54,195,255,.75), 0 0 22px rgba(54,195,255,.35), 0 16px 34px rgba(0,0,0,.5); cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.toolbar { display: flex; flex-direction: column; gap: 8px; background: var(--frost); border: 1px solid var(--edge); border-radius: var(--radius); padding: 8px; }
.swatches, .tools { display: grid; gap: 6px; justify-content: center; }
.swatches { grid-template-columns: repeat(8, minmax(0, 40px)); }
.tools { grid-template-columns: repeat(7, minmax(0, var(--tap))); }
.swatch { width: 100%; aspect-ratio: 1; height: auto; border-radius: 50%; border: 3px solid #fff; background: var(--sw); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 3px var(--pink), var(--glow-pink); transform: scale(1.1); }
.width { width: 100%; aspect-ratio: 1; height: auto; border-radius: 14px; border: 1px solid var(--edge); background: var(--paper); display: grid; place-items: center; cursor: pointer; }
.width span { width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink); }
.width.on, .btn.tool.on { box-shadow: 0 0 0 3px var(--pink), var(--glow-pink); }
.btn.tool { background: var(--paper); color: var(--ink); padding: 0; width: 100%; min-width: 0; aspect-ratio: 1; min-height: 0; }
.done-row { display: flex; align-items: center; gap: 10px; }
.done-row .done { flex: 1; }
.waiting h2, .reveal-phone h2, .entry h2 { margin: 0; text-align: center; font-size: 2rem; color: #fff; text-shadow: 0 0 12px var(--pink); }
.ready-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.ready-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: var(--frost); border: 1px solid var(--edge); opacity: .55; }
.ready-list li.ready { opacity: 1; border-color: rgba(78,240,181,.6); }
.ready-list .tick { margin-left: auto; color: var(--mint); }
.waiting .timer { text-align: center; }

/* film frames: paper inside an indigo film strip with glowing edge; player content never glows */
.frame { color: var(--ink); background: var(--paper); border-radius: 4px; position: relative; display: flex; flex-direction: column; align-items: stretch; justify-content: center; padding: 10px; aspect-ratio: 1; overflow: hidden;
  border: 14px solid var(--indigo); border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42'%3E%3Crect width='42' height='42' fill='%231d1856'/%3E%3Crect x='15' y='3' width='12' height='8' rx='2' fill='%23fffaf0' fill-opacity='.85'/%3E%3Crect x='15' y='31' width='12' height='8' rx='2' fill='%23fffaf0' fill-opacity='.85'/%3E%3C/svg%3E") 14 round;
  box-shadow: 0 0 0 2px var(--blue), 0 0 22px rgba(54,195,255,.45), 0 18px 40px rgba(0,0,0,.5); }
.frame canvas { width: 100%; height: auto; aspect-ratio: 1; display: block; border-radius: 6px; min-height: 0; }
.frame.draw { padding: 6px 6px 28px; }
.film-row .frame.draw { padding-bottom: calc(var(--u) * 3.4); }
.frame.text { padding: 14px; }
.frame .by { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: .85rem; font-weight: 700; color: #5d5880; }
.frame.hidden { background: linear-gradient(180deg, #2b2478, #1c1752); color: #fff; align-items: center; }
.frame.hidden .q { font-size: 3rem; font-weight: 800; color: #fff; text-shadow: 0 0 6px var(--blue), 0 0 20px var(--blue); }
.frame.missing { background: #ece7f7; align-items: center; text-align: center; }
.frame.current { box-shadow: 0 0 0 3px var(--pink), 0 0 30px rgba(255,63,164,.6), 0 18px 40px rgba(0,0,0,.55); }
.mini-current { width: min(220px, 64vw); align-self: center; margin: 16px 0; }
.reveal-controls { display: flex; gap: 10px; justify-content: center; align-items: center; }
.reveal-controls .primary { min-width: 140px; }

/* poster */
.poster-phone { width: min(900px, 100%); }
.poster-strip { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); width: 100%; }
.poster { margin: 0; background: var(--frost); border: 1px solid var(--edge); border-radius: 16px; padding: 10px 10px 14px; }
.poster figcaption { font-weight: 800; margin-bottom: 10px; color: #fff; }
.poster-frames { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.poster-frames .frame { padding: 3px; border-width: 6px; box-shadow: 0 0 0 1px var(--blue); }
.poster-frames .frame .by { display: none; }
.poster-frames .story-text { font-size: .62rem; line-height: 1.2; }
.poster-controls { display: flex; justify-content: center; }

/* TV host screen: a fixed 16:9 neon stage (backdrop art/runtime/pt07/tv-backdrop.png). --u = 1% of the stage height,
   so a 4K TV, a 1080p screen and a laptop window all keep the same composition and the title sits inside the marquee. */
body.view-host { background: var(--deep); }
.view-host main { padding: 0; }
.tv { --u: min(1vh, .5625vw); position: relative; width: min(100vw, 177.78vh); aspect-ratio: 16 / 9; margin: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 2.2); color: #fff;
  background: var(--deep) url('/art/tv-backdrop.jpg') center / 100% 100% no-repeat; padding: calc(var(--u) * 30) 12% calc(var(--u) * 12); }
.tv-logo { font-size: calc(var(--u) * 7); position: absolute; top: calc(var(--u) * 17.5); left: 12%; right: 12%; text-align: center; }
.tv .mascot { width: calc(var(--u) * 22); height: calc(var(--u) * 22); }
.tv-sub { font-size: calc(var(--u) * 3.2); margin: 0; color: var(--muted); }
.code-huge { font-size: calc(var(--u) * 13); font-weight: 800; letter-spacing: .25em; padding: calc(var(--u) * .6) calc(var(--u) * 4); border-radius: calc(var(--u) * 3); border: 3px solid var(--blue); color: #fff; text-shadow: 0 0 8px var(--blue), 0 0 30px rgba(54,195,255,.7); box-shadow: var(--glow-blue), inset 0 0 30px rgba(54,195,255,.25); background: rgba(10,8,32,.6); }
.tv-members, .tv-ready { list-style: none; padding: 0; margin: 0; display: flex; gap: calc(var(--u) * 1.6); flex-wrap: wrap; justify-content: center; }
.tv-members li, .tv-ready li { background: rgba(29,24,86,.8); border: 1px solid var(--edge); border-radius: 99px; padding: calc(var(--u) * .9) calc(var(--u) * 2.2); font-size: calc(var(--u) * 2.8); display: flex; gap: calc(var(--u) * 1); align-items: center; }
.tv-ready li { opacity: .55; } .tv-ready li.ready { opacity: 1; border-color: var(--mint); box-shadow: 0 0 14px rgba(78,240,181,.45); }
.tv .mark { width: calc(var(--u) * 2.8); height: calc(var(--u) * 2.8); }
.tv-marks .mark { width: calc(var(--u) * 4.4); height: calc(var(--u) * 4.4); }
.tv-round { position: absolute; bottom: calc(var(--u) * 3.5); left: 3%; font-size: calc(var(--u) * 2.6); color: var(--muted); }
.tv-title { font-size: calc(var(--u) * 5); margin: 0; text-align: center; text-shadow: 0 0 6px #fff, 0 0 22px var(--pink); }
.tv-stage .tv-title { position: absolute; top: calc(var(--u) * 18.5); left: 13%; right: 13%; font-size: calc(var(--u) * 4.4); }
.tv-timer { font-size: calc(var(--u) * 16); line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; text-shadow: 0 0 8px var(--blue), 0 0 30px rgba(54,195,255,.6); }
.tv-timer.low { color: var(--pink); text-shadow: var(--glow-pink); }
.tv-timer.count { font-size: calc(var(--u) * 7); color: var(--mint); }
.tv-host-row { display: flex; gap: calc(var(--u) * 2); position: absolute; bottom: calc(var(--u) * 3); right: 3%; }
.tv-reveal { padding: 0; }
.tv-titleband { position: absolute; top: calc(var(--u) * 18.2); left: 13%; right: 13%; height: calc(var(--u) * 9); display: flex; gap: calc(var(--u) * 3); align-items: center; justify-content: center; }
.film-no { font-size: calc(var(--u) * 2.6); color: var(--muted); font-weight: 700; }
.film-title { font-size: calc(var(--u) * 4.8); font-weight: 800; color: #fff; text-shadow: 0 0 10px var(--pink), 0 0 2px #fff; }
.film-row { position: absolute; top: calc(var(--u) * 32); bottom: calc(var(--u) * 21); left: 9%; right: 9%; display: flex; gap: 3.4%; align-items: center; justify-content: center; }
.film-row .frame { border-width: calc(var(--u) * 1.8); width: calc(var(--u) * 21); transition: width .4s ease, box-shadow .4s ease; }
.film-row .frame.current { width: calc(var(--u) * 46); border-width: calc(var(--u) * 3); }
.film-row .frame.past { opacity: 1; }
.film-row .frame.text.current .story-text { font-size: calc(var(--u) * 3.9); }
.film-row .frame.text .story-text { font-size: calc(var(--u) * 1.6); }
.film-row .frame .by { font-size: calc(var(--u) * 1.4); }
.film-row .frame.current .by { font-size: calc(var(--u) * 2.2); }
.tv-foot { position: absolute; left: 3%; right: 3%; bottom: calc(var(--u) * 3); display: flex; justify-content: space-between; align-items: center; }
.tv-marks { display: flex; gap: calc(var(--u) * 1.6); padding: calc(var(--u) * 1) calc(var(--u) * 2); border-radius: 99px; background: rgba(10,8,32,.7); }
.tv .reveal-controls { gap: calc(var(--u) * 1.6); }
.tv .reveal-controls .btn.round { width: calc(var(--u) * 8.5); height: calc(var(--u) * 8.5); background: rgba(29,24,86,.85); border: 2px solid var(--blue); box-shadow: var(--glow-blue); }
.tv .reveal-controls .ic { width: calc(var(--u) * 3.6); height: calc(var(--u) * 3.6); }
.tv .reveal-controls .btn.primary { min-height: calc(var(--u) * 8.5); padding: 0 calc(var(--u) * 3.4); border-radius: 99px; font-size: calc(var(--u) * 3.2); }
.tv-poster { padding-top: calc(var(--u) * 30); justify-content: flex-start; }
.tv-poster .tv-title { position: absolute; top: calc(var(--u) * 18.5); left: 13%; right: 13%; font-size: calc(var(--u) * 4.6); }
.tv-poster .poster-strip { grid-template-columns: repeat(auto-fit, minmax(calc(var(--u) * 34), 1fr)); gap: calc(var(--u) * 1.6); width: 100%; }
.tv-poster .poster figcaption { font-size: calc(var(--u) * 2); }
.tv-poster .poster-controls { position: absolute; bottom: calc(var(--u) * 3); right: 3%; }
@keyframes shimmer { 0%, 100% { box-shadow: 0 0 10px rgba(255,194,61,.7), 0 0 30px rgba(255,63,164,.35), inset 0 0 22px rgba(255,194,61,.18); } 50% { box-shadow: 0 0 14px rgba(255,194,61,.9), 0 0 40px rgba(255,63,164,.5), inset 0 0 26px rgba(255,194,61,.25); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
body.energy-saver * { animation: none !important; transition: none !important; }
body.energy-saver .card { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* phone landscape: keep the canvas big, tools beside it, everything on one screen */
@media (orientation: landscape) and (max-height: 520px) {
  main { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .stage { height: calc(100dvh - 12px); gap: 6px; }
  .task { font-size: 1.05rem; } .timer { font-size: 1.1rem; }
  .prompt-row .input-card { padding: 6px 12px; } .prompt-row .story-text { font-size: .95rem; }
  .draw-stage { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr) auto; column-gap: 10px; row-gap: 6px; }
  .draw-stage .stage-head, .draw-stage .prompt-row { grid-column: 1 / -1; }
  .draw-stage .pad-wrap { grid-row: 3 / 5; grid-column: 1; }
  .draw-stage .toolbar { grid-column: 2; grid-row: 3; width: 196px; padding: 6px; gap: 6px; overflow: auto; }
  .draw-stage .swatches { grid-template-columns: repeat(4, 38px); }
  .draw-stage .tools { grid-template-columns: repeat(4, 42px); }
  .draw-stage .swatch { border-width: 2px; }
  .draw-stage .done-row { grid-column: 2; grid-row: 4; width: 196px; }
  .draw-stage .done-row .save-status { display: none; }
  .draw-stage .done { min-height: 48px; }
  .text-stage .input-drawing { max-height: 40vh; }
}

/* ---- drawing controller v2 (tools, colours, size, popovers, stickers) ---- */
.html-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.toolbar { position: relative; }
.tools-row { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.tbtn { font: inherit; aspect-ratio: 1; min-width: 0; min-height: 40px; max-height: 52px; border-radius: 12px; border: 1px solid var(--edge); background: var(--paper); color: var(--ink); display: grid; place-items: center; cursor: pointer; padding: 0; touch-action: manipulation; }
.tbtn .ic { width: 60%; height: 60%; max-width: 26px; max-height: 26px; }
.tbtn.on { box-shadow: 0 0 0 3px var(--pink), var(--glow-pink); }
.tbtn:disabled { opacity: .35; }
.tbtn.ok { background: linear-gradient(180deg, #ffd56a, var(--citrus)); }
.tbtn.ghost { background: var(--frost); color: #fff; }
.tbtn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.toolbar .swatches { grid-template-columns: repeat(9, minmax(0, 40px)); }
.swatch.more { background: conic-gradient(#ff3b3b, #ffb000, #3ad13a, #2fb6ff, #6a4bff, #ff3fa4, #ff3b3b); display: grid; place-items: center; }
.swatch.more .ic { width: 70%; height: 70%; opacity: 0; }
.swatch.more.on { background: var(--sw); box-shadow: 0 0 0 3px var(--pink), var(--glow-pink); }
.size-row { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.size-dot { justify-self: center; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); box-shadow: 0 0 8px rgba(54,195,255,.6); }
input.size { -webkit-appearance: none; appearance: none; background: transparent; padding: 0; border: 0; height: 36px; }
input.size::-webkit-slider-runnable-track { height: 8px; border-radius: 99px; background: linear-gradient(90deg, rgba(54,195,255,.5), rgba(255,63,164,.8)); }
input.size::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%; background: var(--paper); border: 3px solid var(--pink); box-shadow: var(--glow-pink); }
input.size::-moz-range-track { height: 8px; border-radius: 99px; background: linear-gradient(90deg, rgba(54,195,255,.5), rgba(255,63,164,.8)); }
input.size::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--paper); border: 3px solid var(--pink); }
input.size:focus { box-shadow: none; }
.popover { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 6; background: rgba(24,20,70,.96); border: 1px solid var(--pink); box-shadow: var(--glow-pink), 0 18px 40px rgba(0,0,0,.6); border-radius: 18px; padding: 10px; }
.popover[hidden] { display: none; }
.shape-pop { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.colour-pop .extra { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.colour-pop .recent { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.colour-pop .swatch { width: 100%; }
.colour-pop .recent .swatch { width: 40px; }
.swatch.spectrum { margin-left: auto; position: relative; overflow: hidden; background: conic-gradient(#ff3b3b, #ffb000, #3ad13a, #2fb6ff, #6a4bff, #ff3fa4, #ff3b3b); width: 52px !important; height: 52px; }
.swatch.spectrum .ic { display: none; }
.custom-colour { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.pad-wrap { position: relative; }
.place-bar { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; gap: 6px; padding: 6px; border-radius: 16px; background: rgba(24,20,70,.92); border: 1px solid var(--pink); box-shadow: var(--glow-pink); z-index: 4; }
.place-bar[hidden] { display: none; }
.place-bar .tbtn { width: 46px; }
.sticker-sheet { position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 16px; background: rgba(18,15,51,.97); border: 1px solid var(--blue); box-shadow: var(--glow-blue); }
.sticker-sheet[hidden] { display: none; }
.sheet-head { display: grid; grid-template-columns: 28px 1fr 46px; gap: 8px; align-items: center; }
.sheet-head .search-ic .ic { color: var(--muted); }
.sticker-search { font-size: 1rem; padding: 8px 12px; }
.sticker-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.sticker-tabs .tab { flex: none; min-width: 44px; height: 40px; border-radius: 12px; border: 1px solid var(--edge); background: var(--frost); color: #fff; font: inherit; font-size: 1.1rem; cursor: pointer; }
.sticker-tabs .tab.on { border-color: var(--pink); box-shadow: var(--glow-pink); }
.sticker-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; align-content: start; }
.sticker { padding: 4px; border-radius: 12px; border: 0; background: var(--paper); cursor: pointer; }
.sticker canvas { width: 100%; height: auto; display: block; }
.btn.dice .ic { width: 30px; height: 30px; }
.btn.dice.roll .ic { animation: roll .5s ease; }
@keyframes roll { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(200deg) scale(1.25); } 100% { transform: rotate(360deg) scale(1); } }
@media (orientation: landscape) and (max-height: 520px) {
  .draw-stage .toolbar { width: 236px; }
  .draw-stage .done-row { width: 236px; }
  .draw-stage .tools-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .draw-stage .toolbar .swatches { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tbtn { min-height: 0; }
  .popover { bottom: auto; top: 0; left: auto; right: calc(100% + 8px); width: 300px; }
}

/* lobby v2: graphics first */
.mode-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.mode-tile { font: inherit; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px 8px; border-radius: 16px; border: 1px solid var(--edge); background: var(--frost); cursor: pointer; }
.mode-tile .ic { width: 30px; height: 30px; }
.mode-tile .mt-name { font-size: .72rem; color: var(--muted); }
.mode-tile.on { border-color: var(--pink); box-shadow: var(--glow-pink); background: rgba(255,63,164,.14); }
.mode-tile.on .mt-name { color: #fff; }
.mode-tile:disabled { cursor: default; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.opt-ic .ic { width: 26px; height: 26px; color: var(--muted); }
.opt-val { min-width: 2ch; text-align: center; font-size: 1.3rem; }
.chip { font: inherit; font-weight: 800; color: #fff; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--edge); background: var(--frost); display: inline-flex; align-items: center; gap: 4px; justify-content: center; cursor: pointer; }
.chip .ic { width: 24px; height: 24px; }
.chip.on { border-color: var(--blue); box-shadow: var(--glow-blue); }
.chip:disabled { cursor: default; opacity: .8; }
.waiting-dots { display: flex; gap: 8px; justify-content: center; }
.ghost-seat { width: 26px; height: 26px; border-radius: 50%; border: 2px dashed rgba(255,255,255,.35); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.badge .ic { width: 16px; height: 16px; }
.btn.start .ic { width: 30px; height: 30px; }
.tv-link { align-self: center; }

/* voting, credits, league */
.vote-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.vote-strip .frame { padding-bottom: 10px; }
.vote-strip .frame .story-text { font-size: .82rem; }
.vote { position: absolute; right: -6px; bottom: -6px; width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--blue); background: var(--night); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: var(--glow-blue); z-index: 2; }
.vote .ic { width: 24px; height: 24px; }
.vote.on { background: var(--pink); border-color: #fff; box-shadow: var(--glow-pink); transform: scale(1.08); }
.vote.on .ic { fill: #fff; }
.vote-count, .mine-tag { position: absolute; right: 4px; bottom: 4px; display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 99px; background: var(--pink); color: #fff; font-size: .85rem; box-shadow: var(--glow-pink); }
.vote-count .ic, .mine-tag .ic { width: 16px; height: 16px; }
.mine-tag { background: var(--indigo); box-shadow: none; border: 1px solid var(--edge); }
.vote-hint { display: flex; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 1.4rem; }
.vote-hint .ic { width: 30px; height: 30px; }
.film-chip { align-self: center; display: inline-flex; gap: 6px; align-items: center; padding: 4px 14px; border-radius: 99px; border: 2px solid var(--citrus); box-shadow: var(--glow-citrus); font-weight: 800; }
.round-title { margin: 0; text-align: center; color: #fff; text-shadow: 0 0 12px var(--pink); }
.poster-body { display: grid; gap: 14px; }
.league { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.league li { display: grid; grid-template-columns: 30px 26px minmax(0, 1fr) minmax(40px, 1.2fr) 38px 40px; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 14px; background: var(--frost); border: 1px solid var(--edge); animation: rise .5s ease both; animation-delay: var(--d); }
.league li.rank-1 { border-color: var(--citrus); box-shadow: var(--glow-citrus); }
.league .pos { font-weight: 800; color: var(--citrus); text-align: center; }
.league .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.league .bar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.league .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--pink)); border-radius: 99px; animation: grow .9s ease both; animation-delay: var(--d); }
.league .plus { color: var(--mint); font-weight: 800; text-align: right; }
.league .tot { font-size: 1.2rem; text-align: right; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes grow { from { width: 0 !important; } }
.tv-league li { font-size: calc(var(--u) * 2.4); padding: calc(var(--u) * .8) calc(var(--u) * 1.6); grid-template-columns: calc(var(--u) * 3.5) calc(var(--u) * 3) minmax(0, 1fr) minmax(0, 1fr) calc(var(--u) * 4.5) calc(var(--u) * 5); }
.tv-league .tot { font-size: calc(var(--u) * 3); }
.tv-poster-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: calc(var(--u) * 2.4); width: 100%; align-items: start; max-height: calc(var(--u) * 56); overflow: hidden; }
.tv-poster-grid .poster-strip { grid-template-columns: repeat(auto-fit, minmax(calc(var(--u) * 26), 1fr)); }
.film-row .frame.credit { width: calc(var(--u) * 30); }
.film-row .frame.credit .by { font-size: calc(var(--u) * 2); color: var(--ink); }
.is-credits .film-row .frame .vote-count { font-size: calc(var(--u) * 2.2); }
.tv-vote-hint { position: absolute; bottom: calc(var(--u) * 4); left: 50%; transform: translateX(-50%); color: #fff; opacity: .85; }
.tv-vote-hint .ic { width: calc(var(--u) * 6); height: calc(var(--u) * 6); filter: drop-shadow(0 0 8px var(--pink)); }
.frame.text .story-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 9; overflow: hidden; }
.frame.text.mid .story-text { font-size: .88em; }
.frame.text.long .story-text { font-size: .74em; line-height: 1.25; }
.vote-strip .frame.text { padding: 8px 8px 22px; }
.vote-strip .frame.text .story-text { font-size: .74rem; }
.vote-strip .frame.text.long .story-text { font-size: .64rem; }
.film-row .frame.text.current.mid .story-text { font-size: calc(var(--u) * 3.3); }
.film-row .frame.text.current.long .story-text { font-size: calc(var(--u) * 2.7); }

/* premiere intro */
.intro { position: fixed; inset: 0; z-index: 50; background: #050414; overflow: hidden; display: grid; place-items: center; transition: opacity .45s ease; }
.intro.out { opacity: 0; }
.i-cam { width: min(100vw, 177.78vh); aspect-ratio: 16 / 9; position: relative; transform-origin: 50% 60%; animation: i-dolly 4.2s cubic-bezier(.2,.7,.1,1) both; }
.i-stage { position: absolute; inset: 0; }
.i-backdrop { position: absolute; inset: 0; background: url('/art/tv-backdrop.jpg') center / 100% 100% no-repeat; animation: i-lights 4.2s ease both; }
.i-curtain { position: absolute; top: 28%; bottom: 14%; width: 38%; background: repeating-linear-gradient(90deg, #a3105c 0 4%, #e0237f 4% 7%, #7a0a45 7% 10%); box-shadow: inset 0 0 40px rgba(0,0,0,.6), 0 0 30px rgba(255,63,164,.5); animation: i-part 1.4s 2.3s cubic-bezier(.6,0,.2,1) both; }
.i-curtain.l { left: 12%; border-radius: 0 0 40% 0; } .i-curtain.r { right: 12%; border-radius: 0 0 0 40%; --dir: 1; }
.i-title { position: absolute; top: 18.5%; left: 13%; right: 13%; height: 9%; display: grid; place-items: center; font-family: "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif; font-weight: 800; font-size: min(5.2vh, 2.9vw); color: #fff; text-shadow: 0 0 6px #fff, 0 0 18px #ff3fa4, 0 0 40px #ff3fa4; animation: i-flicker 1.3s 1.4s steps(1) both; }
.i-mascot { position: absolute; left: 50%; bottom: 17%; width: 18%; transform: translateX(-50%); filter: drop-shadow(0 0 20px rgba(255,63,164,.6)); animation: i-pop .8s 3.1s cubic-bezier(.3,1.6,.5,1) both; }
.i-spot { position: absolute; top: -20%; width: 30vw; height: 140vh; background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0) 80%); clip-path: polygon(45% 0, 55% 0, 100% 100%, 0 100%); mix-blend-mode: screen; animation: i-sweep 3.2s ease-in-out both; }
.i-spot.a { left: 10%; transform-origin: 50% 0; } .i-spot.b { right: 10%; transform-origin: 50% 0; animation-direction: reverse; }
.i-flash { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.55), transparent 60%); opacity: 0; animation: i-flash .9s 3.05s ease-out both; }
@keyframes i-dolly { 0% { transform: scale(.42); filter: brightness(.2) blur(2px); } 35% { transform: scale(.55); filter: brightness(.55); } 100% { transform: scale(1); filter: none; } }
@keyframes i-lights { 0%, 20% { filter: saturate(.2) brightness(.4); } 60% { filter: saturate(1.2) brightness(1.15); } 100% { filter: none; } }
@keyframes i-part { from { transform: translateX(0); } to { transform: translateX(calc(var(--dir, -1) * 110%)); opacity: .0; } }
@keyframes i-flicker { 0% { opacity: 0; } 10% { opacity: 1; } 18% { opacity: .2; } 30% { opacity: 1; } 38% { opacity: .4; } 50%, 100% { opacity: 1; } }
@keyframes i-pop { from { transform: translateX(-50%) scale(0) rotate(-20deg); } to { transform: translateX(-50%) scale(1) rotate(0); } }
@keyframes i-sweep { 0% { transform: rotate(-25deg); opacity: 0; } 20% { opacity: 1; } 80% { opacity: 1; } 100% { transform: rotate(25deg); opacity: 0; } }
@keyframes i-flash { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
.intro-phone .i-cam { width: 100vw; aspect-ratio: auto; height: 100vh; animation-duration: 2s; }
.intro-phone .i-backdrop { background-size: cover; background-position: 50% 30%; animation-duration: 2s; }
.intro-phone .i-curtain, .intro-phone .i-spot { display: none; }
.intro-phone .i-title { top: 30%; font-size: 9vw; animation-delay: .4s; }
.intro-phone .i-mascot { width: 44vw; bottom: 24%; animation-delay: 1s; }
.intro-phone .i-flash { animation-delay: .95s; }
.intro.calm * { animation: none !important; }
.intro.calm .i-cam { animation: i-fade 1s ease both !important; }
@keyframes i-fade { from { opacity: 0; } }

/* sound toggle: one small icon, top corner, never in the way */
.sound-toggle { position: fixed; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); z-index: 40; width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(18,15,51,.7); color: #fff; display: grid; place-items: center; padding: 0; cursor: pointer; }
.sound-toggle .ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle.off { color: var(--pink, #ff3fa4); }
.view-host .sound-toggle { width: calc(5 * var(--u, 1vh)); height: calc(5 * var(--u, 1vh)); }

/* emoji sticker sheet (Noto) */
.sticker-sheet .sheet-row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.sticker-sheet .sheet-row .sticker-tabs { flex: 1; min-width: 0; }
.sticker-tabs .tab img { width: 26px; height: 26px; display: block; margin: auto; }
.sticker-tabs .tab .ic { width: 22px; height: 22px; }
.tone-row { display: flex; gap: 4px; flex: none; }
.tone-row .tone { width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); background: var(--sw); padding: 0; cursor: pointer; }
.tone-row .tone.on { border-color: #fff; box-shadow: 0 0 0 2px var(--pink); }
.sticker-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.sticker { background: transparent; padding: 2px; aspect-ratio: 1; display: grid; place-items: center; }
.sticker:hover, .sticker:focus-visible { background: rgba(255,255,255,.12); }
.sticker img { width: 100%; height: auto; display: block; }
.sticker-none { grid-column: 1 / -1; display: grid; place-items: center; padding: 30px; opacity: .5; }
.sticker-none .ic { width: 40px; height: 40px; }
@media (max-width: 430px) { .sticker-sheet .sheet-row { flex-wrap: wrap; } .tone-row { width: 100%; justify-content: center; } }
.view-player.in-stage .sound-toggle { display: none; } /* the phone timer lives there while drawing/writing */
