:root{
      --bg:#08101c;
      --panel:#111827;
      --panel-2:#0c1524;
      --line:#2d3b54;
      --line-soft:rgba(148,163,184,.14);
      --text:#f8fafc;
      --muted:#9fb0c8;
      --muted-2:#6b7c94;
      --shadow:0 18px 48px rgba(0,0,0,.38);
      --shadow-sm:0 4px 16px rgba(0,0,0,.22);
      --gold:#fbbf24;
      --danger:#fb7185;
      --ok:#34d399;
      --accent:#60a5fa;
      --accent-soft:rgba(96,165,250,.14);
      --radius-sm:10px;
      --radius:14px;
      --radius-lg:18px;
      --space-1:4px;
      --space-2:8px;
      --space-3:12px;
      --space-4:16px;
      --space-5:20px;
      --focus:0 0 0 3px rgba(96,165,250,.35);
    }

    *{box-sizing:border-box}
    html,body{
      margin:0;
      width:100%;
      height:100%;
      overflow:hidden;
      background:var(--bg);
      color:var(--text);
      font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
    }
    body{
      background:
        radial-gradient(circle at 18% 0%,rgba(96,165,250,.14),transparent 28rem),
        radial-gradient(circle at 88% 8%,rgba(251,191,36,.09),transparent 24rem),
        linear-gradient(180deg,#080d18,#0c1422);
    }

    button,input,select{font:inherit}
    button{cursor:pointer}

    .app{
      width:min(1100px,100%);
      height:100dvh;
      margin:0 auto;
      padding:max(8px,env(safe-area-inset-top)) 10px max(8px,env(safe-area-inset-bottom));
      overflow:hidden;
    }

    .screen{
      display:none;
      height:100%;
      min-height:0;
    }
    .screen.active{display:flex;flex-direction:column}

    .glass{
      background:rgba(17,24,39,.94);
      border:1px solid var(--line);
      border-radius:18px;
      box-shadow:var(--shadow);
      backdrop-filter:blur(12px);
    }

    .topbar{
      flex:0 0 auto;
      min-height:0;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:8px;
      margin-bottom:6px;
    }

    .brand{display:flex;align-items:center;gap:10px;min-width:0}
    .logo{
      width:46px;height:46px;border-radius:14px;
      display:grid;place-items:center;
      background:
        radial-gradient(circle at 30% 22%,rgba(255,255,255,.4),transparent 42%),
        linear-gradient(145deg,#fbbf24 0%,#f59e0b 42%,#fb7185 100%);
      color:#251307;
      flex:0 0 auto;
      box-shadow:
        0 0 0 1px rgba(255,255,255,.12) inset,
        0 6px 14px rgba(0,0,0,.28);
      overflow:hidden;
    }
    .logo-mark{
      width:36px;
      height:36px;
      display:block;
      filter:drop-shadow(0 1px 0 rgba(255,255,255,.18));
    }
    .brand-text{
      min-width:0;
      display:flex;
      flex-direction:column;
      justify-content:center;
    }
    /* TEAM / THE GAME: same block width, letters spaced to edges */
    .wordmark{
      display:flex;
      flex-direction:column;
      gap:4px;
      width:clamp(4.85rem,15.5vw,6.1rem);
      line-height:1;
    }
    .wordmark-team,
    .wordmark-game{
      display:flex;
      justify-content:space-between;
      align-items:baseline;
      width:100%;
      margin:0;
      text-transform:uppercase;
      font-style:normal;
    }
    .wordmark-team i,
    .wordmark-game i{
      font-style:normal;
      font-weight:inherit;
      line-height:1;
    }
    .wordmark-team{
      color:#fbbf24;
      font-size:clamp(1.12rem,3.5vw,1.42rem);
      font-weight:1000;
      text-shadow:0 1px 0 rgba(0,0,0,.35);
    }
    .wordmark-game{
      color:#f8fafc;
      font-size:clamp(.58rem,1.85vw,.74rem);
      font-weight:900;
      letter-spacing:0;
    }
    .wordmark-game .wm-gap{
      display:block;
      width:.28em;
      flex:0 0 auto;
    }

    h1,h2,p{margin:0}
    h1{font-size:clamp(1.05rem,3.3vw,1.55rem);line-height:1.05}
    h2{font-size:clamp(1rem,3vw,1.3rem)}
    .subtitle{color:var(--muted);font-size:clamp(.62rem,2.1vw,.78rem);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}

    .btn{
      border:1px solid #354762;
      border-radius:12px;
      min-height:38px;
      padding:7px 11px;
      font-weight:900;
      color:var(--text);
      background:#1c2a41;
    }
    .btn.primary{
      border:0;
      color:#251407;
      background:linear-gradient(135deg,#fbbf24,#fb7185);
    }
    .btn.danger{
      background:rgba(251,113,133,.14);
      border-color:rgba(251,113,133,.36);
      color:#ffd5de;
    }

    /* SETUP */
    .setup-panel{
      flex:1 1 auto;
      min-height:0;
      padding:10px;
      display:grid;
      grid-template-rows:auto auto auto minmax(0,1fr) auto;
      gap:7px;
      overflow:hidden;
    }

    .setup-head{
      display:grid;
      grid-template-columns:1fr minmax(105px,160px);
      align-items:end;
      gap:10px;
    }

    label{
      display:block;
      margin-bottom:4px;
      color:var(--muted);
      font-size:.72rem;
      font-weight:850;
    }

    input,select{
      width:100%;
      min-height:38px;
      padding:0 10px;
      border-radius:10px;
      border:1px solid #354762;
      background:#0a1322;
      color:var(--text);
      outline:none;
    }
    input[type="color"]{padding:3px}

    .player-tabs{
      display:grid;
      grid-template-columns:repeat(var(--tab-count),minmax(0,1fr));
      gap:5px;
      min-height:38px;
    }

    .player-tab{
      min-width:0;
      min-height:38px;
      padding:0 4px;
      border-radius:11px;
      border:1px solid #334762;
      background:#101a2b;
      color:var(--muted);
      font-size:.72rem;
      font-weight:1000;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }

    .player-tab.active{
      color:#fff;
      border-color:var(--tab-color,#60a5fa);
      background:color-mix(in srgb,var(--tab-color,#60a5fa) 15%,#101a2b);
      box-shadow:0 0 0 2px color-mix(in srgb,var(--tab-color,#60a5fa) 25%,transparent);
    }

    .players-setup{
      min-height:0;
      overflow:hidden;
      display:block;
    }

    .setup-player{
      display:none;
      grid-template-columns:34px 118px minmax(0,1fr);
      gap:10px;
      align-items:stretch;
      padding:10px;
      border-radius:15px;
      background:#0c1524;
      border:1px solid #2b3b53;
      min-height:0;
      height:100%;
      overflow:hidden;
    }

    .setup-player.active{
      display:grid;
    }

    .index{
      width:38px;height:38px;border-radius:11px;
      display:grid;place-items:center;
      background:#18263b;
      color:var(--gold);
      font-weight:950;
      font-size:.9rem;
      align-self:center;
    }

    .setup-fields{
      min-width:0;
      display:grid;
      grid-template-columns:minmax(118px,1fr) 82px 82px;
      gap:7px 8px;
      align-content:center;
    }


    .player-preview{
      position:relative;
      cursor:pointer;
      -webkit-tap-highlight-color:transparent;
    }

    .player-preview::after{
      content:"🎨";
      position:absolute;
      right:5px;
      top:5px;
      width:26px;
      height:26px;
      display:grid;
      place-items:center;
      border-radius:50%;
      background:rgba(8,16,28,.88);
      border:1px solid rgba(255,255,255,.2);
      font-size:.82rem;
      box-shadow:0 3px 8px rgba(0,0,0,.28);
    }

    .color-input{
      display:none;
    }

    .color-modal{
      position:fixed;
      inset:0;
      z-index:120;
      display:none;
      place-items:center;
      padding:18px;
      background:rgba(3,7,14,.76);
      backdrop-filter:blur(5px);
    }

    .color-modal.show{
      display:grid;
    }

    .color-dialog{
      width:min(420px,100%);
      border-radius:20px;
      padding:16px;
      background:#111827;
      border:1px solid #40516e;
      box-shadow:0 22px 50px rgba(0,0,0,.5);
    }

    .color-dialog-head{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      margin-bottom:14px;
    }

    .color-dialog-title{
      min-width:0;
      font-size:1.05rem;
      font-weight:1000;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }

    .color-close{
      width:36px;
      height:36px;
      flex:0 0 auto;
      padding:0;
      border-radius:50%;
      border:1px solid #43536d;
      background:#1b2639;
      color:#fff;
      font-weight:1000;
    }

    .color-modal-preview{
      display:flex;
      align-items:center;
      justify-content:center;
      min-height:104px;
      margin-bottom:14px;
      border-radius:15px;
      background:
        radial-gradient(circle at 50% 30%,rgba(255,255,255,.05),transparent 58%),
        #0b1422;
      overflow:hidden;
    }

    .color-modal-person{
      position:relative;
      width:58px;
      height:88px;
      transform:scale(var(--preview-scale,1));
      transform-origin:center bottom;
    }

    .color-modal-person .head{
      position:absolute;
      left:31%;
      top:3%;
      width:39%;
      aspect-ratio:1;
      border-radius:50%;
      background:var(--skin,#f1c7a5);
      border:1px solid rgba(0,0,0,.25);
      z-index:3;
    }

    .color-modal-person .hair{
      position:absolute;
      left:28%;
      top:1%;
      width:45%;
      height:16%;
      border-radius:15px 15px 6px 6px;
      background:var(--hair,#3a251b);
      z-index:4;
    }

    .color-modal-person .shirt{
      position:absolute;
      left:22%;
      top:31%;
      width:56%;
      height:43%;
      border-radius:11px 11px 7px 7px;
      background:var(--shirt,#ef4444);
      border:1px solid rgba(0,0,0,.28);
      z-index:2;
      transform:scaleX(var(--body-width,1));
      transform-origin:center;
    }

    .color-modal-person .arm{
      position:absolute;
      top:36%;
      width:18%;
      height:37%;
      background:var(--skin,#f1c7a5);
      border-radius:8px;
      z-index:1;
      border:1px solid rgba(0,0,0,.18);
    }

    .color-modal-person .arm.left{
      left:8%;
      transform:rotate(11deg);
    }

    .color-modal-person .arm.right{
      right:8%;
      transform:rotate(-11deg);
    }

    .color-modal-person .shorts{
      position:absolute;
      left:25%;
      top:66%;
      width:50%;
      height:12%;
      background:#334155;
      border:1px solid rgba(0,0,0,.2);
      border-radius:2px 2px 7px 7px;
      z-index:2;
      transform:scaleX(var(--body-width,1));
      transform-origin:center;
    }

    .color-modal-person .leg{
      position:absolute;
      top:75%;
      width:20%;
      height:22%;
      background:#475569;
      border-radius:0 0 7px 7px;
      border:1px solid rgba(0,0,0,.2);
    }

    .color-modal-person .leg.left{left:24%}
    .color-modal-person .leg.right{right:24%}

    .color-modal-person .shoe{
      position:absolute;
      top:94%;
      width:24%;
      height:7%;
      background:#111827;
      border-radius:999px;
    }

    .color-modal-person .shoe.left{left:18%}
    .color-modal-person .shoe.right{right:18%}

    .color-grid{
      display:grid;
      grid-template-columns:repeat(4,minmax(0,1fr));
      gap:10px;
    }

    .color-choice{
      width:100%;
      aspect-ratio:1;
      max-width:68px;
      justify-self:center;
      padding:0;
      border-radius:50%;
      border:3px solid rgba(255,255,255,.22);
      background:var(--choice);
      box-shadow:inset 0 0 0 3px rgba(0,0,0,.12);
      transition:transform .08s ease,border-color .12s ease,box-shadow .12s ease;
    }

    .color-choice:active{
      transform:scale(.92);
    }

    .color-choice.selected{
      border-color:#fff;
      box-shadow:
        0 0 0 4px rgba(96,165,250,.55),
        inset 0 0 0 3px rgba(0,0,0,.12);
      transform:scale(1.06);
    }
    .setup-fields .name-field{grid-column:1 / 3}
    .setup-player input{
      min-height:36px;
      font-size:.92rem;
    }

    .height-field input,
    .weight-field input{
      min-width:0;
      text-align:center;
    }

    .player-preview{
      --shirt:#ef4444;
      --preview-scale:1;
      min-width:0;
      display:flex;
      flex-direction:column;
      align-items:center;
      justify-content:flex-end;
      padding:5px 3px 6px;
      border-radius:13px;
      background:
        radial-gradient(circle at 50% 25%,color-mix(in srgb,var(--shirt) 22%,transparent),transparent 56%),
        #101b2d;
      border:1px solid color-mix(in srgb,var(--shirt) 58%,#334155);
      overflow:hidden;
    }

    .preview-stage{
      width:100%;
      height:min(18vh,132px);
      display:flex;
      align-items:flex-end;
      justify-content:center;
      overflow:hidden;
    }

    .preview-person{
      position:relative;
      width:62px;
      height:94px;
      transform:scale(var(--preview-scale));
      transform-origin:center bottom;
    }

    .preview-person .head,
    .child-person .head{
      position:absolute;
      left:31%;
      top:3%;
      width:39%;
      aspect-ratio:1;
      border-radius:50%;
      background:var(--skin);
      border:1px solid rgba(0,0,0,.25);
      z-index:3;
      transform:scaleX(calc(.84 + (var(--body-width,1) - .58) * .32 / .58));
      transform-origin:center center;
    }

    .preview-person .hair,
    .child-person .hair{
      position:absolute;
      left:28%;
      top:1%;
      width:45%;
      height:16%;
      border-radius:15px 15px 6px 6px;
      background:var(--hair);
      z-index:4;
    }

    .preview-person .shirt,
    .child-person .shirt{
      position:absolute;
      left:22%;
      top:31%;
      width:56%;
      height:43%;
      border-radius:11px 11px 7px 7px;
      background:var(--shirt);
      border:1px solid rgba(0,0,0,.28);
      z-index:2;
      transform:scaleX(var(--body-width,1));
      transform-origin:center center;
    }

    .preview-person .arm,
    .child-person .arm{
      position:absolute;
      top:36%;
      width:18%;
      height:37%;
      background:var(--skin);
      border-radius:8px;
      z-index:1;
      border:1px solid rgba(0,0,0,.18);
    }
    .preview-person .arm.left,.child-person .arm.left{left:calc(8% - (var(--body-width,1) - 1) * 6%);transform:rotate(11deg)}
    .preview-person .arm.right,.child-person .arm.right{right:calc(8% - (var(--body-width,1) - 1) * 6%);transform:rotate(-11deg)}

    .preview-person .leg,
    .child-person .leg{
      position:absolute;
      top:70%;
      width:23%;
      height:27%;
      background:#334155;
      border-radius:0 0 6px 6px;
      border:1px solid rgba(0,0,0,.2);
    }
    .preview-person .leg.left,.child-person .leg.left{left:calc(24% - (var(--body-width,1) - 1) * 4%)}
    .preview-person .leg.right,.child-person .leg.right{right:calc(24% - (var(--body-width,1) - 1) * 4%)}

    .preview-name{
      width:100%;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
      text-align:center;
      font-size:.72rem;
      line-height:1.05;
      font-weight:1000;
    }
    .preview-height{
      margin-top:2px;
      color:var(--muted);
      font-size:.62rem;
      font-weight:850;
    }

    /* GAME */
    .game-panel{
      flex:1 1 auto;
      min-height:0;
      padding:4px 2px 0;
      display:flex;
      flex-direction:column;
      overflow:hidden;
      background:transparent;
      border:0;
      box-shadow:none;
    }

    .stage{
      flex:1 1 auto;
      min-height:0;
      height:auto;
      position:relative;
      overflow:hidden;
      border-radius:18px;
      background:
        radial-gradient(circle at 50% 15%,rgba(255,255,255,.04),transparent 45%),
        linear-gradient(180deg,rgba(255,255,255,.015),rgba(255,255,255,.005));
    }

    .stage-overlay{
      position:absolute;
      inset:0;
      pointer-events:none;
      overflow:hidden;
      z-index:25;
    }

    /* Interactive board info — under note row (never on stage with Úkoly) */
    .board-info{
      flex:0 0 auto;
      display:flex;
      align-items:center;
      gap:10px;
      width:100%;
      margin:0;
      padding:9px 12px max(10px,env(safe-area-inset-bottom));
      border:0;
      border-top:1px solid var(--line-soft);
      background:linear-gradient(180deg,rgba(15,23,42,.55),rgba(8,13,24,.88));
      color:var(--text);
      text-align:left;
      cursor:default;
      -webkit-tap-highlight-color:transparent;
      transition:background .15s ease, box-shadow .15s ease;
    }
    .board-info.is-interactive{
      cursor:pointer;
    }
    .board-info.is-interactive:active{
      background:linear-gradient(180deg,rgba(30,41,59,.7),rgba(8,13,24,.92));
    }
    .board-info.has-player{
      box-shadow:inset 0 2px 0 rgba(251,191,36,.22);
    }
    .board-info.has-target .board-info-dot{
      background:#60a5fa;
      box-shadow:0 0 0 3px rgba(96,165,250,.2);
    }
    .board-info.has-player .board-info-dot{
      background:#fbbf24;
      box-shadow:0 0 0 3px rgba(251,191,36,.22);
    }
    .board-info-dot{
      flex:0 0 auto;
      width:10px;
      height:10px;
      border-radius:50%;
      background:var(--muted-2);
    }
    .board-info-copy{
      flex:1 1 auto;
      min-width:0;
      display:flex;
      flex-direction:column;
      gap:2px;
    }
    .board-info-lead{
      font-size:clamp(.82rem,2.4vw,.95rem);
      font-weight:900;
      line-height:1.15;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .board-info-detail{
      font-size:clamp(.68rem,1.9vw,.78rem);
      font-weight:700;
      color:var(--muted);
      line-height:1.2;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .board-info-action{
      flex:0 0 auto;
      padding:5px 10px;
      border-radius:999px;
      border:1px solid rgba(251,191,36,.4);
      background:rgba(251,191,36,.12);
      color:#fde68a;
      font-size:.72rem;
      font-weight:900;
      letter-spacing:.04em;
      text-transform:uppercase;
    }

    /* In-game tasks hub — primary board control */
    .quest-hub{
      position:absolute;
      left:10px;
      top:10px;
      z-index:32;
      display:flex;
      align-items:center;
      gap:11px;
      min-width:min(72%,220px);
      max-width:min(88%,300px);
      padding:11px 14px 11px 12px;
      border-radius:16px;
      border:1px solid rgba(148,163,184,.32);
      background:linear-gradient(155deg,rgba(30,41,59,.95),rgba(15,23,42,.92));
      box-shadow:0 8px 22px rgba(0,0,0,.4);
      color:var(--text);
      cursor:pointer;
      text-align:left;
      transition:transform .15s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
      -webkit-tap-highlight-color:transparent;
    }
    .quest-hub:active{transform:scale(.97)}
    .quest-hub-scroll{
      position:relative;
      flex:0 0 auto;
      width:36px;
      height:44px;
    }
    .quest-hub-scroll-roll{
      position:absolute;
      left:2px;right:2px;top:0;
      height:10px;
      border-radius:5px;
      background:linear-gradient(90deg,#b45309,#d97706,#b45309);
      box-shadow:0 1px 0 rgba(0,0,0,.3);
    }
    .quest-hub-scroll-body{
      position:absolute;
      left:5px;right:5px;top:8px;bottom:2px;
      border-radius:3px;
      background:linear-gradient(180deg,#fef3c7,#fde68a);
      border:1px solid rgba(180,83,9,.35);
    }
    .quest-hub-copy{
      min-width:0;
      flex:1 1 auto;
      display:flex;
      flex-direction:column;
      gap:3px;
    }
    .quest-hub-title{
      font-size:clamp(.95rem,3.2vw,1.12rem);
      font-weight:1000;
      letter-spacing:.03em;
      line-height:1.05;
    }
    .quest-hub-sub{
      font-size:clamp(.72rem,2.2vw,.84rem);
      font-weight:750;
      color:var(--muted);
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
      max-width:14rem;
    }
    .quest-hub-badge{
      flex:0 0 auto;
      min-width:1.55rem;
      height:1.55rem;
      padding:0 6px;
      border-radius:999px;
      display:inline-grid;
      place-items:center;
      font-size:.78rem;
      font-weight:1000;
      background:#fbbf24;
      color:#1c1004;
    }
    /* Visual states */
    .quest-hub-empty{
      opacity:.78;
      border-color:rgba(148,163,184,.2);
      background:linear-gradient(155deg,rgba(30,41,59,.75),rgba(15,23,42,.7));
    }
    .quest-hub-empty .quest-hub-scroll-body{
      background:linear-gradient(180deg,#e2e8f0,#cbd5e1);
      border-color:rgba(100,116,139,.4);
    }
    .quest-hub-empty .quest-hub-scroll-roll{
      background:linear-gradient(90deg,#64748b,#94a3b8,#64748b);
    }
    .quest-hub-open{
      border-color:rgba(96,165,250,.45);
      box-shadow:0 6px 18px rgba(37,99,235,.2);
    }
    .quest-hub-active{
      border-color:rgba(56,189,248,.55);
      background:linear-gradient(155deg,rgba(14,116,144,.35),rgba(15,23,42,.9));
      box-shadow:0 0 0 1px rgba(56,189,248,.15),0 8px 22px rgba(14,165,233,.25);
    }
    .quest-hub-active .quest-hub-sub{color:#7dd3fc}
    .quest-hub-review{
      border-color:rgba(251,191,36,.65);
      background:linear-gradient(155deg,rgba(180,83,9,.35),rgba(15,23,42,.92));
      box-shadow:0 0 0 1px rgba(251,191,36,.2),0 8px 22px rgba(245,158,11,.28);
      animation:quest-hub-pulse 1.8s ease-in-out infinite;
    }
    .quest-hub-review .quest-hub-sub{color:#fcd34d}
    .quest-hub-review .quest-hub-badge{
      background:#f59e0b;
    }
    @keyframes quest-hub-pulse{
      0%,100%{box-shadow:0 0 0 1px rgba(251,191,36,.2),0 8px 22px rgba(245,158,11,.25)}
      50%{box-shadow:0 0 0 3px rgba(251,191,36,.28),0 10px 28px rgba(245,158,11,.4)}
    }

    /* Preview chips under hub (still on stage, clickable → panel) */
    .quest-bubble{
      position:absolute;
      left:10px;
      top:78px;
      z-index:32;
      display:none;
      flex-direction:column;
      gap:6px;
      width:min(70%,280px);
      max-height:min(30vh,180px);
      overflow:auto;
      pointer-events:auto;
      -webkit-overflow-scrolling:touch;
    }
    .quest-bubble.has-items{display:flex}
    .quest-bubble-item{
      padding:7px 10px;
      border-radius:12px;
      background:linear-gradient(145deg,rgba(37,99,235,.3),rgba(10,20,36,.94));
      border:1px solid rgba(96,165,250,.4);
      box-shadow:0 4px 14px rgba(0,0,0,.3);
      text-align:left;
      cursor:pointer;
      color:inherit;
      font:inherit;
      width:100%;
    }
    .quest-bubble-item.quest-pending{
      background:linear-gradient(145deg,rgba(245,158,11,.25),rgba(10,20,36,.94));
      border-color:rgba(251,191,36,.5);
    }
    .quest-bubble-kicker{
      display:block;
      font-size:.58rem;
      font-weight:800;
      letter-spacing:.04em;
      text-transform:uppercase;
      color:#93c5fd;
      margin-bottom:1px;
    }
    .quest-pending .quest-bubble-kicker{color:#fbbf24}
    .quest-bubble-text{
      display:block;
      font-size:clamp(.7rem,2vw,.85rem);
      font-weight:850;
      color:#f8fafc;
      line-height:1.2;
    }
    .quest-bubble-meta{
      display:block;
      margin-top:2px;
      font-size:.62rem;
      font-weight:700;
      color:var(--muted);
    }
    .task-progress{
      margin-top:4px;
      font-size:.72rem;
    }


    /* ===== Balance scale (physics-inspired) =====
       Beam rotates about fulcrum; hangers + pans counter-rotate so pans stay level
       and chains hang plumb (world-vertical). */
    .balance{
      position:absolute;
      inset:0;
      display:grid;
      place-items:center;
      padding-bottom:132px;
      /* soft floor contact shadow */
      background:
        radial-gradient(ellipse 55% 18% at 50% 86%,rgba(0,0,0,.45),transparent 70%);
    }

    .beam-wrap{
      --fulcrum-y: min(30vh, 218px);
      --beam-w: min(88vw, 720px);
      --hang: min(11vh, 78px);
      --metal-hi: #c5d0dc;
      --metal-mid: #7b8796;
      --metal-lo: #3d4654;
      --metal-edge: #1a222d;
      position:relative;
      width:min(94%,780px);
      height:min(100%,420px);
      display:grid;
      place-items:center;
      transform:translateY(-28px) scale(.68);
      transform-origin:center center;
    }

    /* Heavy cast base — tripod feel */
    .scale-base{
      position:absolute;
      left:50%;
      bottom:0;
      width:min(48vw,260px);
      height:min(14vh,78px);
      transform:translateX(-50%);
      z-index:2;
    }
    .scale-base::before{
      content:"";
      position:absolute;
      left:8%;
      right:8%;
      bottom:0;
      height:42%;
      border-radius:40% 40% 18% 18% / 70% 70% 30% 30%;
      background:
        radial-gradient(ellipse 80% 60% at 50% 30%,rgba(255,255,255,.12),transparent 55%),
        linear-gradient(180deg,#5a6574 0%,#2a3340 55%,#151b24 100%);
      box-shadow:
        0 14px 28px rgba(0,0,0,.5),
        inset 0 1px 0 rgba(255,255,255,.14),
        inset 0 -8px 14px rgba(0,0,0,.45);
    }
    .scale-base::after{
      /* three feet suggestion */
      content:"";
      position:absolute;
      left:50%;
      bottom:0;
      width:100%;
      height:28%;
      transform:translateX(-50%);
      background:
        radial-gradient(ellipse 18% 90% at 12% 50%,#2a3340 0 55%,transparent 56%),
        radial-gradient(ellipse 18% 90% at 50% 80%,#2a3340 0 55%,transparent 56%),
        radial-gradient(ellipse 18% 90% at 88% 50%,#2a3340 0 55%,transparent 56%);
      opacity:.95;
      filter:drop-shadow(0 4px 6px rgba(0,0,0,.4));
    }

    /* Column with mild taper + capital */
    .scale-pillar{
      position:absolute;
      left:50%;
      bottom:42px;
      width:22px;
      height:min(28vh,168px);
      transform:translateX(-50%);
      z-index:3;
      border-radius:8px 8px 4px 4px;
      background:
        linear-gradient(90deg,
          rgba(0,0,0,.35) 0%,
          rgba(255,255,255,.14) 28%,
          rgba(255,255,255,.04) 48%,
          rgba(0,0,0,.25) 100%),
        linear-gradient(180deg,#8b97a6 0%,#4b5565 45%,#2c3542 100%);
      box-shadow:
        inset 0 0 0 1px rgba(255,255,255,.08),
        0 8px 16px rgba(0,0,0,.35);
    }
    .scale-pillar::before{
      /* capital / yoke top */
      content:"";
      position:absolute;
      left:50%;
      top:-10px;
      width:38px;
      height:18px;
      transform:translateX(-50%);
      border-radius:6px 6px 3px 3px;
      background:
        linear-gradient(180deg,#a8b4c2,#5a6574 60%,#3a4452);
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,.25),
        0 3px 6px rgba(0,0,0,.35);
    }
    .scale-pillar::after{
      /* column foot flare */
      content:"";
      position:absolute;
      left:50%;
      bottom:-6px;
      width:34px;
      height:14px;
      transform:translateX(-50%);
      border-radius:4px;
      background:linear-gradient(180deg,#6b7686,#2a3340);
      box-shadow:inset 0 1px 0 rgba(255,255,255,.1);
    }

    /* Knife-edge fulcrum triangle under beam */
    .fulcrum{
      position:absolute;
      left:50%;
      bottom:calc(var(--fulcrum-y) - 6px);
      width:0;
      height:0;
      transform:translateX(-50%);
      z-index:19;
      border-left:11px solid transparent;
      border-right:11px solid transparent;
      border-bottom:16px solid #9aa6b4;
      filter:drop-shadow(0 2px 3px rgba(0,0,0,.4));
      pointer-events:none;
    }
    .fulcrum::after{
      content:"";
      position:absolute;
      left:50%;
      top:10px;
      width:22px;
      height:6px;
      transform:translateX(-50%);
      border-radius:2px;
      background:linear-gradient(180deg,#b8c2ce,#5a6574);
    }

    /* Pivot pin through beam */
    .pivot{
      position:absolute;
      left:50%;
      bottom:calc(var(--fulcrum-y) - 12px);
      width:28px;
      height:28px;
      transform:translateX(-50%);
      border-radius:50%;
      z-index:22;
      background:
        radial-gradient(circle at 32% 28%,#e8eef5 0 18%,transparent 19%),
        radial-gradient(circle at 50% 50%,#9aa6b4 0 42%,#4a5564 55%,#1e2630 100%);
      border:2px solid #0f141b;
      box-shadow:
        0 4px 10px rgba(0,0,0,.45),
        inset 0 1px 0 rgba(255,255,255,.35);
    }
    .pivot::after{
      content:"";
      position:absolute;
      inset:32%;
      border-radius:50%;
      background:radial-gradient(circle at 40% 35%,#d0d8e2,#2a3340);
      box-shadow:inset 0 1px 2px rgba(0,0,0,.5);
    }

    /* Beam: rigid bar with end caps; rotates about center */
    .beam{
      --tilt:0deg;
      position:absolute;
      left:50%;
      bottom:var(--fulcrum-y);
      width:var(--beam-w);
      height:14px;
      transform:translateX(-50%) rotate(var(--tilt));
      transform-origin:center center;
      z-index:8;
      /* slight bounce like real scale settling */
      transition:transform .75s cubic-bezier(.22,1.25,.36,1);
      background:transparent;
      border-radius:0;
      box-shadow:none;
    }
    .beam-bar{
      position:absolute;
      inset:0;
      border-radius:3px;
      background:
        linear-gradient(180deg,
          rgba(255,255,255,.28) 0%,
          rgba(255,255,255,.06) 22%,
          rgba(0,0,0,.12) 55%,
          rgba(0,0,0,.35) 100%),
        linear-gradient(90deg,#6b7686 0%,#c5d0dc 18%,#8b97a6 50%,#c5d0dc 82%,#5a6574 100%);
      box-shadow:
        0 6px 12px rgba(0,0,0,.4),
        inset 0 1px 0 rgba(255,255,255,.35),
        inset 0 -1px 0 rgba(0,0,0,.35);
    }
    .beam-bar::before,
    .beam-bar::after{
      /* end knobs / eyes for chains */
      content:"";
      position:absolute;
      top:50%;
      width:16px;
      height:16px;
      margin-top:-8px;
      border-radius:50%;
      background:
        radial-gradient(circle at 35% 30%,#e2e8f0,#6b7686 55%,#2a3340);
      border:1px solid #1a222d;
      box-shadow:0 2px 4px rgba(0,0,0,.4);
    }
    .beam-bar::before{left:11.5%}
    .beam-bar::after{right:11.5%}
    .beam-ridge{
      position:absolute;
      left:18%;
      right:18%;
      top:3px;
      height:2px;
      border-radius:1px;
      background:linear-gradient(90deg,transparent,#e8eef5 20%,#e8eef5 80%,transparent);
      opacity:.45;
      pointer-events:none;
    }

    /* Chains hang from beam; counter-rotate so they stay world-vertical */
    .hanger{
      position:absolute;
      top:12px;
      width:14px;
      height:var(--hang);
      margin-left:-7px;
      transform-origin:top center;
      transform:rotate(calc(var(--tilt) * -1));
      transition:transform .75s cubic-bezier(.22,1.25,.36,1);
      z-index:9;
      pointer-events:none;
    }
    .hanger.left{left:14%}
    .hanger.right{left:86%}
    .hanger .chain{
      position:absolute;
      left:50%;
      top:0;
      bottom:8px;
      width:5px;
      margin-left:-2.5px;
      background:
        repeating-linear-gradient(
          180deg,
          #d6dee8 0 5px,
          #8b97a6 5px 7px,
          #5a6574 7px 9px,
          #c5d0dc 9px 11px
        );
      border-radius:3px;
      box-shadow:
        inset 1px 0 0 rgba(255,255,255,.35),
        inset -1px 0 0 rgba(0,0,0,.35),
        1px 0 2px rgba(0,0,0,.25);
    }
    .hanger .hook{
      position:absolute;
      left:50%;
      bottom:0;
      width:12px;
      height:12px;
      margin-left:-6px;
      border-radius:50%;
      border:2px solid #9aa6b4;
      background:radial-gradient(circle at 40% 35%,#e8eef5,#3d4654);
      box-shadow:0 2px 3px rgba(0,0,0,.4);
    }

    /* Pans stay level (counter-rotate with beam tilt) */
    .plate{
      position:absolute;
      top:calc(12px + var(--hang) - 4px);
      width:min(39vw,260px);
      height:min(31vh,240px);
      left:14%;
      transform-origin:top center;
      transform:translateX(-50%) rotate(calc(var(--tilt) * -1));
      transition:transform .75s cubic-bezier(.22,1.25,.36,1);
      display:grid;
      place-items:end center;
      z-index:10;
    }
    .plate.left{left:14%}
    .plate.right{left:86%}

    /* Circular pan disc under the load */
    .plate .pan{
      position:absolute;
      left:50%;
      bottom:0;
      width:88%;
      height:18px;
      transform:translateX(-50%);
      z-index:1;
      border-radius:50%;
      background:
        radial-gradient(ellipse 70% 80% at 50% 35%,rgba(255,255,255,.2),transparent 55%),
        linear-gradient(180deg,#a8b4c2 0%,#6b7686 40%,#3d4654 100%);
      box-shadow:
        0 8px 14px rgba(0,0,0,.42),
        inset 0 2px 0 rgba(255,255,255,.25),
        inset 0 -3px 6px rgba(0,0,0,.4);
      border:1px solid rgba(15,20,28,.55);
    }
    .plate .pan::before{
      content:"";
      position:absolute;
      left:8%;
      right:8%;
      top:2px;
      height:42%;
      border-radius:50%;
      background:radial-gradient(ellipse at 50% 40%,rgba(255,255,255,.18),transparent 70%);
      pointer-events:none;
    }
    .plate .pan-rim{
      position:absolute;
      left:50%;
      bottom:10px;
      width:78%;
      height:8px;
      transform:translateX(-50%);
      z-index:0;
      border-radius:50%;
      background:linear-gradient(180deg,#5a6574,#2a3340);
      box-shadow:0 4px 8px rgba(0,0,0,.35);
      opacity:.85;
    }

    .target{
      /* Shared prop metrics so both selection frames match */
      --prop-h:min(26vh,200px);
      --prop-w:min(calc(var(--prop-h) * .9),96%);
      --frame-pad-x:12px;
      --frame-pad-top:34px;  /* room for header badge + fuse tip */
      --frame-pad-bot:8px;
      --frame-bottom:10px;
      position:relative;
      width:100%;
      height:100%;
      display:grid;
      place-items:end center;
      background:none;
      border:0;
      padding:0;
      outline:none;
      z-index:2;
      -webkit-tap-highlight-color:transparent;
    }

    .target.selected .outline{
      opacity:1;
      transform:translateX(-50%) scale(1.02);
    }

    /* Selection frame: same box model for sud + truhla, hugs the prop */
    .outline{
      position:absolute;
      left:50%;
      right:auto;
      top:auto;
      bottom:var(--frame-bottom);
      width:calc(var(--prop-w) + var(--frame-pad-x) * 2);
      max-width:98%;
      height:calc(var(--prop-h) + var(--frame-pad-top) + var(--frame-pad-bot));
      transform:translateX(-50%);
      border-radius:18px;
      opacity:0;
      pointer-events:none;
      transition:opacity .15s ease,transform .15s ease;
      box-shadow:0 0 0 3px rgba(255,255,255,.06);
      z-index:4;
    }

    .barrel-target .outline{
      box-shadow:0 0 0 3px rgba(251,146,60,.95),0 0 24px rgba(251,146,60,.35);
    }

    .chest-target .outline{
      box-shadow:0 0 0 3px rgba(251,191,36,.95),0 0 24px rgba(251,191,36,.35);
    }

    /* Header badge sits on the top edge of the frame (same for both targets) */
    .target-label{
      position:absolute;
      left:50%;
      /* Align with outline top: bottom + height → top edge, half-overlap badge */
      bottom:calc(var(--frame-bottom) + var(--prop-h) + var(--frame-pad-bot) + var(--frame-pad-top) - 14px);
      top:auto;
      transform:translate(-50%,0) scale(1.55);
      transform-origin:center center;
      z-index:22; /* always above fuse/spark */
      display:inline-flex;
      align-items:center;
      gap:6px;
      padding:5px 10px;
      border-radius:999px;
      background:rgba(6,12,22,.97);
      border:2px solid rgba(255,255,255,.2);
      color:#ffffff;
      font-size:clamp(.78rem,2.5vw,1rem);
      line-height:1;
      font-weight:1000;
      letter-spacing:.01em;
      white-space:nowrap;
      text-shadow:0 2px 5px rgba(0,0,0,.7);
      box-shadow:0 6px 16px rgba(0,0,0,.4);
      pointer-events:none;
    }
    .target-label .stat-ico{
      width:1em;
      height:1em;
    }

    .barrel-target.selected .target-label{
      border-color:#fb923c;
      box-shadow:0 0 0 2px rgba(251,146,60,.18),0 6px 16px rgba(0,0,0,.4);
    }

    .chest-target.selected .target-label{
      border-color:#fbbf24;
      box-shadow:0 0 0 2px rgba(251,191,36,.18),0 6px 16px rgba(0,0,0,.4);
    }

    .count-pill{
      display:inline-flex;
      align-items:center;
      justify-content:center;
      min-width:58px;
      margin-left:7px;
      padding:3px 7px;
      border-radius:999px;
      background:rgba(255,255,255,.12);
      color:#fff7cf;
      font-size:.9em;
      font-variant-numeric:tabular-nums;
      text-shadow:none;
    }

    /* BARREL */
    .barrel-wrap{
      position:relative;
      height:var(--prop-h);
      width:var(--prop-w);
      max-width:96%;
      display:grid;
      place-items:end center;
      margin-bottom:var(--frame-bottom);
      z-index:5;
    }

    .barrel{
      position:relative;
      height:82%;
      aspect-ratio:.78/1;
      border-radius:14% 14% 19% 19% / 13% 13% 10% 10%;
      overflow:hidden;
      border:clamp(4px,.85vh,7px) solid #402515;
      background:
        repeating-linear-gradient(
          90deg,
          #6f3b1f 0 12%,
          #9a5b2e 12% 28%,
          #854a26 28% 40%
        );
      box-shadow:
        inset 0 0 0 2px rgba(255,255,255,.05),
        inset 10px 0 18px rgba(0,0,0,.2),
        inset -10px 0 18px rgba(0,0,0,.25),
        0 15px 25px rgba(0,0,0,.34);
    }

    .barrel::before{
      content:"";
      position:absolute;
      inset:0;
      z-index:3;
      pointer-events:none;
      background:
        linear-gradient(90deg,rgba(0,0,0,.18),transparent 13%,transparent 87%,rgba(0,0,0,.2)),
        linear-gradient(180deg,rgba(255,255,255,.04),transparent 20%,transparent 80%,rgba(0,0,0,.12));
    }

    .barrel::after{
      content:"";
      position:absolute;
      left:5%;
      right:5%;
      top:2%;
      height:7%;
      z-index:6;
      border-radius:50%;
      border:2px solid rgba(42,26,17,.85);
      background:linear-gradient(180deg,#b06b38,#6f3b1f);
      box-shadow:0 3px 8px rgba(0,0,0,.32);
      pointer-events:none;
    }

    .powder-stack{
      position:absolute;
      left:0;right:0;bottom:0;
      height:100%;
      display:flex;
      flex-direction:column-reverse;
      z-index:2;
      pointer-events:none;
    }

    .powder-layer{
      position:relative;
      flex:0 0 10%;
      width:100%;
      opacity:.97;
      /* Keep each award as its own band — even same color must not look merged */
      border-top:2px solid rgba(255,255,255,.22);
      border-bottom:1px solid rgba(0,0,0,.28);
      box-sizing:border-box;
      animation:addLayer .34s cubic-bezier(.2,.85,.25,1.12);
      box-shadow:inset 0 5px 8px rgba(255,255,255,.08),inset 0 -5px 8px rgba(0,0,0,.18);
    }

    .powder-layer::before{
      content:"";
      position:absolute;
      left:0;right:0;top:-3px;
      height:7px;
      border-radius:50%;
      background:inherit;
      filter:brightness(1.12);
      box-shadow:0 2px 4px rgba(0,0,0,.35);
      border-top:1px solid rgba(255,255,255,.25);
    }

    .powder-layer::after{
      content:"";
      position:absolute;
      inset:0;
      background:
        radial-gradient(circle at 18% 35%,rgba(255,255,255,.17) 0 2px,transparent 3px),
        radial-gradient(circle at 72% 60%,rgba(0,0,0,.18) 0 3px,transparent 4px),
        radial-gradient(circle at 44% 72%,rgba(255,255,255,.12) 0 2px,transparent 3px);
      background-size:29px 29px,35px 35px,25px 25px;
      /* Slight per-layer offset so identical colors still read as separate bands */
      background-position:
        calc(var(--layer-i, 0) * 3px) calc(var(--layer-i, 0) * 2px),
        calc(var(--layer-i, 0) * -4px) calc(var(--layer-i, 0) * 3px),
        calc(var(--layer-i, 0) * 2px) calc(var(--layer-i, 0) * -2px);
    }

    .barrel-label{
      position:absolute;
      left:50%;
      top:43%;
      transform:translate(-50%,-50%);
      z-index:6;
      width:58%;
      padding:6% 4%;
      border-radius:9px;
      background:#ead6a7;
      color:#2e1d0f;
      border:3px solid #50331f;
      font-weight:1000;
      font-size:clamp(.47rem,1.65vh,.72rem);
      line-height:1.05;
      text-align:center;
      box-shadow:0 6px 10px rgba(0,0,0,.25);
    }

    /* Fuse sticks up into the frame pad above the barrel, but under the header badge */
    .fuse{
      position:absolute;
      top:2%;
      left:56%;
      width:36%;
      height:18%;
      border-top:clamp(4px,.85vh,8px) solid #3a2a1c;
      border-radius:50%;
      transform:rotate(-18deg);
      z-index:8; /* below .target-label (22) so knot never covers the header */
      pointer-events:none;
      filter:drop-shadow(0 1px 2px rgba(0,0,0,.45));
    }
    .fuse::after{
      /* charred tip of the fuse */
      content:"";
      position:absolute;
      top:-3px;
      right:4%;
      width:7px;
      height:7px;
      border-radius:50%;
      background:#1a120c;
      box-shadow:0 0 0 1px #4a3728;
    }

    /* Spark/smolder only when barrel is almost full (.danger) */
    .spark{
      position:absolute;
      top:0%;
      right:8%;
      width:clamp(11px,2.2vh,18px);
      aspect-ratio:1;
      border-radius:50%;
      background:#fef3c7;
      box-shadow:0 0 8px #fff,0 0 18px #fbbf24,0 0 30px #fb923c;
      opacity:0;
      visibility:hidden;
      z-index:9; /* below header badge */
      pointer-events:none;
    }
    .danger .spark{
      opacity:1;
      visibility:visible;
      animation:flicker .16s infinite alternate;
      box-shadow:0 0 10px #fff,0 0 22px #fbbf24,0 0 36px #fb923c,#ef4444 0 0 14px;
    }
    .danger .fuse::after{
      background:radial-gradient(circle at 40% 35%,#fde68a,#f59e0b 55%,#7c2d12);
      box-shadow:0 0 6px #fbbf24,0 0 12px #ef4444;
    }

    /* CHEST — same outer box as barrel so both frames match */
    .chest-wrap{
      position:relative;
      width:var(--prop-w);
      max-width:96%;
      height:var(--prop-h);
      display:grid;
      place-items:end center;
      filter:drop-shadow(0 15px 18px rgba(0,0,0,.34));
      margin-bottom:var(--frame-bottom);
      z-index:5;
    }

    .chest-lid{
      position:absolute;
      left:8%;
      right:8%;
      top:4%;
      height:40%;
      z-index:6;
      border:clamp(4px,.7vh,7px) solid #4a2b16;
      border-radius:52% 52% 12% 12% / 72% 72% 20% 20%;
      background:
        linear-gradient(90deg,rgba(0,0,0,.18),transparent 18%,transparent 82%,rgba(0,0,0,.2)),
        repeating-linear-gradient(90deg,#78401e 0 14%,#a45e2d 14% 30%,#8b4b23 30% 44%);
      transform-origin:center bottom;
      transform:rotateX(11deg);
      box-shadow:inset 0 4px 0 rgba(255,255,255,.08),0 5px 10px rgba(0,0,0,.28);
    }

    .chest-lid::after{
      content:"";
      position:absolute;
      left:4%;
      right:4%;
      bottom:8%;
      height:15%;
      border-radius:6px;
      background:linear-gradient(180deg,#e1b64f,#8d6423);
      border:2px solid #5d421a;
    }

    .chest-cavity{
      position:absolute;
      left:13%;
      right:13%;
      bottom:32%;
      height:30%;
      z-index:3;
      border-radius:50%;
      background:#17100b;
      box-shadow:inset 0 8px 11px rgba(0,0,0,.88);
    }

    .treasure-pile-bg{
      position:absolute;
      left:13%;
      right:13%;
      bottom:32%;
      height:13%;
      z-index:6;
      border-radius:45% 45% 40% 40%;
      background:linear-gradient(180deg,#f8d267,#b7791f);
      box-shadow:0 0 14px rgba(251,191,36,.36);
      opacity:.85;
    }

    .chest-body{
      position:absolute;
      left:4%;
      right:4%;
      bottom:3%;
      height:56%;
      z-index:5;
      border:clamp(4px,.7vh,7px) solid #4a2b16;
      border-radius:7% 7% 14% 14%;
      background:
        linear-gradient(90deg,rgba(0,0,0,.2),transparent 13%,transparent 87%,rgba(0,0,0,.22)),
        repeating-linear-gradient(90deg,#78401e 0 14%,#a45e2d 14% 30%,#8b4b23 30% 44%);
      box-shadow:inset 0 4px 0 rgba(255,255,255,.07);
    }

    .chest-body::before,
    .chest-body::after{
      content:"";
      position:absolute;
      top:-4%;
      bottom:-3%;
      width:8%;
      background:linear-gradient(90deg,#8d6423,#e1b64f,#8d6423);
      border:2px solid #5d421a;
      z-index:3;
    }
    .chest-body::before{left:12%}
    .chest-body::after{right:12%}

    /* Lock sits on the chest front, always UNDER gems */
    .chest-lock{
      position:absolute;
      left:50%;
      bottom:12%;
      transform:translateX(-50%);
      width:16%;
      aspect-ratio:.72/1;
      z-index:6;
      border-radius:5px 5px 9px 9px;
      background:linear-gradient(135deg,#ffe08a,#b77a1d);
      border:2px solid #6d4815;
      box-shadow:0 4px 7px rgba(0,0,0,.28);
      pointer-events:none;
    }

    /* Gems always above lock/body — never covered */
    .treasure-pile{
      position:absolute;
      left:12%;
      right:12%;
      bottom:30%;
      height:34%;
      z-index:10;
      display:grid;
      grid-template-columns:repeat(5,minmax(0,1fr));
      grid-template-rows:repeat(2,minmax(0,1fr));
      align-items:end;
      justify-items:center;
      gap:2px 1px;
      pointer-events:none;
      overflow:visible;
    }

    .treasure-item{
      --gem:#fbbf24;
      width:clamp(20px,4.6vw,34px);
      aspect-ratio:1;
      position:relative;
      z-index:11;
      animation:dropTreasure .38s cubic-bezier(.18,.85,.3,1.2);
      background:var(--gem);
      border:2px solid color-mix(in srgb,var(--gem) 58%,#111827);
      box-shadow:
        inset 4px 4px 7px rgba(255,255,255,.28),
        inset -4px -5px 7px rgba(0,0,0,.22),
        0 4px 7px rgba(0,0,0,.36),
        0 0 12px color-mix(in srgb,var(--gem) 55%,transparent);
    }

    .treasure-item.gem{clip-path:polygon(50% 0,94% 30%,78% 100%,22% 100%,6% 30%)}
    .treasure-item.coin{border-radius:50%;aspect-ratio:1/.7;transform:rotate(-8deg)}
    .treasure-item.crystal{clip-path:polygon(50% 0,88% 23%,82% 76%,50% 100%,18% 76%,12% 23%)}
    .treasure-item::after{
      content:"";
      position:absolute;
      left:24%;
      top:14%;
      width:24%;
      height:22%;
      border-radius:50%;
      background:rgba(255,255,255,.42);
      filter:blur(.4px);
    }

    @keyframes dropTreasure{
      from{transform:translateY(-85px) rotate(-26deg) scale(.45);opacity:0}
      70%{transform:translateY(3px) rotate(7deg) scale(1.1);opacity:1}
      to{transform:translateY(0) rotate(0) scale(1);opacity:1}
    }

    .chest-full .chest-wrap{
      animation:chestGlow .65s ease-in-out infinite alternate;
    }
    @keyframes chestGlow{
      from{filter:drop-shadow(0 15px 18px rgba(0,0,0,.34))}
      to{filter:drop-shadow(0 0 20px rgba(251,191,36,.72))}
    }

    /* CHILDREN */
    .children{
      position:absolute;
      left:0;
      right:0;
      bottom:24px;
      z-index:12;
      min-height:0;
      display:grid;
      grid-template-columns:repeat(var(--child-cols),minmax(0,1fr));
      gap:4px 6px;
      align-items:end;
      padding:0 10px 2px;
      background:linear-gradient(180deg,transparent,rgba(6,10,18,.08) 35%,rgba(6,10,18,.18));
    }

    .child{
      --shirt:#3b82f6;
      --skin:#f1c7a5;
      --hair:#3a251b;
      --height-scale:1;
      --body-tilt:0deg;
      --arm-left-rot:12deg;
      --arm-right-rot:-12deg;
      --leg-left-rot:2deg;
      --leg-right-rot:-3deg;
      --offsetY:0px;
      position:relative;
      min-width:0;
      background:none;
      border:0;
      padding:2px 0 0;
      color:var(--text);
      overflow:visible;
      display:flex;
      flex-direction:column;
      align-items:center;
      justify-content:flex-end;
      -webkit-tap-highlight-color:transparent;
      transform:translateY(var(--offsetY));
      border-radius:16px;
      transition:box-shadow .15s ease, outline-color .15s ease;
    }
    .child-figure,
    .child-meta{
      appearance:none;
      background:none;
      border:0;
      padding:0;
      margin:0;
      color:inherit;
      font:inherit;
      cursor:pointer;
      display:flex;
      flex-direction:column;
      align-items:center;
      width:100%;
      min-width:0;
      -webkit-tap-highlight-color:transparent;
    }
    .child-figure:disabled,
    .child-meta:disabled{opacity:.45;cursor:not-allowed}
    .child-figure:active .child-person{
      transform:rotate(var(--body-tilt)) scale(calc(var(--height-scale) * .96));
    }
    .child-meta{
      position:relative;
      z-index:2;
      padding:3px 4px 4px;
      border-radius:10px;
      gap:0;
    }
    .child-meta:active{
      background:rgba(255,255,255,.07);
    }

    .child-person{
      position:relative;
      width:clamp(48px,8.8vw,72px);
      height:clamp(68px,12.6vw,104px);
      transform:rotate(var(--body-tilt)) scale(var(--height-scale));
      transform-origin:center bottom;
      transition:transform .08s ease;
      filter:drop-shadow(0 6px 8px rgba(0,0,0,.18));
      pointer-events:none;
    }

    .child-shadow{
      position:absolute;
      left:50%;
      bottom:2px;
      width:56%;
      height:7px;
      transform:translateX(-50%);
      border-radius:50%;
      background:radial-gradient(circle, rgba(0,0,0,.38), transparent 72%);
      z-index:0;
      filter:blur(1px);
    }

    .child-name{
      width:100%;
      margin-top:2px;
      text-align:center;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
      /* ~50% larger than previous clamp(.58rem,1.85vw,.82rem) */
      font-size:clamp(.87rem,2.78vw,1.23rem);
      line-height:1.05;
      font-weight:1000;
    }

    .child-stats{
      display:flex;
      justify-content:center;
      gap:8px;
      margin-top:2px;
      min-width:0;
      color:var(--muted);
      /* double previous clamp(.48rem,1.4vw,.62rem) */
      font-size:clamp(.96rem,2.8vw,1.24rem);
      font-weight:900;
      font-variant-numeric:tabular-nums;
    }

    .stat-dot{
      display:inline-flex;
      align-items:center;
      gap:4px;
      line-height:1;
    }
    .stat-dot.bad{color:#fb923c}
    .stat-dot.good{color:#fbbf24}

    /* CSS icons — no emoji font required (□ tofu on systems without Noto/Segoe emoji) */
    .stat-ico{
      display:inline-block;
      flex:0 0 auto;
      width:0.95em;
      height:0.95em;
      position:relative;
      vertical-align:middle;
    }
    .stat-ico.barrel{
      border-radius:18% 18% 22% 22% / 14% 14% 18% 18%;
      background:
        linear-gradient(180deg,rgba(255,255,255,.18),transparent 35%),
        repeating-linear-gradient(90deg,#8b4a24 0 28%,#c47a3a 28% 55%,#6f3b1f 55% 100%);
      border:1.5px solid #3d2414;
      box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.35);
    }
    .stat-ico.barrel::after{
      content:"";
      position:absolute;
      left:12%;
      right:12%;
      top:38%;
      height:18%;
      border-radius:2px;
      background:linear-gradient(180deg,#fbbf24,#d97706);
      box-shadow:0 0 0 1px rgba(0,0,0,.25);
    }
    .stat-ico.gem{
      clip-path:polygon(50% 0,100% 38%,78% 100%,22% 100%,0 38%);
      background:
        linear-gradient(145deg,#fef3c7 0%,#fbbf24 42%,#d97706 100%);
      box-shadow:0 1px 2px rgba(0,0,0,.35);
    }
    .stat-ico.gem::after{
      content:"";
      position:absolute;
      left:28%;
      top:18%;
      width:28%;
      height:28%;
      background:rgba(255,255,255,.55);
      clip-path:polygon(0 100%,50% 0,100% 100%);
      transform:rotate(-18deg);
    }

    /* Player contribution history sheet */
    .player-history-totals{
      display:flex;
      gap:8px;
      margin:0 0 12px;
    }
    .player-history-totals .hist-chip{
      flex:1;
      display:flex;
      align-items:center;
      justify-content:center;
      gap:6px;
      padding:10px 8px;
      border-radius:12px;
      background:rgba(15,23,42,.55);
      border:1px solid var(--line-soft);
      font-weight:900;
      font-size:.95rem;
      font-variant-numeric:tabular-nums;
    }
    .player-history-totals .hist-chip.bad{color:#fb923c;border-color:rgba(251,146,60,.35)}
    .player-history-totals .hist-chip.good{color:#fbbf24;border-color:rgba(251,191,36,.35)}
    .player-history-status{
      margin:0 0 10px;
      padding:8px 10px;
      border-radius:10px;
      font-size:.82rem;
      line-height:1.35;
      background:rgba(96,165,250,.1);
      border:1px solid rgba(96,165,250,.25);
      color:#bfdbfe;
    }
    .player-history-status.error{
      background:rgba(251,113,133,.12);
      border-color:rgba(251,113,133,.35);
      color:#fecdd3;
    }
    .player-history-award{
      margin:0 0 14px;
      padding:12px;
      border-radius:14px;
      background:rgba(15,23,42,.45);
      border:1px solid var(--line-soft);
    }
    .player-history-award-actions{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:8px;
      margin-top:8px;
    }
    .player-history-section{margin:0 0 16px}
    .player-history-heading{
      display:flex;
      align-items:center;
      gap:8px;
      margin:0 0 8px;
      font-size:.92rem;
      font-weight:1000;
      color:var(--text);
    }
    .player-history-list{
      display:flex;
      flex-direction:column;
      gap:6px;
    }
    .player-history-empty{
      margin:0;
      padding:12px;
      border-radius:12px;
      background:rgba(15,23,42,.35);
      border:1px dashed var(--line-soft);
      color:var(--muted);
      font-size:.85rem;
      text-align:center;
    }
    .player-history-item{
      display:grid;
      grid-template-columns:minmax(0,1fr) auto;
      gap:4px 10px;
      padding:10px 12px;
      border-radius:12px;
      background:rgba(15,23,42,.5);
      border:1px solid var(--line-soft);
    }
    .player-history-item .hist-when{
      font-size:.78rem;
      color:var(--muted);
      font-variant-numeric:tabular-nums;
    }
    .player-history-item .hist-src{
      font-size:.72rem;
      font-weight:800;
      text-transform:uppercase;
      letter-spacing:.03em;
      color:var(--muted-2);
      text-align:right;
    }
    .player-history-item .hist-note{
      grid-column:1 / -1;
      margin:0;
      font-size:.88rem;
      line-height:1.35;
      color:var(--text);
      word-break:break-word;
    }
    .player-history-item .hist-note.muted{color:var(--muted-2);font-style:italic;font-size:.82rem}


    .preview-person .shorts,
    .child-person .shorts{
      position:absolute;
      left:25%;
      top:66%;
      width:50%;
      height:12%;
      background:#334155;
      border:1px solid rgba(0,0,0,.2);
      border-radius:2px 2px 7px 7px;
      z-index:2;
      transform:scaleX(var(--body-width,1));
      transform-origin:center center;
    }

    .child-person .shirt{
      top:30%;
      height:40%;
      border-radius:13px 13px 10px 10px;
    }


    .preview-person .arm,
    .child-person .arm{
      transform:scaleX(calc(.88 + (var(--body-width,1) - .58) * .42 / .58));
      transform-origin:center top;
    }

    .preview-person .leg,
    .child-person .leg{
      transform:scaleX(calc(.9 + (var(--body-width,1) - .58) * .38 / .58));
      transform-origin:center top;
    }

    .child-person .arm.left{transform:rotate(var(--arm-left-rot)) scaleX(calc(.88 + (var(--body-width,1) - .58) * .42 / .58))}
    .child-person .arm.right{transform:rotate(var(--arm-right-rot)) scaleX(calc(.88 + (var(--body-width,1) - .58) * .42 / .58))}
    .child-person .leg.left{transform:rotate(var(--leg-left-rot)) scaleX(calc(.9 + (var(--body-width,1) - .58) * .38 / .58))}
    .child-person .leg.right{transform:rotate(var(--leg-right-rot)) scaleX(calc(.9 + (var(--body-width,1) - .58) * .38 / .58))}
    .child-person .leg{
      top:75%;
      width:20%;
      height:22%;
      background:#475569;
      border-radius:0 0 7px 7px;
    }

    .child-person .shoe{
      position:absolute;
      top:94%;
      width:24%;
      height:7%;
      background:#111827;
      border-radius:999px;
      z-index:1;
    }
    .child-person .shoe.left{left:18%}
    .child-person .shoe.right{right:18%}

    .child-name{
      margin-top:4px;
      text-shadow:0 2px 5px rgba(0,0,0,.4);
    }

    /* PROJECTILES */
    .projectile{
      position:absolute;
      width:18px;
      aspect-ratio:1;
      pointer-events:none;
      z-index:40;
      will-change:transform,opacity;
    }

    .projectile.powder{
      border-radius:50%;
      box-shadow:0 0 12px currentColor;
      filter:blur(.4px);
      background:currentColor;
    }

    .projectile.treasure{
      background:currentColor;
      border:2px solid rgba(255,255,255,.25);
      box-shadow:0 0 12px currentColor;
      clip-path:polygon(50% 0,95% 32%,78% 100%,22% 100%,5% 32%);
    }

    .projectile-tail{
      position:absolute;
      inset:-6px;
      border-radius:50%;
      background:radial-gradient(circle,rgba(255,255,255,.35),transparent 65%);
      opacity:.6;
    }

    /* OVERLAYS — above game, below side sheets (unlock/tasks/admin) */
    .explosion-layer,
    .treasure-layer{
      position:fixed;
      inset:0;
      display:none;
      place-items:center;
      background:rgba(3,7,14,.72);
      backdrop-filter:blur(4px);
      z-index:90;
      overflow:hidden;
      pointer-events:auto;
    }
    .explosion-layer.show,
    .treasure-layer.show{display:grid}

    .explosion,
    .treasure-burst{
      position:relative;
      width:min(320px,82vw);
      aspect-ratio:1;
      display:grid;
      place-items:center;
      pointer-events:none; /* don't block the action card underneath */
    }

    .explosion{animation:boomIn .5s cubic-bezier(.2,.9,.25,1.25)}
    .explosion::before,
    .explosion::after{
      content:"";
      position:absolute;
      inset:16%;
      border-radius:50%;
      background:radial-gradient(circle,#fff7c2 0 12%,#fbbf24 13% 28%,#fb923c 29% 48%,#ef4444 49% 63%,transparent 64%);
      filter:drop-shadow(0 0 32px rgba(251,146,60,.9));
      animation:pulseBoom .55s ease-out infinite alternate;
    }
    .explosion::after{
      inset:5%;
      opacity:.55;
      transform:rotate(25deg);
      clip-path:polygon(50% 0%,61% 31%,89% 11%,72% 40%,100% 50%,71% 60%,90% 90%,60% 72%,50% 100%,39% 72%,10% 90%,29% 59%,0 50%,29% 39%,11% 10%,39% 31%);
    }

    .treasure-burst{animation:treasureIn .5s cubic-bezier(.2,.9,.25,1.2)}
    .treasure-burst::before{
      content:"";
      position:absolute;
      inset:3%;
      border-radius:50%;
      background:
        repeating-conic-gradient(
          from 0deg,
          rgba(251,191,36,.92) 0deg 7deg,
          transparent 7deg 18deg
        );
      mask:radial-gradient(circle,transparent 0 26%,#000 27% 100%);
      opacity:.82;
      animation:spinGlow 7s linear infinite;
    }
    .treasure-burst::after{
      content:"💎";
      position:absolute;
      inset:19%;
      display:grid;
      place-items:center;
      border-radius:50%;
      font-size:clamp(5rem,24vw,9rem);
      background:radial-gradient(circle,#fff7c2 0 10%,#fbbf24 11% 35%,#b45309 67%,transparent 68%);
      filter:drop-shadow(0 0 30px rgba(251,191,36,.82));
    }

    @keyframes boomIn{
      from{transform:scale(.2) rotate(-18deg);opacity:0}
      to{transform:scale(1);opacity:1}
    }
    @keyframes pulseBoom{
      from{transform:scale(.94)}
      to{transform:scale(1.05)}
    }
    @keyframes treasureIn{
      from{transform:scale(.25) rotate(-20deg);opacity:0}
      to{transform:scale(1);opacity:1}
    }
    @keyframes spinGlow{
      to{transform:rotate(360deg)}
    }
    @keyframes flicker{
      from{transform:scale(.78)}
      to{transform:scale(1.22)}
    }

    .explosion-content,
    .treasure-content{
      position:relative;
      z-index:4;
      text-align:center;
      font-weight:1000;
      text-shadow:0 3px 8px rgba(0,0,0,.7);
    }
    .explosion-content{color:#2a1305}
    .treasure-content{color:#fff4c7;margin-top:70%}
    .boom{font-size:clamp(2.8rem,12vw,5rem);line-height:1}

    .overlay-card{
      position:fixed;
      left:50%;
      bottom:max(12px,env(safe-area-inset-bottom));
      transform:translateX(-50%);
      width:min(480px,calc(100% - 20px));
      background:#111827;
      border-radius:17px;
      padding:14px;
      box-shadow:var(--shadow);
      text-align:center;
      z-index:96;
      pointer-events:auto;
    }
    .overlay-card.explosion-card{border:1px solid #3a4a64}
    .overlay-card.treasure-card{border:1px solid #665324}
    .overlay-card h2{margin:0 0 4px}
    .overlay-card p{
      margin:5px 0 9px;
      color:var(--muted);
      font-size:.84rem;
    }
    .overlay-card .overlay-status{
      min-height:1.2em;
      margin:0 0 10px;
      font-size:.82rem;
      color:var(--danger);
    }
    .overlay-card .overlay-status:empty{display:none}
    .overlay-actions{
      display:flex;
      flex-direction:column;
      gap:7px;
    }
    .overlay-actions.row-2{
      display:grid;
      grid-template-columns:1fr 1fr;
    }

    @media(max-width:560px){
      .target{
        --frame-pad-top:30px;
      }
      .target-label{
        transform:translate(-50%,0) scale(1.48);
        padding:5px 9px;
      }
      .setup-player{
        grid-template-columns:30px minmax(0,1fr) 78px;
        gap:7px;
        min-height:126px;
      }
      .index{
        width:32px;height:32px;
      }
      .setup-fields{
        grid-template-columns:minmax(0,1fr) minmax(0,1fr);
        gap:6px;
      }
      .preview-stage{height:80px}
      .preview-person{width:44px;height:66px}
    }

    @media (orientation:landscape) and (max-height:650px){
      .balance{
        padding-bottom:116px;
      }
      .beam-wrap{
        --fulcrum-y:min(36vh,200px);
        --hang:min(12vh,70px);
        width:min(90%,760px);
        height:min(100%,360px);
        transform:translateY(-22px) scale(.65);
      }
      .plate{
        width:min(31vw,250px);
        height:min(46vh,230px);
      }
      .target{
        --prop-h:min(48vh,210px);
        --prop-w:min(calc(var(--prop-h) * .9),96%);
      }
      .child-person{
        width:clamp(38px,7.1vh,58px);
        height:clamp(54px,10.5vh,82px);
      }
      .children{
        grid-template-columns:repeat(6,minmax(0,1fr));
        padding:0 6px 2px;
        bottom:12px;
      }
    }

    /* v17 compact setup layout */
    #setupScreen .setup-panel{
      grid-template-rows:auto auto minmax(0,1fr) auto;
      gap:6px;
      padding:8px;
      overflow:hidden;
    }

    .setup-title-row{
      display:grid;
      grid-template-columns:minmax(0,1fr) 112px;
      gap:10px;
      align-items:end;
      min-height:0;
    }

    .setup-title{
      min-width:0;
    }

    .setup-title .subtitle{
      font-size:clamp(.62rem,2vw,.78rem);
    }

    .player-count-control{
      min-width:0;
    }

    .player-count-control label{
      margin-bottom:3px;
    }

    .player-count-control select{
      min-height:34px;
      padding:0 7px;
      font-size:.84rem;
    }

    #setupScreen .player-tabs{
      min-height:34px;
      height:34px;
      gap:4px;
    }

    #setupScreen .player-tab{
      min-height:34px;
      height:34px;
      padding:0 3px;
      border-radius:9px;
      font-size:clamp(.6rem,1.9vw,.72rem);
    }

    #setupScreen .players-setup{
      min-height:0;
      height:100%;
      overflow:hidden;
    }

    #setupScreen .setup-player{
      position:relative;
      display:none;
      grid-template-columns:124px minmax(0,1fr);
      grid-template-rows:minmax(0,1fr);
      gap:8px;
      align-items:stretch;
      min-height:0;
      height:100%;
      padding:8px;
      overflow:hidden;
    }

    #setupScreen .setup-player.active{
      display:grid;
    }

    #setupScreen .index{
      position:absolute;
      left:7px;
      top:7px;
      z-index:6;
      width:27px;
      height:27px;
      border-radius:8px;
      font-size:.72rem;
      pointer-events:none;
    }

    #setupScreen .setup-fields{
      grid-column:1;
      grid-row:1;
      display:grid;
      grid-template-columns:minmax(0,1fr) minmax(0,1fr);
      gap:6px 5px;
      align-content:center;
      min-width:0;
      padding-top:25px;
    }

    #setupScreen .setup-fields .name-field{
      grid-column:1 / 3;
    }

    #setupScreen .setup-player label{
      margin-bottom:3px;
      font-size:.65rem;
    }

    #setupScreen .setup-player input{
      width:100%;
      min-width:0;
      min-height:34px;
      height:34px;
      padding:0 6px;
      font-size:.84rem;
      border-radius:8px;
    }

    #setupScreen .height-field input,
    #setupScreen .weight-field input{
      text-align:center;
    }

    #setupScreen .player-preview{
      grid-column:2;
      grid-row:1;
      min-width:0;
      min-height:0;
      height:100%;
      padding:4px 4px 6px;
      justify-content:center;
      overflow:hidden;
    }

    #setupScreen .preview-stage{
      flex:1 1 auto;
      min-height:0;
      height:auto;
      max-height:none;
      overflow:visible;
    }

    #setupScreen .preview-person{
      width:70px;
      height:106px;
    }

    #setupScreen .preview-name{
      flex:0 0 auto;
      margin-top:2px;
      font-size:.78rem;
    }

    #setupScreen .preview-height{
      flex:0 0 auto;
      font-size:.62rem;
    }

    #setupScreen #startBtn{
      min-height:36px;
      height:36px;
      padding:5px 10px;
    }

    @media(max-width:390px){
      #setupScreen .setup-title-row{
        grid-template-columns:minmax(0,1fr) 100px;
        gap:7px;
      }

      #setupScreen .setup-player{
        grid-template-columns:112px minmax(0,1fr);
        gap:6px;
        padding:7px;
      }

      #setupScreen .setup-fields{
        gap:5px 4px;
      }

      #setupScreen .setup-player input{
        min-height:32px;
        height:32px;
        font-size:.8rem;
        padding:0 5px;
      }

      #setupScreen .preview-person{
        width:64px;
        height:97px;
      }
    }

    @media(max-height:700px){
      #setupScreen .topbar{
        min-height:38px;
        margin-bottom:4px;
      }

      #setupScreen .logo{
        width:38px;
        height:38px;
      }
      #setupScreen .logo-mark{
        width:30px;
        height:30px;
      }

      #setupScreen .setup-panel{
        gap:4px;
        padding:6px;
      }

      #setupScreen .setup-title .subtitle{
        display:none;
      }

      #setupScreen .player-tabs{
        min-height:30px;
        height:30px;
      }

      #setupScreen .player-tab{
        min-height:30px;
        height:30px;
      }

      #setupScreen .preview-person{
        width:58px;
        height:88px;
      }

      #setupScreen #startBtn{
        min-height:34px;
        height:34px;
      }
    }

    /* v18 effects & juice */
    @keyframes appShake{
      0%,100%{transform:translate(0,0)}
      20%{transform:translate(-6px,3px)}
      40%{transform:translate(5px,-4px)}
      60%{transform:translate(-4px,2px)}
      80%{transform:translate(3px,-2px)}
    }
    .app.shake{animation:appShake .42s ease-in-out}

    @keyframes childIdle{
      0%,100%{transform:translateY(var(--offsetY))}
      50%{transform:translateY(calc(var(--offsetY) - 3px))}
    }
    .child{
      animation:childIdle 2.4s ease-in-out infinite;
      animation-delay:var(--idle-delay,0s);
    }
    .child:disabled{animation-play-state:paused}

    .particle{
      position:absolute;
      left:0;
      top:0;
      width:8px;
      height:8px;
      border-radius:50%;
      pointer-events:none;
      z-index:45;
      will-change:transform,opacity;
    }
    .particle.spark-particle{border-radius:2px}

    .impact-ring{
      position:absolute;
      left:0;
      top:0;
      width:34px;
      height:34px;
      margin:-17px 0 0 -17px;
      border-radius:50%;
      border:3px solid currentColor;
      pointer-events:none;
      z-index:42;
      opacity:.85;
    }



    /* ========== Portal chrome (login, sheets, admin) ========== */

    .btn{
      transition:background .15s ease,border-color .15s ease,transform .1s ease,opacity .15s;
    }
    .btn:active{transform:scale(.98)}
    .btn:focus-visible{outline:none;box-shadow:var(--focus)}
    .btn.sm{
      min-height:32px;
      padding:5px 10px;
      font-size:.78rem;
      font-weight:700;
      border-radius:9px;
    }
    .btn.ghost{
      background:transparent;
      border-color:transparent;
      color:var(--muted);
    }
    .btn.ghost:hover{background:rgba(255,255,255,.05);color:var(--text)}
    .btn.icon{
      width:36px;min-width:36px;height:36px;min-height:36px;
      padding:0;border-radius:11px;
      display:inline-grid;place-items:center;
      font-size:1.1rem;line-height:1;font-weight:500;
    }
    .btn.block{width:100%}
    input:focus-visible,select:focus-visible{
      outline:none;border-color:var(--accent);box-shadow:var(--focus);
    }

    /* Login */
    #loginScreen{
      justify-content:center;
      padding-bottom:max(12px,env(safe-area-inset-bottom));
    }
    #loginScreen .topbar{margin-bottom:14px}
    .login-panel{
      width:min(400px,100%);
      margin:0 auto;
      padding:22px 20px 24px;
      display:flex;
      flex-direction:column;
      gap:var(--space-4);
    }
    .login-kicker{
      font-size:.72rem;
      font-weight:800;
      letter-spacing:.08em;
      text-transform:uppercase;
      color:var(--muted-2);
    }
    .login-panel h2{
      margin:0;
      font-size:1.4rem;
      font-weight:800;
      letter-spacing:-.02em;
      line-height:1.15;
    }
    .login-lead{
      margin:-6px 0 0;
      color:var(--muted);
      font-size:.88rem;
      line-height:1.45;
    }
    .field{display:flex;flex-direction:column;gap:6px}
    .field > label,
    .field-label{
      margin:0;
      font-size:.72rem;
      font-weight:750;
      letter-spacing:.02em;
      color:var(--muted);
      text-transform:uppercase;
    }
    .field input,.field select,
    .form-control{
      width:100%;
      min-height:44px;
      padding:0 14px;
      border-radius:var(--radius-sm);
      border:1px solid var(--line);
      background:#0a1220;
      color:var(--text);
    }
    .login-form{display:flex;flex-direction:column;gap:var(--space-3)}
    .check-row{
      display:flex;
      align-items:center;
      gap:10px;
      margin:0;
      font-size:.9rem;
      color:var(--muted);
      font-weight:600;
      cursor:pointer;
      user-select:none;
    }
    .check-row input{width:auto;min-height:0;accent-color:var(--accent)}
    .login-error,.error-text{color:var(--danger);font-size:.88rem;margin:0;line-height:1.35}
    .boot-hint{color:var(--muted);font-size:.85rem;min-height:1.2em;margin:0}

    /* Game top chrome — brand left, user + actions one compact row */
    #gameScreen .topbar{
      flex-wrap:nowrap;
      gap:8px;
      margin-bottom:4px;
      align-items:center;
      min-height:0;
    }
    #gameScreen .brand{
      flex:0 1 auto;
      min-width:0;
    }
    .topbar-right{
      display:flex;
      flex-direction:row;
      flex-wrap:wrap;
      align-items:center;
      justify-content:flex-end;
      gap:5px;
      min-width:0;
      flex:1 1 auto;
    }
    .topbar-meta{
      display:flex;
      flex-wrap:nowrap;
      gap:4px;
      align-items:center;
      justify-content:flex-end;
      min-width:0;
    }
    .topbar-actions{
      display:flex;
      flex-wrap:wrap;
      gap:4px;
      align-items:center;
      justify-content:flex-end;
    }
    .topbar-actions .btn{
      min-height:30px;
      padding:4px 9px;
      font-size:.74rem;
      font-weight:750;
      border-radius:9px;
    }
    .badge{
      display:inline-flex;
      align-items:center;
      gap:5px;
      max-width:min(42vw,11rem);
      padding:3px 8px;
      border-radius:999px;
      font-size:.68rem;
      font-weight:750;
      letter-spacing:.01em;
      background:var(--accent-soft);
      border:1px solid rgba(96,165,250,.32);
      color:#dbeafe;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .badge::before{
      content:"";
      width:6px;height:6px;border-radius:50%;
      background:currentColor;opacity:.85;flex:0 0 auto;
    }
    .badge.gold{
      background:rgba(251,191,36,.12);
      border-color:rgba(251,191,36,.38);
      color:#fde68a;
    }
    .badge.warn{
      background:rgba(251,113,133,.12);
      border-color:rgba(251,113,133,.38);
      color:#fecdd3;
    }
    .badge.neutral{
      background:rgba(148,163,184,.1);
      border-color:rgba(148,163,184,.22);
      color:var(--muted);
    }
    .badge.neutral::before{display:none}

    /* Admin identity preview — click name in topbar */
    .identity-wrap{
      position:relative;
      display:inline-flex;
      max-width:min(48vw,12.5rem);
    }
    button.identity-badge{
      appearance:none;
      font:inherit;
      cursor:default;
      border:1px solid rgba(148,163,184,.22);
      max-width:100%;
    }
    button.identity-badge.identity-switchable{
      cursor:pointer;
      border-color:rgba(96,165,250,.4);
      background:rgba(96,165,250,.1);
      color:#dbeafe;
    }
    button.identity-badge.identity-switchable:hover,
    button.identity-badge.identity-switchable:focus-visible{
      outline:none;
      border-color:rgba(147,197,253,.7);
      background:rgba(96,165,250,.18);
    }
    button.identity-badge.identity-previewing{
      background:rgba(251,191,36,.14);
      border-color:rgba(251,191,36,.45);
      color:#fde68a;
    }
    button.identity-badge.identity-previewing::before{
      display:inline-block;
      content:"";
      width:6px;height:6px;border-radius:50%;
      background:currentColor;opacity:.9;flex:0 0 auto;
    }
    .identity-menu{
      position:absolute;
      top:calc(100% + 6px);
      right:0;
      z-index:80;
      width:min(86vw,16.5rem);
      padding:8px;
      border-radius:12px;
      border:1px solid var(--line);
      background:linear-gradient(180deg,rgba(18,26,42,.98),rgba(10,15,26,.98));
      box-shadow:0 12px 32px rgba(0,0,0,.45);
    }
    .identity-menu[hidden]{display:none !important}
    .identity-menu-hint{
      margin:0 4px 8px;
      font-size:.68rem;
      line-height:1.35;
      color:var(--muted);
    }
    .identity-menu-list{
      display:flex;
      flex-direction:column;
      gap:4px;
      max-height:min(52vh,18rem);
      overflow:auto;
    }
    .identity-option{
      display:flex;
      flex-direction:column;
      align-items:flex-start;
      gap:1px;
      width:100%;
      padding:8px 10px;
      border-radius:9px;
      border:1px solid transparent;
      background:rgba(255,255,255,.03);
      color:var(--text);
      font:inherit;
      text-align:left;
      cursor:pointer;
    }
    .identity-option:hover,
    .identity-option:focus-visible{
      outline:none;
      border-color:rgba(96,165,250,.35);
      background:rgba(96,165,250,.1);
    }
    .identity-option.is-active{
      border-color:rgba(251,191,36,.4);
      background:rgba(251,191,36,.1);
    }
    .identity-option-name{
      font-size:.82rem;
      font-weight:750;
    }
    .identity-option-meta{
      font-size:.68rem;
      color:var(--muted);
    }
    /* Note field sits under the board; interactive board-info is below it */
    .note-row{
      flex:0 0 auto;
      display:flex;
      flex-direction:column;
      gap:5px;
      padding:8px 2px 6px;
      margin-top:4px;
      border-top:1px solid var(--line-soft);
      background:linear-gradient(180deg,transparent,rgba(8,13,24,.55));
    }
    .note-row-label{
      margin:0;
      font-size:.68rem;
      font-weight:800;
      letter-spacing:.06em;
      text-transform:uppercase;
      color:var(--muted-2);
      padding:0 2px;
    }
    .note-row-fields{
      display:flex;
      gap:8px;
      align-items:center;
    }
    .note-row input{
      flex:1;
      min-height:42px;
      padding:0 12px;
      border-radius:var(--radius-sm);
      border:1px solid var(--line);
      background:#0b1220;
      color:var(--text);
      font-size:.88rem;
      transition:border-color .15s ease, box-shadow .15s ease, background .15s ease;
    }
    .note-row input:focus-visible{
      border-color:var(--accent);
      box-shadow:var(--focus);
    }
    /* Strong red nudge when selecting sud/truhla with empty note */
    .note-row.note-nudge input,
    .note-row.note-nudge-empty input{
      animation:noteNudge 1.1s ease;
      border-color:#fb7185;
      background:rgba(127,29,29,.35);
      box-shadow:
        0 0 0 3px rgba(251,113,133,.45),
        0 0 22px rgba(239,68,68,.55),
        inset 0 0 12px rgba(239,68,68,.15);
    }
    .note-row.note-nudge-empty .note-row-label{
      color:#fecdd3;
      animation:noteLabelFlash 1.1s ease;
    }
    .note-row.note-nudge:not(.note-nudge-empty) input{
      /* milder pulse when note already filled */
      animation:noteNudgeSoft .7s ease;
      border-color:rgba(251,113,133,.55);
      box-shadow:0 0 0 2px rgba(251,113,133,.25);
    }
    @keyframes noteNudge{
      0%{transform:translateX(0);box-shadow:0 0 0 0 rgba(239,68,68,.0)}
      12%{transform:translateX(-4px)}
      24%{transform:translateX(4px)}
      36%{transform:translateX(-3px)}
      48%{transform:translateX(3px)}
      60%{transform:translateX(-2px)}
      72%{transform:translateX(1px)}
      100%{
        transform:translateX(0);
        box-shadow:
          0 0 0 3px rgba(251,113,133,.45),
          0 0 22px rgba(239,68,68,.55),
          inset 0 0 12px rgba(239,68,68,.15);
      }
    }
    @keyframes noteNudgeSoft{
      0%,100%{transform:translateX(0)}
      20%{transform:translateX(-2px)}
      40%{transform:translateX(2px)}
      60%{transform:translateX(-1px)}
    }
    @keyframes noteLabelFlash{
      0%,100%{opacity:1}
      30%{opacity:.55}
      60%{opacity:1}
    }
    #undoPointBtn{
      flex:0 0 auto;
      min-height:42px;
      white-space:nowrap;
    }
    #portalStatus{
      margin:0 0 6px;
      padding:8px 10px;
      border-radius:10px;
      font-size:.82rem;
      line-height:1.35;
      display:none;
    }
    #portalStatus:not([hidden]):not(:empty){display:block}
    #portalStatus.error{
      background:rgba(251,113,133,.12);
      border:1px solid rgba(251,113,133,.35);
      color:#fecdd3;
    }
    #portalStatus.ok{
      background:rgba(52,211,153,.1);
      border:1px solid rgba(52,211,153,.3);
      color:#a7f3d0;
    }
    #adminStatus{
      margin:0;
      padding:8px 10px;
      border-radius:10px;
      font-size:.82rem;
      line-height:1.35;
    }
    #adminStatus.error{
      background:rgba(251,113,133,.12);
      border:1px solid rgba(251,113,133,.35);
      color:#fecdd3;
    }
    #adminStatus.ok{
      background:rgba(52,211,153,.1);
      border:1px solid rgba(52,211,153,.3);
      color:#a7f3d0;
    }
    /* Session-linked child (kid account) */
    .child-selected{outline:2px solid var(--accent);outline-offset:2px}
    /* Board pick for awarding (name / figure) */
    .child-board-selected{
      outline:2px solid #fbbf24;
      outline-offset:3px;
      box-shadow:0 0 0 4px rgba(251,191,36,.18),0 8px 18px rgba(0,0,0,.25);
    }
    .child-board-selected.child-selected{
      outline-color:#fbbf24;
      box-shadow:
        0 0 0 2px rgba(96,165,250,.45),
        0 0 0 5px rgba(251,191,36,.2),
        0 8px 18px rgba(0,0,0,.25);
    }
    #parentBtn.elevated{
      border-color:rgba(251,191,36,.55);
      color:#fde68a;
      background:rgba(251,191,36,.1);
    }

    /* Side sheets (admin / tasks / parent) */
    .side-panel{
      position:fixed;inset:0;z-index:110;display:none;
      background:rgba(3,6,12,.68);
      backdrop-filter:blur(6px);
      -webkit-backdrop-filter:blur(6px);
      align-items:flex-end;
      justify-content:center;
      padding:0;
      animation:sheetFade .18s ease;
    }
    .side-panel.open{display:flex}
    @keyframes sheetFade{
      from{opacity:0}
      to{opacity:1}
    }
    .side-sheet{
      width:min(440px,100%);
      max-height:min(92dvh,760px);
      background:
        radial-gradient(ellipse 80% 40% at 50% 0%,rgba(96,165,250,.08),transparent 55%),
        linear-gradient(180deg,#141c2e 0%,#0d1422 100%);
      border:1px solid var(--line);
      border-bottom:0;
      border-radius:22px 22px 0 0;
      box-shadow:0 -8px 40px rgba(0,0,0,.45);
      display:flex;
      flex-direction:column;
      min-height:0;
      overflow:hidden;
      animation:sheetUp .22s cubic-bezier(.2,.8,.2,1);
    }
    @keyframes sheetUp{
      from{transform:translateY(18px);opacity:.6}
      to{transform:translateY(0);opacity:1}
    }
    .side-sheet::before{
      content:"";
      display:block;
      width:40px;height:4px;
      margin:10px auto 0;
      border-radius:999px;
      background:rgba(255,255,255,.14);
      flex:0 0 auto;
    }
    .side-head{
      flex:0 0 auto;
      display:flex;
      align-items:flex-start;
      justify-content:space-between;
      gap:12px;
      padding:10px 16px 12px;
      border-bottom:1px solid var(--line-soft);
    }
    .side-head-text{min-width:0;display:flex;flex-direction:column;gap:2px}
    .side-head h2{
      margin:0;
      font-size:1.15rem;
      font-weight:800;
      letter-spacing:-.02em;
      line-height:1.2;
    }
    .side-sub{
      margin:0;
      font-size:.78rem;
      color:var(--muted);
      line-height:1.3;
    }
    .side-body{
      flex:1 1 auto;
      min-height:0;
      overflow:auto;
      padding:14px 16px calc(18px + env(safe-area-inset-bottom));
      display:flex;
      flex-direction:column;
      gap:14px;
      -webkit-overflow-scrolling:touch;
    }

    /* Segmented tabs */
    .seg-tabs{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:3px;
      padding:3px;
      border-radius:12px;
      background:rgba(0,0,0,.28);
      border:1px solid var(--line-soft);
      flex:0 0 auto;
    }
    .seg-tabs .admin-tab,
    .seg-tabs button{
      min-height:36px;
      border:0;
      border-radius:10px;
      background:transparent;
      color:var(--muted);
      font-size:.82rem;
      font-weight:750;
      padding:0 10px;
      box-shadow:none;
    }
    .seg-tabs .admin-tab.active,
    .seg-tabs button.active{
      background:#1e2d45;
      color:var(--text);
      box-shadow:var(--shadow-sm);
    }

    /* Admin: list → detail (no nested expanded mess) */
    .admin-shell{
      gap:10px !important;
    }
    .admin-view{
      display:flex;
      flex-direction:column;
      gap:12px;
      min-height:0;
    }
    .admin-view[hidden]{display:none !important}
    .admin-new-btn{
      min-height:44px !important;
      font-weight:800 !important;
      flex:0 0 auto;
    }
    .admin-back-btn{
      align-self:flex-start;
      min-height:36px !important;
      padding-left:8px !important;
      color:var(--accent) !important;
      font-weight:750 !important;
    }
    .admin-view-title{
      margin:0;
      font-size:1.05rem;
      font-weight:800;
      letter-spacing:-.02em;
    }
    .admin-list-hint{
      margin:0;
      font-size:.75rem;
    }
    .profile-rows{
      display:flex;
      flex-direction:column;
      gap:6px;
    }
    .profile-row-wrap{
      display:flex;
      align-items:stretch;
      gap:6px;
    }
    .profile-row-wrap.is-inactive{opacity:.55}
    .profile-row{
      display:flex;
      align-items:center;
      gap:10px;
      flex:1 1 auto;
      min-width:0;
      text-align:left;
      padding:10px 10px;
      min-height:56px;
      border-radius:14px;
      border:1px solid var(--line-soft);
      background:linear-gradient(180deg,rgba(18,26,40,.98),rgba(10,16,28,.98));
      color:var(--text);
      cursor:pointer;
      font:inherit;
      transition:border-color .12s,background .12s;
    }
    .profile-row:active{transform:scale(.99)}
    .profile-row:hover,
    .profile-row:focus-visible{
      border-color:rgba(96,165,250,.4);
      outline:none;
    }
    .profile-row .entity-avatar{
      width:40px;height:40px;border-radius:12px;
    }
    .profile-row-main{
      flex:1 1 auto;
      min-width:0;
      display:flex;
      flex-direction:column;
      gap:2px;
    }
    .profile-row-name{
      font-size:.95rem;
      font-weight:780;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .profile-row-meta{
      font-size:.72rem;
      color:var(--muted);
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .profile-row-chevron{
      flex:0 0 auto;
      color:var(--muted-2);
      font-size:1.25rem;
      line-height:1;
      padding:0 2px;
    }
    .profile-row-del{
      flex:0 0 auto;
      min-width:44px;
      min-height:56px !important;
      padding:0 10px !important;
      border-radius:14px !important;
      font-size:1rem;
      font-weight:800;
    }
    .admin-confirm-bar{
      display:flex;
      flex-direction:column;
      gap:10px;
      padding:12px;
      border-radius:14px;
      border:1px solid rgba(251,113,133,.4);
      background:rgba(251,113,133,.1);
    }
    .admin-confirm-bar[hidden]{display:none !important}
    .admin-confirm-text{
      margin:0;
      font-size:.88rem;
      font-weight:650;
      color:#fecdd3;
      line-height:1.35;
    }
    .admin-confirm-actions{
      display:flex;
      gap:8px;
    }
    .admin-confirm-actions .btn{flex:1 1 auto}
    .profile-create-form,
    .profile-edit-form{
      display:flex;
      flex-direction:column;
      gap:12px;
    }
    .profile-create-btn{
      min-height:48px !important;
      font-size:1rem !important;
      font-weight:800 !important;
      margin-top:4px;
    }
    .avatar-fields{
      display:flex;
      flex-direction:column;
      gap:12px;
      padding:12px;
      border-radius:12px;
      border:1px solid var(--line-soft);
      background:rgba(0,0,0,.22);
    }
    .avatar-fields[hidden]{display:none !important}
    .color-field{
      display:flex;
      align-items:center;
      gap:12px;
      min-height:48px;
      padding:6px 12px 6px 6px;
      border-radius:12px;
      border:1px solid var(--line);
      background:#0a1220;
    }
    .color-field input[type="color"]{
      -webkit-appearance:none;
      appearance:none;
      width:56px;
      min-width:56px;
      height:40px;
      min-height:40px;
      padding:0;
      border:2px solid rgba(255,255,255,.2);
      border-radius:10px;
      background:transparent;
      cursor:pointer;
      flex:0 0 auto;
    }
    .color-field input[type="color"]::-webkit-color-swatch-wrapper{padding:0}
    .color-field input[type="color"]::-webkit-color-swatch{
      border:0;
      border-radius:8px;
    }
    .color-field input[type="color"]::-moz-color-swatch{
      border:0;
      border-radius:8px;
    }
    .color-hex{
      font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
      font-size:.88rem;
      font-weight:700;
      color:var(--text);
      letter-spacing:.04em;
      text-transform:uppercase;
    }
    .form-grid{
      display:grid;
      gap:12px;
    }
    .form-grid.two{
      grid-template-columns:1fr 1fr;
    }
    .form-grid .span-2{grid-column:1 / -1}
    input[type="number"].form-control,
    .field input[type="number"]{
      min-height:44px;
      font-size:1rem;
      font-variant-numeric:tabular-nums;
    }
    .side-sub{font-size:.75rem}

    .perm-block{
      display:flex;
      flex-direction:column;
      gap:8px;
    }
    .perm-block-title{
      margin:0;
      font-size:.68rem;
      font-weight:800;
      letter-spacing:.06em;
      text-transform:uppercase;
      color:var(--muted-2);
    }
    .perm-grid{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:6px;
    }
    .perm-grid label{
      display:flex;
      align-items:flex-start;
      gap:8px;
      margin:0;
      padding:8px 9px;
      border-radius:10px;
      border:1px solid var(--line-soft);
      background:rgba(0,0,0,.18);
      font-size:.76rem;
      font-weight:650;
      color:var(--muted);
      line-height:1.25;
      cursor:pointer;
    }
    .perm-grid label:has(input:checked){
      border-color:rgba(96,165,250,.4);
      background:var(--accent-soft);
      color:#dbeafe;
    }
    .perm-grid input{width:auto;min-height:0;margin-top:2px;accent-color:var(--accent);flex:0 0 auto}

    /* Entity cards */
    .entity-list{
      display:flex;
      flex-direction:column;
      gap:10px;
    }
    .list-section-title{
      display:flex;
      align-items:baseline;
      justify-content:space-between;
      gap:8px;
      margin:2px 0 0;
      font-size:.68rem;
      font-weight:800;
      letter-spacing:.07em;
      text-transform:uppercase;
      color:var(--muted-2);
    }
    .list-count{
      font-weight:700;
      letter-spacing:0;
      text-transform:none;
      color:var(--muted);
      font-size:.72rem;
    }
    .entity-card{
      border:1px solid var(--line-soft);
      border-radius:var(--radius);
      background:linear-gradient(180deg,rgba(18,26,40,.95),rgba(10,16,28,.95));
      padding:12px 12px 10px;
      display:flex;
      flex-direction:column;
      gap:10px;
    }
    .entity-card.is-inactive{
      opacity:.72;
      border-style:dashed;
    }
    .entity-head{
      display:flex;
      align-items:flex-start;
      justify-content:space-between;
      gap:10px;
    }
    .entity-identity{
      display:flex;
      align-items:center;
      gap:10px;
      min-width:0;
    }
    .entity-avatar{
      width:36px;height:36px;
      border-radius:11px;
      display:grid;place-items:center;
      font-size:.85rem;
      font-weight:800;
      color:#0b1220;
      background:linear-gradient(135deg,#93c5fd,#60a5fa);
      flex:0 0 auto;
      text-transform:uppercase;
    }
    .entity-avatar.swatch{
      box-shadow:inset 0 0 0 2px rgba(255,255,255,.2);
      color:transparent;
      font-size:0;
    }
    .entity-title{
      margin:0;
      font-size:.95rem;
      font-weight:780;
      line-height:1.2;
      letter-spacing:-.01em;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .entity-sub{
      margin:2px 0 0;
      font-size:.75rem;
      color:var(--muted);
      line-height:1.3;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .status-pill{
      display:inline-flex;
      align-items:center;
      gap:5px;
      padding:3px 8px;
      border-radius:999px;
      font-size:.68rem;
      font-weight:750;
      flex:0 0 auto;
      background:rgba(52,211,153,.12);
      border:1px solid rgba(52,211,153,.32);
      color:#a7f3d0;
    }
    .status-pill.off{
      background:rgba(148,163,184,.08);
      border-color:rgba(148,163,184,.22);
      color:var(--muted);
    }
    .status-pill::before{
      content:"";
      width:6px;height:6px;border-radius:50%;
      background:currentColor;
    }
    .chip-row{
      display:flex;
      flex-wrap:wrap;
      gap:5px;
    }
    .chip{
      display:inline-flex;
      align-items:center;
      padding:3px 8px;
      border-radius:999px;
      font-size:.68rem;
      font-weight:700;
      background:rgba(148,163,184,.1);
      border:1px solid rgba(148,163,184,.16);
      color:var(--muted);
    }
    .chip.accent{
      background:var(--accent-soft);
      border-color:rgba(96,165,250,.28);
      color:#bfdbfe;
    }
    .chip.gold{
      background:rgba(251,191,36,.1);
      border-color:rgba(251,191,36,.28);
      color:#fde68a;
    }
    .chip.warn{
      background:rgba(251,113,133,.1);
      border-color:rgba(251,113,133,.28);
      color:#fecdd3;
    }
    .entity-actions{
      display:flex;
      flex-wrap:wrap;
      gap:6px;
      padding-top:2px;
      border-top:1px solid var(--line-soft);
    }
    .entity-actions .btn{flex:1 1 auto;min-width:fit-content}
    .empty-state{
      text-align:center;
      padding:28px 16px;
      border:1px dashed var(--line);
      border-radius:var(--radius);
      background:rgba(0,0,0,.15);
    }
    .empty-state p{margin:0;color:var(--muted);font-size:.88rem;line-height:1.4}
    .empty-state .empty-icon{
      font-size:1.6rem;
      margin-bottom:8px;
      opacity:.7;
    }

    /* Tasks */
    .panel-section{display:flex;flex-direction:column;gap:10px}
    .task-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
    .task-item-block{
      border:1px solid var(--line-soft);
      border-radius:var(--radius);
      background:linear-gradient(180deg,rgba(18,26,40,.95),rgba(10,16,28,.95));
      overflow:hidden;
    }
    .task-item{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
      padding:12px;
    }
    .task-item-block > .task-item{border:0;background:transparent;border-radius:0}
    .task-item > div:first-child{min-width:0;flex:1}
    .task-item strong{
      display:block;
      font-size:.9rem;
      font-weight:750;
      line-height:1.25;
      margin-bottom:3px;
    }
    .task-actions{display:flex;gap:6px;flex-wrap:wrap;flex:0 0 auto;align-items:center}
    .task-edit-form{
      display:flex;
      flex-direction:column;
      gap:10px;
      padding:0 12px 12px;
      border-top:1px solid var(--line-soft);
    }
    .task-edit-form[hidden]{display:none !important}
    .task-edit-form .field{margin-top:8px}
    .task-create.admin-form,
    #taskCreateForm:not([hidden]){
      display:flex;
      flex-direction:column;
      gap:10px;
      padding:12px;
      border:1px solid var(--line-soft);
      border-radius:var(--radius);
      background:rgba(8,14,24,.45);
    }
    #taskCreateForm label{margin:0}
    [hidden]{display:none !important}

    /* Parent / gesture */
    .unlock-card{
      padding:14px;
      border-radius:var(--radius);
      border:1px solid var(--line-soft);
      background:rgba(8,14,24,.45);
      display:flex;
      flex-direction:column;
      gap:12px;
      text-align:center;
    }
    .unlock-card .muted{margin:0;line-height:1.4}
    .pattern-pad{
      display:grid;
      grid-template-columns:repeat(3,1fr);
      gap:14px;
      width:min(200px,58vw);
      margin:4px auto 0;
    }
    .pattern-cell{
      aspect-ratio:1;
      border-radius:50%;
      border:2px solid rgba(148,163,184,.28);
      background:rgba(10,18,32,.9);
      color:var(--text);
      font-weight:750;
      font-size:.85rem;
      transition:background .12s,border-color .12s,transform .1s;
    }
    .pattern-cell:active{transform:scale(.94)}
    .pattern-cell.on{
      background:linear-gradient(145deg,#3b82f6,#2563eb);
      border-color:#93c5fd;
      box-shadow:0 0 0 3px rgba(59,130,246,.25);
    }
    .gesture-actions{
      display:flex;
      gap:8px;
      justify-content:center;
      flex-wrap:wrap;
    }
    .parent-chip{
      border:1px solid var(--line);
      background:#0b1220;
      color:var(--text);
      border-radius:999px;
      padding:8px 12px;
      margin:0 6px 6px 0;
    }
    .parent-chip.selected{border-color:var(--accent);background:rgba(59,130,246,.2)}

    .muted{color:var(--muted);font-size:.85rem;line-height:1.4}
    .login-row{display:flex;align-items:center;gap:8px;font-size:.9rem;color:var(--muted)}
    .admin-form{display:flex;flex-direction:column;gap:10px}
    code{font-size:.75rem;word-break:break-all}

    @media (min-width:700px){
      .side-panel{
        align-items:center;
        padding:24px;
      }
      .side-sheet{
        border-radius:var(--radius-lg);
        border-bottom:1px solid var(--line);
        max-height:min(84dvh,720px);
        width:min(460px,100%);
      }
      .side-sheet::before{display:none}
      .side-head{padding-top:16px}
    }
    @media (max-width:420px){
      .form-grid.two{grid-template-columns:1fr}
      .form-grid .span-2{grid-column:auto}
      .perm-grid{grid-template-columns:1fr}
      .topbar-actions .btn{font-size:.7rem;padding:4px 7px;min-height:28px}
      .badge{max-width:min(36vw,8.5rem);font-size:.64rem;padding:2px 7px}
      #gameScreen .logo{width:40px;height:40px}
      #gameScreen .logo-mark{width:30px;height:30px}
      #gameScreen .wordmark{width:clamp(4.2rem,14vw,5.2rem)}
    }

/* Extracted from former inline styles (CSP: no style attributes) */
.beam { --tilt: 0deg; }
.treasure-full-title {
  font-size: clamp(1.4rem, 6vw, 2.5rem);
}
.treasure-logout {
  margin-top: 7px;
}
.muted-help {
  margin: 4px 0 0;
  font-size: 0.75rem;
}
.chip-row-spaced {
  margin-top: 6px;
}
.hist-action-empty {
  font-size: 0.75rem;
}
