/* MassGrader standalone interface */
.massgrader-window{width:min(1120px,100%);max-height:calc(100dvh - 28px);display:flex;flex-direction:column;gap:13px;overflow:auto;text-align:left;padding:26px 22px 20px}
.massgrader-window h2,.massgrader-window>.case-subtitle{text-align:center;margin:0;flex:0 0 auto}
.massgrader-window>.case-subtitle{margin-bottom:2px}
.mg-top-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(210px,.82fr) minmax(0,1fr);gap:12px;align-items:stretch}
.mg-pane,.mg-gauge-panel,.mg-list-pane{min-width:0;border:1px solid #d0ccc4;border-radius:8px;background:rgba(238,236,232,.72);padding:11px}
.mg-pane{display:flex;flex-direction:column;gap:9px}
.mg-pane-heading,.mg-list-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;color:#514d47;font-size:11px;letter-spacing:.07em}
.mg-pane-heading span{font-size:10px;letter-spacing:0;color:#8a847b}
.mg-drop-slot{position:relative;display:flex;min-height:138px;align-items:center;justify-content:center;gap:9px;padding:10px;border:1px dashed #aaa399;border-radius:7px;background:rgba(220,216,209,.42);color:#8a847b;font-size:11px;text-align:center;transition:border-color .2s,background .2s,box-shadow .2s}
.mg-drop-slot.is-over{border-color:#8c754b;background:rgba(205,183,139,.2);box-shadow:0 0 0 3px rgba(174,145,93,.13)}
.mg-drop-slot.has-card{border-style:solid;border-color:#c3b9a7;background:#eeece8;color:#504c46}
.mg-drop-slot img{width:76px;height:92px;object-fit:contain;background:#e5e2dd;border-radius:4px}.mg-clear-slot{position:absolute;top:5px;left:5px;width:22px;height:22px;border:0;border-radius:50%;background:rgba(125,117,104,.18);color:#6b6257;font-size:17px;line-height:1;cursor:pointer}.mg-clear-slot:hover{background:rgba(125,117,104,.3)}
.mg-drop-info{min-width:0;display:flex;flex-direction:column;gap:5px;text-align:left}
.mg-drop-info strong{font-size:12px;overflow-wrap:anywhere}
.mg-drop-info small{font-size:10px;color:#817b72}
.mg-drop-qty{position:absolute;top:6px;right:6px;padding:4px 6px;border-radius:4px;background:#6c655b;color:#fff;font-size:10px;font-weight:700}
.mg-gauge-panel{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;min-width:0;padding:9px}
.mg-gauge{position:relative;display:block;width:min(100%,260px);height:178px;overflow:visible;flex:0 0 auto;margin:0 auto}
.mg-gauge-svg{position:absolute;inset:0;width:100%;height:150px;overflow:visible}
.mg-gauge-track,.mg-gauge-green{fill:none;stroke-width:16;stroke-linecap:round}
.mg-gauge-track{stroke:#c94d48}
.mg-gauge-green{stroke:#28a66d;stroke-dasharray:0 314.16;transition:stroke-dasharray .35s ease}
.mg-gauge-needle{transform-box:view-box;transform-origin:120px 125px;transform:rotate(-87deg);transition:transform 2.5s cubic-bezier(.12,.72,.14,1);filter:drop-shadow(0 1px 2px rgba(35,25,20,.4))}
.mg-gauge-needle path{fill:none;stroke:#7f2926;stroke-width:5;stroke-linecap:round}
.mg-gauge-hub{fill:#51483d;stroke:#e9e2d5;stroke-width:2}
.mg-gauge-readout{position:absolute;left:0;right:0;bottom:15px;text-align:center;color:#514d47;font-size:24px;font-weight:800;font-variant-numeric:tabular-nums}
.mg-gauge-caption{position:absolute;left:0;right:0;bottom:0;text-align:center;color:#8a847b;font-size:8px;letter-spacing:.18em}
.mg-quantity-control{display:flex;align-items:center;justify-content:center;gap:7px;color:#716a60;font-size:10px;font-weight:700}
.mg-quantity-control select{min-width:54px;height:27px;padding:3px 7px;border:1px solid #c9c4bb;border-radius:6px;background:#eeece8;color:#514d47;font:700 11px Arial,Helvetica,sans-serif}
.mg-quantity-control select:disabled{opacity:.5}

.mg-start{min-width:150px;font-weight:800;letter-spacing:.08em;background:#d8d1c5}
.mg-start:disabled{opacity:.42;cursor:not-allowed}
.mg-status{min-height:28px;margin:0;color:#77736e;font-size:10px;line-height:1.4;text-align:center}
.mg-lower-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;min-height:0}
.mg-list-pane{display:flex;flex-direction:column;gap:9px;min-height:0}
.mg-list-heading input,.mg-list-heading select{height:29px;min-width:0;padding:5px 8px;border:1px solid #cbc6be;border-radius:6px;background:#eeece8;color:#514d47;font:11px Arial,Helvetica,sans-serif;outline:none}.mg-list-heading input{width:min(38%,180px)}.mg-list-heading select{width:124px;max-width:42%;cursor:pointer}
.mg-modes{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.mg-modes button{min-height:30px;padding:6px 9px;border:1px solid #c9c4bb;border-radius:999px;background:#e2ded7;color:#5b554d;font:700 10px Arial,Helvetica,sans-serif;cursor:pointer;transition:background .16s,border-color .16s,transform .16s}
.mg-modes button:hover{background:#f2eee6;border-color:#a99b80}
.mg-modes button:active{transform:scale(.96)}
.mg-modes button:disabled{opacity:.4;cursor:not-allowed}
.mg-card-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(88px,1fr));gap:7px;max-height:260px;overflow:auto;align-content:start;padding:2px;scrollbar-width:thin}
.mg-card{position:relative;display:flex;min-width:0;flex-direction:column;gap:4px;padding:6px;border:1px solid #d0ccc4;border-radius:6px;background:#eeece8;color:#514d47;cursor:grab;text-align:left;transition:border-color .15s,opacity .15s,transform .15s}
.mg-card:hover{border-color:#a99b80;transform:translateY(-1px)}
.mg-card:active{cursor:grabbing}
.mg-card.selected{border-color:#9a8050;box-shadow:0 0 0 2px rgba(174,145,93,.18)}
.mg-card img{display:block;width:100%;height:70px;object-fit:contain;background:#e5e2dd;border-radius:3px;pointer-events:none}
.mg-card strong{font-size:9px;line-height:1.25;overflow-wrap:anywhere}
.mg-card small{font-size:8px;color:#827b72}
.mg-card-chance{align-self:flex-start;padding:3px 5px;border-radius:4px;background:#e3e0d9;color:#686157;font-size:9px;font-weight:800;font-variant-numeric:tabular-nums}
.mg-card-chance.good{background:#d8eadf;color:#27764d}
.mg-card-chance.unavailable{background:#e6e2dc;color:#9a9389}
.mg-more{align-self:center;min-height:29px;padding:5px 12px;font-size:10px}
.mg-prize-area[hidden]{display:none!important}.mg-prize-area{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px;border:1px solid #b6a77e;border-radius:8px;background:linear-gradient(135deg,rgba(237,224,184,.5),rgba(238,236,232,.85));animation:mg-prize-appear .55s cubic-bezier(.2,.8,.2,1) both}
.mg-prize-heading{font-size:13px;font-weight:900;letter-spacing:.12em;color:#96702d}
.mg-prize-card{display:flex;align-items:center;justify-content:center;gap:12px;flex-wrap:wrap}
.mg-prize-item{position:relative;width:104px;padding:7px;border:1px solid #c7b47c;border-radius:6px;background:#f4f0e5;text-align:center;box-shadow:0 5px 18px rgba(92,69,29,.12)}
.mg-prize-item img{width:100%;height:105px;object-fit:contain;background:#e7e1d4;border-radius:3px}
.mg-prize-item strong{display:block;margin-top:5px;font-size:10px;color:#51442d;overflow-wrap:anywhere}
.mg-prize-item small{display:block;margin-top:3px;color:#8d7548;font-size:9px}
.mg-prize-count{position:absolute;top:5px;right:5px;padding:4px 6px;border-radius:4px;background:#7b6335;color:#fff;font-size:10px;font-weight:800}
.mg-claim{min-width:180px;background:#d9c58f;border-color:#b9a36a;color:#4e3c1d;font-weight:900;letter-spacing:.08em}
.massgrader-window.is-rolling .mg-gauge-needle{transition:transform 2.5s cubic-bezier(.12,.72,.14,1)}
.massgrader-window.is-burned .mg-gauge{animation:mg-burn 1.1s ease-in forwards}
.massgrader-window.is-burned .mg-gauge:after{content:"";position:absolute;inset:10px;border-radius:50%;background:radial-gradient(circle at 12% 22%,#d8a16a 0 2px,transparent 3px),radial-gradient(circle at 82% 18%,#d8a16a 0 3px,transparent 4px),radial-gradient(circle at 91% 62%,#b96b4c 0 2px,transparent 3px),radial-gradient(circle at 24% 78%,#d8a16a 0 3px,transparent 4px),radial-gradient(circle at 61% 12%,#c97853 0 2px,transparent 3px),radial-gradient(circle at 72% 86%,#d8a16a 0 2px,transparent 3px),radial-gradient(circle,rgba(50,35,31,.72),rgba(90,35,30,.18) 45%,transparent 70%);animation:mg-ash 1.1s ease-out forwards}
@keyframes mg-prize-appear{from{opacity:0;transform:translateY(12px) scale(.94)}to{opacity:1;transform:translateY(0) scale(1)}}
@keyframes mg-burn{0%{filter:none;transform:scale(1);opacity:1}35%{filter:brightness(1.5) sepia(.7);transform:scale(1.03)}100%{filter:grayscale(1) brightness(.25) blur(3px);transform:scale(.75) rotate(-8deg);opacity:0}}
@keyframes mg-ash{0%{opacity:0;transform:scale(.4)}40%{opacity:.85;transform:scale(1)}100%{opacity:0;transform:scale(1.5)}}
@keyframes mg-needle-break{to{transform:rotate(155deg) translateY(12px);opacity:0}}
html[data-theme="dark"] .massgrader-window{background:#242522;border-color:#484943;color:#e7e4de}
html[data-theme="dark"] .mg-pane,html[data-theme="dark"] .mg-gauge-panel,html[data-theme="dark"] .mg-list-pane{background:#2a2b27;border-color:#484943}
html[data-theme="dark"] .mg-pane-heading,html[data-theme="dark"] .mg-list-heading{color:#e0dcd4}
html[data-theme="dark"] .mg-pane-heading span,html[data-theme="dark"] .mg-status{color:#aaa69e}
html[data-theme="dark"] .mg-drop-slot{background:#20211e;border-color:#5b5c54;color:#aaa69e}
html[data-theme="dark"] .mg-drop-slot.has-card{background:#30312d;border-color:#75694f}
html[data-theme="dark"] .mg-drop-info strong,html[data-theme="dark"] .mg-gauge-readout{color:#f0ece4}
html[data-theme="dark"] .mg-drop-info small{color:#aaa69e}html[data-theme="dark"] .mg-quantity-control{color:#aaa69e}
html[data-theme="dark"] .mg-gauge-readout{color:#f0ece4}html[data-theme="dark"] .mg-quantity-control{color:#aaa69e}
html[data-theme="dark"] .mg-list-heading input,html[data-theme="dark"] .mg-list-heading select,html[data-theme="dark"] .mg-quantity-control select{background:#20211e;border-color:#4b4c46;color:#e7e4de}
html[data-theme="dark"] .mg-modes button{background:#363730;border-color:#55564e;color:#e0dcd4}
html[data-theme="dark"] .mg-modes button:hover{background:#414239;border-color:#8c8067}
html[data-theme="dark"] .mg-card{background:#30312d;border-color:#4b4c46;color:#e0dcd4}
html[data-theme="dark"] .mg-card img{background:#20211e}
html[data-theme="dark"] .mg-card small{color:#aaa69e}
html[data-theme="dark"] .mg-card-chance{background:#44453e;color:#d0ccc4}
html[data-theme="dark"] .mg-card-chance.good{background:#244b36;color:#a8e0bd}
html[data-theme="dark"] .mg-card-chance.unavailable{background:#3a3b36;color:#88877f}
html[data-theme="dark"] .mg-prize-area{background:linear-gradient(135deg,rgba(91,69,32,.34),rgba(42,43,39,.92));border-color:#8e794b}
html[data-theme="dark"] .mg-prize-item{background:#363329;border-color:#8e794b}
html[data-theme="dark"] .mg-prize-item img{background:#25241f}
html[data-theme="dark"] .mg-prize-item strong{color:#f0e5c8}
html[data-theme="dark"] .mg-prize-item small{color:#d4bf8b}
html[data-theme="dark"] .mg-claim{background:#6c5930;border-color:#a58c52;color:#fff0c7}
@media(max-width:760px){.massgrader-window{padding:25px 12px 14px;gap:9px}.mg-top-grid{grid-template-columns:1fr 1fr}.mg-gauge-panel{grid-column:1/-1;grid-row:2}.mg-pane{padding:8px}.mg-drop-slot{min-height:110px;flex-direction:column}.mg-drop-slot img{width:64px;height:70px}.mg-lower-grid{grid-template-columns:1fr}.mg-card-list{max-height:220px;grid-template-columns:repeat(auto-fill,minmax(76px,1fr))}.mg-card img{height:62px}}
@media(max-width:420px){.mg-top-grid{grid-template-columns:1fr}.mg-gauge-panel{grid-column:auto;grid-row:auto;order:3}.mg-pane:first-child{order:1}.mg-pane:last-child{order:2}.mg-drop-slot{min-height:90px;flex-direction:row}.mg-list-heading{align-items:flex-start;flex-direction:column}.mg-list-heading input,.mg-list-heading select{width:100%;max-width:none}.mg-modes button{padding:6px 7px;font-size:9px}.mg-card-list{grid-template-columns:repeat(3,minmax(0,1fr))}.mg-gauge{width:260px;max-width:100%}.mg-quantity-control{justify-content:space-between}}
@media(prefers-reduced-motion:reduce){.mg-prize-area,.massgrader-window.is-burned .mg-gauge,.massgrader-window.is-burned .mg-gauge:after,.massgrader-window.is-burned .mg-gauge-needle{animation:none!important}.mg-gauge-needle{transition:none!important}}

/* Mobile-only MassGrader: compact portrait layout */
@media (max-width: 600px){
  .massgrader-window{
    width:100%;
    height:100dvh;
    max-height:100dvh;
    max-width:none;
    padding:48px 10px calc(14px + env(safe-area-inset-bottom));
    gap:10px;
    border-radius:0;
    overflow-x:hidden;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
  }
  .massgrader-window h2{font-size:21px}
  .massgrader-window>.case-subtitle{font-size:11px;line-height:1.35;margin:0 24px 2px}
  .mg-top-grid{
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    gap:8px;
    align-items:stretch;
  }
  .mg-pane{
    min-width:0;
    padding:8px;
    gap:7px;
    border-radius:9px;
  }
  .mg-pane:first-child{order:1}
  .mg-pane:last-child{order:2}
  .mg-pane-heading{font-size:10px;letter-spacing:.035em;align-items:flex-start;flex-direction:column;gap:2px}
  .mg-pane-heading span{font-size:9px}
  .mg-drop-slot{
    min-height:106px;
    padding:7px 5px;
    flex-direction:column;
    gap:5px;
    font-size:10px;
    line-height:1.25;
    overflow-wrap:anywhere;
  }
  .mg-drop-slot img{width:54px;height:58px}
  .mg-drop-info{text-align:center;align-items:center;gap:3px}
  .mg-drop-info strong{font-size:10px}
  .mg-drop-info small{font-size:9px}
  .mg-drop-qty{top:4px;right:4px;font-size:9px}
  .mg-quantity-control{justify-content:space-between;gap:4px;font-size:9px;flex-wrap:wrap}
  .mg-quantity-control select{min-width:48px;height:30px}
  .mg-gauge-panel{
    order:3;
    grid-column:1/-1;
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(112px,.8fr);
    grid-template-rows:auto auto;
    gap:3px 8px;
    padding:5px 10px;
    align-items:center;
  }
  .mg-gauge{grid-column:1;grid-row:1/3;width:min(100%,220px);height:138px}
  .mg-gauge-svg{height:116px}
  .mg-gauge-readout{bottom:12px;font-size:21px}
  .mg-gauge-caption{font-size:7px}
  .mg-start{grid-column:2;grid-row:1;min-width:0;width:100%;min-height:42px;padding:9px 6px;font-size:12px}
  .mg-status{grid-column:2;grid-row:2;min-height:0;font-size:9px;line-height:1.3;margin:0}
  .mg-lower-grid{
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    gap:8px;
    min-height:0;
    align-items:start;
  }
  .mg-list-pane{min-width:0;padding:8px;gap:7px;border-radius:9px}
  .mg-list-heading{align-items:stretch;flex-direction:column;gap:6px;font-size:10px}
  .mg-list-heading input,.mg-list-heading select{width:100%;max-width:none;height:34px;font-size:11px}
  .mg-modes{gap:4px}
  .mg-modes button{flex:1 1 calc(50% - 4px);min-height:34px;padding:6px 5px;font-size:9px;line-height:1.2}
  .mg-card-list{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:6px;
    max-height: min(34dvh, 260px);
    overflow-y:auto;
    overscroll-behavior:contain;
    padding:2px;
  }
  .mg-card{padding:5px;gap:4px;min-height:0;cursor:pointer;touch-action:manipulation}
  .mg-card img{height:66px}
  .mg-card strong{font-size:9px;line-height:1.2}
  .mg-card small{font-size:8px}
  .mg-card-chance{font-size:8px;padding:3px 4px}
  .mg-more{min-height:34px;width:100%}
  .mg-prize-area{padding:10px;gap:8px}
  .mg-prize-item{width:88px}
  .mg-prize-item img{height:88px}
  .mg-claim{min-height:42px;width:100%}
}
@media (max-width:380px){
  .massgrader-window{padding-left:8px;padding-right:8px}
  .mg-top-grid,.mg-lower-grid{gap:6px}
  .mg-pane,.mg-list-pane{padding:6px}
  .mg-drop-slot{min-height:98px;font-size:9px}
  .mg-gauge-panel{grid-template-columns:minmax(0,1fr) minmax(100px,.75fr);padding:4px 7px}
  .mg-card-list{grid-template-columns:repeat(2,minmax(0,1fr));max-height:32dvh}
  .mg-card img{height:58px}
}
