/* Pip-Boy CRT phosphor-green visual system.
   Every colour, gradient and font below is a design token from
   `pipboy-terminal-chrome`. Nothing outside this set may be introduced:
   reuse green and amber at alpha via the rgba() ladders, and express dim
   text with element `opacity`, never with a colour alpha. */

:root {
    /* ── The six literals ─────────────────────────────────────── */
    --phosphor: #33ff66;
    --phosphor-bright: #aaffc0;
    --amber: #ffb02e;
    --screen-bg: #06110a;
    --case-gradient: linear-gradient(160deg, #22261c, #0e100b);
    --page-gradient: radial-gradient(circle at 50% 30%, #14170f 0%, #050604 70%);

    /* ── Green opacity ladder ─────────────────────────────────── */
    --green-border: rgba(51, 255, 102, 0.4);      /* default control border */
    --green-border-soft: rgba(51, 255, 102, 0.25);
    --green-border-strong: rgba(51, 255, 102, 0.5);
    --green-hairline: rgba(51, 255, 102, 0.2);    /* dividers: 0.15–0.28 */
    --green-hairline-faint: rgba(51, 255, 102, 0.15);
    --green-fill: rgba(51, 255, 102, 0.08);       /* tinted fills: 0.08–0.14 */
    --green-fill-active: rgba(51, 255, 102, 0.14);
    --green-dashed: rgba(51, 255, 102, 0.45);

    /* ── Amber opacity ladder ─────────────────────────────────── */
    --amber-border: rgba(255, 176, 46, 0.5);
    --amber-fill: rgba(255, 176, 46, 0.12);
    --amber-glow: 0 0 4px rgba(255, 176, 46, 0.4);
    --amber-glow-strong: 0 0 6px rgba(255, 176, 46, 0.5);

    /* ── CRT ──────────────────────────────────────────────────── */
    --phosphor-text-glow: 0 0 4px rgba(51, 255, 102, 0.55);
    --screen-inner-glow: inset 0 0 60px rgba(51, 255, 102, 0.14), inset 0 0 6px rgba(51, 255, 102, 0.4);

    --font-display: 'VT323', monospace;
    --font-body: 'Share Tech Mono', monospace;

    /* ── Safe-area / edge-to-edge ─────────────────────────────────
       Insets are routed through variables (defaulting to the OS-reported
       `env(safe-area-inset-*)`) so the shell can pad the case away from a
       notch/home indicator while reaching the display edge where no inset
       exists. `--pb-edge-margin` is the small floating margin used in a plain
       browser tab (where insets resolve to 0); it collapses to 0 when the app
       runs fullscreen/standalone so the case goes truly edge-to-edge. */
    --pb-safe-top: env(safe-area-inset-top, 0px);
    --pb-safe-right: env(safe-area-inset-right, 0px);
    --pb-safe-bottom: env(safe-area-inset-bottom, 0px);
    --pb-safe-left: env(safe-area-inset-left, 0px);
    --pb-edge-margin: 12px;
}

/* Installed/fullscreen: drop the floating margin so the case reaches the
   physical display edges; safe-area insets still keep content off the notch. */
@media (display-mode: standalone), (display-mode: fullscreen) {
    :root { --pb-edge-margin: 0px; }
}

* { box-sizing: border-box; }

/* Square corners are the rule. The case, screen, and the three bezel parts
   below are the only elements permitted a non-zero radius. */
button, input, select, textarea { border-radius: 0; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--page-gradient);
    color: var(--phosphor);
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    /* Per-side max(fallback, safe-area): the case reaches the display edge when
       no inset exists (fullscreen collapses the fallback to 0) and stays clear
       of a notch/home indicator when the OS reports one. */
    padding-top: max(var(--pb-edge-margin), var(--pb-safe-top));
    padding-right: max(var(--pb-edge-margin), var(--pb-safe-right));
    padding-bottom: max(var(--pb-edge-margin), var(--pb-safe-bottom));
    padding-left: max(var(--pb-edge-margin), var(--pb-safe-left));
}

::selection { background: rgba(51, 255, 102, 0.35); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(51, 255, 102, 0.3); }
::-webkit-scrollbar-track { background: transparent; }

.vt { font-family: var(--font-display); }

/* ── CRT keyframes ──────────────────────────────────────────────── */

@keyframes crtFlicker {
    0%, 100% { opacity: 0.97; }
    50% { opacity: 1; }
    52% { opacity: 0.94; }
}

/* The sweep translates a band down the screen; it is applied to
   `.pb-scanline-sweep`, a rendered element. */
@keyframes scanSweep {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(250%); }
}

/* ── Case + screen skeleton ─────────────────────────────────────── */

/* The case fills the body's content box — the viewport minus the small uniform
   `body` padding (the "tiny margin") — in every orientation, with no fixed pixel
   `max-width`/`max-height` cap that would leave it floating in dead space on a
   large viewport. Internal scrolling stays inside `.pb-screen-content`. */
.pb-case {
    width: 100%;
    height: 100%;
    background: var(--case-gradient);
    border: 1px solid #333829;
    border-radius: 26px;
    padding: 16px 14px 12px;
    box-shadow:
        inset 0 2px 3px rgba(120, 140, 90, 0.25),
        inset 0 -6px 14px rgba(0, 0, 0, 0.7),
        0 24px 60px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pb-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.7;
    /* Top-most chrome: pad by the top inset so the status text/nav never lands
       under the notch when the case bleeds toward the display edge. */
    padding: var(--pb-safe-top) 4px 0;
}

/* The status LED is round, per the reference; see the case/screen/bezel
   exceptions to the no-border-radius rule. */
.pb-statusbar .dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--phosphor);
    box-shadow: 0 0 6px var(--phosphor);
    margin-right: 7px;
}

.pb-statusbar-nav { display: flex; gap: 6px; }
.pb-statusbar-nav[hidden] { display: none; }

.pb-statusbar-btn {
    background: transparent;
    border: 1px solid var(--green-border);
    color: var(--phosphor);
    font-family: var(--font-body);
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 2px 6px;
    cursor: pointer;
}
.pb-statusbar-btn:hover { background: var(--green-fill); }
.pb-statusbar-btn[hidden] { display: none; }

/* The `✎` editor toggle carries a glyph and, while active, a pressed/tinted look. */
.pb-statusbar-btn--toggle { font-size: 11px; }
.pb-statusbar-btn--toggle.active {
    background: var(--green-fill);
    border-color: var(--green-border-strong);
    color: var(--phosphor-bright);
    text-shadow: 0 0 6px var(--phosphor-bright);
}

/* Critical state swaps the status dot and label to amber. */
.pb-statusbar.critical .dot {
    background: var(--amber);
    box-shadow: 0 0 6px var(--amber);
}
.pb-statusbar.critical .pb-status-label { color: var(--amber); text-shadow: var(--amber-glow); }

.pb-screen {
    flex: 1;
    min-height: 0;
    background: var(--screen-bg);
    border: 2px solid #05170c;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--screen-inner-glow);
    text-shadow: var(--phosphor-text-glow);
    animation: crtFlicker 4s infinite;
    display: flex;
    flex-direction: column;
}

.pb-screen * { text-shadow: inherit; }

/* Holds whatever screen is mounted; siblings below are the CRT overlays,
   which stack above it at z-index 3–5. */
.pb-screen-inner {
    position: relative;
    z-index: 2;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Scrolling lives here and nowhere else (pipboy-responsive-shell). */
.pb-screen-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
    /* Keep native vertical scrolling but hand horizontal gestures to the swipe
       handler (sheet.js) so touch devices never fire `pointercancel` mid-swipe.
       No descendant here relies on horizontal touch-drag (the only overflow-x:auto
       regions — `.pb-tabs`/`.pb-subtabs` — are siblings, not descendants). */
    touch-action: pan-y;
}

/* ── CRT overlays (never interactive) ───────────────────────────── */

.pb-scanline-texture,
.pb-vignette,
.pb-editor-ring,
.pb-critical-ring {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* z3 texture, z4 vignette, z5 critical ring — all above content (z2). */
.pb-scanline-texture {
    z-index: 3;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.18) 0px,
        rgba(0, 0, 0, 0.18) 1px,
        transparent 1px,
        transparent 3px
    );
}

.pb-vignette {
    z-index: 4;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.pb-scanline-sweep {
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 40%;
    z-index: 3;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(51, 255, 102, 0.08), transparent);
    animation: scanSweep 7s linear infinite;
}

/* Always-visible signal of editor mode, shown with the ◉ EDITOR strip. Sits
   below the critical ring (z4 vs z5); chrome.js hides it while critical so the
   amber ring takes precedence, matching the banner precedence rule. */
.pb-editor-ring {
    z-index: 4;
    border-radius: 14px;
    border: 1px solid var(--green-border-strong);
    box-shadow: inset 0 0 45px rgba(51, 255, 102, 0.25);
}
.pb-editor-ring[hidden] { display: none; }

/* Shown alongside the ⚠ STATO CRITICO banner, never instead of it. */
.pb-critical-ring {
    z-index: 5;
    border-radius: 14px;
    border: 1px solid var(--amber-border);
    box-shadow: inset 0 0 45px rgba(255, 176, 46, 0.3);
}
.pb-critical-ring[hidden] { display: none; }

/* ── Bottom bezel ───────────────────────────────────────────────── */

.pb-bezel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 8px 2px;
    flex: none;
}

.pb-knobs { display: flex; gap: 8px; }

.pb-knob {
    width: 22px; height: 22px;
    flex: none;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #3a4030, #14170f);
    border: 1px solid #444a37;
    box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.6);
}

.pb-grille {
    flex: 1;
    height: 6px;
    margin: 0 14px;
    border-radius: 3px;
    background: repeating-linear-gradient(90deg, #2a2f22 0 3px, #12140d 3px 6px);
}

.pb-nub {
    width: 34px; height: 12px;
    flex: none;
    border-radius: 6px;
    background: linear-gradient(#3a4030, #14170f);
    border: 1px solid #444a37;
}

/* ── Typography ─────────────────────────────────────────────────── */

h1, h2, h3 { margin: 0 0 8px; font-family: var(--font-display); letter-spacing: 1px; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; text-transform: uppercase; opacity: 0.85; }

.pb-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.6;
}

.pb-section-head {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.75;
    margin: 14px 0 6px;
}
.pb-section-head::before { content: '▸ '; }

.pb-hairline {
    border: none;
    border-top: 1px solid var(--green-hairline);
    margin: 10px 0;
}

.pb-dashed {
    border: none;
    border-top: 1px dashed rgba(51, 255, 102, 0.3);
    margin: 10px 0;
}

/* ── Controls ───────────────────────────────────────────────────── */

.pb-btn {
    background: transparent;
    border: 1px solid var(--green-border);
    color: var(--phosphor);
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 12px;
    padding: 8px 12px;
    cursor: pointer;
}
.pb-btn:hover { background: var(--green-fill); }
.pb-btn:disabled { opacity: 0.35; cursor: default; }
.pb-btn--primary { box-shadow: 0 0 6px rgba(51, 255, 102, 0.4); }
/* Dashed marks "add" and optional actions. */
.pb-btn--dashed { border: 1px dashed var(--green-dashed); }
.pb-btn--danger { border-color: var(--amber-border); color: var(--amber); }
.pb-btn--block { width: 100%; }

.pb-input, .pb-select {
    background: rgba(51, 255, 102, 0.06);
    border: 1px solid rgba(51, 255, 102, 0.35);
    color: var(--phosphor);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 8px;
    width: 100%;
}
.pb-input::placeholder { color: rgba(51, 255, 102, 0.4); }

/* Render the native option popup on the phosphor theme rather than the
   browser-default light list. Native option styling is only partially honored
   on some platforms — this states the on-theme intent, accepting that variance. */
.pb-select option,
.pb-select optgroup {
    background: var(--screen-bg);
    color: var(--phosphor);
}

.pb-field { display: flex; flex-direction: column; gap: 4px; text-align: left; }

.pb-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pb-stepper button {
    width: 38px; height: 38px;
    border: 1px solid var(--green-border);
    background: transparent;
    color: var(--phosphor);
    font-family: var(--font-display);
    font-size: 22px;
    cursor: pointer;
}
.pb-stepper button:disabled { opacity: 0.3; cursor: default; }
.pb-stepper .value {
    font-family: var(--font-display);
    font-size: 28px;
    min-width: 48px;
    text-align: center;
}

.pb-pips { display: flex; gap: 4px; flex-wrap: wrap; }
.pb-pip {
    width: 14px; height: 14px;
    border: 1px solid var(--green-border);
}
.pb-pip.filled {
    background: var(--phosphor);
    box-shadow: 0 0 6px var(--phosphor);
}

.pb-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--green-border-soft);
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
}
.pb-chip .kind {
    font-size: 8px;
    opacity: 0.6;
    text-transform: uppercase;
}
.pb-chip.damaged { text-decoration: line-through; color: var(--amber); border-color: rgba(255, 176, 46, 0.4); }

.pb-row {
    border: 1px solid var(--green-border-soft);
    padding: 10px;
    margin-bottom: 8px;
}

/* ── Header / tabs / footer ─────────────────────────────────────── */

.pb-header {
    padding: 10px 14px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pb-header-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.pb-tabs {
    display: flex;
    border-top: 1px solid var(--green-hairline);
    border-bottom: 1px solid var(--green-hairline);
    overflow-x: auto;
}
.pb-tab {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
    cursor: pointer;
    white-space: nowrap;
    background: transparent;
    border: none;
    color: var(--phosphor);
    font-family: var(--font-body);
    position: relative;
}
/* 2px glowing underline, not an inset shadow. */
.pb-tab.active {
    opacity: 1;
    background: var(--green-fill-active);
}
.pb-tab.active::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 2px;
    background: var(--phosphor);
    box-shadow: 0 0 6px var(--phosphor);
}

/* Second-level subtab row: only rendered when the active first-level tab has
   subtabs (the [hidden] attribute removes it otherwise). Lighter than the L1
   bar — smaller text, a tinted fill on the active one, no underline. */
.pb-subtabs {
    display: flex;
    border-bottom: 1px solid var(--green-hairline-faint);
    overflow-x: auto;
}
.pb-subtabs[hidden] { display: none; }
.pb-subtab {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    cursor: pointer;
    white-space: nowrap;
    background: transparent;
    border: none;
    border-right: 1px solid var(--green-hairline-faint);
    color: var(--phosphor);
    font-family: var(--font-body);
}
.pb-subtab:last-child { border-right: none; }
.pb-subtab.active {
    opacity: 1;
    background: var(--green-fill);
    box-shadow: inset 0 -2px 0 var(--green-border-soft);
}

.pb-footer {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    opacity: 0.6;
    /* Bottom-most chrome: pad the base by the bottom inset so the footer clears
       the home indicator when the case reaches the display edge. */
    padding: 6px 14px calc(6px + var(--pb-safe-bottom));
    border-top: 1px solid var(--green-hairline-faint);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pb-banner-critical {
    background: var(--amber-fill);
    border: 1px solid var(--amber-border);
    color: var(--amber);
    text-shadow: var(--amber-glow-strong);
    padding: 8px 12px;
    margin: 10px 14px 0;
    text-align: center;
    font-family: var(--font-display);
    font-size: 18px;
    letter-spacing: 2px;
}

.pb-offline-banner {
    background: rgba(255, 176, 46, 0.1);
    border: 1px solid rgba(255, 176, 46, 0.4);
    color: var(--amber);
    padding: 8px 12px;
    margin: 10px 14px 0;
    font-size: 11px;
    text-align: center;
}

.pb-error {
    color: var(--amber);
    text-shadow: var(--amber-glow);
    font-size: 12px;
    margin-top: 6px;
}

.pb-center-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    gap: 12px;
    text-align: center;
}

.pb-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pb-select-item {
    border: 1px solid rgba(51, 255, 102, 0.3);
    padding: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pb-select-item:hover { background: var(--green-fill); }

/* ── Sheet header ───────────────────────────────────────────────── */

.pb-species-chip {
    border: 1px solid var(--green-border-soft);
    padding: 2px 8px;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.pb-pa-control {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
/* Squares only: the − and + flank the pip row; there is no numeric readout. */
.pb-pa-track {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex: 1;
}
/* Pip row sizes to its content so the − / + controls hug the squares
   instead of being pushed to opposite edges of the header. */
.pb-pa-track .pb-pips { flex: 0 0 auto; }
.pb-pa-track button {
    width: 30px; height: 30px;
    border: 1px solid var(--green-border);
    background: transparent;
    color: var(--phosphor);
    font-family: var(--font-display);
    font-size: 18px;
    cursor: pointer;
}
.pb-pa-track button:disabled { opacity: 0.3; cursor: default; }

.pb-editor-strip {
    border: 1px solid var(--green-border-soft);
    background: var(--green-fill);
    color: var(--phosphor);
    padding: 6px 12px;
    margin: 10px 14px 0;
    text-align: center;
    font-size: 11px;
    letter-spacing: 1px;
}

/* ── S.P.E tab ──────────────────────────────────────────────────── */

.pb-hint { font-size: 10px; opacity: 0.45; margin-bottom: 12px; }

.pb-approach-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--green-hairline-faint);
    color: var(--phosphor);
    font-family: var(--font-body);
    padding: 8px 2px;
    cursor: pointer;
}
.pb-approach-row:hover { background: var(--green-fill); }

.pb-approach-letter { font-size: 22px; width: 18px; flex: none; }
.pb-approach-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pb-approach-name { font-size: 12px; letter-spacing: 1px; }
.pb-approach-desc { font-size: 10px; opacity: 0.5; }

.pb-legend {
    border: 1px solid var(--green-border-soft);
    padding: 10px;
    margin-top: 14px;
    font-size: 10px;
    line-height: 1.5;
}
.pb-legend-label { opacity: 0.6; }

.pb-stepper-row { display: flex; align-items: center; gap: 10px; }
.pb-stepper-row .pb-approach-name { flex: 1; }

/* ── ABIL tab ───────────────────────────────────────────────────── */

.pb-split-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pb-add-row { display: flex; gap: 6px; align-items: center; margin-top: 8px; }

.pb-select--inline { width: auto; }
.pb-btn--icon { padding: 4px 8px; font-size: 12px; }
.pb-btn--tiny { padding: 2px 6px; font-size: 9px; }

.pb-empty { font-size: 11px; opacity: 0.5; }
.pb-empty-dashed {
    border: 1px dashed var(--green-hairline);
    padding: 10px;
    text-align: center;
    font-size: 11px;
    opacity: 0.5;
}

.pb-spend-row {
    border-bottom: 1px dashed var(--green-hairline-faint);
    padding: 5px 0;
    font-size: 11px;
}
.pb-spend-head { opacity: 0.6; }

/* ── SALUTE tab ─────────────────────────────────────────────────── */

.pb-net-box {
    border: 1px solid var(--green-border-soft);
    padding: 10px;
    margin-bottom: 12px;
    text-align: center;
}
.pb-net-value { font-size: 34px; line-height: 1; }
.pb-net-value.amber { color: var(--amber); text-shadow: var(--amber-glow-strong); }

.pb-cond-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: 1px solid var(--green-border-soft);
    color: var(--phosphor);
    font-family: var(--font-body);
    font-size: 11px;
    padding: 9px 10px;
    margin-bottom: 6px;
    cursor: pointer;
    text-align: left;
}
.pb-cond-row:hover { background: var(--green-fill); }
.pb-cond-sign { font-family: var(--font-display); font-size: 18px; width: 12px; }
.pb-cond-name { flex: 1; letter-spacing: 1px; }
.pb-cond-tag { font-size: 9px; opacity: 0.6; letter-spacing: 1px; }
.pb-cond-remove { opacity: 0.6; }

.pb-preset-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pb-preset { font-size: 10px; padding: 6px 8px; }

.pb-toggle-row { display: flex; gap: 6px; margin-top: 8px; }
.pb-toggle { flex: 1; font-size: 11px; padding: 11px 0; }
.pb-toggle.active { background: var(--green-fill-active); }

.pb-btn--submit {
    margin-top: 8px;
    background: rgba(51, 255, 102, 0.1);
    border: 1px solid var(--green-border-strong);
    font-family: var(--font-display);
    font-size: 18px;
    padding: 11px 0;
}

/* ── ZAINO tab ──────────────────────────────────────────────────── */

/* Pinned at the bottom of every INV subtab. Sized to fit ~360px: three boxes
   share the width with a min-width of 0 so the numeric input can shrink rather
   than overflow the case. */
.pb-resource-row { display: flex; gap: 6px; margin-top: 12px; }
.pb-resource-box {
    flex: 1 1 0;
    min-width: 0;
    border: 1px solid var(--green-border-soft);
    padding: 6px 4px;
    text-align: center;
}
.pb-resource-box .pb-stepper { justify-content: center; gap: 2px; }
.pb-resource-box .pb-stepper--tiny button { width: 22px; height: 22px; font-size: 14px; }
.pb-resource-box .pb-label { font-size: 9px; }
.pb-resource-input {
    width: 100%;
    min-width: 0;
    text-align: center;
    padding: 4px 0;
    font-family: var(--font-display);
    font-size: 16px;
}
/* Hide the native number spinners; the ± buttons are the affordance. */
.pb-resource-input::-webkit-inner-spin-button,
.pb-resource-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pb-resource-input { -moz-appearance: textfield; appearance: textfield; }

.pb-stepper--tiny button { width: 26px; height: 26px; font-size: 16px; }

.pb-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }

/* CORE: tinted fill + solid border. EXTRA: unfilled + dashed border. */
.pb-chip--core {
    background: var(--green-fill-active);
    border: 1px solid var(--green-border);
}
.pb-chip--extra {
    background: transparent;
    border: 1px dashed var(--green-dashed);
}
.pb-chip {
    color: var(--phosphor);
    font-family: var(--font-body);
    cursor: pointer;
}
.pb-chip-input { width: 74px; background: transparent; border: none; color: inherit; font: inherit; }
.pb-chip-remove { background: transparent; border: none; color: inherit; cursor: pointer; padding: 0 2px; }

.pb-danger-tag {
    color: var(--amber);
    border: 1px solid var(--amber-border);
    text-shadow: var(--amber-glow);
    font-size: 9px;
    letter-spacing: 1px;
    padding: 1px 5px;
}

.pb-consumable-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px dashed var(--green-hairline-faint);
    padding: 8px 2px;
}
.pb-consumable-name { flex: 1; font-size: 12px; }

/* ── DADI tab ───────────────────────────────────────────────────── */

.pb-approach-picker { display: flex; gap: 4px; margin: 8px 0; }
.pb-approach-picker .pb-seg { font-family: var(--font-display); font-size: 16px; padding: 6px 0; }

.pb-pool-readout {
    text-align: center;
    font-size: 34px;
    margin: 12px 0 8px;
}

.pb-dice-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    min-height: 42px;
}

.pb-die {
    width: 42px; height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--green-border);
    background: transparent;
    color: var(--phosphor);
    font-family: var(--font-display);
    font-size: 24px;
    cursor: pointer;
}
/* A `6` glows bright; 4/5 plain green; 1–3 dim. */
.pb-die--full {
    color: var(--phosphor-bright);
    background: var(--green-fill-active);
    text-shadow: 0 0 6px var(--phosphor-bright);
}
.pb-die--cost { color: var(--phosphor); }
.pb-die--fail { opacity: 0.45; }

.pb-die.selected {
    border: 2px solid var(--phosphor);
    background: var(--green-fill-active);
}

/* Dropped by SVANTAGGIO: dimmed, struck through, and not a button. */
.pb-die.dropped {
    opacity: 0.3;
    text-decoration: line-through;
    cursor: default;
}

.pb-result-box {
    border: 1px solid var(--green-border-soft);
    text-align: center;
    font-size: 20px;
    letter-spacing: 2px;
    padding: 10px;
    margin: 10px 0;
}

.pb-register { max-height: 160px; overflow-y: auto; }

/* ── Dossier ────────────────────────────────────────────────────── */

.pb-dossier-card {
    border: 1px solid var(--green-border-soft);
    padding: 10px;
    cursor: pointer;
}
.pb-dossier-card:hover { background: var(--green-fill); }
.pb-dossier-skills { margin-top: 4px; }

.pb-mini-special { display: flex; gap: 6px; margin-top: 6px; }
.pb-mini-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--green-hairline);
    padding: 2px 0;
}
.pb-mini-letter { font-size: 12px; opacity: 0.6; }
.pb-mini-value { font-size: 16px; }

/* ── Creation wizard ────────────────────────────────────────────── */

.pb-progress { display: flex; gap: 4px; margin-top: 6px; }
.pb-progress-seg {
    flex: 1;
    height: 3px;
    background: var(--green-hairline);
}
.pb-progress-seg.filled {
    background: var(--phosphor);
    box-shadow: 0 0 4px var(--phosphor);
}

.pb-wizard-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-top: 1px solid var(--green-hairline-faint);
}
.pb-wizard-footer .pb-error { margin: 0; flex: 1; font-size: 10px; }
.pb-wizard-footer #pb-cr-next,
.pb-wizard-footer #pb-cr-create { margin-left: auto; }
.pb-btn--create {
    background: rgba(51, 255, 102, 0.14);
    border-color: var(--green-border-strong);
    padding: 8px 20px;
}

.pb-species-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 10px;
}
.pb-species-option.active { background: var(--green-fill-active); }

.pb-info-box {
    border: 1px solid var(--green-border-soft);
    padding: 10px;
    margin-top: 10px;
    font-size: 11px;
    line-height: 1.5;
}
.pb-info-perm { color: var(--phosphor); }
.pb-info-svan { color: var(--amber); text-shadow: var(--amber-glow); margin-top: 6px; }

.pb-remaining { font-size: 18px; }
.pb-remaining.amber { color: var(--amber); text-shadow: var(--amber-glow-strong); }
.pb-remaining.zero { color: var(--phosphor); text-shadow: 0 0 6px var(--phosphor); }

.pb-pa-panels { display: flex; gap: 8px; margin-top: 10px; }
.pb-pa-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 0;
}
.pb-pa-panel.active { background: var(--green-fill-active); }
.pb-pa-panel-value { font-size: 30px; }

.pb-segmented { display: flex; gap: 4px; margin-top: 6px; }
.pb-seg {
    flex: 1;
    background: transparent;
    border: 1px solid var(--green-border);
    color: var(--phosphor);
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 1px;
    padding: 6px 0;
    cursor: pointer;
}
.pb-seg.active { background: var(--green-fill-active); }

.pb-equip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 6px;
    text-align: left;
}
.pb-equip-row.active { background: var(--green-fill-active); }

.pb-scraps-value { font-size: 22px; }

.pb-summary-list { margin: 0; padding-left: 18px; font-size: 11px; line-height: 1.7; }

/* ── Login ──────────────────────────────────────────────────────── */

.pb-login-wordmark { font-size: 44px; margin: 0; letter-spacing: 3px; }
.pb-login-subtitle { font-size: 10px; letter-spacing: 2px; opacity: 0.6; text-transform: uppercase; }
.pb-login-flavor { font-size: 11px; opacity: 0.7; letter-spacing: 1px; align-self: flex-start; }
.pb-login-form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 280px; }

@media (max-width: 420px) {
    .pb-case { border-radius: 16px; padding: 10px 8px 8px; }
    .pb-screen { border-radius: 8px; }
}

/* ── INV subtab: section head with the + add trigger ────────────── */

.pb-inv-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pb-inv-add { line-height: 1; }

/* ── Add-item popup ─────────────────────────────────────────────── */

.pb-hidden { display: none !important; }

.pb-popup-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(3, 8, 5, 0.75);
}
.pb-popup {
    position: relative;
    width: 100%;
    max-width: 320px;
    max-height: 90%;
    overflow-y: auto;
    border: 1px solid var(--green-border);
    background: var(--screen-bg);
    box-shadow: var(--screen-inner-glow);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
/* Small red ✕ in the top-right cancels with no write. */
.pb-popup-close {
    position: absolute;
    top: 6px; right: 6px;
    width: 24px; height: 24px;
    border: 1px solid var(--amber-border);
    background: transparent;
    color: var(--amber);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
}
.pb-popup-close:hover { background: var(--amber-fill); }
.pb-popup-title {
    font-family: var(--font-display);
    font-size: 18px;
    letter-spacing: 2px;
    padding-right: 28px;
}
.pb-popup-tabs { display: flex; border-bottom: 1px solid var(--green-hairline); }
.pb-popup-tab {
    flex: 1;
    padding: 6px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--phosphor);
    font-family: var(--font-body);
}
.pb-popup-tab.active { opacity: 1; background: var(--green-fill); }
.pb-popup-body { display: flex; flex-direction: column; gap: 8px; }
.pb-popup-pane { display: flex; flex-direction: column; gap: 8px; }
.pb-popup-tags { min-height: 4px; }
.pb-popup-actions { display: flex; justify-content: flex-end; }

/* --- full-screen catalog picker sheet -------------------------------------
   The mobile-readable replacement for the native <datalist>. It opens above the
   add-item popup (which sits at z-index 40), so it takes a higher layer and
   fills the screen, with scrolling confined to its own list. Safe-area aware so
   the sheet clears a notch. */
.pb-picker-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    background: rgba(3, 8, 5, 0.85);
}
.pb-picker {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding:
        max(14px, var(--pb-safe-top)) max(14px, var(--pb-safe-right))
        max(14px, var(--pb-safe-bottom)) max(14px, var(--pb-safe-left));
    background: var(--screen-bg);
    box-shadow: var(--screen-inner-glow);
    gap: 10px;
}
.pb-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.pb-picker-title {
    font-family: var(--font-display);
    font-size: 18px;
    letter-spacing: 2px;
}
.pb-picker-close {
    flex: none;
    width: 32px; height: 32px;
    border: 1px solid var(--amber-border);
    background: transparent;
    color: var(--amber);
    font-family: var(--font-body);
    font-size: 15px;
    cursor: pointer;
}
.pb-picker-close:hover { background: var(--amber-fill); }
.pb-picker-search { flex: none; }
/* The only scroll region: the sheet itself never scrolls, its list does. */
.pb-picker-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pb-picker-row {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 12px;
    border: 1px solid var(--green-border);
    background: rgba(51, 255, 102, 0.06);
    color: var(--phosphor);
    font-family: var(--font-body);
    font-size: 14px;
    cursor: pointer;
}
.pb-picker-row:hover { background: var(--green-fill); }
/* The "use my typed text" row reads as an add affordance, not a catalog hit. */
.pb-picker-freetext { border-style: dashed; }

/* The add-item popup's "Scegli esistente" field is a button that opens the
   picker; it borrows .pb-input but aligns like a field and dims its placeholder. */
.pb-popup-picker-field { text-align: left; cursor: pointer; }
.pb-popup-picker-field:disabled { opacity: 0.5; cursor: default; }
.pb-popup-picker-value[data-empty] { color: rgba(51, 255, 102, 0.4); }
