      :root {
        --bg: #e8f1f6;
        --bg-deep: #d9e9f2;
        --surface: #ffffff;
        --surface-2: #f2f8fb;
        --ink: #17323f;
        --muted: #55707f;
        --line: #c8dbe5;
        --line-strong: #9fbecf;
        --accent: #e85d2a;
        --accent-soft: #fdeee6;
        --pine: #1d6f5c;
        --pine-soft: #e2f2ec;
        --sky: #2f7fb8;
        --gold: #d98e1c;
        --gold-soft: #fdf3dd;
        --chip: #eef5f9;
        --stage-line: #b9d4e2;
        --shadow: 0 10px 30px rgba(23, 50, 63, .10);
        --shadow-sm: 0 2px 8px rgba(23, 50, 63, .08);
      }
      @media (prefers-color-scheme: dark) {
        :root {
          --bg: #0c1a23;
          --bg-deep: #0a141c;
          --surface: #152936;
          --surface-2: #1a3243;
          --ink: #e9f4f9;
          --muted: #9db9c6;
          --line: #2a4657;
          --line-strong: #3d6076;
          --accent: #ff7a45;
          --accent-soft: #3d2718;
          --pine: #3cb598;
          --pine-soft: #17382f;
          --sky: #5aa9dd;
          --gold: #f0b95a;
          --gold-soft: #3a2f16;
          --chip: #1d3647;
          --stage-line: #33566c;
          --shadow: 0 10px 30px rgba(0, 0, 0, .35);
          --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
        }
      }
      * { box-sizing: border-box; }
      html { scroll-behavior: smooth; }
      body {
        margin: 0;
        font-family: "Nunito", system-ui, sans-serif;
        background: var(--bg);
        color: var(--ink);
        line-height: 1.45;
      }
      button, select, input, textarea { font: inherit; color: inherit; }
      button { cursor: pointer; }
      button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
        outline: 3px solid var(--sky);
        outline-offset: 2px;
      }
      .wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 64px; }

      /* ---------- Intro ---------- */
      .intro {
        display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end;
        justify-content: space-between; margin-bottom: 18px;
      }
      .intro h1 {
        font-family: "Baloo 2", "Nunito", sans-serif;
        font-size: clamp(1.7rem, 4.5vw, 2.5rem);
        line-height: 1.05; margin: 0 0 6px; letter-spacing: -.01em;
      }
      .intro h1 .carrot { color: var(--accent); }
      .lede { margin: 0; color: var(--muted); max-width: 56ch; font-size: 1.02rem; }
      .room-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
      .room-code {
        font-family: "Space Mono", monospace; font-weight: 700; letter-spacing: .08em;
        background: var(--ink); color: var(--bg); border-radius: 8px; padding: 6px 12px; font-size: .95rem;
      }
      .tag {
        border: 1.5px solid var(--line-strong); color: var(--muted); border-radius: 999px;
        padding: 5px 12px; font-size: .83rem; font-weight: 700; background: var(--surface);
      }
      .tag.demo { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
      .intro-actions { display: flex; gap: 8px; flex-wrap: wrap; }

      /* ---------- Buttons ---------- */
      .btn {
        min-height: 44px; padding: 9px 16px; border-radius: 12px;
        border: 1.5px solid var(--line-strong); background: var(--surface);
        font-weight: 800; font-size: .95rem; box-shadow: var(--shadow-sm);
        display: inline-flex; align-items: center; gap: 8px; justify-content: center;
      }
      .btn:hover { border-color: var(--sky); }
      .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
      .btn.primary:hover { filter: brightness(1.07); }
      .btn.pine { background: var(--pine); border-color: var(--pine); color: #fff; }
      .btn.ghost { box-shadow: none; }
      .btn.small { min-height: 38px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
      .btn:disabled { opacity: .45; cursor: not-allowed; }
      .btn[aria-pressed="true"] { background: var(--pine); border-color: var(--pine); color: #fff; }

      /* ---------- Layout ---------- */
      .layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 18px; align-items: start; }
      /* Preview stays in view while the controls column scrolls (desktop) */
      #stage-card { position: sticky; top: 16px; }
      @media (max-width: 900px) {
        .layout { grid-template-columns: 1fr; gap: 12px; }
        /* On a phone the preview pins to the top of the screen, compact,
           so picking parts and moving sliders below never hides it. */
        #stage-card {
          top: 0; z-index: 40;
          border-radius: 0 0 20px 20px;
          box-shadow: 0 12px 24px rgba(23, 50, 63, .18);
        }
      }

      .card {
        background: var(--surface); border: 1.5px solid var(--line); border-radius: 20px;
        box-shadow: var(--shadow); overflow: hidden;
      }

      /* ---------- Stage ---------- */
      .stage-head {
        display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
        padding: 14px 16px 10px;
      }
      .stage-head label { font-weight: 800; font-size: .85rem; color: var(--muted); display: block; margin-bottom: 4px; }
      .challenge-wrap { flex: 1 1 220px; }
      select, input[type="text"], textarea {
        width: 100%; min-height: 44px; border: 1.5px solid var(--line-strong); border-radius: 10px;
        background: var(--surface-2); padding: 9px 12px; font-weight: 600;
      }
      textarea { min-height: 44px; resize: vertical; }
      .stage-frame { padding: 0 16px; }
      .stage-box {
        border: 2px solid var(--stage-line); border-radius: 16px; overflow: hidden;
        background: #bfe0f2; line-height: 0;
        display: flex; justify-content: center;
      }
      /* The wrap gets an explicit width derived from the height budget, and
         the SVG fills it at its true 4:5 ratio — never a collapsed or
         letterboxed box, on any browser. */
      .stage-wrap {
        position: relative; display: block; line-height: 0; margin: 0 auto;
        width: min(100%, calc((100vh - 270px) * 0.8));
        width: min(100%, calc((100dvh - 270px) * 0.8));
      }
      .stage-wrap > #stage svg { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; }
      #stage-overlay {
        position: absolute; inset: 0; width: 100%; height: 100%; display: block;
        pointer-events: none;
      }
      .stage-box.interactive #stage-overlay { pointer-events: all; touch-action: none; cursor: crosshair; }
      .stage-box.shape-mode #stage-overlay { cursor: grab; }
      .stage-box.shape-mode #stage-overlay:active { cursor: grabbing; }
      /* Desktop preview height is budgeted by the .stage-wrap width above. */
      .stage-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px 16px; }
      .stage-scroll-hint { display: none; }

      @media (max-width: 900px) {
        .stage-head { padding: 8px 12px 6px; gap: 8px; flex-wrap: nowrap; align-items: flex-end; }
        .stage-head label { font-size: .78rem; margin-bottom: 3px; }
        .stage-head select { min-height: 38px; padding: 6px 8px; font-size: .9rem; }
        .stage-head .btn.small { min-height: 38px; flex: none; }
        .stage-frame { padding: 0 12px; }
        .stage-box { border-radius: 12px; }
        /* Portrait picture ~38% of the screen tall, at its true ratio. */
        .stage-wrap { width: min(100%, calc(38vh * 0.8)); width: min(100%, calc(38dvh * 0.8)); }
        .stage-actions { padding: 8px 12px 10px; }
        .stage-actions .btn { min-height: 38px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
        .stage-scroll-hint {
          display: block; text-align: center; font-size: .78rem; font-weight: 800;
          color: var(--muted); padding: 0 12px 10px; margin-top: -2px;
        }
      }

      /* Adjuster — lives in the controls panel, right under the part choices,
         so size / tilt / position can be changed while watching the preview. */
      .adjuster {
        margin-top: 16px; border: 1.5px solid var(--line); border-radius: 14px;
        padding: 14px; background: var(--surface-2);
      }
      .adjuster h3 { margin: 0 0 4px; font-size: .95rem; font-family: "Baloo 2", sans-serif; }
      .adjuster p { margin: 0 0 10px; color: var(--muted); font-size: .88rem; }
      .adj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
      @media (max-width: 480px) { .adj-grid { grid-template-columns: 1fr; } }
      .adj-grid label { font-size: .82rem; font-weight: 800; color: var(--muted); display: flex; justify-content: space-between; }
      .adj-grid label output { color: var(--ink); font-family: "Space Mono", monospace; font-size: .8rem; }
      input[type="range"] { width: 100%; min-height: 36px; accent-color: var(--accent); }
      .adj-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

      /* ---------- Panel / tabs ---------- */
      .panel { padding: 16px; }
      .tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
      @media (max-width: 900px) {
        .panel { padding: 12px; }
        /* One swipeable row of categories instead of three wrapped rows —
           keeps the choices and sliders up close under the pinned preview. */
        .tabs {
          flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
          margin: 0 -12px 12px; padding: 2px 12px 6px; scrollbar-width: none;
        }
        .tabs::-webkit-scrollbar { display: none; }
        .tab { flex: none; }
        .options { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
        .adjuster { margin-top: 12px; }
      }
      .tab {
        min-height: 40px; padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--line-strong);
        background: var(--chip); font-weight: 800; font-size: .9rem;
      }
      .tab[aria-selected="true"] { background: var(--pine); border-color: var(--pine); color: #fff; }
      .options { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
      .opt {
        min-height: 48px; padding: 8px 10px; border-radius: 12px; border: 1.5px solid var(--line);
        background: var(--surface-2); font-weight: 700; font-size: .9rem; text-align: left;
        display: flex; align-items: center; gap: 8px;
      }
      .opt .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1.5px solid rgba(0,0,0,.18); }
      .opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
      .opt[aria-pressed="true"]::after { content: "✓"; margin-left: auto; color: var(--accent); font-weight: 900; }
      .subhead { font-size: .82rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
      .swatches { display: flex; flex-wrap: wrap; gap: 8px; }
      .swatch {
        width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface);
        box-shadow: 0 0 0 1.5px var(--line-strong); padding: 0;
      }
      .swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--accent); }
      .extra-group { margin-bottom: 6px; }
      .tool-note { margin: 0 0 12px; color: var(--muted); font-size: .92rem; }
      .tool-note strong { color: var(--ink); }
      .tool-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
      .tool-range { display: grid; gap: 4px; margin-top: 14px; max-width: 340px; }
      .tool-range label { font-size: .82rem; font-weight: 800; color: var(--muted); display: flex; justify-content: space-between; }
      .tool-range label output { color: var(--ink); font-family: "Space Mono", monospace; font-size: .8rem; }
      .selected-note { margin-top: 12px; font-weight: 800; font-size: .9rem; background: var(--pine-soft); color: var(--pine); border-radius: 10px; padding: 9px 12px; }
      .pet-controls { display: grid; gap: 10px; margin-top: 4px; }
      .pet-control { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface-2); }
      .pet-control-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
      .pet-control-head strong { font-size: .95rem; }
      .pet-control .tool-range { margin-top: 8px; max-width: 100%; }

      /* Details form */
      .details { margin-top: 22px; border-top: 1.5px dashed var(--line); padding-top: 16px; }
      .details h2 { font-family: "Baloo 2", sans-serif; margin: 0 0 4px; font-size: 1.25rem; }
      .details p { margin: 0 0 14px; color: var(--muted); font-size: .92rem; }
      .field { margin-bottom: 12px; }
      .field label { display: block; font-weight: 800; font-size: .88rem; margin-bottom: 5px; }
      .field label .req { color: var(--accent); }
      .field .hint { font-weight: 600; color: var(--muted); font-size: .8rem; }
      .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
      @media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
      .submit-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

      /* ---------- Gallery ---------- */
      .gallery-section { margin-top: 28px; }
      .gallery-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
      .gallery-head h2 { font-family: "Baloo 2", sans-serif; font-size: 1.6rem; margin: 0 0 4px; }
      .gallery-head p { margin: 0; color: var(--muted); max-width: 60ch; }
      .winner-tools {
        display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
        background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px;
        padding: 12px; margin: 16px 0; box-shadow: var(--shadow-sm);
      }
      .winner-tools .wt-label { font-weight: 800; font-size: .85rem; color: var(--muted); margin-right: 2px; }
      .stars-left { font-family: "Space Mono", monospace; font-weight: 700; background: var(--gold-soft); color: var(--gold); border-radius: 8px; padding: 6px 10px; font-size: .88rem; }
      .winner-banner {
        display: none; border-radius: 16px; padding: 16px 20px; margin-bottom: 16px;
        background: var(--gold-soft); border: 2px solid var(--gold); font-size: 1.05rem;
      }
      .winner-banner.show { display: block; }
      .winner-banner strong { font-family: "Baloo 2", sans-serif; font-size: 1.3rem; }
      .winner-banner .how { display: block; font-size: .88rem; color: var(--muted); font-weight: 700; margin-top: 2px; }
      .gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
      .entry { display: flex; flex-direction: column; }
      .entry .thumb { line-height: 0; border-bottom: 1.5px solid var(--line); }
      .entry .thumb svg { width: 100%; height: auto; display: block; }
      .entry .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
      .entry h3 { font-family: "Baloo 2", sans-serif; margin: 0; font-size: 1.25rem; line-height: 1.15; }
      .entry .team { color: var(--sky); font-weight: 800; font-size: .88rem; }
      .entry dl { margin: 6px 0 0; display: grid; gap: 5px; font-size: .92rem; }
      .entry dl div { display: grid; grid-template-columns: 86px 1fr; gap: 8px; }
      .entry dt { font-weight: 800; color: var(--muted); font-size: .8rem; padding-top: 2px; }
      .entry dd { margin: 0; }
      .entry .card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 12px; align-items: center; }
      .entry .tally { font-family: "Space Mono", monospace; font-weight: 700; font-size: .9rem; color: var(--gold); }
      .entry.is-winner { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), var(--shadow); }
      .entry.is-drawing { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky), var(--shadow); }
      .badge-mine { background: var(--pine-soft); color: var(--pine); font-weight: 800; font-size: .75rem; border-radius: 999px; padding: 3px 9px; }
      .badge-demo { background: var(--chip); color: var(--muted); font-weight: 800; font-size: .75rem; border-radius: 999px; padding: 3px 9px; }
      .empty-note {
        border: 1.5px dashed var(--line-strong); border-radius: 16px; padding: 22px;
        text-align: center; color: var(--muted); background: var(--surface-2); font-weight: 600;
      }

      /* ---------- Presenter ---------- */
      .presenter {
        position: fixed; inset: 0; z-index: 50; background: #0b1720; color: #eef6fa;
        display: none; flex-direction: column; padding: 18px; overflow-y: auto;
      }
      .presenter.open { display: flex; }
      .presenter-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; flex: none; }
      .presenter-top .p-title { font-family: "Space Mono", monospace; font-size: .85rem; letter-spacing: .1em; color: #8fb6c9; }
      .presenter-main { flex: 1 0 auto; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: center; min-height: 0; padding: 14px 0; }
      .presenter-stage { line-height: 0; display: flex; justify-content: center; align-items: center; min-height: 0; width: 100%; }
      /* Size the slide from the height budget at the picture's true 4:5
         ratio, so the WHOLE snowman always fits — width:auto/max-height
         alone made phone browsers squash it into a cropped wide strip. */
      .presenter-stage svg {
        display: block; height: auto; aspect-ratio: 4 / 5; border-radius: 18px; margin: 0 auto;
        width: min(100%, calc((100vh - 200px) * 0.8));
        width: min(100%, calc((100dvh - 200px) * 0.8));
      }
      @media (max-width: 760px) {
        .presenter { padding: 14px; }
        .presenter-main { display: flex; flex-direction: column; align-items: stretch; gap: 16px; overflow: visible; }
        .presenter-stage { flex: none; }
        .presenter-stage svg { width: min(100%, calc(46vh * 0.8)); width: min(100%, calc(46dvh * 0.8)); }
        .presenter-info { flex: none; }
        .presenter-nav { flex: none; padding-bottom: 8px; }
      }
      .presenter-info h2 { font-family: "Baloo 2", sans-serif; font-size: clamp(2rem, 6vw, 3.4rem); margin: 0 0 6px; line-height: 1.02; }
      .presenter-info .p-team { color: #7cc3ea; font-weight: 800; font-size: 1.15rem; margin-bottom: 18px; }
      .presenter-info dl { display: grid; gap: 14px; margin: 0; }
      .presenter-info dt { font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #8fb6c9; }
      .presenter-info dd { margin: 2px 0 0; font-size: clamp(1.05rem, 2.6vw, 1.5rem); font-weight: 700; }
      .presenter-nav { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; position: sticky; bottom: 0; background: #0b1720; padding: 10px 0 4px; flex: none; }
      .presenter .btn { background: #1b3444; border-color: #33566c; color: #eef6fa; box-shadow: none; }
      .presenter .btn[aria-pressed="true"] { background: var(--pine); border-color: var(--pine); }
      .presenter .counter { font-family: "Space Mono", monospace; color: #8fb6c9; padding: 0 8px; }

      .toast {
        position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(80px);
        background: var(--ink); color: var(--bg); font-weight: 800; border-radius: 12px;
        padding: 12px 20px; z-index: 60; transition: transform .25s ease; max-width: 92vw; text-align: center;
        box-shadow: var(--shadow);
      }
      .toast.show { transform: translateX(-50%) translateY(0); }
      @media (prefers-reduced-motion: reduce) {
        html { scroll-behavior: auto; }
        .toast { transition: none; }
      }

/* ================= Phase 2: live game chrome ================= */
.brandbar { display:flex; align-items:center; gap:12px; margin-bottom:18px; flex-wrap:wrap; }
.brand-logo { height:44px; width:auto; }
.brand-logo + .brand-fallback { display:none; }
.brand-fallback { font-family:"Baloo 2","Nunito",sans-serif; font-weight:800; font-size:1.5rem; color:var(--pine); }
.brand-game { color:var(--muted); font-weight:800; border-left:2px solid var(--line); padding-left:12px; }
.banner { background:var(--gold-soft); border:1.5px solid var(--gold); border-radius:12px; padding:12px 14px; margin-bottom:16px; }
.status { min-height:1.4em; font-weight:700; color:var(--muted); }
.foot { margin-top:34px; color:var(--muted); font-size:.88rem; }
.home-grid { align-items:start; }
.home-stack { display:grid; gap:18px; }
.panel h2 { margin-top:0; }
.field.check label { display:flex; gap:8px; align-items:center; font-weight:700; }
.field.check input { width:auto; }
.qrbox { background:#fff; display:inline-block; padding:10px; border-radius:14px; border:1.5px solid var(--line); margin:6px 0 10px; }
.chips { display:flex; flex-wrap:wrap; gap:8px; margin:10px 0; }
.chip { background:var(--chip); border:1.5px solid var(--line); border-radius:999px; padding:5px 12px; font-weight:700; font-size:.9rem; }
.chip .drv { color:var(--accent); font-weight:800; }
.team-block { border:1.5px solid var(--line); border-radius:12px; padding:10px 12px; margin:10px 0; background:var(--surface-2); }
.team-block h3 { margin:0 0 4px; font-size:1rem; }
.team-block .card-line { color:var(--gold); font-weight:800; }
.queue-item { display:flex; gap:12px; align-items:center; border:1.5px solid var(--line); border-radius:12px; padding:8px 10px; margin:8px 0; background:var(--surface); }
.queue-item .qthumb { width:64px; flex:0 0 64px; }
.queue-item .qthumb svg { width:100%; height:auto; display:block; border-radius:8px; }
.queue-item .qmeta { flex:1; min-width:0; }
.queue-item .qmeta strong { display:block; }
.pill { font-size:.78rem; font-weight:800; border-radius:999px; padding:3px 9px; border:1.5px solid var(--line-strong); color:var(--muted); }
.pill.ok { border-color:var(--pine); color:var(--pine); background:var(--pine-soft); }
.now-stage { max-width:340px; margin:0 auto; }
.now-stage svg, .presenter-stage svg, .thumb svg { width:100%; height:auto; display:block; }
.entry.is-winner { border-color:var(--gold); box-shadow:0 0 0 3px var(--gold-soft), var(--shadow); }
.entry.is-drawing { outline:3px solid var(--accent); outline-offset:2px; }
.vote-ctl { display:inline-flex; align-items:center; gap:8px; }
.vote-ctl .vcount { font-weight:800; }
.tally { font-weight:800; color:var(--gold); }
.badge-team { background:var(--pine-soft); color:var(--pine); border-radius:999px; padding:3px 9px; font-size:.78rem; font-weight:800; }
#h-winner.show, #p-winner.show { display:block; }
.winner-banner { display:none; }
.winner-banner.show { display:block; }
.p-title { font-weight:800; letter-spacing:.06em; }
.counter { font-weight:800; }
@media (max-width: 900px) { .brand-logo { height:36px; } }
