/* =======================================================================
   SSA Super Dice Roller - Accessible CSS (WCAG 2.1 AA)
   Scope EVERYTHING under .ssa-dice to avoid theme bleed.
   ======================================================================= */

/* -- Tokens ------------------------------------------------------------ */
:root { --ssa-dice-accent:#37c7ab; }

.ssa-dice{
  --bg:#f4f8ff;
  --card:#ffffff;
  --text:#112033;
  --muted:#48617e;
  --accent:#0f62fe;
  --ring:#69a3ff;

  /* dice hues */
  --d2:#fbbf24; --d4:#f59e0b; --d6:#9b7ede; --d8:#25c6da;
  --d10:#56d0e9; --d12:#3b82f6; --d20:#d81b60; --d100:#94a3b8;

  font-family:"Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
  color:var(--text);
  background:linear-gradient(165deg,#f9fbff 0%,#edf3fd 100%);
  border:1px solid #d8e3f3;
  border-radius:22px;
  padding:16px;
  box-shadow:0 14px 36px rgba(16,39,71,.12);
  max-width:980px; margin:20px auto;
}

@media (prefers-color-scheme:light){
  .ssa-dice{
    --bg:#f4f8ff;
    --card:#ffffff;
    --text:#112033;
    --muted:#48617e;
    --accent:#0f62fe;
    --ring:#69a3ff;
    background:linear-gradient(165deg,#f9fbff 0%,#edf3fd 100%);
  }
}

.ssa-dice *{ box-sizing:border-box }

/* -- Header ------------------------------------------------------------ */
/* -- Header ------------------------------------------------------------ */
.ssa-dice__logo{ font-size:28px }
.ssa-dice__title{ font-size:22px; line-height:1.15; margin:0 }
.ssa-dice__subtitle{ color:var(--muted); font-size:12px }

/* -- Quick bar & mode -------------------------------------------------- */
.ssa-dice__quickbar{ display:flex; flex-wrap:wrap; gap:8px; background:var(--card); padding:10px; border-radius:14px; margin:10px 0 }
.ssa-dice__spacer{ flex:1 }

.ssa-dice .qb,
.ssa-dice .ssa-chip,
.ssa-dice .ssa-mode-btn,
.ssa-dice .ssa-btn{
  background:#0f172a; color:var(--text);
  border:2px solid #3a4a66;
  border-radius:12px;
  padding:10px 12px;
  min-height:44px;                 /* 44px target */
  cursor:pointer; font-size:14px;
}

@media (prefers-color-scheme:light){
  .ssa-dice .qb, .ssa-dice .ssa-chip, .ssa-dice .ssa-mode-btn, .ssa-dice .ssa-btn{
    background:#f8fafc; color:var(--text); border-color:#cbd5e1;
  }
}

.ssa-dice .ssa-mode{ display:flex; gap:6px; align-items:center; margin-right:8px }
.ssa-dice .ssa-mode-btn.is-active{
  outline:3px solid var(--ring); outline-offset:2px;
  background:rgba(255,255,255,.08);
}
@media (prefers-color-scheme:light){
  .ssa-dice .ssa-mode-btn.is-active{ background:rgba(0,0,0,.06) }
}

/* focus ring for all clickable bits */
.ssa-dice .qb:hover,
.ssa-dice .ssa-chip:hover,
.ssa-dice .ssa-mode-btn:hover,
.ssa-dice .ssa-btn:hover{ outline:3px solid var(--ring) }

.ssa-dice .qb:focus-visible,
.ssa-dice .ssa-chip:focus-visible,
.ssa-dice .ssa-mode-btn:focus-visible,
.ssa-dice .ssa-btn:focus-visible{ outline:3px solid var(--ring); outline-offset:2px }

/* Advantage radios (make label a big target) */
.ssa-dice__advwrap{ display:flex; align-items:center; gap:10px }
.ssa-dice__adv{
  display:flex; align-items:center; gap:8px; color:var(--muted); font-size:13px;
  padding:6px 10px; border-radius:8px;
}
.ssa-dice__adv input{ inline-size:1rem; block-size:1rem }

/* -- Expression row ---------------------------------------------------- */
.ssa-dice__row{ display:grid; grid-template-columns:1fr auto auto auto auto; gap:8px; margin:8px 0 }
.ssa-dice .ssa-input,
.ssa-dice .ssa-num,
.ssa-dice select{
  width:100%; min-height:46px;
  background:#0b1220; color:var(--text);
  border:2px solid #3a4a66; border-radius:12px; padding:10px 12px;
}
.ssa-dice select{ appearance:auto }
.ssa-dice .ssa-input::placeholder{ color:#a9b7c8 }
.ssa-dice .ssa-input:focus-visible,
.ssa-dice .ssa-num:focus-visible,
.ssa-dice select:focus-visible{ outline:3px solid var(--ring); outline-offset:2px; border-color:transparent }

.ssa-dice .ssa-btn.ssa-primary{
  background:linear-gradient(180deg,var(--accent),#139f88);
  border-color:transparent; color:#071219; font-weight:800;
}

.ssa-help{ background:#0e1422; border:1px solid #25314a; border-radius:10px; color:var(--muted); padding:8px 10px; margin:6px 0 10px; font-size:13px }
.ssa-help code{ color:var(--text) }
.ssa-help kbd{ background:#111a2a; border:1px solid #2a3955; border-radius:6px; padding:1px 6px }

/* -- Advanced options -------------------------------------------------- */
.ssa-dice__opts{ background:var(--card); border:1px solid #26304a; border-radius:14px; padding:8px 10px; margin-top:6px }
.ssa-dice__opts summary{ cursor:pointer; font-weight:600 }
.ssa-dice__opts-grid{ display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:10px; margin-top:10px }
.ssa-dice .opt{ display:flex; align-items:center; gap:8px; background:#0f1626; border:1px solid #334155; padding:8px; border-radius:10px; font-size:13px }
.ssa-dice .opt span{ font-weight:600 }
.ssa-dice .opt input[type="number"]{ width:100px; background:#0b1220; border:1px solid #3a4a66; border-radius:8px; color:var(--text); padding:6px }
.opt--colspan{ grid-column:span 3 }

/* -- Results / history ------------------------------------------------- */
.ssa-dice__results{ margin-top:12px; background:var(--card); border:1px solid #26304a; border-radius:14px; padding:12px; position:relative; overflow:visible }
.ssa-total{ font-size:24px; font-weight:800; margin-bottom:10px }
@keyframes flash{ 0%{ background:var(--accent); color:#071219 } 100%{ background:transparent; color:inherit } }
.ssa-total.flash{ animation:flash .6s ease }
.ssa-total.is-crit{ box-shadow:0 0 0 2px rgba(34,197,94,.45) inset,0 0 20px rgba(34,197,94,.25); border-radius:10px; padding:4px 8px }
.ssa-total.is-fumble{ box-shadow:0 0 0 2px rgba(239,68,68,.45) inset,0 0 20px rgba(239,68,68,.25); border-radius:10px; padding:4px 8px }

.ssa-dice__canvas{
  display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:10px;
  min-height:84px; padding:18px 14px; border-radius:14px;
  background:rgba(148,163,184,.08); outline:1px solid rgba(148,163,184,.25);
}
.ssa-breakdown{ margin-top:10px; color:var(--muted); font-size:13px; word-break:break-word }

.ssa-probability{
  margin-top:12px;
  padding:12px;
  border:1px solid rgba(55,199,171,.28);
  border-radius:12px;
  background:rgba(15,23,42,.08);
  color:var(--muted);
  font-size:13px;
}
.ssa-probability__grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
}
.ssa-probability__grid span{
  display:grid;
  gap:3px;
  min-width:0;
  padding:8px;
  border:1px solid rgba(148,163,184,.25);
  border-radius:10px;
  background:rgba(2,6,23,.08);
}
.ssa-probability__grid strong{ font-size:11px; text-transform:uppercase; letter-spacing:.04em }
.ssa-probability p{ margin:8px 0 0; font-size:12px; color:var(--muted) }

.ssa-history{ margin-top:14px; background:var(--card); border:1px solid #26304a; border-radius:14px }
.ssa-history__title{ padding:8px 12px; border-bottom:1px solid #26304a; font-weight:700 }
.ssa-history__list{ list-style:decimal; padding:8px 22px; max-height:200px; overflow:auto; margin:0 }

.ssa-session-card{
  margin-top:14px;
  padding:14px;
  background:var(--card);
  border:1px solid #26304a;
  border-radius:14px;
}
.ssa-session-card__head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.ssa-session-card h3{ margin:0; font-size:16px }
.ssa-session-card__head span{ color:var(--muted); font-size:12px }
.ssa-session-card label{ display:block; margin-bottom:6px; color:var(--muted); font-size:13px }
.ssa-session-card textarea{
  width:100%;
  min-height:82px;
  resize:vertical;
  background:#0b1220;
  color:var(--text);
  border:2px solid #3a4a66;
  border-radius:12px;
  padding:10px 12px;
}
.ssa-session-card__summary{ margin:8px 0 0; color:var(--muted); font-size:13px }

/* -- Inline message / invalid ----------------------------------------- */
.ssa-msg{ color:var(--muted); font-size:13px; margin-top:6px }
.ssa-input.is-invalid{ border-color:#b91c1c; outline:3px solid #b91c1c }
.ssa-msg.is-error{ color:#fecaca }
@keyframes shake{10%,90%{transform:translateX(-1px)}20%,80%{transform:translateX(2px)}30%,50%,70%{transform:translateX(-4px)}40%,60%{transform:translateX(4px)}}
.ssa-input.shake{ animation:shake .45s ease }

/* -- Dice (hardened SVG) ---------------------------------------------- */
.ssa-die{
  width:64px !important; height:64px !important;
  display:inline-grid !important; place-items:center;
  position:relative; transform-style:preserve-3d; perspective:800px;
  filter:drop-shadow(0 6px 10px rgba(0,0,0,.25));
}
.ssa-die svg{ display:block !important; width:100% !important; height:100% !important; overflow:visible !important }
.ssa-dice svg, .ssa-dice svg *{ visibility:visible !important; pointer-events:auto !important; fill:initial !important }
.ssa-die svg polygon{ fill:#3b82f6 !important; stroke:rgba(0,0,0,.22) !important; stroke-width:2.5 !important }
.ssa-die[data-sides="2"]   svg polygon{ fill:var(--d2)  !important }
.ssa-die[data-sides="4"]   svg polygon{ fill:var(--d4)  !important }
.ssa-die[data-sides="6"]   svg polygon{ fill:var(--d6)  !important }
.ssa-die[data-sides="8"]   svg polygon{ fill:var(--d8)  !important }
.ssa-die[data-sides="10"]  svg polygon{ fill:var(--d10) !important }
.ssa-die[data-sides="12"]  svg polygon{ fill:var(--d12) !important }
.ssa-die[data-sides="20"]  svg polygon{ fill:var(--d20) !important }
.ssa-die[data-sides="100"] svg polygon{ fill:var(--d100)!important }

.ssa-die svg text{ font-weight:900; font-size:22px; fill:#fff !important; dominant-baseline:middle; text-anchor:middle }
@media (prefers-color-scheme:light){ .ssa-die svg text{ fill:#0b1220 !important } }

.ssa-die.is-dropped{ opacity:.45; filter:grayscale(.15) drop-shadow(0 2px 6px rgba(0,0,0,.18)) }
.ssa-die.is-dropped text{ opacity:.7 }

.ssa-die[data-exploded="1"] svg polygon{
  stroke:rgba(255,255,255,.85) !important; stroke-width:3 !important;
  filter:drop-shadow(0 0 8px rgba(255,255,255,.25));
}
.ssa-die[data-exploded="1"]::after{
  content:"!"; position:absolute; top:2px; right:4px; font-size:14px; font-weight:900; line-height:1;
  color:#fff; background:var(--d20); border-radius:4px; padding:0 4px;
}

/* roll + settle */
.ssa-die.rolling{ animation:roll-die .9s cubic-bezier(.25,1.5,.5,1) }
@keyframes roll-die{ 0%{transform:rotate(0) scale(1)} 60%{transform:rotate(360deg) scale(1.08)} 100%{transform:rotate(0) scale(1)} }
.ssa-die.finalized{ transform:none !important; animation:die-pop .22s ease-out }
@keyframes die-pop{ 0%{transform:scale(.92)} 100%{transform:scale(1)} }
.ssa-die.bounce{ animation:bounce .35s ease }
@keyframes bounce{ 0%{transform:translateY(0)} 50%{transform:translateY(-5px)} 100%{transform:translateY(0)} }

/* -- Confetti ---------------------------------------------------------- */
/* -- Confetti ---------------------------------------------------------- */
/* -- Confetti ---------------------------------------------------------- */
/* -- Confetti ---------------------------------------------------------- */

/* -- D&D panel --------------------------------------------------------- */
.ssa-dd-panel{ background:var(--card); border:1px solid #26304a; border-radius:12px; padding:10px; margin:10px 0 }
.ssa-tabs{ display:flex; gap:6px; margin:8px 0 10px }
.ssa-tab{ border:1px solid #25314a; background:#0e1422; color:var(--text); padding:8px 12px; border-radius:10px; cursor:pointer; min-height:40px }
.ssa-tab.is-active{ background:#111a2a }
.ssa-tab:focus-visible{ outline:3px solid var(--ring); outline-offset:2px }
.ssa-tabpane[hidden]{ display:none !important }

.ssa-dd__row{ display:grid; gap:10px; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)) }
.ssa-dd__group{ background:#0e1422; border:1px solid #25314a; border-radius:10px; padding:10px }
.ssa-dd__title{ font-weight:700; margin-bottom:6px }
.ssa-dd__stats{ margin-top:8px; font-size:13px; color:var(--text) }

/* Table text forced visible on dark themes */
.ssa-dd-table{ width:100%; border-collapse:collapse; font-size:13px }
.ssa-dd-table th,.ssa-dd-table td{
  background:#0b1220 !important; color:var(--text) !important; -webkit-text-fill-color:var(--text) !important;
  border:1px solid #25314a !important; padding:6px 8px; text-align:left;
}
.ssa-dd-table th{ background:#111a2a !important; color:#ffffff !important; font-weight:700 }
.ssa-dd__totals,.ssa-dd .ssa-note{ color:var(--text) }

/* Death saves ticks (success = teal, failure = red) */
.ssa-ticks{ display:flex; gap:6px; min-height:20px }
.ssa-ticks .tick{ width:14px; height:14px; border-radius:50%; background:#37c7ab }
.ssa-dice [id$="-death-failure"] .tick{ background:#ef4444 }  /* correct selector */

/* -- MTG panel --------------------------------------------------------- */
.ssa-mtg-panel{ background:var(--card); border:1px solid #26304a; border-radius:12px; padding:10px; margin:10px 0 }
.ssa-mtg__toolbar{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:10px }
.ssa-mtg__grid{ display:grid; gap:10px; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)) }

.ssa-mtg-panel .mtg-card{ background:#0e1422; border:1px solid #25314a; border-radius:14px; padding:10px }
.ssa-mtg-panel .mtg-card__head{ display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:8px }
.ssa-mtg-panel .mtg-name{
  background:#0b1220; color:var(--text); border:2px solid #3a4a66; border-radius:8px; padding:10px;
  min-height:44px; min-width:140px;
}
.ssa-mtg-panel .mtg-life{
  display:grid; grid-template-columns:60px 60px 1fr 60px 60px; align-items:center; gap:8px; margin:6px 0
}
.ssa-mtg-panel .mtg-life__total{ font-size:28px; text-align:center; color:var(--text) }

.ssa-mtg-panel .mtg-btn,
.ssa-mtg-panel .mtg-counter__controls button{
  background:#0f172a; color:var(--text);
  border:2px solid #3a4a66; border-radius:10px;
  padding:8px 10px; min-height:40px; cursor:pointer;
}
.ssa-mtg-panel .mtg-btn:hover,
.ssa-mtg-panel .mtg-counter__controls button:hover{ outline:3px solid var(--ring) }
.ssa-mtg-panel .mtg-btn:focus-visible,
.ssa-mtg-panel .mtg-counter__controls button:focus-visible{ outline:3px solid var(--ring); outline-offset:2px }

.ssa-mtg-panel .mtg-counters{ display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:10px; margin-top:8px }
.ssa-mtg-panel .mtg-counter{ display:flex; justify-content:space-between; align-items:center; gap:10px }
.ssa-mtg-panel .mtg-counter__value{ display:inline-block; min-width:2ch; text-align:center; font-weight:800; color:var(--text) }

.ssa-mtg-panel details.mtg-cmd{ margin-top:8px }
.ssa-mtg-panel .mtg-order{ margin:8px 0 0 18px }
.ssa-mtg-panel .mtg-turns{ display:flex; align-items:center; gap:10px; margin-top:8px }
.ssa-mtg-panel .mtg-turns__now strong{ font-size:16px }

/* -- Simple mode ------------------------------------------------------- */
.ssa-dice.is-simple .ssa-dice__row,
.ssa-dice.is-simple .ssa-dice__opts{ display:none }

/* -- Responsive -------------------------------------------------------- */
@media (max-width:820px){ .ssa-dice__row{ grid-template-columns:1fr auto auto } }
@media (max-width:600px){
  .ssa-dice__row{ grid-template-columns:1fr }
  .ssa-dice__row .ssa-btn{ width:100% }
  .ssa-dice__quickbar{ overflow-x:auto; gap:6px }
.qb{ white-space:normal; overflow-wrap:break-word }
  .ssa-dice__opts-grid{ grid-template-columns:repeat(2,minmax(0,1fr)) }
  .opt--colspan{ grid-column:span 2 }
  .ssa-probability__grid{ grid-template-columns:1fr }
  .ssa-session-card__head{ display:block }
  .ssa-session-card__head span{ display:block; margin-top:4px }
}
@media (max-width:380px){
  .ssa-dice__opts-grid{ grid-template-columns:1fr }
  .opt--colspan{ grid-column:1 }
}

/* -- Reduced motion & forced colors ----------------------------------- */
@media (prefers-reduced-motion:reduce){
  .ssa-die.animate, .ssa-die.rolling, .ssa-die.bounce{ animation:none !important }
  .ssa-die{ transition:none }
  .ssa-total.flash{ animation:none }
}
@media (forced-colors:active){
  .ssa-dice *{ forced-color-adjust:auto }
  .ssa-dice .ssa-btn, .ssa-dice .ssa-chip, .ssa-dice .ssa-mode-btn,
  .ssa-dice .ssa-input, .ssa-dice .ssa-num, .ssa-dice select,
  .ssa-mtg-panel .mtg-btn, .ssa-mtg-panel .mtg-counter__controls button, .ssa-mtg-panel .mtg-name{ border-width:2px }
}
/* =====================================================================
   PATCH: controls, tabs, tables (WCAG + theme-proof)
   Paste after everything else.
   ===================================================================== */

/* --- 1) Form controls (selects + numbers + text) -------------------- */
.ssa-dice select,
.ssa-dice input[type="text"],
.ssa-dice input[type="search"],
.ssa-dice input[type="number"]{
  -webkit-appearance: none;
  appearance: none;
  background: #0b1220;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  border: 2px solid #3a4a66;
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 12px;
  line-height: 1.2;
  font: inherit;
}

/* Select: visible arrow with good contrast */
.ssa-dice select{
  padding-right: 38px; /* room for arrow */
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23e6eef7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
@media (prefers-color-scheme: light){
  .ssa-dice select{
    background-color: #f8fafc;
    border-color:#cbd5e1;
    background-image:
      url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%230b1220' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  }
}

/* Focus ring consistent with buttons */
.ssa-dice select:focus-visible,
.ssa-dice input[type="text"]:focus-visible,
.ssa-dice input[type="search"]:focus-visible,
.ssa-dice input[type="number"]:focus-visible{
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-color: transparent;
}

/* If your theme hides spinners and leaves weird boxes, either keep: */
.ssa-dice input[type="number"]{
  /* comment these two if you want native spinners back */
  /* -moz-appearance: textfield; */
}
.ssa-dice input[type="number"]::-webkit-outer-spin-button,
.ssa-dice input[type="number"]::-webkit-inner-spin-button{
  /* comment next line if you want the spinner arrows shown */
  /* -webkit-appearance: none; */
  margin: 0;
}

/* Checkboxes inside panels: ensure visible on dark */
.ssa-dice input[type="checkbox"]{
  width: 18px; height: 18px; accent-color: var(--accent);
}

/* --- 2) Tabs (D&D / MTG): make readable & ARIA-state aware ---------- */
.ssa-dice .ssa-tabs{ gap:8px }
.ssa-dice .ssa-tab{
  background:#0e1422;
  border: 2px solid #3a4a66;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 40px;
  font-weight: 600;
}
.ssa-dice .ssa-tab:hover,
.ssa-dice .ssa-tab:focus-visible{ outline:3px solid var(--ring); outline-offset:2px }

/* reflect ARIA instead of only the .is-active class */
.ssa-dice .ssa-tab.is-active,
.ssa-dice .ssa-tab[aria-selected="true"]{
  background:#111a2a;
  border-color:#445777;
}

/* some themes drop opacity in panels - neutralize it */
.ssa-dice .ssa-dd-panel *,
.ssa-dice .ssa-mtg-panel *{
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  --tw-text-opacity: 1 !important;      /* tailwind override */
}

/* --- 3) Tables (Ability Scores etc.) -------------------------------- */
.ssa-dice .ssa-dd-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: transparent;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
}
.ssa-dice .ssa-dd-table th,
.ssa-dice .ssa-dd-table td{
  background: #0b1220 !important;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  border: 1.5px solid #25314a !important;
  padding: 8px 10px;
}
.ssa-dice .ssa-dd-table th{
  background: #111a2a !important;
  font-weight: 700;
}
.ssa-dice .ssa-dd-table tbody tr:nth-child(even) td{
  background: #0e1524 !important;       /* zebra stripe for readability */
}
@media (prefers-color-scheme: light){
  .ssa-dice .ssa-dd-table th,
  .ssa-dice .ssa-dd-table td{
    background:#f2f6fb !important; border-color:#cbd5e1 !important; color:#0b1220 !important; -webkit-text-fill-color:#0b1220 !important;
  }
  .ssa-dice .ssa-dd-table th{ background:#e9eef7 !important }
  .ssa-dice .ssa-dd-table tbody tr:nth-child(even) td{ background:#f7f9fd !important }
}

/* -- D&D panel --------------------------------------------------------- */
/* scope-safe/no-op */

.ssa-dice .ssa-dd-panel select,
.ssa-dice .ssa-dd-panel input[type="number"],
.ssa-dice .ssa-dd-panel input[type="text"]{
  background:#0b1220;
  border:2px solid #3a4a66;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  min-height:44px;
}

/* --- 5) Death Saves failure lane (correct, non-broken selector) ------ */
.ssa-dice [id$="-death-failure"] .tick{ background:#ef4444 }

/* --- 6) Force readable labels inside cards (light/dark) -------------- */
.ssa-dice .ssa-dd__group .ssa-note,
.ssa-dice .ssa-dd__group strong{ color: var(--text) !important; -webkit-text-fill-color: var(--text) !important }

/* SSA dark-neon final alignment. */
.ssa-dice {
  --bg: #030712 !important;
  --card: rgba(8, 18, 34, 0.98) !important;
  --text: #f4fdff !important;
  --muted: #dbeafe !important;
  --accent: #2dd4bf !important;
  --ring: rgba(56, 189, 248, 0.54) !important;
  color-scheme: dark;
  background:
    radial-gradient(circle at 8% 0%, rgba(45, 212, 191, 0.10), transparent 32%),
    linear-gradient(180deg, rgba(8, 18, 34, 0.98), rgba(3, 8, 18, 0.98)) !important;
  border-color: rgba(56, 189, 248, 0.38) !important;
  color: var(--text) !important;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36) !important;
}

.ssa-dice :is(.ssa-dice__quickbar, .ssa-dice__opts, .ssa-dice__results, .ssa-history, .ssa-probability, .ssa-session-card, .ssa-dd-panel, .ssa-mtg-panel, .ssa-dd__group, .ssa-mtg-panel .mtg-card, .ssa-help) {
  background: linear-gradient(180deg, rgba(8, 18, 34, 0.98), rgba(3, 8, 18, 0.98)) !important;
  border-color: rgba(56, 189, 248, 0.34) !important;
  color: var(--muted) !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24) !important;
}

.ssa-dice :is(p, li, span, small, em, div, label, td, th, code, kbd) {
  color: var(--muted) !important;
}

.ssa-dice :is(h1, h2, h3, h4, strong, b, .ssa-total, .ssa-history__title, .ssa-mtg-panel .mtg-life__total) {
  color: var(--text) !important;
  text-shadow: 0 0 16px rgba(56, 189, 248, 0.24);
}

.ssa-dice :is(.qb, .ssa-chip, .ssa-mode-btn, .ssa-btn, .ssa-tab, .ssa-mtg-panel .mtg-btn, .ssa-mtg-panel .mtg-counter__controls button) {
  background: rgba(2, 6, 23, 0.92) !important;
  border-color: rgba(56, 189, 248, 0.34) !important;
  color: var(--text) !important;
}

.ssa-dice :is(.ssa-btn-primary, .ssa-btn, .ssa-mode-btn.is-active, .ssa-tab.is-active) {
  background: linear-gradient(135deg, #2dd4bf, #38bdf8) !important;
  border-color: rgba(45, 212, 191, 0.72) !important;
  color: #031018 !important;
  box-shadow: 0 12px 28px rgba(34, 211, 238, 0.22) !important;
}

.ssa-dice :is(.ssa-input, input:not([type="checkbox"]):not([type="radio"]), select, textarea, .mtg-name) {
  background: rgba(2, 6, 23, 0.88) !important;
  border-color: rgba(148, 163, 184, 0.42) !important;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
}

/* --- MOBILE POLISH (append at end) ----------------------------------- */

/* Lock sizing so iOS doesn't auto-zoom text and change proportions */
.ssa-dice{
  font-size:16px;
  text-size-adjust:100%;
  -webkit-text-size-adjust:100%;
}

/* -- Expression row ---------------------------------------------------- */
@media (max-width:600px){
  .ssa-dice__row{
    /* keep input + 3-4 buttons instead of stacking to a single column */
    grid-template-columns: 1fr auto auto auto; /* add/remove 'auto' for # of buttons */
    align-items: stretch;
  }
  .ssa-dice__row .ssa-btn{ width:auto } /* don't full-width the buttons */
}

/* Quickbar: same look, smooth scroll, and clean edges on mobile */
.ssa-dice__quickbar{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  scroll-snap-type:x mandatory;
  gap:8px;
  padding-bottom:8px;
  /* soft fade at edges */
  mask-image: linear-gradient(to right,
    transparent 0, black 12px, black calc(100% - 12px), transparent 100%);
}
.ssa-dice .qb{ scroll-snap-align:start; white-space:normal; overflow-wrap:break-word }

/* Dice canvas & totals: breathe a bit less on phones */
@media (max-width:600px){
  .ssa-dice__canvas{ padding:12px 10px; gap:8px; min-height:72px }
  .ssa-total{ font-size:22px }
}

/* Dice size: keep "desktop" look but allow tiny screens to fit */
.ssa-die{
  width:clamp(56px,16vw,64px) !important;
  height:clamp(56px,16vw,64px) !important;
}

/* MTG card tightening so the 5-button life row still fits cleanly */
@media (max-width:480px){
  .ssa-mtg-panel .mtg-life{
    grid-template-columns:52px 52px 1fr 52px 52px;
    gap:6px;
  }
  .ssa-mtg-panel .mtg-life__total{ font-size:24px }
  .ssa-mtg-panel .mtg-name{ min-width:0 } /* prevent overflow */
  .ssa-mtg-panel .mtg-counters{ grid-template-columns:1fr 1fr }
}

/* Inputs/buttons at 16px avoid iOS "zoom on focus" */
.ssa-dice input, .ssa-dice select, .ssa-dice button{ font-size:16px }

/* --- MOBILE/THEME OVERRIDES: ensure readable text on dark buttons/tabs --- */
/* Force text to your scoped var everywhere it matters */
.ssa-dice .ssa-chip,
.ssa-dice .ssa-btn,
.ssa-dice .ssa-mode-btn,
.ssa-dice .ssa-tab,
.ssa-dice .mtg-btn,
.ssa-dice .mtg-counter__controls button {
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important; /* iOS Safari */
  text-shadow: none !important;                    /* kill theme shadows */
  mix-blend-mode: normal !important;               /* kill blend weirdness */
}

/* If any inner spans/icons are getting themed, inherit the color */
.ssa-dice .ssa-chip *,
.ssa-dice .ssa-btn *,
.ssa-dice .ssa-mode-btn *,
.ssa-dice .ssa-tab *,
.ssa-dice .mtg-btn *,
.ssa-dice .mtg-counter__controls button * {
  color: inherit !important;
  -webkit-text-fill-color: inherit !important;
  mix-blend-mode: inherit !important;
}

/* Subtabs (D&D / MTG) active state - keep contrast */
.ssa-dice .ssa-tab.is-active,
.ssa-dice .ssa-tab[aria-selected="true"]{
  background:#111a2a !important;
  border-color:#445777 !important;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
}

/* Final hard stop for dice, MTG, gear, and generated result cards. */
.ssa-dice :is(
  #results,
  [id*="result"],
  [id*="Result"],
  [class*="result"],
  [class*="probability"],
  [class*="session"],
  [class*="history"],
  [class*="card"],
  [class*="panel"],
  [class*="gear"],
  table,
  thead,
  tbody,
  tr,
  td,
  th,
  [aria-live="polite"]
) {
  border-color: rgba(45, 212, 191, 0.34) !important;
  background:
    radial-gradient(circle at 8% 0%, rgba(45, 212, 191, 0.10), transparent 32%),
    linear-gradient(180deg, rgba(8, 18, 34, 0.98), rgba(3, 8, 18, 0.98)) !important;
  color: #dbeafe !important;
}

.ssa-dice :is(a:not(.ssa-btn):not(.btn)) {
  color: #7dd3fc !important;
}

/* SSA final UX pass: companion blocks, spacing, and mobile breathing room. */
.ssa-dice,
.ssa-dice-companion {
  max-width: 1080px;
  margin-left: auto;
  margin-right: auto;
}

.ssa-dice {
  display: grid !important;
  gap: 18px !important;
  padding: clamp(18px, 3vw, 30px) !important;
  border-radius: 8px !important;
}

/* -- Header ------------------------------------------------------------ */
.ssa-history__title,
.ssa-gear__head,
.ssa-dice-next__head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
}

.ssa-dice__quickbar,
.ssa-dice__opts,
.ssa-dice__results,
.ssa-history,
.ssa-dd-panel,
.ssa-mtg-panel,
.ssa-dice-companion {
  border-radius: 8px !important;
  padding: clamp(14px, 2vw, 22px) !important;
}

.ssa-history__clear {
  border: 1px solid rgba(125, 211, 252, 0.34) !important;
  background: rgba(2, 6, 23, 0.72) !important;
  color: #f4fdff !important;
  -webkit-text-fill-color: #f4fdff !important;
  border-radius: 999px !important;
  padding: 7px 11px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
}

.ssa-history__clear:hover,
.ssa-history__clear:focus-visible {
  border-color: rgba(45, 212, 191, 0.72) !important;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18) !important;
}

.ssa-dice-companion {
  margin-top: 18px !important;
  margin-bottom: 18px !important;
  background:
    radial-gradient(circle at 8% 0%, rgba(45, 212, 191, 0.10), transparent 32%),
    linear-gradient(180deg, rgba(8, 18, 34, 0.98), rgba(3, 8, 18, 0.98)) !important;
  border: 1px solid rgba(56, 189, 248, 0.34) !important;
  color: #dbeafe !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24) !important;
}

.ssa-dice-companion :is(h2, h3, h4, strong, b, summary) {
  color: #f4fdff !important;
  -webkit-text-fill-color: #f4fdff !important;
}

.ssa-dice-companion :is(p, li, span, small, em, div) {
  color: #dbeafe !important;
  -webkit-text-fill-color: #dbeafe !important;
}

.ssa-dice-companion a:not(.btn) {
  color: #7dd3fc !important;
}

.ssa-dice-companion :is(.card, details, .ssa-tabpane, .ssa-gear__disclosure, .ssa-gear__sponsored) {
  background: rgba(2, 6, 23, 0.56) !important;
  border: 1px solid rgba(56, 189, 248, 0.28) !important;
  border-radius: 8px !important;
  color: #dbeafe !important;
}

.ssa-dice-companion .card,
.ssa-dice-companion details {
  padding: 14px !important;
}

.ssa-dice-next__kicker {
  margin: 0 !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  color: #5eead4 !important;
  -webkit-text-fill-color: #5eead4 !important;
}

.ssa-dice-next__head h3 {
  margin: 0 !important;
}

.ssa-dice-next__grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 12px !important;
  margin-top: 14px !important;
}

.ssa-dice-next__grid a {
  display: grid !important;
  gap: 6px !important;
  min-height: 104px !important;
  padding: 14px !important;
  border: 1px solid rgba(56, 189, 248, 0.28) !important;
  border-radius: 8px !important;
  background: rgba(2, 6, 23, 0.64) !important;
  text-decoration: none !important;
}

.ssa-dice-next__grid a:hover,
.ssa-dice-next__grid a:focus-visible {
  border-color: rgba(45, 212, 191, 0.72) !important;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18) !important;
}

.ssa-dice-next__grid strong {
  font-size: 16px !important;
}

.ssa-gear .card a.btn {
  min-height: 42px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 8px !important;
}

@media (max-width: 700px) {
  .ssa-dice {
    gap: 14px !important;
    padding: 16px !important;
  }

  .ssa-dice__row {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .ssa-dice__row .ssa-input {
    grid-column: 1 / -1 !important;
  }

  .ssa-dice__row .ssa-btn {
    width: 100% !important;
    min-height: 44px !important;
  }

  .ssa-dice-companion {
    padding: 16px !important;
  }

  .ssa-dice-next__grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 640px) {
  .ssa-dice,
  .ssa-gear {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 12px !important;
    overflow-x: hidden !important;
  }

  .ssa-dice :where(*),
  .ssa-gear :where(*) {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
  }

  .ssa-dice :where(.grid, [class*="-grid"], [class*="__grid"], [class*="-actions"]),
  .ssa-gear :where(.grid, [class*="-grid"], [class*="__grid"], [class*="-actions"]) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
/* SSA dark-neon hard stop for legacy pale dice widgets. */
body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) {
  --ssa-neon-bg: #050b12;
  --ssa-neon-surface: rgba(5, 14, 24, 0.98);
  --ssa-neon-surface-2: rgba(8, 26, 40, 0.96);
  --ssa-neon-border: rgba(45, 211, 218, 0.56);
  --ssa-neon-text: #f4fbff;
  --ssa-neon-muted: #cfefff;
  --ssa-neon-accent: #2ed3da;
  background: linear-gradient(135deg, var(--ssa-neon-bg), #061927) !important;
  border-color: var(--ssa-neon-border) !important;
  color: var(--ssa-neon-text) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) :is(section, article, aside, fieldset, details, summary, table, thead, tbody, tfoot, tr, td, th, label, legend, [aria-live], [role="tabpanel"], [role="group"], [class*="card"], [class*="Card"], [class*="panel"], [class*="Panel"], [class*="box"], [class*="Box"], [class*="tile"], [class*="Tile"], [class*="widget"], [class*="Widget"], [class*="result"], [class*="Result"], [class*="summary"], [class*="Summary"], [class*="output"], [class*="Output"], [class*="metric"], [class*="Metric"], [class*="stat"], [class*="Stat"], [class*="notice"], [class*="Notice"], [class*="warning"], [class*="Warning"], [class*="callout"], [class*="Callout"], [class*="option"], [class*="Option"], [class*="question"], [class*="Question"], [class*="field"], [class*="Field"], [class*="group"], [class*="Group"], [class*="item"], [class*="Item"], [class*="row"], [class*="Row"], [class*="form"], [class*="Form"], [class*="input"], [class*="Input"], [class*="history"], [class*="History"], [class*="dashboard"], [class*="Dashboard"], [class*="profile"], [class*="Profile"], [class*="prompt"], [class*="Prompt"], [class*="intro"], [class*="Intro"], [class*="body"], [class*="Body"]) {
  background: linear-gradient(135deg, var(--ssa-neon-surface), var(--ssa-neon-surface-2)) !important;
  border-color: var(--ssa-neon-border) !important;
  box-shadow: 0 0 0 1px rgba(45, 211, 218, 0.16), 0 18px 44px rgba(0, 0, 0, 0.34) !important;
  color: var(--ssa-neon-text) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea) {
  background: rgba(3, 10, 18, 0.98) !important;
  border-color: var(--ssa-neon-border) !important;
  color: var(--ssa-neon-text) !important;
  -webkit-text-fill-color: var(--ssa-neon-text) !important;
  box-shadow: inset 0 0 0 1px rgba(45, 211, 218, 0.14) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) :is(input[type="checkbox"], input[type="radio"]) {
  accent-color: var(--ssa-neon-accent) !important;
  background-color: rgba(3, 10, 18, 0.98) !important;
  border-color: var(--ssa-neon-border) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) input::placeholder,
body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) {
  --ssa-neon-bg: #050b12;
  --ssa-neon-surface: rgba(5, 14, 24, 0.98);
  --ssa-neon-surface-2: rgba(8, 26, 40, 0.96);
  --ssa-neon-border: rgba(45, 211, 218, 0.56);
  --ssa-neon-text: #f4fbff;
  --ssa-neon-muted: #cfefff;
  --ssa-neon-accent: #2ed3da;
  background: linear-gradient(135deg, var(--ssa-neon-bg), #061927) !important;
  border-color: var(--ssa-neon-border) !important;
  color: var(--ssa-neon-text) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) :is(section, article, aside, fieldset, details, summary, table, thead, tbody, tfoot, tr, td, th, label, legend, [aria-live], [role="tabpanel"], [role="group"], [class*="card"], [class*="Card"], [class*="panel"], [class*="Panel"], [class*="box"], [class*="Box"], [class*="tile"], [class*="Tile"], [class*="widget"], [class*="Widget"], [class*="result"], [class*="Result"], [class*="summary"], [class*="Summary"], [class*="output"], [class*="Output"], [class*="metric"], [class*="Metric"], [class*="stat"], [class*="Stat"], [class*="notice"], [class*="Notice"], [class*="warning"], [class*="Warning"], [class*="callout"], [class*="Callout"], [class*="option"], [class*="Option"], [class*="question"], [class*="Question"], [class*="field"], [class*="Field"], [class*="group"], [class*="Group"], [class*="item"], [class*="Item"], [class*="row"], [class*="Row"], [class*="form"], [class*="Form"], [class*="input"], [class*="Input"], [class*="history"], [class*="History"], [class*="dashboard"], [class*="Dashboard"], [class*="profile"], [class*="Profile"], [class*="prompt"], [class*="Prompt"], [class*="intro"], [class*="Intro"], [class*="body"], [class*="Body"]) {
  background: linear-gradient(135deg, var(--ssa-neon-surface), var(--ssa-neon-surface-2)) !important;
  border-color: var(--ssa-neon-border) !important;
  box-shadow: 0 0 0 1px rgba(45, 211, 218, 0.16), 0 18px 44px rgba(0, 0, 0, 0.34) !important;
  color: var(--ssa-neon-text) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea) {
  background: rgba(3, 10, 18, 0.98) !important;
  border-color: var(--ssa-neon-border) !important;
  color: var(--ssa-neon-text) !important;
  -webkit-text-fill-color: var(--ssa-neon-text) !important;
  box-shadow: inset 0 0 0 1px rgba(45, 211, 218, 0.14) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) :is(input[type="checkbox"], input[type="radio"]) {
  accent-color: var(--ssa-neon-accent) !important;
  background-color: rgba(3, 10, 18, 0.98) !important;
  border-color: var(--ssa-neon-border) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) textarea::placeholder {
  color: rgba(207, 239, 255, 0.72) !important;
  -webkit-text-fill-color: rgba(207, 239, 255, 0.72) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) :is(button:not(.mf-danger-button), .button:not(.mf-danger-button), .btn:not(.mf-danger-button), [role="button"]:not(.mf-danger-button), input[type="button"], input[type="submit"], input[type="reset"], a.button, a.btn, [class*="-btn"]:not(.mf-danger-button), [class*="-button"]:not(.mf-danger-button), [class*="Button"]:not(.mf-danger-button)) {
  background: linear-gradient(135deg, #33f7ff, #21c6d3 55%, #1498ff) !important;
  border-color: rgba(84, 245, 255, 0.82) !important;
  color: #021018 !important;
  -webkit-text-fill-color: #021018 !important;
  box-shadow: 0 0 18px rgba(45, 211, 218, 0.28), 0 12px 28px rgba(0, 0, 0, 0.32) !important;
  text-shadow: none !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) :is(h1, h2, h3, h4, h5, h6, p, li, label, span, small, strong, b, em, legend, summary, td, th, output, div) {
  color: var(--ssa-neon-text) !important;
}

body :is(
  .ssa-dice.ssa-dice,
  .ssa-gear.ssa-gear,
  [class^="ssa-dice"][class^="ssa-dice"],
  [class*=" ssa-dice"][class*=" ssa-dice"]
) a:not(.button):not(.btn) {
  color: #7ff7ff !important;
}

/* Final mobile geometry lock: keep lazy-rendered dice tools readable even when
   shared tool/sidebar CSS loads later or constrains the content column. */
.ssa-dice-page {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 18px !important;
  width: min(1080px, calc(100dvw - 24px)) !important;
  max-width: calc(100dvw - 24px) !important;
  min-width: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
  float: none !important;
  clear: both !important;
  flex: 1 1 100% !important;
  flex-direction: column !important;
  grid-column: 1 / -1 !important;
  column-count: 1 !important;
  column-width: auto !important;
  column-gap: 0 !important;
  overflow-x: hidden !important;
}

.ssa-dice-page > * {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  flex: 0 0 100% !important;
  float: none !important;
  clear: both !important;
  column-span: all !important;
}

@supports selector(:has(*)) {
  body :is(main, article, .site-main, .content-area, .entry-content, .wp-block-post-content, .ssa-lazy-shortcode, .ssa-lazy-shortcode-content, .ssa-lazy-shortcode-placeholder):has(.ssa-dice-page) {
    display: block !important;
    column-count: 1 !important;
    column-width: auto !important;
    columns: auto !important;
    column-gap: 0 !important;
    overflow-x: hidden !important;
  }
}

.ssa-dice,
.ssa-dice *,
.ssa-dice *::before,
.ssa-dice *::after,
.ssa-dice-companion,
.ssa-dice-companion *,
.ssa-dice-companion *::before,
.ssa-dice-companion *::after {
  box-sizing: border-box !important;
  writing-mode: horizontal-tb !important;
  text-orientation: mixed !important;
  letter-spacing: 0 !important;
  word-break: normal !important;
}

.ssa-dice,
.ssa-dice-companion {
  width: min(1080px, calc(100dvw - 24px)) !important;
  max-width: calc(100dvw - 24px) !important;
  min-width: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
  overflow-x: hidden !important;
}

.ssa-dice :is(h1,h2,h3,h4,h5,h6,p,li,label,legend,summary,span,strong,b,em,small,div,td,th,button,a,code,kbd),
.ssa-dice-companion :is(h1,h2,h3,h4,h5,h6,p,li,label,legend,summary,span,strong,b,em,small,div,td,th,button,a,code,kbd) {
  max-width: 100% !important;
  min-width: 0 !important;
  white-space: normal !important;
  overflow-wrap: break-word !important;
  word-break: normal !important;
  text-align: inherit;
}

.ssa-dice :is(.ssa-dice__quickbar,.ssa-mode,.ssa-dice__advwrap,.ssa-dd__chips,.ssa-inline,.ssa-tabs,.ssa-gear__links,.ssa-gear__cta),
.ssa-dice-companion :is(.ssa-dice-next__head,.ssa-gear__head) {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 10px !important;
  min-width: 0 !important;
}

.ssa-dice :is(.ssa-dice__row,.ssa-dice__opts-grid,.ssa-dd__row,.ssa-death,.mtg-counters,.ssa-probability__grid,.ssa-dice-next__grid),
.ssa-dice-companion :is(.ssa-dice-next__grid,.ssa-gear__grid) {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)) !important;
  gap: 12px !important;
  min-width: 0 !important;
}

.ssa-dice :is(.ssa-dice__row,.mtg-life) {
  grid-template-columns: minmax(0, 1fr) repeat(4, auto) !important;
}

.ssa-dice :is(.ssa-dd-panel,.ssa-mtg-panel,.ssa-tabpane,.ssa-dd__group,.ssa-mtg-panel .mtg-card,.ssa-history,.ssa-dice__results,.ssa-help,details,fieldset),
.ssa-dice-companion :is(.card,details,.ssa-tabpane,.ssa-gear__disclosure,.ssa-gear__sponsored) {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
}

.ssa-dice :is(.ssa-btn,.ssa-chip,.ssa-mode-btn,.ssa-tab,.qb,.mtg-btn),
.ssa-dice-companion :is(.btn,button,a.button) {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  min-width: 44px !important;
  max-width: 100% !important;
  white-space: normal !important;
  overflow-wrap: break-word !important;
  text-align: center !important;
}

@media (max-width: 640px) {
  .ssa-dice-page,
  .ssa-dice,
  .ssa-dice-companion {
    width: min(100%, calc(100dvw - 12px)) !important;
    max-width: calc(100dvw - 12px) !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .ssa-dice :is(.ssa-dice__row,.ssa-dice__opts-grid,.ssa-dd__row,.ssa-death,.mtg-counters,.ssa-probability__grid,.ssa-dice-next__grid),
  .ssa-dice-companion :is(.ssa-dice-next__grid,.ssa-gear__grid) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .ssa-dice .mtg-life {
    grid-template-columns: repeat(2, minmax(44px, auto)) minmax(0, 1fr) repeat(2, minmax(44px, auto)) !important;
  }

  .ssa-dice .ssa-dice__row .ssa-input {
    grid-column: 1 / -1 !important;
  }

  .ssa-dice :is(.ssa-btn,.ssa-chip,.ssa-mode-btn,.ssa-tab,.qb,.mtg-btn),
  .ssa-dice-companion :is(.btn,button,a.button) {
    min-height: 44px !important;
  }
}
