/* ============================================
   PROGRESS INTEL — Premium Styles
   Nocturnal Conquest Redesign Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@700;800;900&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    --pi-bg: #0c0f17;
    /* Midnight Bedrock */
    --pi-bg-deep: #06080d;
    --pi-panel: #151b26;
    /* Slate Panel */
    --pi-panel-raised: #1f2736;
    --pi-gold: #fbbf24;
    /* Treasury Gold */
    --pi-gold-deep: #d97706;
    --pi-gold-text: #fde68a;
    /* Warning Amber (war sub-score 4-6 band — previously referenced but undefined) */
    --pi-yellow: #f59e0b;
    --pi-green: #10b981;
    /* Treasury Green */
    --pi-green-deep: #047857;
    --pi-red: #ef4444;
    --pi-blue: #3b82f6;
    --pi-purple: #d946ef;
    /* Elixir Purple */
    --pi-purple-glow: rgba(217, 70, 239, 0.08);
    --pi-ink: #f8fafc;
    --pi-ink-soft: #94a3b8;
    --pi-ink-faint: #475569;
    --pi-border-color: #202a3a;
    /* Crisp Dark Slate border */
    --pi-border-chunky: 1px solid var(--pi-border-color);
}

/* ===== CSS Enhancements ===== */
.chart-fill {
  fill: rgba(255, 204, 0, 0.15); /* Sleek translucent gold */
}

.intel-badge {
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 11px;
}

.subtext-disabled {
  color: #a0998e; /* Rich readable beige/gray instead of dark gray */
}

/* ===== Typography Overrides ===== */
h1,
h2,
h3,
h4,
h5,
h6,
.banner,
.wp-score,
.wp-sub-val,
.stat-tile-val,
.stat-box-val,
.finish-date,
.pi-section-header,
.pi-progress-pct,
.progress-pct,
.section-title,
.lane-title {
    font-family: 'Rubik', sans-serif !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
    text-transform: uppercase !important;
}

body,
#progress-view,
.pi-tab-btn,
.upgrade-row,
.portrait-card,
.stat-box-lbl,
.finish-label,
.power-name,
.builder-num,
.builder-lvl,
.lab-name,
.lab-lvl {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
}

.eta,
.lab-time,
.builder-time,
.stat-tile-val span,
.wp-sub-val span,
.power-lvl,
.lab-time,
.builder-time {
    font-family: 'JetBrains Mono', monospace !important;
}

/* ===== Page Container + Nocturnal Conquest Backdrop ===== */
#progress-view {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px 14px 120px;
    position: relative;
    background: var(--pi-bg);
    border-left: var(--pi-border-chunky);
    border-right: var(--pi-border-chunky);
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--pi-ink);
    min-height: 100vh;
}

#progress-view>* {
    position: relative;
    z-index: 1;
}

/* ===== Redesign Core Classes ===== */
.headbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.avatar {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(160deg, #3a4a5c, #212b37);
    border: var(--pi-border-chunky);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.avatar img {
    border-radius: 4px;
}

.who {
    flex: 1;
    text-align: left;
}

.who .name {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--pi-ink);
    margin: 0;
}

.who .clan {
    font-size: 12px;
    color: var(--pi-ink-faint);
    margin-top: 2px;
}

.th-badge {
    background: var(--pi-gold);
    color: #4a3007;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 8px;
    border: var(--pi-border-chunky);
}

.banner {
    display: inline-block;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #4a3007;
    background: var(--pi-gold);
    padding: 5px 14px;
    border-radius: 6px 6px 0 0;
    border: 2px solid var(--pi-border-color);
    border-bottom: none;
    position: relative;
    top: 1px;
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.25) inset;
    z-index: 2;
}

.hero-card {
    background: linear-gradient(180deg, #242e3a, #1c2530);
    border: var(--pi-border-chunky);
    border-radius: 18px;
    padding: 22px 18px 18px;
    margin-bottom: 16px;
    text-align: center;
    position: relative;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 10px 24px rgba(0, 0, 0, 0.35),
        0 2px 0 rgba(0, 0, 0, 0.5);
    transition: transform 0.15s ease;
}

.hero-card:active {
    transform: scale(0.98);
}

.hero-pct {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 56px;
    line-height: 1;
    color: var(--pi-green);
    text-shadow: 0 2px 0 #123315;
}

.hero-label {
    font-size: 12px;
    color: var(--pi-ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 2px;
}

.war-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    background: var(--pi-panel);
    border-radius: 10px;
    padding: 10px 12px;
    border: 2px solid var(--pi-border-color);
}

.war-row .lbl {
    font-size: 12px;
    color: var(--pi-ink-soft);
    white-space: nowrap;
}

.war-bar-track {
    flex: 1;
    height: 10px;
    background: var(--pi-bg-deep);
    border-radius: 6px;
    overflow: hidden;
}

.war-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pi-gold-deep), var(--pi-gold));
    border-radius: 6px;
}

.war-score {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--pi-gold-text);
    white-space: nowrap;
}

.section {
    margin-bottom: 16px;
    text-align: left;
}

.section-body {
    background: linear-gradient(180deg, #1d2631, #161d26);
    border: var(--pi-border-chunky);
    border-radius: 0 14px 14px 14px;
    padding: 14px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.04) inset,
        0 8px 18px rgba(0, 0, 0, 0.28);
}

.health-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.health-icon {
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.health-name {
    font-size: 13px;
    width: 56px;
    color: var(--pi-ink-soft);
}

.health-track {
    flex: 1;
    height: 8px;
    background: var(--pi-bg-deep);
    border-radius: 5px;
    overflow: hidden;
}

.health-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

.health-pct {
    font-size: 12px;
    width: 32px;
    text-align: right;
    color: var(--pi-ink-soft);
    font-weight: 700;
}

/* ═══ Smart Health — lowest % category highlight ═══ */
.health-row.needs-attention .health-name {
    color: var(--pi-red) !important;
}

.attention-tag {
    display: inline-flex;
    align-items: center;
    height: 16px;
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pi-red, #ef4444);
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0 5px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
    white-space: nowrap;
    line-height: 1;
    box-sizing: border-box;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

@media (max-width: 360px) {
    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.stat-tile {
    background: linear-gradient(180deg, #26313e, #1c2530);
    border-radius: 10px;
    padding: 8px 4px;
    text-align: center;
    border: 2px solid var(--pi-border-color);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 4px 10px rgba(0, 0, 0, 0.25);
    transition: transform 0.12s ease;
}

/* Maxed stat tile — same green-glow treatment as maxed portraits elsewhere */
.stat-tile.maxed {
    border-color: var(--pi-green);
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.25), 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 4px 10px rgba(0, 0, 0, 0.25);
}

.stat-tile:active {
    transform: scale(0.94);
}

.stat-ring {
    position: relative;
    width: 42px;
    height: 42px;
    margin: 0 auto 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    font-family: 'Baloo 2', sans-serif;
    border: 1px solid var(--pi-bg-deep);
}

.stat-ring::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: #1c2530;
    border-radius: 50%;
    z-index: 1;
}

.stat-ring-text {
    position: relative;
    z-index: 2;
    color: var(--pi-ink);
}

.stat-name {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--pi-ink-faint);
    font-weight: 700;
}

.stat-time {
    font-size: 10px;
    color: var(--pi-ink-soft);
    margin-top: 2px;
}

.action-card {
    background: linear-gradient(135deg, #2f5c33, #1e3a21);
    border: var(--pi-border-chunky);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.08) inset,
        0 8px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.12s ease;
    cursor: pointer;
    text-align: left;
}

.action-card:active {
    transform: scale(0.97);
}

.action-icon {
    font-size: 26px;
}

.action-text {
    flex: 1;
}

.action-title {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--pi-ink);
    margin: 0;
}

.action-sub {
    font-size: 11px;
    color: var(--pi-green);
    margin-top: 2px;
}

.action-btn {
    background: var(--pi-gold);
    color: #4a3007;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 12px;
    padding: 9px 14px;
    border-radius: 8px;
    border: 2px solid var(--pi-border-color);
    box-shadow: 0 2px 0 var(--pi-border-color);
    transition: transform 0.1s, box-shadow 0.1s;
}

.action-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 var(--pi-border-color);
}

.priority-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-bottom: 1px solid var(--pi-border-color);
    border-radius: 8px;
    transition: background 0.12s ease, transform 0.1s ease;
    text-align: left;
}

.priority-row:last-child {
    border-bottom: none;
}

.priority-row:active {
    background: rgba(245, 185, 66, 0.08);
    transform: scale(0.98);
}

.priority-row:active .p-portrait {
    transform: rotate(-4deg) scale(1.08);
}

.rank {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--pi-panel-raised);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: var(--pi-gold-text);
    flex-shrink: 0;
}

.p-portrait {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--pi-panel-raised);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    border: 2px solid var(--pi-border-color);
    overflow: hidden;
    transition: transform 0.15s ease;
}

.p-portrait img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.p-info {
    flex: 1;
}

.p-name {
    font-size: 12.5px;
    font-weight: 700;
    margin: 0;
}

.p-lvl {
    font-size: 10.5px;
    color: var(--pi-ink-faint);
    margin-top: 2px;
}

.p-impact {
    font-size: 11px;
    color: var(--pi-green);
    font-weight: 700;
    text-align: right;
}

.eta-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.eta-chip {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--pi-ink-faint);
    background: var(--pi-panel-raised);
    border: 2px solid var(--pi-border-color);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.eta-chip:active {
    transform: scale(0.95);
}

.eta-chip.active {
    background: var(--pi-gold);
    color: #4a3007;
}

.eta-date {
    text-align: center;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 20px;
    color: var(--pi-ink);
}

.eta-note {
    text-align: center;
    font-size: 10.5px;
    color: var(--pi-ink-faint);
    margin-top: 2px;
}



/* Search bar styling */
.pi-search-bar {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.pi-search-bar input {
    flex: 1;
    background: var(--pi-bg-deep);
    border: 3px solid #0c1015;
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--pi-ink);
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.pi-scan-btn {
    background: var(--pi-gold);
    color: #4a3007;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 14px;
    padding: 12px 20px;
    border-radius: 12px;
    border: 3px solid #0c1015;
    cursor: pointer;
    box-shadow: 0 3px 0 #0c1015;
    transition: transform 0.1s, box-shadow 0.1s;
}

.pi-scan-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #0c1015;
}

/* ===== Stage 2: Tracker Redesign ===== */
.chip-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.chip-row::-webkit-scrollbar {
    height: 4px;
}

.chip-row::-webkit-scrollbar-track {
    background: transparent;
}

.chip-row::-webkit-scrollbar-thumb {
    background: var(--pi-border-color);
    border-radius: 2px;
}

.chip {
    flex-shrink: 0;
    font-size: 11.5px;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 8px;
    background: var(--pi-panel-raised);
    color: var(--pi-ink-soft);
    border: 2px solid var(--pi-border-color);
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease;
    font-family: inherit;
}

.chip:active {
    transform: scale(0.95);
}

.chip.active {
    background: var(--pi-gold);
    color: #4a3007;
}

.upgrade-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--pi-border-color);
    transition: background 0.12s ease;
}

.upgrade-row:last-child {
    border-bottom: none;
}

.upgrade-row:active {
    background: rgba(245, 185, 66, 0.05);
}

.u-portrait {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--pi-panel-raised);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    border: 2px solid var(--pi-border-color);
    flex-shrink: 0;
    overflow: hidden;
}

.u-portrait img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.u-info {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.u-name {
    font-size: 13px;
    font-weight: 700;
    margin: 0;
}

.u-lvl {
    font-size: 11px;
    color: var(--pi-ink-faint);
    margin-top: 2px;
}

.u-right {
    text-align: right;
    flex-shrink: 0;
}

.u-time {
    font-size: 11px;
    color: var(--pi-ink-soft);
    font-weight: 700;
}

.u-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 5px;
    margin-top: 2px;
    display: inline-block;
    text-transform: uppercase;
}

.u-badge.high {
    background: rgba(95, 214, 107, 0.15);
    color: var(--pi-green);
    border: 1px solid rgba(95, 214, 107, 0.3);
}

.u-badge.med {
    background: rgba(245, 185, 66, 0.15);
    color: var(--pi-gold-text);
    border: 1px solid rgba(245, 185, 66, 0.3);
}

.u-badge.low {
    background: rgba(79, 163, 224, 0.15);
    color: var(--pi-blue);
    border: 1px solid rgba(79, 163, 224, 0.3);
}

.portrait-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
}

.portrait-scroll::-webkit-scrollbar {
    height: 4px;
}

.portrait-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.portrait-scroll::-webkit-scrollbar-thumb {
    background: var(--pi-border-color);
    border-radius: 2px;
}

.portrait-card {
    flex-shrink: 0;
    width: 58px;
    text-align: center;
}

.portrait-img {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    background: var(--pi-panel-raised);
    border: 2px solid var(--pi-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    position: relative;
    overflow: hidden;
}

.portrait-img.maxed {
    border-color: var(--pi-green);
}

.portrait-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.portrait-lvl {
    font-size: 9.5px;
    color: var(--pi-ink-faint);
    margin-top: 4px;
    font-weight: 700;
}

.wp-card {
    text-align: center;
    padding: 6px 0 4px;
}

.wp-score {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 34px;
    color: var(--pi-gold-text);
}

.wp-label {
    font-size: 10.5px;
    color: var(--pi-ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.wp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.wp-sub {
    background: var(--pi-panel-raised);
    border-radius: 9px;
    padding: 8px 4px;
    text-align: center;
    border: 2px solid var(--pi-border-color);
}

.wp-sub-val {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 15px;
}

.wp-sub-name {
    font-size: 8.5px;
    color: var(--pi-ink-faint);
    text-transform: uppercase;
    font-weight: 700;
    margin-top: 2px;
}

/* ===== Stage 3: Planner Redesign ===== */
.toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}

.tbtn {
    flex: 1;
    text-align: center;
    font-size: 10.5px;
    font-weight: 700;
    padding: 8px 4px;
    border-radius: 8px;
    background: var(--pi-panel-raised);
    color: var(--pi-ink-soft);
    border: 2px solid var(--pi-border-color);
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.12s ease;
}

.tbtn:active {
    transform: scale(0.95);
}

.tbtn.clear {
    background: #3f2020;
    color: var(--pi-red);
    flex: 0.6;
}

.finish-card {
    background: var(--pi-panel-raised);
    border: var(--pi-border-chunky);
    border-radius: 14px;
    padding: 14px;
    text-align: center;
    margin-bottom: 16px;
}

.finish-label {
    font-size: 11px;
    color: var(--pi-ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.finish-date {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 24px;
    color: var(--pi-gold-text);
    margin: 2px 0 8px;
}

.util-track {
    height: 8px;
    background: var(--pi-bg-deep);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 4px;
}

.util-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pi-green), var(--pi-gold));
    transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

.util-label {
    font-size: 10px;
    color: var(--pi-ink-faint);
}

.lane-title {
    font-size: 11.5px;
    font-weight: 800;
    color: var(--pi-ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 4px 0 6px;
}

.lane-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 14px;
    -webkit-overflow-scrolling: touch;
}

.lane-scroll::-webkit-scrollbar {
    height: 4px;
}

.lane-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.lane-scroll::-webkit-scrollbar-thumb {
    background: var(--pi-border-color);
    border-radius: 2px;
}

.builder-lane {
    background: #181411;
    border: 2px solid var(--parchment-border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
    padding: 8px;
    text-align: center;
    min-height: 140px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.builder-lane:hover {
    border-color: rgba(212, 175, 55, 0.45);
}

.builder-lane.drag-over {
    background: rgba(245, 185, 66, 0.15);
    border-color: var(--pi-gold);
}

.builder-num {
    font-size: 9.5px;
    color: var(--pi-ink-faint);
    font-weight: 700;
    margin-bottom: 6px;
}

/* Phase 1: builder lane headers use the existing gold-ribbon banner class.
   Compact variant: .banner is a section-level tab; inside a lane card it
   must shrink to a small gold chip that still reads as the same ribbon
   (Baloo, uppercase, gold, chunky border). Specificity is kept to the
   existing .builder-num element so no new isolated class is invented. */
.builder-num.banner {
    font-family: 'Baloo 2', 'Rubik', sans-serif;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #4a3007;
    background: linear-gradient(to bottom, #f5d78a, #d9a441);
    border: 2px solid #6b4d1e;
    border-radius: 8px;
    padding: 2px 10px;
    box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.45), 0 2px 4px rgba(0, 0, 0, 0.35);
    display: inline-block;
    position: relative;
    top: auto;
}

/* Phase 1: the base .banner class has a !important mobile override
   (@media max-width:400px) that forces section-tab styling — it would
   flatten the lane-header chip on narrow screens. Match the chip there. */
@media (max-width: 400px) {
    .builder-num.banner {
        font-size: 10px !important;
        font-weight: 800 !important;
        color: #4a3007 !important;
        background: linear-gradient(to bottom, #f5d78a, #d9a441) !important;
        border: 2px solid #6b4d1e !important;
        border-bottom: 2px solid #6b4d1e !important;
        border-radius: 8px !important;
        padding: 2px 10px !important;
        box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.45), 0 2px 4px rgba(0, 0, 0, 0.35) !important;
    }
}

.builder-portrait {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--pi-panel);
    margin: 0 auto 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border: 2px solid var(--pi-gold-deep);
    overflow: hidden;
}

.builder-portrait img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.builder-lvl {
    font-size: 10px;
    font-weight: 700;
}

.builder-time {
    font-size: 9px;
    color: var(--pi-ink-faint);
    margin-top: 2px;
}

.drag-handle {
    font-size: 12px;
    color: var(--pi-ink-faint);
    margin-top: 6px;
}

/* ── Phase 2: lab queue grouped by time horizon ── */
.lab-group {
    background: #181411;
    border: 1.5px solid var(--parchment-border);
    border-radius: var(--radius-md);
    margin: 6px 0;
    overflow: hidden;
}

.lab-group[open] {
    background: #1c1613;
}

.lab-group-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    color: var(--pi-text);
    list-style: none;
    user-select: none;
}

.lab-group-summary::-webkit-details-marker {
    display: none;
}

.lab-group-summary::before {
    content: '▸';
    font-size: 10px;
    color: var(--pi-gold);
    transition: transform 0.15s ease;
}

.lab-group[open] > .lab-group-summary::before {
    transform: rotate(90deg);
}

.lab-group-label {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.lab-group-meta {
    font-size: 10px;
    color: var(--pi-ink-faint);
    font-weight: 500;
}

.lab-group-rows {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.lab-queue {
    max-height: none;
    border: 2px solid var(--pi-border-color);
    border-radius: 10px;
    padding: 0 10px;
    background: var(--pi-panel-raised);
    transition: background 0.15s ease;
}

.lab-free-line {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--pi-ink-soft);
    padding: 9px 4px 8px;
    border-bottom: 1px solid var(--pi-border-color);
}

.lab-free-line b {
    color: var(--pi-purple);
}

.lab-queue.drag-over {
    background: rgba(245, 185, 66, 0.15);
    border-color: var(--pi-gold);
}

.lab-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--pi-border-color);
}

.lab-row:last-child {
    border-bottom: none;
}

/* Phase 1: lab rows are now chunky tr-upgrade-card cards — the legacy
   :last-child border-bottom:none rule (0,2,0) would otherwise strip the
   bottom edge off the final card in each group, leaving an open-bottom
   card. The card class wins for the last row too. */
.lab-row.tr-upgrade-card,
.lab-row.tr-upgrade-card:last-child {
    border-bottom: 2.5px solid var(--parchment-border);
}

.lab-portrait {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--pi-panel);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    border: 2px solid var(--pi-border-color);
    overflow: hidden;
}

.lab-portrait img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.lab-info {
    flex: 1;
}

.lab-name {
    font-size: 12px;
    font-weight: 700;
}

.lab-lvl {
    font-size: 10px;
    color: var(--pi-ink-faint);
}

.lab-time {
    font-size: 10.5px;
    color: var(--pi-ink-soft);
    font-weight: 700;
    flex-shrink: 0;
}

.lab-drag {
    font-size: 12px;
    color: var(--pi-ink-faint);
    flex-shrink: 0;
}

.stat-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-box {
    background: #181411;
    border: 2px solid var(--parchment-border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
    padding: 9px 6px;
    text-align: center;
}

.stat-box-val {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 16px;
    color: var(--pi-gold-text);
}

.stat-box-lbl {
    font-size: 8.5px;
    color: var(--pi-ink-faint);
    text-transform: uppercase;
    font-weight: 700;
    margin-top: 2px;
}

/* ═══ Phase 2: Planner — three-economy layout ═══
   Section containers are the shared dashboard system:
   .coc-wood-panel + .coc-ribbon-banner + .coc-parchment-panel (defined
   in progress-dashboard.html inline <style>), matching the Tracker tabs
   exactly. The old .pi-econ-header gold bars and .pi-planner-lanes-wrap
   box were removed — they were a separate visual language from the rest
   of the page (2026-08-10 drift fix). */

/* ── Phase 2: multi-lane Builder Economy ──
   The old layout had NO display rule on #pi-planner-builders (a block div),
   so all 6 lanes stacked vertically into one giant scroll. Now:
   desktop  → 3×2 grid of builder cards (2 rows of 3)
   mobile   → horizontal swipeable carousel (scroll-snap)
   Each lane keeps its queue stacked compactly inside its own card. */
#pi-planner-builders {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    align-items: start;
}

@media (max-width: 640px) {
    #pi-planner-builders {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    #pi-planner-builders .builder-lane {
        flex: 0 0 148px;
        scroll-snap-align: start;
    }
}

/* 2026-08-11 polish: at <=480px the carousel showed only ~2.5 of 6 cards
   (Builder 3 clipped at the viewport edge, 4-6 off-screen). Collapse to the
   established 2-column grid used by .pi-timer-grid / .pi-warpower-breakdown
   / .pi-remaining-preview-grid at this breakpoint — every lane fully
   visible when scrolled into view, no horizontal scroll, nothing clipped. */
@media (max-width: 480px) {
    #pi-planner-builders {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        overflow-x: visible;
        scroll-snap-type: none;
        padding-bottom: 0;
    }
    #pi-planner-builders .builder-lane {
        flex: none;
        min-width: 0;
    }
}

/* Lane status line (free / busy until) */
.builder-lane-status {
    font-size: 8.5px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 5px;
    margin-bottom: 5px;
    display: inline-block;
}

.builder-lane-status.free {
    color: var(--pi-green);
    background: rgba(46, 204, 113, 0.12);
}

.builder-lane-status.busy {
    color: var(--pi-gold);
    background: rgba(245, 185, 66, 0.12);
}

/* Instant economy */
/* Instant economy content now sits directly in the parchment panel
   (#pi-power-optimizer inside .coc-parchment-panel); the old dark
   .pi-instant-body box was removed with the 2026-08-10 drift fix. */
.pi-instant-banner {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--pi-ink-soft);
    background: rgba(245, 185, 66, 0.08);
    border: 1px dashed rgba(245, 185, 66, 0.35);
    border-radius: 7px;
    padding: 6px 9px;
    margin-bottom: 10px;
}

.pi-instant-banner svg {
    color: var(--pi-gold);
    flex-shrink: 0;
}

/* Builder Utilization summary */
.pi-util-summary {
    margin-bottom: 14px;
    padding: 12px 14px;
    background: #181411;
    border: 2px solid var(--parchment-border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
}

.pi-util-summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.pi-util-summary-title {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 12px;
    color: var(--pi-gold-text);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.pi-util-summary-pct {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 15px;
    color: var(--pi-gold-text);
}

.pi-util-summary-track {
    height: 8px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 4px;
    overflow: hidden;
}

.pi-util-summary-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pi-gold-deep), var(--pi-gold));
    border-radius: 4px;
    transition: width 0.8s ease;
}

.pi-util-summary-sub {
    font-size: 10px;
    color: var(--pi-ink-faint);
    margin-top: 5px;
}

/* Wall cards in instant economy */
.wall-item {
    background: var(--pi-panel-raised);
    border-radius: 9px;
    padding: 8px 6px;
    text-align: center;
    border: 2px solid var(--pi-border-color);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
    transition: border-color 0.15s ease, transform 0.15s ease;
    position: relative;
}

.wall-item:hover {
    border-color: var(--pi-gold);
}

.wall-icon {
    width: 28px;
    height: 28px;
    margin: 0 auto 4px;
    opacity: 0.85;
    display: block;
}

.wall-name {
    font-size: 9px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wall-lvl {
    font-size: 9px;
    color: var(--pi-ink-faint);
    margin-top: 2px;
}

/* Phase 1: per-segment breakdown under wall cost — explains why the
   total-to-max figure is what it is ("8 segments × 100K/segment · 10 levels left") */
.wall-hint {
    font-size: 8px;
    color: var(--pi-ink-faint);
    margin-top: 3px;
    line-height: 1.35;
    opacity: 0.85;
}

.wall-cost {
    font-size: 9px;
    color: var(--pi-gold-text);
    font-weight: 700;
    margin-top: 2px;
}

/* ── Phase 2: collapsed magic-item toggle ──
   A small book icon in the card corner (not a full-width button).
   Tap → expands the time-saved detail panel inline. */
.pi-magic-wrap {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 3;
}

.pi-magic-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.pi-magic-toggle:hover {
    background: rgba(139, 92, 246, 0.28);
    transform: scale(1.08);
}

.pi-magic-toggle img {
    width: 15px;
    height: 15px;
    object-fit: contain;
}

.pi-magic-panel {
    position: absolute;
    right: 0;
    top: 26px;
    width: 168px;
    text-align: left;
    font-size: 9.5px;
    line-height: 1.4;
    color: var(--pi-ink-soft);
    background: #221a2e;
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 6px;
    padding: 5px 7px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    z-index: 4;
}

/* Builder cards are center-aligned and narrow — keep the magic wrap
   inside the flow at the bottom instead of overlapping the remove ✕. */
.builder-slot .pi-magic-wrap {
    position: static;
    margin-top: 0;
    display: inline-flex;
}

.builder-slot .pi-magic-panel {
    position: absolute;
    top: calc(100% + 4px);
    width: 200px;
    z-index: 60;
    box-sizing: border-box;
}

.builder-lane:nth-child(odd) .builder-slot .pi-magic-panel {
    left: 0;
    right: auto;
}

.builder-lane:nth-child(even) .builder-slot .pi-magic-panel {
    right: 0;
    left: auto;
}

.builder-slot .pi-magic-toggle {
    width: 26px;
    height: 26px;
}

/* Lab rows are horizontal flex lines — keep the icon inline and let the
   detail panel drop down below the row (row is position:relative). */
.lab-row {
    position: relative;
}

.lab-row .pi-magic-wrap {
    position: static;
    display: inline-flex;
    align-items: center;
}

.lab-row .pi-magic-panel {
    position: absolute;
    right: 0;
    top: 100%;
    width: 168px;
    z-index: 5;
}

/* Planner alert cards (Phase 3) */
.pi-planner-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
    border: 2px solid var(--pi-gold-deep);
    background: #181411;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
}

.pi-planner-alert-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.pi-planner-alert-body {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: var(--pi-text);
}

.pi-planner-alert-action {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 7px;
    background: var(--pi-gold);
    color: #1a1408;
    border: 2px solid var(--pi-gold-deep);
    cursor: pointer;
    box-shadow: 0 2px 0 var(--pi-gold-deep);
}

.pi-planner-alert-action:hover {
    filter: brightness(1.08);
}

.pi-planner-alert-dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--pi-ink-faint);
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
}

/* Phase 3: Planner alert title/detail lines */
.pi-planner-alert-title {
    font-size: 12.5px;
    font-weight: 800;
    color: var(--pi-gold);
}

.pi-planner-alert-detail {
    margin-top: 2px;
    font-size: 11px;
    color: var(--pi-text);
    font-weight: 500;
}

/* Phase 3: live countdown (lanes freeing within 48h) */
.pi-countdown {
    color: var(--pi-green);
    font-weight: 700;
    font-size: 10px;
    white-space: nowrap;
}

/* Phase 2: wall progress visualizer (tier-grouped heatmap) */
.pi-wall-viz {
    margin-top: 12px;
    padding: 10px 12px;
    border: 2px solid var(--parchment-border);
    border-radius: var(--radius-md);
    background: #181411;
    grid-column: 1 / -1;
}

/* Phase 2: tier legend under the wall heatmap bar */
.pi-wall-viz-keyrow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 7px;
}

.pi-wall-viz-key {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 9.5px;
    font-weight: 700;
    color: var(--pi-ink-soft);
}

.pi-wall-viz-key i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.pi-wall-viz-bar {
    display: flex;
    height: 14px;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.04);
}

.pi-wall-viz-seg {
    height: 100%;
    min-width: 2px;
}

.pi-wall-viz-meta {
    margin-top: 6px;
    font-size: 10.5px;
    color: var(--pi-ink-soft);
    font-weight: 600;
}

/* Phase 3: Instant Economy 'Cheapest first' sort chip */
.pi-sort-chip {
    font-size: 10.5px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 999px;
    border: 2px solid var(--pi-border-color);
    background: var(--pi-panel);
    color: var(--pi-ink-soft);
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.pi-sort-chip:hover {
    border-color: var(--pi-gold-deep);
    color: var(--pi-gold);
}

.pi-sort-chip.active {
    background: var(--pi-gold);
    color: #1a1408;
    border-color: var(--pi-gold-deep);
    box-shadow: 0 2px 0 var(--pi-gold-deep);
}

/* ETA-to-max line (Phase 3) */
.pi-planner-eta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.pi-planner-eta-boosts {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px;
    border-radius: var(--radius-md);
    background: #181411;
    border: 2px solid var(--parchment-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
}

.pi-planner-eta-chip {
    padding: 4px 10px;
    border: 2px solid rgba(212, 175, 55, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--pi-ink-soft);
    font-family: 'Baloo 2', 'Rubik', sans-serif;
    font-size: 0.62rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.pi-planner-eta-chip:hover {
    border-color: var(--pi-gold);
    color: var(--pi-gold);
}

.pi-planner-eta-chip.active {
    background: linear-gradient(to bottom, #f5d78a, #d9a441);
    color: #4a3007;
    border-color: #6b4d1e;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.pi-planner-eta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    background: #181411;
    border: 2px solid var(--parchment-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
    font-size: 12.5px;
    color: var(--pi-text);
    flex: 1;
    min-width: 260px;
}

.pi-planner-eta b {
    color: var(--pi-gold-text);
}

.power-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.power-item {
    background: var(--pi-panel-raised);
    border-radius: 9px;
    padding: 8px 5px;
    text-align: center;
    border: 2px solid var(--pi-border-color);
}

.power-icon {
    font-size: 16px;
}

.power-name {
    font-size: 9px;
    font-weight: 700;
    margin-top: 3px;
}

.power-lvl {
    font-size: 9px;
    color: var(--pi-ink-faint);
}

.instant-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 800;
    color: var(--pi-purple);
    background: #2a2140;
    padding: 2px 8px;
    border-radius: 6px;
    margin-bottom: 8px;
}


/* ===== SEARCH HERO SECTION ===== */
.pi-search-hero {
    text-align: center;
    padding: 32px 16px 24px;
    position: relative;
}

.pi-search-hero h2 {
    font-family: 'ClashBold', 'Impact', sans-serif;
    font-size: 1.6rem;
    color: var(--pi-gold);
    margin-bottom: 4px;
    text-shadow: 0 0 12px rgba(212, 175, 55, 0.15);
}

.pi-search-hero .pi-tagline {
    font-size: 0.8rem;
    color: var(--pi-text-dim);
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

.pi-search-bar {
    display: flex;
    gap: 8px;
    max-width: 400px;
    margin: 0 auto 12px;
}

.pi-search-bar input {
    flex: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--pi-border);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--pi-text);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.pi-search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-family: inherit;
}

.pi-search-bar input:focus {
    border-color: var(--pi-gold);
    box-shadow: 0 0 12px var(--pi-gold-glow);
}

.pi-scan-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    height: 44px;
    padding: 0 var(--space-lg);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--gold-light), var(--gold-primary));
    color: #1A1A1A;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    border: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transition: all var(--duration-fast) var(--ease-out);
    cursor: pointer;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pi-scan-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.pi-scan-btn:active {
    transform: translateY(1px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.pi-scan-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pi-api-notice {
    font-size: 0.7rem;
    color: var(--pi-text-dim);
    margin-top: 8px;
    opacity: 0.7;
}

/* ===== LOADING STATE ===== */
.pi-loading {
    text-align: center;
    padding: 60px 20px;
    display: none;
}

.pi-loading.active {
    display: block;
}

.pi-loading .loading-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
}

.pi-loading-text {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--pi-gold);
    font-size: 0.9rem;
}

/* ===== DASHBOARD CONTAINER ===== */
.pi-dashboard {
    display: none;
    animation: piFadeIn 0.5s ease-out;
}

.pi-dashboard.active {
    display: block;
}

@keyframes piFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== A) PROGRESS SNAPSHOT CARD ===== */
.pi-snapshot {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-ambient);
}

/* Subtle gold top glow */
.pi-snapshot::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--pi-gold), transparent);
    opacity: 0.35;
}

.pi-snapshot-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.pi-th-badge {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--pi-gold-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.pi-th-badge img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.pi-th-badge .pi-th-level {
    position: absolute;
    bottom: -6px;
    right: -6px;
    background: var(--pi-gold);
    color: #000;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: bold;
}

.pi-player-info h3 {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--pi-text);
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.pi-player-info span {
    font-size: 0.75rem;
    color: var(--pi-text-dim);
}

/* Big progress percentage */
.pi-progress-big {
    text-align: center;
    margin: 16px 0;
}

.pi-progress-big .pi-percent {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 3.5rem;
    color: var(--pi-gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
    line-height: 1;
}

.pi-progress-big .pi-percent-label {
    font-size: 0.75rem;
    color: var(--pi-text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* War readiness meter */
.pi-readiness {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--pi-glass-light);
    border-radius: 10px;
    margin-top: 16px;
}

.pi-readiness-label {
    font-size: 0.75rem;
    color: var(--pi-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.pi-readiness-bar {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.pi-readiness-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease-out;
    background: linear-gradient(90deg, var(--pi-red), var(--pi-yellow), var(--pi-green));
}

.pi-readiness-score {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    min-width: 36px;
    text-align: right;
}

/* ETA Row */
.pi-eta-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.pi-eta-card {
    flex: 1;
    background: var(--pi-glass-light);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.pi-eta-card .pi-eta-value {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--pi-text);
    margin-bottom: 2px;
}

.pi-eta-card .pi-eta-label {
    font-size: 0.6rem;
    color: var(--pi-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mode indicator badges */
.pi-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pi-mode-badge.auto {
    background: rgba(74, 222, 128, 0.15);
    color: var(--pi-green);
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.pi-mode-badge.manual {
    background: rgba(250, 204, 21, 0.15);
    color: var(--pi-yellow);
    border: 1px solid rgba(250, 204, 21, 0.2);
}

.pi-mode-badge.json {
    background: rgba(96, 165, 250, 0.15);
    color: #60A5FA;
    border: 1px solid rgba(96, 165, 250, 0.25);
}

.pi-mode-hint {
    margin: 5px 0 0;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    letter-spacing: 0.3px;
}

/* ===== B) TIMER CARDS ===== */
.pi-timers-section {
    margin-bottom: 16px;
}

.pi-section-title {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--pi-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-left: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pi-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--pi-border), transparent);
}

.pi-timer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.pi-timer-card {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    padding: 16px 12px;
    text-align: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
    transition: transform 0.2s, box-shadow 0.2s;
}

.pi-timer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.pi-timer-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.pi-timer-ring {
    width: 48px;
    height: 48px;
    margin: 0 auto 8px;
    position: relative;
}

.pi-timer-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.pi-timer-ring .ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 4;
}

.pi-timer-ring .ring-fill {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.5s ease-out;
}

.pi-timer-ring .ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.6rem;
    color: var(--pi-text);
}

.pi-timer-days {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--pi-text);
    margin-bottom: 2px;
}

.pi-timer-label {
    font-size: 0.6rem;
    color: var(--pi-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Extra 2-col for last 2 cards */
.pi-timer-grid .pi-timer-card:nth-child(4),
.pi-timer-grid .pi-timer-card:nth-child(5) {
    grid-column: span 1;
}

/* Bottom row: span 2 cards across 3 cols */
@media (min-width: 360px) {
    .pi-timer-overflow {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-top: 8px;
    }
}

/* ===== C) UPGRADE SUGGESTIONS ===== */
.pi-suggestions-section {
    margin-bottom: 16px;
}

.pi-suggestion-card {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 14px;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
}

.pi-suggestion-card:hover {
    border-color: var(--pi-gold-glow);
    transform: translateX(4px);
}

.pi-sug-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--pi-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.pi-sug-info {
    flex: 1;
    min-width: 0;
}

.pi-sug-category {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.pi-sug-category.war {
    color: var(--pi-red);
}

.pi-sug-category.farm {
    color: var(--pi-green);
}

.pi-sug-category.defense {
    color: var(--pi-blue);
}

.pi-sug-category.value {
    color: var(--pi-purple);
}

.pi-sug-name {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--pi-text);
    margin-bottom: 4px;
}

.pi-sug-meta {
    display: flex;
    gap: 12px;
    font-size: 0.65rem;
    color: var(--pi-text-dim);
}

.pi-sug-stars {
    display: flex;
    align-items: center;
    gap: 2px;
    color: var(--pi-gold);
    font-size: 0.7rem;
}

.pi-sug-stars .star-filled {
    opacity: 1;
}

.pi-sug-stars .star-empty {
    opacity: 0.25;
}

.pi-sug-arrow {
    color: var(--pi-text-dim);
    font-size: 0.7rem;
    flex-shrink: 0;
    opacity: 0.4;
}

/* ===== D) WAR POWER RATING ===== */
.pi-warpower-section {
    margin-bottom: 16px;
}

.pi-warpower-card {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    padding: 24px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
}

/* Top gold glow line */
.pi-warpower-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--pi-gold), transparent);
    opacity: 0.5;
}

.pi-warpower-title {
    font-size: 0.7rem;
    color: var(--pi-text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.pi-warpower-score {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 3rem;
    color: var(--pi-gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    line-height: 1;
    margin-bottom: 4px;
}

.pi-warpower-max {
    font-size: 0.8rem;
    color: var(--pi-text-dim);
    margin-bottom: 16px;
}

.pi-warpower-breakdown {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.pi-wp-stat {
    background: var(--pi-glass-light);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.pi-wp-stat-label {
    font-size: 0.6rem;
    color: var(--pi-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.pi-wp-stat-value {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1.1rem;
}

.pi-wp-offense {
    color: var(--pi-red);
}

.pi-wp-defense {
    color: var(--pi-blue);
}

.pi-wp-heroes {
    color: var(--pi-purple);
}

.pi-wp-utility {
    color: var(--pi-green);
}

/* ===== E) PLANNER (LOCKED V1) ===== */
.pi-planner-section {
    margin-bottom: 16px;
}

.pi-planner-locked {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    padding: 32px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.pi-planner-locked::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(45deg,
            transparent,
            transparent 10px,
            rgba(255, 255, 255, 0.01) 10px,
            rgba(255, 255, 255, 0.01) 20px);
    pointer-events: none;
}

.pi-lock-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.6;
}

.pi-lock-title {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--pi-text);
    margin-bottom: 6px;
}

.pi-lock-subtitle {
    font-size: 0.75rem;
    color: var(--pi-text-dim);
    max-width: 280px;
    margin: 0 auto;
    line-height: 1.4;
}

.pi-lock-teaser {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 20px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.pi-lock-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    opacity: 0.5;
}

.pi-lock-slot-icon {
    font-size: 0.9rem;
}

.pi-lock-slot-text {
    font-size: 0.7rem;
    color: var(--pi-text-dim);
    font-style: italic;
}

/* ===== EXPORT BAR ===== */
.pi-export-bar {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.pi-export-btn {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: 10px;
    padding: 8px 14px;
    color: var(--pi-text-dim);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pi-export-btn:hover {
    color: var(--pi-gold);
    border-color: var(--pi-gold-glow);
    transform: translateY(-1px);
}

/* ===== CATEGORY BREAKDOWN SECTION ===== */
.pi-breakdown-section {
    margin-bottom: 16px;
}

.pi-breakdown-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
}

.pi-breakdown-tabs::-webkit-scrollbar {
    display: none;
}

.pi-breakdown-tab {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--pi-border);
    background: transparent;
    color: var(--pi-text-dim);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.65rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    text-transform: uppercase;
}

.pi-breakdown-tab.active {
    background: var(--pi-gold);
    color: #000;
    border-color: var(--pi-gold);
}

.pi-breakdown-tab:hover:not(.active) {
    border-color: rgba(255, 215, 0, 0.3);
    color: var(--pi-text);
}

.pi-breakdown-content {
    display: none;
}

.pi-breakdown-content.active {
    display: block;
    animation: piFadeIn 0.3s ease-out;
}

/* Unit grid inside breakdown */
.pi-unit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}

.pi-unit-card {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    transition: all 0.2s;
    position: relative;
}

.pi-unit-card.maxed {
    border-color: rgba(74, 222, 128, 0.3);
}

.pi-unit-card.maxed::after {
    content: '✓';
    position: absolute;
    top: 3px;
    right: 5px;
    font-size: 0.55rem;
    color: var(--pi-green);
    font-weight: bold;
}

.pi-unit-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 auto 4px;
}

.pi-unit-card .pi-unit-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    border-radius: 6px;
}

.pi-unit-emoji {
    font-size: 1.4rem;
    line-height: 1;
}

.pi-sug-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    border-radius: 6px;
}

.pi-unit-card .pi-unit-level {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
}

.pi-unit-card .pi-unit-level .pi-current {
    color: var(--pi-text);
}

.pi-unit-card .pi-unit-level .pi-max {
    color: var(--pi-text-dim);
    font-size: 0.6rem;
}

.pi-unit-card .pi-unit-name {
    font-size: 0.55rem;
    color: var(--pi-text-dim);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Level bar under each unit card */
.pi-unit-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.pi-unit-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s ease-out;
}

.pi-unit-bar-fill.green {
    background: var(--pi-green);
}

.pi-unit-bar-fill.yellow {
    background: var(--pi-yellow);
}

.pi-unit-bar-fill.red {
    background: var(--pi-red);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .pi-timer-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pi-snapshot-header {
        flex-direction: column;
        text-align: center;
    }

    .pi-warpower-breakdown {
        grid-template-columns: repeat(2, 1fr);
    }

    .pi-search-bar {
        flex-direction: column;
    }

    .pi-scan-btn {
        width: 100%;
    }

    .pi-eta-row {
        flex-direction: column;
    }
}

@media (max-width: 360px) {
    .pi-progress-big .pi-percent {
        font-size: 2.8rem;
    }

    .pi-warpower-score {
        font-size: 2.5rem;
    }

    .pi-unit-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
}

/* ===== ERROR STATE ===== */
.pi-error {
    display: none;
    text-align: center;
    padding: 40px 20px;
}

.pi-error.active {
    display: block;
}

.pi-error-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.6;
}

.pi-error-text {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--pi-red);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.pi-error-hint {
    font-size: 0.75rem;
    color: var(--pi-text-dim);
}

/* ===== TIMER CARDS (SVG Rings) ===== */
.pi-timer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.pi-timer-card {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    padding: 16px 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pi-timer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.1);
}

.pi-timer-ring {
    position: relative;
    width: 72px;
    height: 72px;
}

.pi-timer-ring svg {
    width: 100%;
    height: 100%;
}

.pi-ring-progress {
    transition: stroke-dashoffset 0s;
}

.pi-ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--pi-text);
}

.pi-timer-info {
    text-align: center;
}

.pi-timer-label {
    font-size: 0.75rem;
    color: var(--pi-text-dim);
    margin-bottom: 4px;
}

.pi-timer-eta {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    color: var(--pi-gold);
}

.pi-timer-detail {
    font-size: 0.65rem;
    color: var(--pi-text-dim);
    margin-top: 2px;
}

/* ===== UNIT CARDS (Breakdown Grid) ===== */
.pi-unit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 12px 0;
}

.pi-unit-card {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pi-unit-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.3);
}

.pi-unit-card.pi-unit-maxed {
    border-color: rgba(74, 222, 128, 0.3);
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.08), var(--pi-glass));
}

.pi-unit-img-wrap {
    position: relative;
    width: 52px;
    height: 52px;
    margin: 0 auto 6px;
}

.pi-unit-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.pi-unit-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1.2rem;
    color: var(--pi-gold);
}

.pi-maxed-badge {
    position: absolute;
    bottom: -3px;
    right: -3px;
    background: linear-gradient(135deg, #4ADE80, #22C55E);
    color: #000;
    font-size: 0.5rem;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.pi-unit-name {
    font-size: 0.65rem;
    color: var(--pi-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.pi-unit-level {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--pi-gold);
    margin-bottom: 4px;
}

.pi-unit-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.pi-unit-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.pi-empty-cat {
    text-align: center;
    padding: 30px;
    color: var(--pi-text-dim);
    font-size: 0.85rem;
    grid-column: 1 / -1;
}

/* ===== SUGGESTION CARDS ===== */
.pi-suggestion-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: fadeInUp 0.4s ease-out both;
}

.pi-suggestion-card:hover {
    transform: translateX(4px);
    box-shadow: -4px 0 20px rgba(255, 215, 0, 0.1);
}

.pi-urgency-critical {
    border-left: 3px solid var(--pi-red);
}

.pi-urgency-high {
    border-left: 3px solid var(--pi-yellow);
}

.pi-urgency-medium {
    border-left: 3px solid var(--pi-blue);
}

.pi-sugg-rank {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--pi-gold);
    min-width: 28px;
}

.pi-sugg-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.pi-sugg-icon span {
    font-size: 1.6rem;
}

.pi-sugg-info {
    flex: 1;
    min-width: 0;
}

.pi-sugg-name {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--pi-text);
}

.pi-sugg-levels {
    font-size: 0.7rem;
    color: var(--pi-gold);
    margin: 2px 0;
}

.pi-sugg-reason {
    font-size: 0.65rem;
    color: var(--pi-text-dim);
    line-height: 1.3;
}

.pi-sugg-meta {
    text-align: right;
    flex-shrink: 0;
}

.pi-sugg-stars {
    font-size: 0.6rem;
    line-height: 1;
}

.pi-sugg-weight {
    font-size: 0.65rem;
    color: var(--pi-text-dim);
    margin-top: 4px;
}

/* ===== IMPORT BUTTON ===== */
.pi-import-btn {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(96, 165, 250, 0.05)) !important;
    border-color: rgba(96, 165, 250, 0.3) !important;
    color: var(--pi-blue) !important;
}

.pi-import-btn:hover {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.3), rgba(96, 165, 250, 0.1)) !important;
}

/* ===== JSON IMPORT MODAL ===== */
.pi-json-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.pi-json-modal-content {
    /* Matches the CoC parchment/wood language used by the rest of the
       dashboard instead of the flat dark card this used to be. */
    background:
        radial-gradient(ellipse at 50% 0%, rgba(241, 196, 15, 0.10), transparent 62%),
        linear-gradient(150deg, #251714 0%, #16100c 55%, #120c09 100%);
    border: 3px solid #06080b;
    border-radius: 18px;
    padding: 26px 26px 24px;
    max-width: 560px;
    width: 100%;
    max-height: 86vh;
    overflow-y: auto;
    position: relative;
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.07),
        inset 0 -3px 0 rgba(0, 0, 0, 0.55),
        0 24px 64px rgba(0, 0, 0, 0.75),
        0 0 46px rgba(241, 196, 15, 0.09);
    animation: piJsonPop 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes piJsonPop {
    from { transform: translateY(10px) scale(0.985); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* Inner hairline, same trick as .coc-wood-panel::before */
.pi-json-modal-content::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1.5px solid rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    pointer-events: none;
}

.pi-json-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    border: 1.5px solid rgba(255, 255, 255, 0.10);
    border-radius: 9px;
    color: var(--pi-text-dim);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 1;
}

.pi-json-modal-close:hover {
    color: #fff;
    background: rgba(231, 76, 60, 0.9);
    border-color: rgba(231, 76, 60, 0.9);
    transform: rotate(90deg);
}

.pi-json-modal-close:focus-visible {
    outline: 2px solid var(--pi-gold);
    outline-offset: 2px;
}

.pi-json-modal-title {
    font-family: 'ClashBold', 'Baloo 2', 'Rubik', sans-serif;
    font-weight: 800;
    color: #ffd700;
    font-size: 1.4rem;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
    padding-right: 40px;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
}

.pi-json-modal-hint {
    font-size: 0.82rem;
    color: #c9bfae;
    line-height: 1.55;
    margin-bottom: 14px;
}

.pi-json-modal-hint strong {
    color: #ffd700;
}

/* Village JSON acquisition steps (dashboard modal). The in-game label is
   "Export village data in JSON format" near the bottom of More Settings —
   kept in sync with the same list in progress.html. */
.pi-json-steps {
    font-size: 0.82rem;
    color: #c9bfae;
    line-height: 1.85;
    margin: 0 0 10px;
    padding: 12px 16px 12px 34px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-left: 3px solid rgba(241, 196, 15, 0.5);
    border-radius: 10px;
    counter-reset: pi-json-step;
    list-style: none;
}

.pi-json-steps li {
    position: relative;
    counter-increment: pi-json-step;
}

/* Numbered gold pips instead of default list markers. */
.pi-json-steps li::before {
    content: counter(pi-json-step);
    position: absolute;
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(241, 196, 15, 0.16);
    border: 1px solid rgba(241, 196, 15, 0.42);
    border-radius: 50%;
    color: #ffd700;
    font-size: 0.66rem;
    font-weight: 800;
}

.pi-json-steps strong {
    color: #f6f0e4;
}

.pi-json-steps-note {
    font-size: 0.74rem;
    color: #a09587;
    line-height: 1.5;
    margin: 0 0 16px;
    padding-left: 2px;
}

.pi-json-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.55);
    border: 1.5px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    color: #e8f0f8;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.76rem;
    line-height: 1.6;
    padding: 14px;
    resize: vertical;
    min-height: 190px;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.pi-json-textarea::placeholder {
    color: #6b6155;
}

.pi-json-textarea:focus {
    border-color: rgba(241, 196, 15, 0.65);
    box-shadow: 0 0 0 3px rgba(241, 196, 15, 0.12);
}

.pi-json-error {
    color: #ffb4ab;
    font-size: 0.78rem;
    font-weight: 600;
    margin-top: 10px;
    padding: 9px 12px;
    background: rgba(231, 76, 60, 0.14);
    border: 1px solid rgba(231, 76, 60, 0.32);
    border-radius: 9px;
}

.pi-json-parse-btn {
    margin-top: 16px;
    width: 100%;
    height: 46px;
    font-size: 15px;
}

@media (max-width: 480px) {
    .pi-json-modal {
        padding: 12px;
    }

    .pi-json-modal-content {
        padding: 22px 18px 20px;
        max-height: 92vh;
    }

    .pi-json-modal-title {
        font-size: 1.2rem;
    }
}

/* ===== PROGRESS GLOW ===== */
.pi-glow {
    text-shadow: 0 0 30px rgba(74, 222, 128, 0.6), 0 0 60px rgba(74, 222, 128, 0.3) !important;
    color: #4ADE80 !important;
}

/* ===== CONFETTI ===== */
.pi-confetti {
    position: absolute;
    top: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    animation: piConfettiFall 1.8s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
    z-index: 100;
}

@keyframes piConfettiFall {
    0% {
        transform: translateY(-20px) scale(0) rotate(0deg);
        opacity: 1;
    }

    20% {
        transform: translateY(-30px) scale(1) rotate(90deg);
        opacity: 1;
    }

    100% {
        transform: translateY(200px) scale(0.3) rotate(720deg);
        opacity: 0;
    }
}

/* ===== TOAST ===== */
.pi-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(20, 16, 10, 0.95);
    border: 1px solid var(--pi-gold-dim);
    color: var(--pi-gold);
    padding: 10px 20px;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.pi-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== SCROLL REVEAL ===== */
.pi-reveal-target {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.pi-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ===== SHAKE ANIMATION ===== */
.pi-shake {
    animation: piShake 0.5s ease-in-out;
}

@keyframes piShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px);
    }

    40% {
        transform: translateX(8px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 480px) {
    .pi-timer-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pi-unit-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .pi-suggestion-card {
        padding: 10px 8px;
        gap: 8px;
    }

    .pi-sugg-icon img {
        width: 32px;
        height: 32px;
    }

    .pi-json-modal-content {
        padding: 20px 16px;
        max-height: 90vh;
    }
}

/* ============================================================
   PHASE 1 — Upgrade Tracker Styles
   ============================================================ */

/* ===== Section Header with Sort ===== */
.pi-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

/* ===== Sort Dropdown ===== */
.pi-sort-dropdown {
    background: var(--pi-glass);
    color: var(--pi-text);
    border: 1px solid var(--pi-border);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 0.7rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.pi-sort-dropdown:focus {
    border-color: var(--pi-gold);
    box-shadow: 0 0 8px var(--pi-gold-dim);
}

.pi-sort-dropdown option {
    background: #1a1510;
    color: var(--pi-text);
}

/* ===== Remaining Tabs ===== */
.pi-remaining-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.pi-remaining-tabs::-webkit-scrollbar {
    display: none;
}

.pi-rem-tab {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--pi-border);
    background: var(--pi-glass);
    color: var(--pi-text-dim);
    font-size: 0.65rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.pi-rem-tab:hover {
    border-color: var(--pi-gold);
    color: var(--pi-text);
}

.pi-rem-tab.active {
    background: var(--pi-gold-dim);
    color: var(--pi-gold);
    border-color: var(--pi-gold);
}

.pi-rem-tab-json {
    border-style: dashed;
    opacity: 0.5;
}

.pi-rem-tab-json.active,
.pi-rem-tab-json.available {
    opacity: 1;
    border-style: solid;
}

/* ===== Remaining Upgrade Cards ===== */
.pi-remaining-section {
    margin-bottom: 20px;
}

.pi-remaining-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--pi-gold-dim) transparent;
}

.pi-rem-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: default;
}

.pi-rem-card:hover {
    transform: translateY(-1px);
    border-color: var(--pi-gold);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.08), inset 0 0 30px rgba(255, 215, 0, 0.02);
}

.pi-rem-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.03);
}

.pi-rem-info {
    flex: 1;
    min-width: 0;
}

.pi-rem-name {
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--pi-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pi-rem-levels {
    font-size: 0.65rem;
    color: var(--pi-text-dim);
    margin-top: 2px;
}

.pi-rem-levels span {
    color: var(--pi-gold);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

.pi-rem-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
}

.pi-rem-time {
    font-size: 0.65rem;
    color: var(--pi-blue);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

.pi-rem-war {
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

.pi-rem-war.high {
    background: rgba(74, 222, 128, 0.15);
    color: var(--pi-green);
}

.pi-rem-war.medium {
    background: rgba(250, 204, 21, 0.15);
    color: var(--pi-yellow);
}

.pi-rem-war.low {
    background: rgba(248, 113, 113, 0.15);
    color: var(--pi-red);
}

.pi-remaining-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--pi-gold);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
}

/* ===== Timeline Sections ===== */
.pi-timeline-section {
    margin-bottom: 20px;
}

.pi-timeline-subtitle {
    font-size: 0.6rem;
    color: var(--pi-text-dim);
    margin: -4px 0 12px 0;
    font-style: italic;
}

/* Builder Lanes */
.pi-builder-lanes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pi-builder-lane {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: 12px;
    overflow-x: auto;
    scrollbar-width: none;
}

.pi-builder-lane::-webkit-scrollbar {
    display: none;
}

.pi-lane-label {
    flex-shrink: 0;
    font-size: 0.6rem;
    color: var(--pi-text-dim);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    min-width: 50px;
}

.pi-lane-slots {
    display: flex;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.pi-lane-slot {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.1);
    border-radius: 8px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.pi-lane-slot:hover {
    background: rgba(255, 215, 0, 0.12);
}

.pi-lane-slot-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: contain;
}

.pi-lane-slot-name {
    font-size: 0.6rem;
    color: var(--pi-text);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    white-space: nowrap;
}

.pi-lane-slot-time {
    font-size: 0.55rem;
    color: var(--pi-blue);
    white-space: nowrap;
}

.pi-lane-empty {
    font-size: 0.6rem;
    color: var(--pi-text-dim);
    font-style: italic;
    padding: 4px 0;
}

/* Lab Lane */
.pi-lab-lane {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--pi-gold-dim) transparent;
}

.pi-lab-slot {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: 12px;
    min-width: 80px;
    transition: transform 0.2s, border-color 0.2s;
}

.pi-lab-slot:hover {
    transform: translateY(-2px);
    border-color: var(--pi-blue);
}

.pi-lab-slot-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
}

.pi-lab-slot-name {
    font-size: 0.6rem;
    color: var(--pi-text);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.pi-lab-slot-time {
    font-size: 0.55rem;
    color: var(--pi-blue);
}

.pi-lab-slot-war {
    font-size: 0.5rem;
    padding: 1px 5px;
    border-radius: 6px;
    background: rgba(74, 222, 128, 0.1);
    color: var(--pi-green);
}

/* ===== ETA Bar ===== */
.pi-eta-bar {
    margin-top: 20px;
    background: linear-gradient(135deg, rgba(15, 12, 8, 0.97), rgba(30, 25, 15, 0.97));
    border: 1px solid var(--pi-gold);
    border-radius: var(--pi-radius);
    padding: 16px;
    box-shadow: 0 4px 30px rgba(255, 215, 0, 0.08);
}

.pi-eta-bar-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 12px;
}

.pi-eta-bar-item {
    text-align: center;
    flex: 1;
}

.pi-eta-bar-value {
    font-size: 1.1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--pi-gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.pi-eta-bar-label {
    font-size: 0.65rem;
    color: var(--pi-text);
    margin-top: 4px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

.pi-eta-bar-sub {
    font-size: 0.55rem;
    color: var(--pi-text-dim);
    margin-top: 2px;
}

.pi-eta-bar-divider {
    width: 1px;
    height: 50px;
    background: var(--pi-border);
    flex-shrink: 0;
}

.pi-eta-confidence {
    text-align: center;
    font-size: 0.6rem;
    color: var(--pi-text-dim);
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--pi-border);
    font-style: italic;
}

.pi-eta-confidence.high {
    color: var(--pi-green);
}

/* ===== Mode Banner ===== */
.pi-mode-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 12px;
    margin-bottom: 16px;
}

.pi-mode-banner.json {
    background: rgba(74, 222, 128, 0.08);
    border-color: rgba(74, 222, 128, 0.2);
}

.pi-mode-banner-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.pi-mode-banner-text {
    font-size: 0.65rem;
    color: var(--pi-text-dim);
    line-height: 1.4;
}

/* ===== Reveal Animation (IntersectionObserver) ===== */
.pi-reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.pi-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Mobile Responsive for Phase 1 ===== */
@media (max-width: 600px) {
    .pi-section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .pi-sort-dropdown {
        width: 100%;
    }

    .pi-remaining-grid {
        max-height: 350px;
    }

    .pi-rem-card {
        padding: 8px 10px;
        gap: 8px;
    }

    .pi-rem-icon {
        width: 30px;
        height: 30px;
    }

    .pi-rem-name {
        font-size: 0.7rem;
    }

    .pi-eta-bar-inner {
        flex-direction: column;
        gap: 16px;
    }

    .pi-eta-bar-divider {
        width: 60%;
        height: 1px;
    }

    .pi-eta-bar-value {
        font-size: 1rem;
    }

    .pi-lane-slot-name {
        font-size: 0.55rem;
    }

    .pi-lane-slot-icon {
        width: 20px;
        height: 20px;
    }

    .pi-lab-slot {
        min-width: 70px;
        padding: 8px;
    }

    .pi-lab-slot-icon {
        width: 28px;
        height: 28px;
    }

    .pi-section-nav {
        flex-direction: column;
        gap: 8px;
    }

    .pi-section-nav-pills {
        padding-bottom: 6px;
    }

    .pi-mode-toggle {
        align-self: flex-end;
    }

    .pi-remaining-search {
        font-size: 0.7rem;
    }
}

/* ═══════════════════════════════════════════ */
/* Phase 1 Expansion — Section Nav + Mode     */
/* ═══════════════════════════════════════════ */

/* --- Pro-Only Visibility --- */
.pi-pro-only {
    display: none !important;
}

.pi-pro-only.pi-show {
    display: block !important;
}

.pi-section-nav-pills.pi-pro-only.pi-show {
    display: flex !important;
}

.pi-pro-pill {
    display: none;
}

.pi-pro-pill.pi-show {
    display: inline-flex;
}

/* --- Section Nav --- */
.pi-section-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--pi-border);
    margin-bottom: 16px;
}

.pi-section-nav-pills {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
    min-width: 0;
}

.pi-section-nav-pills::-webkit-scrollbar {
    display: none;
}

.pi-nav-pill {
    flex-shrink: 0;
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.15);
    color: var(--pi-text-dim);
    font-size: 0.6rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.pi-nav-pill:hover {
    background: rgba(255, 215, 0, 0.12);
    color: var(--pi-gold);
}

.pi-nav-pill.active {
    background: rgba(255, 215, 0, 0.18);
    border-color: var(--pi-gold);
    color: var(--pi-gold);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.15);
}

/* --- Mode Toggle --- */
.pi-mode-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--pi-border);
    border-radius: 20px;
    overflow: hidden;
    flex-shrink: 0;
}

.pi-mode-btn {
    background: none;
    border: none;
    color: var(--pi-text-dim);
    font-size: 0.6rem;
    font-weight: 600;
    padding: 5px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.pi-mode-btn:hover {
    color: #fff;
}

.pi-mode-btn.active {
    background: var(--pi-gold);
    color: #000;
    border-radius: 20px;
}

/* --- Mode Hint --- */
.pi-mode-hint {
    width: 100%;
    text-align: center;
    font-size: 0.55rem;
    color: var(--pi-text-dim);
    margin-top: 4px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.pi-mode-hint strong {
    color: var(--pi-gold);
}

.pi-mode-hint.pi-hidden {
    display: none;
}

/* --- Search Input --- */
.pi-remaining-search-wrap {
    margin-bottom: 10px;
}

.pi-remaining-search {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--pi-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--pi-text);
    font-size: 0.75rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.pi-remaining-search:focus {
    border-color: var(--pi-gold);
    background: rgba(255, 215, 0, 0.04);
}

.pi-remaining-search::placeholder {
    color: var(--pi-text-dim);
}

/* --- Load More Button --- */
.pi-load-more {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 10px;
    color: var(--pi-gold);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.pi-load-more:hover {
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.1);
}

/* =============================================
   PHASE 1 — CORE FEATURE STYLES
   ============================================= */

/* --- TH Completion Meter --- */
.pi-th-completion {
    margin-top: 16px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(15, 12, 8, 0.95), rgba(30, 25, 15, 0.95));
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
}

.pi-completion-body {
    display: flex;
    align-items: center;
    gap: 28px;
    margin-top: 12px;
}

.pi-completion-ring-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.pi-completion-ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(var(--pi-gold) 0%,
            var(--pi-gold) var(--pct, 0%),
            rgba(255, 255, 255, 0.06) var(--pct, 0%),
            rgba(255, 255, 255, 0.06) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pi-completion-ring::after {
    content: '';
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: rgba(15, 12, 8, 0.98);
    position: absolute;
}

.pi-completion-pct {
    position: relative;
    z-index: 1;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--pi-gold);
    font-family: 'Supercell-Magic', 'Bungee', sans-serif;
}

.pi-completion-sub {
    font-size: 0.65rem;
    color: var(--pi-text-dim);
    text-align: center;
}

.pi-completion-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pi-completion-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pi-cs-label {
    font-size: 0.65rem;
    color: var(--pi-text-dim);
}

.pi-cs-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--pi-text);
}

.pi-completion-badge {
    font-size: 0.6rem;
    padding: 4px 10px;
    border-radius: 20px;
    text-align: center;
    font-weight: 600;
}

.pi-completion-badge.accurate {
    background: rgba(76, 175, 80, 0.12);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: #4CAF50;
}

.pi-completion-badge.partial {
    background: rgba(255, 193, 7, 0.12);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: #FFC107;
}

/* --- Progress Timeline Bar --- */
.pi-progress-timeline {
    margin-top: 16px;
    padding: 20px 28px 28px 20px;
    background: linear-gradient(135deg, rgba(15, 12, 8, 0.95), rgba(30, 25, 15, 0.95));
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    overflow: visible;
}

.pi-timeline-track {
    position: relative;
    height: 18px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    margin: 16px 0 8px;
    overflow: visible;
}

.pi-timeline-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, #665500, var(--pi-gold));
    transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.25);
}

.pi-timeline-marker {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 26px;
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(-1px);
}

.pi-timeline-marker::after {
    content: attr(data-label);
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.5rem;
    color: var(--pi-text-dim);
    white-space: nowrap;
}

.pi-timeline-current {
    position: absolute;
    top: -10px;
    transform: translateX(-50%);
    z-index: 2;
    transition: left 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.pi-timeline-current-label {
    display: block;
    background: var(--pi-gold);
    color: #000;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
    animation: pi-pulse-badge 2s ease-in-out infinite;
}

@keyframes pi-pulse-badge {

    0%,
    100% {
        box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
    }

    50% {
        box-shadow: 0 2px 16px rgba(255, 215, 0, 0.6);
    }
}

.pi-timeline-endpoints {
    display: flex;
    justify-content: space-between;
    font-size: 0.55rem;
    color: var(--pi-text-dim);
    margin-top: 12px;
}

/* --- Filter Chips --- */
.pi-remaining-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.pi-filter-chip {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--pi-text-dim);
    font-size: 0.6rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.pi-filter-chip:hover {
    background: rgba(255, 215, 0, 0.08);
    border-color: rgba(255, 215, 0, 0.2);
}

.pi-filter-chip.active {
    background: rgba(255, 215, 0, 0.15);
    border-color: var(--pi-gold);
    color: var(--pi-gold);
}

/* --- Upgrade Card Cost & Priority --- */
.pi-rem-cost {
    font-size: 0.55rem;
    color: var(--pi-text-dim);
    opacity: 0.7;
    margin-top: 1px;
}

.pi-rem-priority {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.5rem;
    font-weight: 700;
    margin-top: 3px;
}

.pi-rem-priority.high {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.pi-rem-priority.medium {
    background: rgba(255, 193, 7, 0.2);
    color: #FFC107;
}

.pi-rem-priority.low {
    background: rgba(255, 255, 255, 0.08);
    color: var(--pi-text-dim);
}

/* --- ETA Accuracy Tooltip --- */
.pi-eta-tooltip-trigger {
    position: relative;
    cursor: help;
    color: var(--pi-text-dim);
    font-size: 0.7rem;
    margin-left: 4px;
}

.pi-eta-tooltip {
    display: none;
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    padding: 10px 12px;
    background: rgba(30, 25, 15, 0.98);
    border: 1px solid var(--pi-gold);
    border-radius: 10px;
    font-size: 0.58rem;
    color: var(--pi-text);
    line-height: 1.5;
    z-index: 60;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    text-align: left;
}

.pi-eta-tooltip-trigger:hover .pi-eta-tooltip,
.pi-eta-tooltip-trigger:focus .pi-eta-tooltip {
    display: block;
}

/* --- Minimal Mode --- */
.pi-minimal-hide {
    display: none !important;
}

/* --- Mobile Responsive (new features) --- */
@media (max-width: 600px) {
    .pi-completion-body {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .pi-completion-ring {
        width: 100px;
        height: 100px;
    }

    .pi-completion-ring::after {
        width: 74px;
        height: 74px;
    }

    .pi-completion-pct {
        font-size: 1.3rem;
    }

    .pi-timeline-marker::after {
        font-size: 0.45rem;
    }

    .pi-remaining-filters {
        gap: 6px;
    }

    .pi-eta-tooltip {
        width: 200px;
        left: auto;
        right: -20px;
        transform: none;
    }
}


/* ═══════════════════════════════════════════════════
   PHASE 3.1 — PREMIUM TAB SYSTEM
   ═══════════════════════════════════════════════════ */

/* ── Tab Bar (ClashOS Wooden 3D Structure) ── */
.pi-tab-bar {
    display: flex;
    gap: 8px;
    padding: 6px 8px;
    margin: 0 0 24px;
    background: linear-gradient(180deg, #251714 0%, #150b09 100%);
    border: 3.5px solid var(--ink-dark, #06080b);
    border-radius: 16px;
    position: sticky;
    top: var(--topnav-h, 70px);
    z-index: 50;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.08),
        inset 0 -2px 0 rgba(0, 0, 0, 0.6),
        0 8px 24px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.pi-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 14px;
    font-family: 'ClashBold', 'Rubik', 'Baloo 2', sans-serif;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #cbd5e1;
    text-shadow: 0 -1.5px 0 rgba(0, 0, 0, 0.8), 0 1.5px 0 rgba(0, 0, 0, 0.8);
    background: linear-gradient(180deg, #3d2822 0%, #261612 100%);
    border: 2.5px solid #06080b;
    border-bottom: 5px solid #140907;
    border-radius: 10px;
    cursor: pointer;
    box-shadow:
        inset 0 1.5px 0 rgba(255, 255, 255, 0.12),
        0 3px 6px rgba(0, 0, 0, 0.5);
    transition: all 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
    position: relative;
    text-decoration: none;
    user-select: none;
}

.pi-tab-btn:hover {
    filter: brightness(1.15);
    color: #ffd700;
    transform: translateY(-1px);
    box-shadow:
        inset 0 1.5px 0 rgba(255, 255, 255, 0.2),
        0 5px 12px rgba(0, 0, 0, 0.6);
}

.pi-tab-btn.active {
    background: linear-gradient(180deg, #ffd13b 0%, #ff8000 100%);
    color: #ffffff;
    border-color: #06080b;
    border-bottom: 5.5px solid #a34e00;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.4),
        0 4px 14px rgba(241, 196, 15, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.6);
    text-shadow:
        -1.5px -1.5px 0 #000,
        1.5px -1.5px 0 #000,
        -1.5px 1.5px 0 #000,
        1.5px 1.5px 0 #000,
        0 2px 4px rgba(0, 0, 0, 0.8);
    transform: translateY(-1px);
}

.pi-tab-btn:active {
    transform: translateY(2.5px);
    border-bottom-width: 2.5px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 1px 2px rgba(0, 0, 0, 0.6);
}

.pi-tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.pi-tab-icon svg {
    display: block;
}

.pi-tab-label {
    font-size: 13px;
    letter-spacing: 0.04em;
}

@media (max-width: 600px) {
    .pi-tab-bar {
        padding: 4px 6px;
        gap: 4px;
        border-radius: 12px;
        border-width: 2.5px;
    }

    .pi-tab-btn {
        padding: 8px 6px;
        font-size: 11px;
        gap: 4px;
        border-radius: 8px;
        border-width: 2px;
        border-bottom-width: 4px;
    }

    .pi-tab-btn.active {
        border-bottom-width: 4px;
    }

    .pi-tab-label {
        font-size: 11px;
    }

    .pi-tab-icon svg {
        width: 12px;
        height: 12px;
    }
}

/* ── Progress Ring 3D Forge Crest ── */
.pi-progress-ring-card {
    text-align: center;
    padding: 38px 16px 20px !important;
    position: relative;
}

.pi-progress-ring-wrap {
    position: relative;
    width: 168px;
    height: 168px;
    margin: 10px auto 16px;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.75));
}

.pi-progress-ring-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
    overflow: visible;
}

.pi-ring-bg {
    fill: none;
    stroke: #120907;
    stroke-width: 13;
}

.pi-ring-fill {
    fill: none;
    stroke: url(#cocGoldRingGrad);
    stroke-width: 13;
    stroke-linecap: round;
    stroke-dasharray: 377;
    stroke-dashoffset: 377;
    filter: drop-shadow(0 0 6px rgba(255, 170, 0, 0.65));
    transition: stroke-dashoffset 1.2s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.tr-wp-ring-fill {
    stroke: url(#cocWarFlameGrad) !important;
    filter: drop-shadow(0 0 6px rgba(231, 76, 60, 0.65)) !important;
}

.pi-ring-center-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    pointer-events: none;
    z-index: 2;
}

.pi-ring-text {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 32px;
    font-weight: 900;
    line-height: 1;
    margin: 0;
    padding: 0;
    color: #ffd700;
    background: linear-gradient(180deg, #ffffff 0%, #ffe875 25%, #ffd13b 55%, #ff8c00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 1px 2px #000) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.85));
}

.pi-ring-sublabel {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 8.5px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #ffd13b;
    text-transform: uppercase;
    margin: 0;
    padding: 2px 7px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 215, 0, 0.35);
    border-radius: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 4px rgba(0, 0, 0, 0.5);
}

.pi-ring-bottom-plaque {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(180deg, #3d2822 0%, #261612 100%);
    border: 2.5px solid #06080b;
    border-bottom: 4.5px solid #140907;
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 3px 6px rgba(0, 0, 0, 0.5);
}

.pi-ring-plaque-title {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 11px;
    font-weight: 800;
    color: #ffd700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        0 2px 4px rgba(0, 0, 0, 0.8);
}

/* ── Tab Content Panels ── */
.pi-tab-content {
    display: none;
    animation: piTabFadeIn 0.28s ease-out;
}

.pi-tab-content.active {
    display: block;
}

@keyframes piTabFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ═══════════════════════════════════════════════════
   TODAY'S BEST UPGRADE CARD
   ═══════════════════════════════════════════════════ */

.pi-best-upgrade {
    margin-bottom: 16px;
}

.pi-best-upgrade-card {
    position: relative;
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    padding: 20px;
    overflow: hidden;
}

.pi-best-upgrade-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #FF6B35, #FFD700, #4ADE80);
    border-radius: var(--pi-radius) var(--pi-radius) 0 0;
}

.pi-best-upgrade-empty {
    text-align: center;
    color: var(--pi-text-dim);
    padding: 12px;
    font-size: 0.85rem;
}

.pi-best-upgrade-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pi-best-upgrade-img {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
    flex-shrink: 0;
}

.pi-best-upgrade-info {
    flex: 1;
    min-width: 0;
}

.pi-best-upgrade-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--pi-text);
    margin-bottom: 2px;
}

.pi-best-upgrade-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--pi-text-dim);
    margin-bottom: 6px;
}

.pi-best-upgrade-reason {
    font-size: 0.78rem;
    color: var(--pi-green);
    font-weight: 500;
}

.pi-best-upgrade-add-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--pi-gold), #FFA500);
    color: #1a1a1a;
    border: none;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pi-best-upgrade-add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(255, 215, 0, 0.3);
}


/* ═══════════════════════════════════════════════════
   REMAINING PREVIEW (OVERVIEW TAB)
   ═══════════════════════════════════════════════════ */

.pi-remaining-preview {
    margin-bottom: 16px;
}

.pi-remaining-preview .pi-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.pi-view-all-btn {
    background: none;
    border: 1px solid rgba(255, 215, 0, 0.2);
    color: var(--pi-gold);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pi-view-all-btn:hover {
    background: rgba(255, 215, 0, 0.08);
    border-color: rgba(255, 215, 0, 0.35);
}

.pi-remaining-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}


/* ═══════════════════════════════════════════════════
   PLANNER V2 — GUEST LOCK + CONTROLS + LANES
   ═══════════════════════════════════════════════════ */

/* Guest Lock Overlay */
.pi-planner-lock {
    display: none;
    position: relative;
    margin-bottom: 20px;
}

.pi-planner-lock.visible {
    display: block;
}

.pi-planner-lock-inner {
    text-align: center;
    padding: 48px 24px;
    background: rgba(15, 12, 8, 0.9);
    border: 1px solid rgba(255, 215, 0, 0.12);
    border-radius: var(--pi-radius);
    backdrop-filter: blur(16px);
}

.pi-planner-lock-icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
}

.pi-planner-lock-inner h3 {
    font-size: 1.1rem;
    color: var(--pi-text);
    margin-bottom: 8px;
    font-weight: 700;
}

.pi-planner-lock-inner p {
    font-size: 0.85rem;
    color: var(--pi-text-dim);
    margin-bottom: 20px;
    line-height: 1.5;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.pi-planner-lock-btn {
    padding: 10px 28px;
    background: linear-gradient(135deg, var(--pi-gold), #FFA500);
    color: #1a1a1a;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pi-planner-lock-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 18px rgba(255, 215, 0, 0.3);
}

/* Planner V3 — Split Builder/Lab Layout */
.pi-planner-v3 {
    margin-top: 20px;
}

.pi-planner-split {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.pi-planner-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pi-planner-col-builders {
    flex: 3;
    /* 60% */
}

.pi-planner-col-lab {
    flex: 2;
    /* 40% */
}

.pi-planner-col-header {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--pi-text);
    padding: 8px 12px;
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pi-planner-col-builders .pi-planner-col-header {
    border-left: 3px solid var(--pi-gold);
}

.pi-planner-col-lab .pi-planner-col-header {
    border-left: 3px solid var(--pi-cyan, #22d3ee);
}

/* Resource Badges */
.pi-resource-badge {
    display: inline-block;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 4px;
}

.pi-resource-badge.builder {
    background: rgba(255, 215, 0, 0.12);
    color: var(--pi-gold);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.pi-resource-badge.lab {
    background: rgba(34, 211, 238, 0.12);
    color: var(--pi-cyan, #22d3ee);
    border: 1px solid rgba(34, 211, 238, 0.2);
}

/* Planner Summary Grid */
.pi-planner-summary-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* ══════════ Power Optimizer ══════════ */
.pi-power-optimizer {
    margin-top: 20px;
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.pi-power-optimizer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--pi-gold), rgba(255, 215, 0, 0.2), var(--pi-gold));
}

.pi-power-optimizer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.pi-power-optimizer-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--pi-gold);
}

.pi-power-optimizer-subtitle {
    font-size: 0.72rem;
    color: var(--pi-text-dim);
}

.pi-power-score-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 14px;
}

.pi-power-score {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--pi-text);
    background: linear-gradient(135deg, var(--pi-gold), #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pi-power-score-label {
    font-size: 0.72rem;
    color: var(--pi-text-dim);
}

.pi-equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.pi-equipment-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.pi-equipment-card:hover {
    border-color: rgba(255, 215, 0, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

.pi-equipment-card-img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: contain;
}

.pi-equipment-card-info {
    flex: 1;
    min-width: 0;
}

.pi-equipment-card-name {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--pi-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pi-equipment-card-level {
    font-size: 0.64rem;
    color: var(--pi-text-dim);
}

.pi-equipment-card.maxed {
    opacity: 0.5;
}

.pi-power-delta {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
}

.pi-power-delta.up {
    background: rgba(74, 222, 128, 0.15);
    color: var(--pi-green);
}

.pi-power-delta.down {
    background: rgba(248, 113, 113, 0.15);
    color: var(--pi-red);
}

/* ══════════ Responsive: Stack on mobile ══════════ */
@media (max-width: 768px) {
    .pi-planner-split {
        flex-direction: column;
    }

    .pi-planner-col-builders,
    .pi-planner-col-lab {
        flex: 1;
    }

    .pi-equipment-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

.pi-planner-subtitle {
    font-size: 0.82rem;
    color: var(--pi-text-dim);
    margin: 4px 0 16px;
}

.pi-planner-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.pi-planner-autofill-btn,
.pi-planner-clear-btn {
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.pi-planner-autofill-btn {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.2), rgba(74, 222, 128, 0.08));
    color: var(--pi-green);
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.pi-planner-autofill-btn:hover {
    background: rgba(74, 222, 128, 0.18);
}

.pi-planner-clear-btn {
    background: rgba(248, 113, 113, 0.1);
    color: var(--pi-red);
    border: 1px solid rgba(248, 113, 113, 0.15);
}

.pi-planner-clear-btn:hover {
    background: rgba(248, 113, 113, 0.18);
}

/* Planner Lanes Container */
.pi-planner-lanes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.pi-planner-lane {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: 12px;
    padding: 12px;
    min-height: 64px;
    transition: border-color 0.2s ease;
}

.pi-planner-lane.drag-over {
    border-color: var(--pi-gold);
    background: rgba(255, 215, 0, 0.04);
}

.pi-planner-lane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.pi-planner-lane-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--pi-text-dim);
}

.pi-planner-lane-status {
    font-size: 0.72rem;
    color: var(--pi-text-dim);
    opacity: 0.7;
}

.pi-planner-lane-slots {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pi-planner-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--pi-text);
    cursor: grab;
    transition: all 0.2s ease;
}

.pi-planner-slot:hover {
    border-color: rgba(255, 215, 0, 0.2);
    background: rgba(255, 255, 255, 0.06);
}

.pi-planner-slot.dragging {
    opacity: 0.4;
}

.pi-planner-slot-img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: contain;
}

.pi-planner-slot-info {
    flex: 1;
    min-width: 0;
}

.pi-planner-slot-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pi-planner-slot-dates {
    font-size: 0.68rem;
    color: var(--pi-text-dim);
}

.pi-planner-slot-idle {
    font-size: 0.65rem;
    color: var(--pi-yellow);
    font-weight: 500;
}

.pi-planner-slot-remove {
    background: none;
    border: none;
    color: var(--pi-red);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.pi-planner-slot-remove:hover {
    opacity: 1;
}

/* Planner Summary */
/* 2026-08-11 polish: these referenced undefined vars (--pi-glass/--pi-border)
   and fell back to transparent — convert to the wood/parchment card recipe. */
.pi-planner-summary {
    background: #181411;
    border: 2px solid var(--parchment-border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
    padding: 14px 16px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.pi-planner-summary-item {
    flex: 1;
    min-width: 100px;
    text-align: center;
}

.pi-planner-summary-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--pi-gold);
}

.pi-planner-summary-label {
    font-size: 0.72rem;
    color: var(--pi-ink-faint);
    margin-top: 2px;
}

/* Planner Lanes Container */
.pi-planner-lane {
    background: #181411;
    border: 2px solid var(--parchment-border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
    padding: 12px;
    margin-bottom: 10px;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.pi-planner-lane.drag-over {
    border-color: var(--pi-gold);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.15);
}

.pi-planner-lane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pi-planner-lane-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--pi-text);
}

.pi-planner-lane-status {
    font-size: 0.7rem;
    color: var(--pi-text-dim);
}

.pi-planner-lane-slots {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pi-planner-slot-img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
    flex-shrink: 0;
}

.pi-planner-slot.dragging {
    opacity: 0.4;
}

.pi-planner-slot[draggable="true"] {
    cursor: grab;
}

.pi-planner-slot[draggable="true"]:active {
    cursor: grabbing;
}

/* ═══════════════════════════════════════════════════
   PHASE 3.1 — ACCORDION SYSTEM
   ═══════════════════════════════════════════════════ */
.pi-accordion {
    margin-bottom: 12px;
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    overflow: hidden;
    background: var(--pi-glass);
}

.pi-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s;
    user-select: none;
}

.pi-accordion-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

.pi-accordion-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pi-text);
}

.pi-accordion-meta {
    font-size: 0.72rem;
    color: var(--pi-text-dim);
    margin-left: 8px;
}

.pi-accordion-chevron {
    font-size: 0.7rem;
    color: var(--pi-text-dim);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pi-accordion.open .pi-accordion-chevron {
    transform: rotate(180deg);
}

.pi-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 18px;
}

.pi-accordion.open .pi-accordion-body {
    max-height: 2000px;
    padding: 0 18px 16px;
}

/* ═══════════════════════════════════════════════════
   PHASE 3.1 — PLANNER ACTIONS BAR (In-flow toolbar)
   ═══════════════════════════════════════════════════ */
.pi-planner-sticky-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #181411;
    border: 2.5px solid var(--parchment-border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 12px rgba(0, 0, 0, 0.5);
    position: relative;
    top: auto;
    z-index: 10;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.pi-planner-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid #6b4d1e;
    border-bottom-width: 5px;
    border-radius: 8px;
    background: linear-gradient(to bottom, #f5d78a, #d9a441);
    color: #4a3007;
    font-family: 'Baloo 2', 'Rubik', sans-serif;
    font-size: 0.76rem;
    font-weight: 800;
    cursor: pointer;
    transition: filter 0.2s, transform 0.1s;
    white-space: nowrap;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 3px 8px rgba(0, 0, 0, 0.4);
}

.pi-planner-action-btn:hover {
    filter: brightness(1.07);
}

.pi-planner-action-btn:active {
    transform: translateY(2px);
    border-bottom-width: 3px;
}

.pi-planner-action-btn.danger {
    background: linear-gradient(to bottom, #d64541, #a02017);
    color: #ffffff;
    border-color: #6d1410;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25), 0 3px 8px rgba(0, 0, 0, 0.4);
}

.pi-planner-action-btn.danger:hover {
    filter: brightness(1.06);
}

/* ═══ Phase 2 — Planner goal selector + "Why this?" panels ═══ */
.pi-planner-goals {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px 2px 0;
    border-right: 1px solid rgba(212, 175, 55, 0.25);
    margin-right: 4px;
    flex-wrap: wrap;
}
.pi-planner-goals-label {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--pi-ink-soft);
    margin-right: 2px;
}
.pi-goal-chip {
    padding: 5px 12px;
    border: 2px solid rgba(212, 175, 55, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--pi-ink-soft);
    font-family: 'Baloo 2', 'Rubik', sans-serif;
    font-size: 0.68rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.pi-goal-chip:hover {
    border-color: var(--pi-gold);
    color: var(--pi-gold);
}
.pi-goal-chip.active {
    background: linear-gradient(to bottom, #f5d78a, #d9a441);
    color: #4a3007;
    border-color: #6b4d1e;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* "Why this?" — small info toggle + gold-bordered expandable panel */
.pi-why-wrap {
    position: relative;
    display: inline-flex;
}
.pi-why-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1.5px solid var(--pi-gold-deep);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--pi-gold);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
}
.pi-why-toggle:hover {
    background: rgba(251, 191, 36, 0.18);
    transform: scale(1.08);
}
.pi-why-panel {
    display: none;
    position: absolute;
    z-index: 60;
    top: calc(100% + 4px);
    right: 0;
    width: 250px;
    padding: 10px 12px;
    background: #181411;
    border: 2px solid var(--pi-gold-deep);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 4px 14px rgba(0, 0, 0, 0.5);
    font-size: 0.7rem;
    line-height: 1.6;
    color: var(--pi-text);
    text-align: left;
}
.builder-slot {
    position: relative;
}
.builder-slot .pi-why-wrap {
    position: static;
}
.builder-slot .pi-why-panel {
    position: absolute;
    top: calc(100% + 4px);
    z-index: 60;
    width: 210px;
    box-sizing: border-box;
}
.builder-lane:nth-child(odd) .builder-slot .pi-why-panel {
    left: 0;
    right: auto;
}
.builder-lane:nth-child(even) .builder-slot .pi-why-panel {
    right: 0;
    left: auto;
}
.pi-why-title {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--pi-gold);
    margin-bottom: 4px;
}
.pi-why-line {
    font-size: 0.68rem;
    color: var(--pi-text);
}
.pi-why-line b {
    color: var(--pi-gold);
}
.pi-why-goal {
    margin-top: 5px;
    padding-top: 4px;
    border-top: 1px solid rgba(212, 175, 55, 0.25);
    font-size: 0.6rem;
    color: var(--pi-ink-soft);
}
.pi-why-not {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(212, 175, 55, 0.3);
}
.pi-why-not-title {
    font-size: 0.66rem;
    font-weight: 800;
    color: var(--pi-red);
    margin-bottom: 2px;
}
.pi-why-not-line {
    font-size: 0.64rem;
    color: var(--pi-ink-soft);
}

/* ═══ Phase 3 — Plan Health + Next Best Move ═══
   Both cards reuse the EXISTING .pi-util-summary (parchment panel) and
   .pi-planner-alert (gold-bordered) card classes — the rules below are
   ONLY the layout/typography no shared class covers (the 3-row health
   grid and the NBM inner breakdown container). Tokens: --pi-* set. */
.pi-plan-health-rows {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 8px;
}
.pi-plan-health-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--pi-ink-soft);
}
.pi-plan-health-row b {
    font-family: 'Baloo 2', 'Rubik', sans-serif;
    font-weight: 800;
    font-size: 0.76rem;
    color: var(--pi-gold-text);
}
.pi-nbm {
    align-items: center;
    border-color: var(--pi-gold);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45), 0 0 14px rgba(251, 191, 36, 0.1);
}
.pi-nbm-item {
    margin-top: 3px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--pi-text);
}
.pi-nbm-item b {
    color: var(--pi-gold);
}
.pi-nbm-breakdown {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(212, 175, 55, 0.22);
    border-radius: 7px;
}

.pi-planner-save-status {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--pi-text-dim);
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
}

.pi-planner-save-status.saved {
    color: var(--pi-green);
}

.pi-planner-save-status.saving {
    color: var(--pi-yellow);
}

.pi-planner-save-status.unsaved {
    color: var(--pi-text-dim);
}

.pi-planner-tracker-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 14px;
    border: 1px dashed var(--pi-border);
    border-radius: 8px;
    background: transparent;
    color: var(--pi-text-dim);
    font-size: 0.76rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pi-planner-tracker-link:hover {
    color: var(--pi-gold);
    border-color: rgba(212, 175, 55, 0.25);
}

/* ═══════════════════════════════════════════════════
   PHASE 3.1 — PLAN FINISH DATE CARD
   ═══════════════════════════════════════════════════ */
.pi-plan-finish-card {
    background: #181411;
    border: 2px solid var(--parchment-border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.pi-plan-finish-date {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--pi-gold);
}

.pi-plan-finish-label {
    font-size: 0.74rem;
    color: var(--pi-text-dim);
    margin-top: 2px;
}

.pi-plan-confidence {
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
}

.pi-plan-confidence.accurate {
    background: rgba(74, 222, 128, 0.1);
    color: var(--pi-green);
    border: 1px solid rgba(74, 222, 128, 0.15);
}

.pi-plan-confidence.partial {
    background: rgba(250, 204, 21, 0.1);
    color: var(--pi-yellow);
    border: 1px solid rgba(250, 204, 21, 0.15);
}

/* ═══════════════════════════════════════════════════
   PHASE 3.1 — AUTH GATED PLANNER (Guest Blur)
   ═══════════════════════════════════════════════════ */
.pi-planner-gated {
    filter: blur(3px);
    pointer-events: none;
    opacity: 0.5;
    user-select: none;
}

/* ═══════════════════════════════════════════════════
   PHASE 3.2 — DRAG STATES
   ═══════════════════════════════════════════════════ */
.pi-planner-slot.dragging {
    opacity: 0.4;
    transform: scale(0.97);
    border: 1px dashed var(--pi-gold);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.15);
}

.pi-planner-lane.drag-over {
    border-color: rgba(212, 175, 55, 0.4);
    background: rgba(212, 175, 55, 0.04);
    box-shadow: inset 0 0 20px rgba(212, 175, 55, 0.06);
}

.pi-rem-card[draggable="true"] {
    cursor: grab;
}

.pi-rem-card[draggable="true"]:active {
    cursor: grabbing;
}

/* ═══════════════════════════════════════════════════
   PHASE 3.2 — MOBILE ACTION MENU
   ═══════════════════════════════════════════════════ */
.pi-mobile-action-wrap {
    display: none;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .pi-mobile-action-wrap {
        display: block;
    }
}

.pi-mobile-action-toggle {
    padding: 4px 10px;
    font-size: 0.7rem;
    border: 1px solid var(--pi-border);
    border-radius: 6px;
    background: rgba(212, 175, 55, 0.06);
    color: var(--pi-gold);
    cursor: pointer;
    transition: all 0.2s;
}

.pi-mobile-action-toggle:hover {
    background: rgba(212, 175, 55, 0.12);
}

.pi-mobile-action-menu {
    display: none;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 0;
}

.pi-mobile-action-menu.open {
    display: flex;
}

.pi-mobile-action-item {
    padding: 5px 10px;
    font-size: 0.7rem;
    border: 1px solid var(--pi-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--pi-text-dim);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.pi-mobile-action-item:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.25);
    color: var(--pi-gold);
}

/* ═══════════════════════════════════════════════════
   PHASE 3.2 — TOAST NOTIFICATION
   ═══════════════════════════════════════════════════ */
.pi-planner-toast {
    position: fixed;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 22px;
    border-radius: 10px;
    background: rgba(22, 22, 26, 0.95);
    border: 1px solid var(--pi-gold);
    color: var(--pi-gold);
    font-size: 0.8rem;
    font-weight: 600;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    opacity: 0;
    transition: bottom 0.35s ease, opacity 0.35s ease;
    pointer-events: none;
}

.pi-planner-toast.show {
    bottom: 24px;
    opacity: 1;
}

/* ═══════════════════════════════════════════════════
   PHASE 3.2 — IDLE WARNING
   ═══════════════════════════════════════════════════ */
.pi-idle-warning {
    flex-basis: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(250, 204, 21, 0.06);
    border: 1px solid rgba(250, 204, 21, 0.12);
    color: var(--pi-yellow);
    font-size: 0.74rem;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════
   PHASE 3.2 — SAVE STATUS FAILED + RETRY
   ═══════════════════════════════════════════════════ */
.pi-planner-save-status.failed {
    color: var(--pi-red, #f87171);
}

.pi-save-retry {
    cursor: pointer;
    text-decoration: underline;
    font-weight: 600;
    margin-left: 4px;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.pi-save-retry:hover {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════
   PHASE 3.1 — RESPONSIVE (small screens)
   ═══════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .pi-tab-btn {
        padding: 8px 6px;
        font-size: 0.75rem;
    }

    .pi-tab-label {
        font-size: 0.72rem;
    }

    .pi-best-upgrade-content {
        flex-direction: column;
        text-align: center;
    }

    .pi-best-upgrade-meta {
        justify-content: center;
    }

    .pi-remaining-preview-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pi-planner-controls {
        flex-direction: column;
    }

    .pi-planner-slot {
        font-size: 0.72rem;
    }
}


/* ═══════════════════════════════════════════════════
   PHASE 4 — RETENTION PANEL
   ═══════════════════════════════════════════════════ */
.pi-retention-section {
    position: relative;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(212, 175, 55, 0.08);
    border-radius: 14px;
    padding: 20px;
    margin-top: 20px;
}

/* ── Streak Badge ── */
.pi-streak-badge-wrap {
    text-align: center;
    margin-bottom: 20px;
}

.pi-streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #888;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.4s ease;
}

.pi-streak-badge.active {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.2);
    color: var(--pi-gold);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.1);
}

.pi-streak-flame {
    font-size: 1.4rem;
    display: inline-block;
}

.pi-streak-badge.active .pi-streak-flame {
    animation: pi-flame-pulse 1.5s ease-in-out infinite;
}

.pi-streak-count {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

.pi-streak-label {
    font-size: 0.8rem;
    opacity: 0.8;
}

@keyframes pi-flame-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15) rotate(-5deg);
    }
}

/* ── Toggle Switch ── */
.pi-retention-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pi-retention-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--pi-text, #e0e0e0);
}

.pi-retention-icon {
    font-size: 1.1rem;
}

.pi-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.pi-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.pi-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    transition: all 0.3s ease;
}

.pi-toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #888;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.pi-toggle-switch input:checked+.pi-toggle-slider {
    background: rgba(212, 175, 55, 0.25);
}

.pi-toggle-switch input:checked+.pi-toggle-slider::before {
    transform: translateX(20px);
    background: var(--pi-gold);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

/* ── Simplified Email Toggle Row ── */
.pi-email-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.pi-email-toggle-row:hover {
    border-color: rgba(212, 175, 55, 0.15);
    background: rgba(255, 255, 255, 0.03);
}

.pi-email-toggle-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.pi-email-toggle-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.pi-email-toggle-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.pi-email-toggle-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--pi-text, #e0e0e0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pi-email-toggle-sub {
    font-size: 0.72rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Lock Overlay ── */
.pi-retention-lock {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 13, 18, 0.88);
    backdrop-filter: blur(6px);
    border-radius: 14px;
    z-index: 10;
}

.pi-retention-lock-inner {
    text-align: center;
    color: #888;
}

.pi-retention-lock-inner p {
    margin: 10px 0 16px;
    font-size: 0.85rem;
}

.pi-retention-lock-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #d4af37, #c5a028);
    color: #0d0d12;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.pi-retention-lock-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .pi-retention-info-grid {
        grid-template-columns: 1fr;
    }

    .pi-retention-time-row {
        flex-direction: column;
        gap: 10px;
    }

    .pi-retention-actions {
        flex-direction: column;
    }
}

/* ═══════════════════════════════════════════════════
   VILLAGE HEALTH (RUSH SCORE) — embedded inside TH Completion
   ═══════════════════════════════════════════════════ */
.pi-rush-inside {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--pi-border);
}

.pi-rush-header-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.pi-rush-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--pi-text);
    letter-spacing: 0.03em;
}

.pi-rush-percent-inline {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
}

.pi-rush-status-inline {
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: auto;
}

.pi-rush-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.pi-rush-bar-label {
    font-size: 0.75rem;
    color: var(--pi-text-dim);
    min-width: 80px;
    white-space: nowrap;
}

.pi-rush-bar-track {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
}

.pi-rush-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease-out;
}

.pi-rush-bar-value {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 32px;
    text-align: right;
    color: var(--pi-text);
}

/* ═══════════════════════════════════════════════════
   UPGRADE IMPACT SIMULATOR
   ═══════════════════════════════════════════════════ */
.pi-impact-sim {
    margin-top: 16px;
}

.pi-impact-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pi-impact-card {
    background: var(--pi-glass);
    border: 1px solid var(--pi-border);
    border-radius: var(--pi-radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: piFadeIn 0.4s ease-out both;
}

.pi-impact-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.pi-impact-rank {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--pi-gold);
    min-width: 28px;
    text-align: center;
}

.pi-impact-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.pi-impact-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.pi-impact-icon span {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.pi-impact-info {
    flex: 1;
    min-width: 0;
}

.pi-impact-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--pi-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pi-impact-levels {
    font-size: 0.7rem;
    color: var(--pi-text-dim);
    margin-top: 2px;
}

.pi-impact-delta {
    text-align: center;
    min-width: 60px;
}

.pi-impact-delta-value {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    color: #4CAF50;
    font-weight: 700;
}

.pi-impact-delta-sub {
    font-size: 0.6rem;
    color: var(--pi-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pi-impact-priority {
    text-align: center;
    min-width: 50px;
    padding: 6px 8px;
    background: rgba(212, 175, 55, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.12);
}

.pi-impact-priority-value {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--pi-gold);
    font-weight: 700;
}

.pi-impact-priority-sub {
    font-size: 0.55rem;
    color: var(--pi-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════════════
   ETA MODE TOGGLE
   ═══════════════════════════════════════════════════ */
.pi-eta-mode-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 4px;
    border: 1px solid var(--pi-border);
}

.pi-eta-mode-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--pi-text-dim);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.pi-eta-mode-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--pi-text);
}

.pi-eta-mode-btn.active {
    background: rgba(212, 175, 55, 0.12);
    color: var(--pi-gold);
    border: 1px solid rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.08);
}

/* ═══════════════════════════════════════════════════
   MOBILE RESPONSIVE FOR NEW CARDS
   ═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .pi-rush-percent-inline {
        font-size: 1.1rem !important;
    }

    .pi-rush-bar-label {
        min-width: 65px !important;
        font-size: 0.65rem !important;
    }

    .pi-impact-card {
        padding: 10px 12px !important;
        gap: 8px !important;
    }

    .pi-impact-icon {
        width: 32px !important;
        height: 32px !important;
    }

    .pi-impact-name {
        font-size: 0.75rem !important;
    }

    .pi-impact-delta-value {
        font-size: 0.85rem !important;
    }

    .pi-impact-priority {
        min-width: 40px !important;
        padding: 4px 6px !important;
    }

    .pi-eta-mode-btn {
        font-size: 0.65rem !important;
        padding: 6px 8px !important;
    }
}

/* ═══════════════════════════════════════════════════
   MAXED STATES & CELEBRATION
   ═══════════════════════════════════════════════════ */
.pi-timer-maxed-card {
    opacity: 0.85;
    border: 1px solid rgba(76, 175, 80, 0.3) !important;
}

.pi-timer-maxed {
    font-size: 0.6rem;
    color: #4CAF50;
    font-weight: 600;
    margin-top: 2px;
}

.pi-maxed-glow {
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.6), 0 0 24px rgba(255, 215, 0, 0.3);
    color: #FFD700 !important;
}

.pi-rush-maxed {
    text-align: center;
    padding: 10px 0 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #FFD700;
    letter-spacing: 0.02em;
}

/* ============================================
   PROGRESS INTEL — COMPREHENSIVE MOBILE OVERHAUL
   Mobile-first for Android/iOS best experience
   ============================================ */

@media (max-width: 768px) {

    /* ── Performance: disable hover on touch ── */
    .pi-timer-card:hover,
    .pi-suggestion-card:hover,
    .pi-unit-card:hover,
    .pi-rem-card:hover,
    .pi-lab-slot:hover,
    .pi-export-btn:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    /* ── Snapshot Card ── */
    .pi-snapshot {
        padding: 18px 14px !important;
    }

    .pi-snapshot-header {
        gap: 12px !important;
    }

    .pi-th-badge {
        width: 52px !important;
        height: 52px !important;
    }

    .pi-th-badge img {
        width: 44px !important;
        height: 44px !important;
    }

    .pi-player-info h3 {
        font-size: 1rem !important;
    }

    .pi-progress-big .pi-percent {
        font-size: 3rem !important;
    }

    .pi-readiness {
        padding: 10px 12px !important;
        gap: 8px !important;
    }

    /* ── ETA Row: wrap on narrow ── */
    .pi-eta-row {
        flex-wrap: wrap !important;
    }

    .pi-eta-card {
        min-width: calc(50% - 6px) !important;
    }

    /* ── Timer Grid: 2-col on phones ── */
    .pi-timer-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .pi-timer-card {
        padding: 12px 8px !important;
    }

    .pi-timer-ring {
        width: 60px !important;
        height: 60px !important;
    }

    /* ── Unit Grid: compact 4-col ── */
    .pi-unit-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }

    .pi-unit-img-wrap {
        width: 40px !important;
        height: 40px !important;
    }

    .pi-unit-name {
        font-size: 0.55rem !important;
    }

    .pi-unit-level {
        font-size: 0.6rem !important;
    }

    /* ── Suggestions: tighter ── */
    .pi-suggestion-card {
        padding: 10px !important;
        gap: 8px !important;
    }

    .pi-sugg-icon img {
        width: 34px !important;
        height: 34px !important;
    }

    .pi-sugg-name {
        font-size: 0.75rem !important;
    }

    .pi-sugg-reason {
        font-size: 0.6rem !important;
    }

    .pi-sugg-rank {
        font-size: 0.95rem !important;
        min-width: 22px !important;
    }

    /* ── War Power card ── */
    .pi-warpower-card {
        padding: 18px 14px !important;
    }

    .pi-warpower-score {
        font-size: 2.5rem !important;
    }

    .pi-warpower-breakdown {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }

    .pi-wp-stat {
        padding: 8px !important;
    }

    .pi-wp-stat-value {
        font-size: 0.95rem !important;
    }

    /* ── ETA Bar: stack columns on mobile ── */
    .pi-eta-bar {
        padding: 14px 12px !important;
    }

    .pi-eta-bar-inner {
        flex-direction: column !important;
        gap: 14px !important;
    }

    .pi-eta-bar-divider {
        width: 50% !important;
        height: 1px !important;
        margin: 0 auto !important;
    }

    .pi-eta-bar-value {
        font-size: 1rem !important;
    }

    /* ── Export Bar ── */
    .pi-export-bar {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 6px !important;
    }

    .pi-export-btn {
        padding: 10px 12px !important;
        min-height: 44px !important;
        font-size: 0.6rem !important;
    }

    /* ── Section Nav Pills: scrollable + touch-friendly ── */
    .pi-section-nav {
        gap: 6px !important;
        padding: 10px 0 !important;
    }

    .pi-section-nav-pills {
        width: 100% !important;
        padding-bottom: 4px !important;
    }

    .pi-nav-pill {
        padding: 8px 14px !important;
        font-size: 0.6rem !important;
        min-height: 40px !important;
        display: flex !important;
        align-items: center !important;
    }

    /* ── Mode Toggle: full width on mobile ── */
    .pi-mode-toggle {
        width: 100% !important;
    }

    .pi-mode-btn {
        flex: 1 !important;
        padding: 8px 10px !important;
        min-height: 40px !important;
        font-size: 0.6rem !important;
        text-align: center !important;
    }

    /* ── Breakdown Tabs: scrollable ── */
    .pi-breakdown-tabs {
        padding-bottom: 6px !important;
    }

    .pi-breakdown-tab {
        padding: 8px 12px !important;
        min-height: 40px !important;
        display: flex !important;
        align-items: center !important;
    }

    /* ── Remaining Tabs: scrollable ── */
    .pi-remaining-tabs {
        padding-bottom: 6px !important;
    }

    .pi-rem-tab {
        padding: 8px 12px !important;
        min-height: 40px !important;
    }

    /* ── Remaining Cards: tighter ── */
    .pi-remaining-grid {
        max-height: 350px !important;
    }

    .pi-rem-card {
        padding: 8px 10px !important;
        gap: 8px !important;
    }

    .pi-rem-icon {
        width: 30px !important;
        height: 30px !important;
    }

    .pi-rem-name {
        font-size: 0.7rem !important;
    }

    /* ── Builder Lanes: scrollable ── */
    .pi-builder-lane {
        padding: 6px 8px !important;
    }

    .pi-lane-label {
        font-size: 0.55rem !important;
        min-width: 44px !important;
    }

    .pi-lane-slot {
        padding: 4px 8px !important;
    }

    .pi-lane-slot-icon {
        width: 20px !important;
        height: 20px !important;
    }

    .pi-lane-slot-name {
        font-size: 0.55rem !important;
    }

    /* ── Lab Lane: compact ── */
    .pi-lab-slot {
        min-width: 70px !important;
        padding: 8px !important;
    }

    .pi-lab-slot-icon {
        width: 28px !important;
        height: 28px !important;
    }

    /* ── Planner: tighter padding ── */
    .pi-planner-locked {
        padding: 24px 16px !important;
    }

    .pi-lock-title {
        font-size: 1rem !important;
    }

    .pi-lock-subtitle {
        font-size: 0.7rem !important;
    }

    /* ── JSON Modal: full-screen on mobile ── */
    .pi-json-modal {
        padding: 12px !important;
    }

    .pi-json-modal-content {
        padding: 20px 14px !important;
        max-height: 90vh !important;
        border-radius: 16px !important;
    }

    .pi-json-textarea {
        min-height: 140px !important;
        font-size: 0.65rem !important;
    }

    .pi-json-parse-btn {
        min-height: 48px !important;
    }

    /* ── Mode Banner: compact ── */
    .pi-mode-banner {
        padding: 10px 12px !important;
        gap: 8px !important;
    }

    .pi-mode-banner-text {
        font-size: 0.6rem !important;
    }

    /* ── Section Titles ── */
    .pi-section-title {
        font-size: 0.75rem !important;
    }

    /* ── Search Hero ── */
    .pi-search-hero {
        padding: 20px 12px 16px !important;
    }

    .pi-search-hero h2 {
        font-size: 1.3rem !important;
    }

    .pi-search-bar {
        flex-direction: column !important;
    }

    .pi-scan-btn {
        width: 100% !important;
        min-height: 48px !important;
    }

    /* ── Sort Dropdown: full width ── */
    .pi-sort-dropdown {
        width: 100% !important;
        min-height: 44px !important;
    }

    .pi-section-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    /* ── Remaining Search: full width ── */
    .pi-remaining-search {
        width: 100% !important;
        font-size: 0.7rem !important;
    }

    /* ── Toast: above bottom nav ── */
    .pi-toast {
        bottom: 110px !important;
    }

    /* ── Retention Info Grid ── */
    .pi-retention-info-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Extra small (phones < 400px) */
@media (max-width: 400px) {
    .pi-unit-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .pi-timer-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .pi-progress-big .pi-percent {
        font-size: 2.5rem !important;
    }

    .pi-warpower-score {
        font-size: 2rem !important;
    }

    .pi-eta-card {
        min-width: 100% !important;
    }

    .pi-snapshot-header {
        flex-direction: column !important;
        text-align: center !important;
    }
}

.pi-accordion-meta {
    font-size: 0.85rem !important;
    color: var(--text-secondary);
    white-space: nowrap;
}

.pi-status,
.cwl-status {
    white-space: nowrap;
}

/* ===== Nocturnal Conquest - Refined Design System Overrides ===== */

/* 1. Refined cards with 1px borders & soft elevations */
.section-body,
.finish-card,
.stat-box,
.power-item,
.upgrade-row,
.portrait-card,
.wp-card,
.lab-queue,
.builder-lane,
.pi-remaining-card,
.pi-priority-row,
.pi-timeline-card,
.pi-snapshot-card,
.pi-readiness,
.pi-banner-action,
.stat-tile {
    background: var(--pi-panel) !important;
    border: 1px solid var(--pi-border-color) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.02) !important;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s ease, box-shadow 0.2s ease !important;
}

/* 2. Sleek thin progress tracks & fills (No AI gradient slop, no blurs) */
.war-bar-fill,
.health-fill,
.util-fill,
.pi-readiness-fill,
.pi-unit-bar-fill,
.pi-timeline-fill,
.pi-rush-bar-fill {
    background: var(--pi-purple) !important;
    position: relative;
    overflow: hidden;
}

/* Remove gloss overlays completely */
.war-bar-fill::after,
.health-fill::after,
.util-fill::after,
.pi-readiness-fill::after,
.pi-unit-bar-fill::after,
.pi-timeline-fill::after,
.pi-rush-bar-fill::after {
    display: none !important;
}

.war-track,
.health-track,
.util-track,
.pi-readiness-track,
.pi-unit-bar,
.pi-timeline-track,
.pi-rush-bar-track,
.pi-unit-track,
.pi-util-bar-seg {
    background: rgba(0, 0, 0, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 4px !important;
    height: 8px !important;
}

/* 3. Sleek, Premium Buttons & Tabs (Under click shift down 1px) */
.tbtn,
.pi-tab-btn,
.pi-action-btn,
.pi-planner-lock-btn,
.pi-search-btn,
.pi-scan-btn,
.co-signin-btn,
.pi-planner-lock-btn,
.co-quick-save {
    border-radius: 8px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-family: 'Rubik', sans-serif !important;
    letter-spacing: -0.015em !important;
    border: 1px solid var(--pi-border-color) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.15s ease, box-shadow 0.15s ease !important;
    cursor: pointer !important;
}

/* Color states */
.tbtn.primary,
.pi-action-btn.primary,
.pi-search-btn,
.pi-scan-btn,
.co-signin-btn,
.pi-planner-lock-btn,
.pi-tab-btn.active {
    background: var(--pi-gold) !important;
    color: #0c0f17 !important;
}

.tbtn:not(.primary),
.pi-tab-btn:not(.active),
.pi-action-btn:not(.primary),
.co-quick-save {
    background: var(--pi-panel) !important;
    color: var(--pi-ink) !important;
}

/* Click / Active Feedback state */
.tbtn:active,
.pi-tab-btn:active,
.pi-action-btn:active,
.pi-planner-lock-btn:active,
.pi-search-btn:active,
.pi-scan-btn:active,
.co-signin-btn:active,
.co-quick-save:active {
    transform: translateY(1px) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

/* 4. Refined Banner Header */
.banner {
    display: inline-block !important;
    font-family: 'Rubik', sans-serif !important;
    font-weight: 800 !important;
    font-size: 11px !important;
    color: #4a3007 !important;
    background: var(--pi-gold) !important;
    padding: 4px 12px !important;
    border-radius: 6px 6px 0 0 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    border: 2px solid var(--pi-border-color) !important;
    border-bottom: none !important;
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.25) inset !important;
}

/* 5. Typography cleanliness */
.pi-section-header,
.lane-title,
.finish-label,
.stat-box-lbl {
    font-family: 'Rubik', sans-serif !important;
    font-weight: 700 !important;
    font-size: 11px !important;
    color: var(--pi-ink-soft) !important;
    text-transform: uppercase !important;
    letter-spacing: -0.015em !important;
}

.finish-date,
.stat-box-val,
.wp-score,
.pi-progress-pct {
    font-family: 'Rubik', sans-serif !important;
    font-weight: 700 !important;
    color: var(--pi-gold) !important;
    text-shadow: none !important;
}

.pi-progress-big .pi-percent {
    font-family: 'Rubik', sans-serif !important;
    font-weight: 800 !important;
    color: var(--pi-purple) !important;
    text-shadow: none !important;
}

/* 6. Refined hover elevations (Nocturnal Conquest - Refined) */
.section-body:hover,
.finish-card:hover,
.stat-box:hover,
.power-item:hover,
.upgrade-row:hover,
.portrait-card:hover,
.wp-card:hover,
.lab-queue:hover,
.builder-lane:hover,
.pi-remaining-card:hover,
.pi-priority-row:hover,
.pi-timeline-card:hover,
.pi-snapshot-card:hover,
.pi-readiness:hover,
.pi-banner-action:hover,
.stat-tile:hover {
    transform: translateY(-2px) !important;
    border-color: rgba(217, 70, 239, 0.3) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.03) !important;
}

/* Active clicks shift down */
.section-body:active,
.finish-card:active,
.stat-box:active,
.power-item:active,
.upgrade-row:active,
.portrait-card:active,
.wp-card:active,
.lab-queue:active,
.builder-lane:active,
.pi-remaining-card:active,
.pi-priority-row:active,
.pi-timeline-card:active,
.pi-snapshot-card:active,
.pi-readiness:active,
.pi-banner-action:active,
.stat-tile:active {
    transform: translateY(1px) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
}

/* 7. Recessed Input fields styling and focus outlines */
.pi-search-bar input {
    background: var(--pi-bg-deep) !important;
    border: 1px solid var(--pi-border-color) !important;
    border-radius: 6px !important;
    color: var(--pi-ink) !important;
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    font-weight: 600 !important;
    outline: none !important;
    box-shadow: none !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

.pi-search-bar input::placeholder {
    color: var(--pi-ink-soft) !important;
    /* Proper contrast: 4.5:1 ratio */
    opacity: 0.7 !important;
}

.pi-search-bar input:focus {
    border-color: var(--pi-gold) !important;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.15) !important;
}



/* ═══════════════════════════════════════════════════
   TRACKER V2 — Wood/Pillow Design System (Step 4 Match)
   ═══════════════════════════════════════════════════ */

/* ── Category Tabs (Pillow-style) ── */
.tr-cat-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scroll-padding: 0 10px;
    padding: 2px 24px 8px 2px;
    margin-bottom: 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
}

.tr-cat-tabs::-webkit-scrollbar {
    display: none;
}

.tr-cat-tab {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 3.5px solid var(--ink-dark);
    background: linear-gradient(to bottom, #2b231d 0%, #15100c 100%);
    color: #8a7a6e;
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
    letter-spacing: 0.03em;
    box-shadow:
        inset 0 2.5px 0 rgba(255, 255, 255, 0.05),
        inset 0 -2.5px 0 rgba(0, 0, 0, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.5);
    user-select: none;
}

.tr-cat-tab:hover {
    color: #ebdcd0;
    transform: translateY(-2px);
    box-shadow:
        inset 0 2.5px 0 rgba(255, 255, 255, 0.08),
        inset 0 -2.5px 0 rgba(0, 0, 0, 0.4),
        0 6px 12px rgba(0, 0, 0, 0.6);
}

.tr-cat-tab:active {
    transform: translateY(1px);
}

.tr-cat-tab.active {
    background: linear-gradient(to bottom, #ffd13b 0%, #ff8000 100%);
    color: #ffffff;
    text-shadow: 0 -1.5px 0 rgba(0, 0, 0, 0.4), 0 1.5px 0 rgba(0, 0, 0, 0.4);
    box-shadow:
        inset 0 2.5px 0 rgba(255, 255, 255, 0.35),
        inset 0 -2.5px 0 rgba(0, 0, 0, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.5);
}

.tr-cat-tab-json {
    opacity: 0.4;
    border-style: dashed;
}

.tr-cat-tab-json.available {
    opacity: 1;
    border-style: solid;
}

/* ── Toolbar: Search + Sort ── */
.tr-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

.tr-search {
    flex: 1;
    padding: 10px 14px;
    background: #0f0a07;
    border: 2.5px solid var(--parchment-border);
    border-radius: var(--radius-md);
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    outline: none;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.6);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tr-search::placeholder {
    color: #55443a;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px;
}

.tr-search:focus {
    border-color: var(--gold-primary);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.6), 0 0 10px var(--gold-glow);
}

.tr-sort {
    flex-shrink: 0;
    padding: 10px 14px;
    background: #0f0a07;
    border: 2.5px solid var(--parchment-border);
    border-radius: var(--radius-md);
    color: #cdc0b0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.6);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
    min-width: 100px;
}

.tr-sort:focus {
    border-color: var(--gold-primary);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.6), 0 0 10px var(--gold-glow);
}

.tr-sort option {
    background: var(--wood-dark);
    color: #cdc0b0;
}

/* ── Filter Chips ── */
.tr-filter-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tr-filter-chip {
    padding: 6px 14px;
    border-radius: var(--radius-md);
    border: 3px solid var(--ink-dark);
    background: linear-gradient(to bottom, #2b231d 0%, #15100c 100%);
    color: #8a7a6e;
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.04),
        inset 0 -2px 0 rgba(0, 0, 0, 0.4),
        0 3px 6px rgba(0, 0, 0, 0.5);
    user-select: none;
    letter-spacing: 0.02em;
}

.tr-filter-chip:hover {
    color: #ebdcd0;
    transform: translateY(-1px);
}

.tr-filter-chip.active {
    background: linear-gradient(to bottom, #ffd13b 0%, #ff8000 100%);
    color: #ffffff;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4), 0 1px 0 rgba(0, 0, 0, 0.4);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.4),
        0 3px 6px rgba(0, 0, 0, 0.5);
}

/* ── Upgrade Cards ── */
.tr-upgrade-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tr-upgrade-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #1a130f;
    border: 2.5px solid var(--parchment-border);
    border-radius: var(--radius-md);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.03),
        inset 0 -2px 0 rgba(0, 0, 0, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.4);
    transition: all 0.15s ease;
    cursor: default;
}

.tr-upgrade-card:hover {
    border-color: #5a4436;
    background: #1f1712;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.03),
        inset 0 -2px 0 rgba(0, 0, 0, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.5);
}

.tr-uc-portrait {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #0a0807;
    border: 2px solid var(--ink-dark);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.tr-uc-portrait img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tr-uc-info {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.tr-uc-name {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 13px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tr-uc-lvl {
    font-size: 11px;
    color: var(--parchment-muted);
    margin-top: 2px;
    font-weight: 600;
}

.tr-uc-wallhint {
    font-size: 9.5px;
    color: rgba(232, 196, 122, 0.75);
    margin-top: 3px;
}

/* ===== Priority Upgrades — compact production cards (2026-08-09) ===== */

/* Section title — gold uppercase + rule line (was a bare unstyled h4). */
.tr-section-title {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-weight: 900;
    font-size: 14px;
    color: var(--gold-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
    white-space: nowrap;
}

/* Header row: title left, ranking-mode toggle right. */
.tr-priority-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Ranking-mode toggle — pillow chips. */
.tr-priority-modes {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.tr-pm-btn {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--parchment-muted);
    background: #14100c;
    border: 2px solid var(--parchment-border);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.12s ease;
}
.tr-pm-btn:hover {
    border-color: #5a4436;
    color: #fff;
}
.tr-pm-btn.active {
    background: linear-gradient(to bottom, #f5d78a, #d9a441);
    color: #0c1015;
    border-color: #6b4d1e;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Compact card — one tight row, no wasted vertical space. */
.tr-priority-card {
    background: #181411;
    border: 2px solid var(--parchment-border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    overflow: hidden;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.tr-priority-card:hover {
    border-color: #5a4436;
    background: #1f1712;
    transform: translateX(3px);
}

/* Rank 1 highlight — visual hierarchy: #1 item is distinctly prominent */
.tr-priority-card.tr-rank-1 {
    border: 2px solid var(--pi-gold-deep, #c89b3c);
    background: linear-gradient(135deg, #241c14 0%, #17120e 100%);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(245, 215, 138, 0.18);
}
.tr-priority-card.tr-rank-1:hover {
    border-color: var(--gold-primary, #e8c47a);
    background: linear-gradient(135deg, #2b2118 0%, #1c1510 100%);
}
.tr-priority-card.tr-rank-1 .tr-uc-time {
    color: var(--gold-primary, #e8c47a);
    font-weight: 900;
    font-size: 12.5px;
    text-shadow: 0 0 8px rgba(245, 215, 138, 0.35);
}

/* Main row: portrait | info | right-rank-badge | why-chevron, vertically centered. */
.tr-pc-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
}
.tr-pc-main:hover .tr-uc-name {
    color: var(--gold-primary);
}
.tr-pc-main .tr-uc-portrait {
    width: 40px;
    height: 40px;
}

/* Name row: unit name + progress ring + level range on ONE baseline line.
   nowrap + ellipsis so long names ("Invisibility Spell") never push the
   ring/level onto a second line (keeps the compact single-row intent). */
.tr-priority-card .tr-uc-name {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: nowrap;
}
.tr-pc-name-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Progress ring (same component as Remaining Upgrades cards) sits inline. */
.tr-pc-ring {
    display: inline-flex;
    align-items: center;
    line-height: 0;
}
.tr-pc-ring svg.tr-uc-ring {
    width: 20px;
    height: 20px;
    vertical-align: -3px;
}
/* Level range inline next to name — same row, not stacked. */
.tr-pc-lvl {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--gold-primary);
    font-weight: 700;
    margin-left: 2px;
}

/* Reason line — now specific per item. */
.tr-pc-reason {
    font-size: 10.5px;
    color: var(--parchment-muted);
    margin-top: 2px;
    line-height: 1.35;
}

/* Cost chips + time — same resource-icon formatting as Remaining Upgrades. */
.tr-pc-costline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
    font-size: 10.5px;
    font-weight: 700;
    color: #d9c08a;
}
.tr-pc-costline img.tr-res-img {
    width: 15px;
    height: 15px;
    vertical-align: -2px;
}
.tr-pc-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(232, 196, 122, 0.75);
    font-weight: 700;
}

/* Right block: rank + urgency badge, aligned with portrait center. */
.tr-pc-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
    text-align: right;
}
.tr-pc-right .tr-uc-time {
    font-size: 11px;
}
.tr-pc-right .tr-uc-badge {
    margin-top: 0;
}

/* Why-chevron button. */
.tr-pc-why {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #241c15;
    border: 1.5px solid var(--parchment-border);
    border-radius: 5px;
    color: var(--parchment-muted);
    cursor: pointer;
    transition: all 0.12s ease;
}
.tr-pc-why svg {
    transition: transform 0.18s ease;
}
.tr-priority-card.is-open .tr-pc-why svg,
.tr-priority-card:has(.tr-pc-drawer.tr-pc-open) .tr-pc-why svg {
    transform: rotate(90deg);
}
.tr-pc-why:hover {
    color: var(--gold-primary);
    border-color: #6b4d1e;
    background: #2c2219;
}

/* "Why this rank?" drawer — real impact-sim values, accordion. */
.tr-pc-drawer {
    display: none;
    padding: 10px 14px 12px;
    background: #120d0a;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.tr-pc-drawer.tr-pc-open {
    display: block;
    animation: trDrawerIn 0.18s ease;
}
@keyframes trDrawerIn {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
}
.tr-pc-drow {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 3px 0;
    font-size: 11px;
    color: var(--parchment-muted);
}
.tr-pc-drow span {
    text-transform: uppercase;
    font-size: 9px;
    letter-spacing: 0.05em;
}
.tr-pc-drow b {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--gold-primary);
    font-weight: 800;
}

/* Focus states for keyboard access. */
.tr-pc-main:focus-visible {
    outline: 2px solid var(--gold-primary);
    outline-offset: -2px;
}

@media (max-width: 600px) {
    .tr-pc-main {
        padding: 8px 10px;
        gap: 8px;
    }
    .tr-pc-main .tr-uc-portrait {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }
    .tr-priority-card .tr-uc-name {
        flex-wrap: wrap;
        gap: 2px 6px;
    }
    .tr-pc-name-text {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        font-size: 12px;
    }
    .tr-pc-ring svg.tr-uc-ring {
        width: 18px;
        height: 18px;
    }
    .tr-pc-lvl {
        font-size: 9.5px;
    }
    .tr-pc-reason {
        font-size: 10px;
    }
    .tr-pc-costline {
        font-size: 10px;
        gap: 6px;
    }
    .tr-pc-right {
        gap: 2px;
    }
    .tr-pc-right .tr-uc-time {
        font-size: 10.5px;
    }
    .tr-pc-why {
        width: 20px;
        height: 20px;
    }
}

.tr-uc-cost {
    font-size: 10px;
    color: #8a7a6e;
    margin-top: 1px;
}

.tr-uc-right {
    text-align: right;
    flex-shrink: 0;
}

.tr-uc-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--gold-primary);
    font-weight: 700;
}

.tr-uc-badge {
    display: inline-block;
    font-size: 8px;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1.5px solid;
}

.tr-uc-badge.high {
    background: rgba(46, 204, 113, 0.15);
    color: var(--green-accent);
    border-color: rgba(46, 204, 113, 0.3);
}

.tr-uc-badge.med {
    background: rgba(241, 196, 15, 0.15);
    color: var(--gold-primary);
    border-color: rgba(241, 196, 15, 0.3);
}

.tr-uc-badge.low {
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
    border-color: rgba(100, 116, 139, 0.3);
}

/* ── Empty State ── */
.tr-empty {
    display: none;
    text-align: center;
    padding: 24px 16px;
}

.tr-empty-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

.tr-empty-text {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 16px;
    color: var(--gold-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    display: block;
}

.tr-empty-sub {
    font-size: 12px;
    color: var(--parchment-muted);
    margin-top: 4px;
    display: block;
}

/* ── Load More ── */
.tr-load-more {
    margin-top: 12px;
    width: 100%;
    height: 40px;
}

/* ── Breakdown Tabs ── */
.tr-breakdown-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scroll-padding: 0 10px;
    padding: 2px 24px 8px 2px;
    margin-bottom: 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
}

.tr-breakdown-tabs::-webkit-scrollbar {
    display: none;
}

.tr-bd-tab {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    border: 3px solid var(--ink-dark);
    background: linear-gradient(to bottom, #2b231d 0%, #15100c 100%);
    color: #8a7a6e;
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.12s ease;
    white-space: nowrap;
    letter-spacing: 0.02em;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.04),
        inset 0 -2px 0 rgba(0, 0, 0, 0.4),
        0 3px 6px rgba(0, 0, 0, 0.5);
    user-select: none;
}

.tr-bd-tab:hover {
    color: #ebdcd0;
    transform: translateY(-1px);
}

.tr-bd-tab.active {
    background: linear-gradient(to bottom, #ffd13b 0%, #ff8000 100%);
    color: #ffffff;
    text-shadow: 0 -1.5px 0 rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3),
                inset 0 -2px 0 rgba(0, 0, 0, 0.4);
}

/* ═══════════════════════════════════════════════════
   STEP 3 — Cost Display Styles (Tracker + Planner)
   ═══════════════════════════════════════════════════ */

        /* Ore cost row in tracker (equipment) */
        .tr-ore-cost {
            font-size: 9px;
            margin-top: 1px;
        }

        .tr-ore-row {
            display: inline-flex;
            align-items: center;
            gap: 2px;
            flex-wrap: wrap;
        }

        .tr-ore-part {
            display: inline-flex;
            align-items: center;
            gap: 2px;
            color: var(--pi-ink-soft);
            font-weight: 700;
            font-family: 'JetBrains Mono', monospace;
            font-size: 9px;
        }

        .tr-ore-icon {
            width: 13px;
            height: 13px;
            object-fit: contain;
            filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
        }

        .tr-ore-plus {
            color: var(--pi-ink-faint);
            font-size: 8px;
            margin: 0 1px;
            font-family: 'JetBrains Mono', monospace;
        }

        /* Planner resources panel */
        .pi-resources-panel {
            background: #181411;
            border: 2px solid var(--parchment-border);
            border-radius: var(--radius-md);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
            padding: 14px 16px;
            margin-top: 12px;
            margin-bottom: 16px;
        }

        .pi-resources-sub {
            font-size: 10px;
            color: var(--pi-ink-faint);
            margin-top: 1px;
        }

        .pi-resources-title {
            font-size: 11px;
            font-weight: 800;
            color: var(--pi-gold-text);
            text-transform: uppercase;
            letter-spacing: 0.04em;
            margin-bottom: 8px;
        }

        .pi-resources-row {
            display: flex;
            gap: 14px;
            flex-wrap: wrap;
        }

        .pi-res-item {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            font-size: 12px;
            font-weight: 700;
            color: var(--pi-ink);
            background: rgba(0, 0, 0, 0.3);
            padding: 4px 10px;
            border-radius: 6px;
            border: 1px solid rgba(255, 255, 255, 0.05);
        }

        .pi-res-icon-sm {
            width: 16px;
            height: 16px;
            object-fit: contain;
            filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
        }
/* ════════════════════════════════════════════════════════════
   Tracker: Click-to-expand Upgrade Ledger (2026-08-07)
   Drawer, progress ring, Almost There, category totals footer
   ════════════════════════════════════════════════════════════ */
.tr-upgrade-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    cursor: pointer;
}
.tr-upgrade-card .tr-uc-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    width: 100%;
}
.tr-upgrade-card.tr-open {
    border-color: #7a5c40;
    background: #221812;
}

/* Chevron toggle hint — inline SVG, gold on open */
.tr-uc-chevron {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    color: #8a7a6e;
    font-size: 10px;
    transition: transform 0.2s ease;
}
.tr-upgrade-card.tr-open .tr-uc-chevron {
    transform: rotate(180deg);
    color: var(--gold-primary, #f5b93b);
}

/* Almost There — gold star chip (no generic green rail / no emoji) */
.tr-uc-near {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 2px 0 4px auto;
    padding: 2px 7px 2px 6px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(245, 185, 59, 0.18), rgba(245, 185, 59, 0.08));
    border: 1.5px solid rgba(245, 185, 59, 0.4);
    color: #f5b93b;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

/* Tab / chip inline SVG icons */
.tr-tab-ico,
.tr-chip-ico {
    vertical-align: -2px;
    margin-right: 5px;
    flex-shrink: 0;
}

/* Real CoC resource icons via CDN (backup/icons exact filenames) —
   30px chunky game-style icons, clearly visible next to the terse labels */
.tr-res-img {
    width: 30px;
    height: 30px;
    vertical-align: -7px;
    margin-right: 5px;
    image-rendering: auto;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}
.tr-res-unknown {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffe08a, #a97c1f);
    margin-right: 4px;
    vertical-align: -5px;
}

/* Ore icons stay compact (13px) while gold/elixir/DE render at 30px */
.tr-res-img-sm {
    width: 13px;
    height: 13px;
    vertical-align: -2px;
    margin-right: 3px;
}

/* Ledger estimated rows — amber tint + ~ marker (final level not in dump) */
.tr-ledger-row.tr-ledger-est {
    background: rgba(245, 185, 59, 0.06);
}
.tr-ledger-row.tr-ledger-est .tr-ledger-lv,
.tr-ledger-row.tr-ledger-est .tr-ledger-time {
    color: #e8b45a;
}
.tr-ledger-note {
    margin-bottom: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(245, 185, 59, 0.08);
    border: 1px dashed rgba(245, 185, 59, 0.35);
    color: #c9a96b;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* 26px current/max progress ring */
.tr-uc-ring {
    vertical-align: -7px;
    margin-right: 5px;
    flex-shrink: 0;
}

/* Ledger drawer — nests inside the card.
   max-height transition (not display:none) so the rows below are pushed
   down smoothly instead of jumping when a drawer opens/closes. */
.tr-uc-drawer {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    border-top: 0 solid rgba(255, 255, 255, 0.06);
    background: #120c09;
    transition: max-height 0.28s ease;
}
.tr-upgrade-card.tr-open .tr-uc-drawer {
    border-top-width: 1px;
}

.tr-ledger-inner {
    padding: 10px 14px 12px;
}
.tr-ledger-table {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.tr-ledger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 5px;
    font-size: 11px;
}
.tr-ledger-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.035);
}
.tr-ledger-lv {
    font-family: 'JetBrains Mono', monospace;
    color: #d8c9b8;
    font-weight: 700;
    white-space: nowrap;
}
.tr-ledger-cost {
    color: #f0e4d4;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px 8px;
    text-align: right;
}
.tr-ledger-time {
    font-family: 'JetBrains Mono', monospace;
    color: var(--gold-primary, #f5b93b);
    font-weight: 700;
    flex-shrink: 0;
}
.tr-ledger-na {
    color: #6b5d52;
}
.tr-ledger-more {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    font-size: 10.5px;
    color: #8a7a6e;
    font-weight: 700;
}
.tr-ledger-showall {
    background: rgba(245, 185, 59, 0.12);
    color: var(--gold-primary, #f5b93b);
    border: 1.5px solid rgba(245, 185, 59, 0.35);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.03em;
}
.tr-ledger-showall:hover {
    background: rgba(245, 185, 59, 0.2);
}

/* Drawer totals — must match the collapsed row's numbers */
.tr-ledger-total {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(245, 185, 59, 0.07);
    border: 1.5px solid rgba(245, 185, 59, 0.25);
    border-radius: 7px;
    font-size: 11px;
}
.tr-ledger-total-label {
    color: var(--gold-primary, #f5b93b);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.tr-ledger-total-cost {
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 8px;
}
.tr-ledger-total-time {
    font-family: 'JetBrains Mono', monospace;
    color: #f0e4d4;
    font-weight: 700;
}
.tr-ledger-add-btn {
    margin-top: 10px;
    width: 100%;
    height: 34px;
    font-size: 12px;
    cursor: pointer;
}

/* Category totals footer under the list */
.tr-list-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 10px;
    padding: 8px 12px;
    background: #1a130f;
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    font-size: 11px;
    color: #c9b9a6;
}
.tr-footer-count {
    font-weight: 900;
    color: var(--gold-primary, #f5b93b);
}
.tr-footer-days {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
}
.tr-footer-cost {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 8px;
    font-weight: 700;
}
.tr-footer-res {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.tr-footer-plus {
    color: rgba(255, 255, 255, 0.35);
    margin: 0 3px;
    font-weight: 900;
}

/* ── Drill-down group overview cards (Equipment by hero, Buildings/Traps by name) ── */
.tr-group-card {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #241a14 0%, #1a130f 100%);
    border: 2.5px solid var(--parchment-border);
    border-radius: var(--radius-md);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.04),
        inset 0 -2px 0 rgba(0, 0, 0, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}
.tr-group-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 0 0 0 rgba(245, 185, 59, 0);
    transition: box-shadow 0.2s ease;
}
.tr-group-card:hover {
    border-color: rgba(245, 185, 59, 0.65);
    background: linear-gradient(to bottom, #2a1f17 0%, #1f1712 100%);
    transform: translateY(-1px);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.04),
        inset 0 -2px 0 rgba(0, 0, 0, 0.4),
        0 5px 14px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(245, 185, 59, 0.18);
}
.tr-group-card:active {
    transform: translateY(0px);
}
.tr-group-portrait {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: radial-gradient(circle at 50% 35%, rgba(245, 185, 59, 0.18) 0%, rgba(0, 0, 0, 0.35) 75%);
    border: 2px solid rgba(245, 185, 59, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.tr-group-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.tr-group-name {
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.05em;
    color: var(--pi-gold-text, #fde68a);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
}
.tr-group-sub {
    font-size: 11px;
    color: #c9b9a6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tr-group-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.tr-group-summary {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 800;
    color: #e8c47a;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
}
.tr-group-days {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'JetBrains Mono', monospace;
    margin-left: 6px;
}
.tr-group-chevron {
    color: rgba(245, 185, 59, 0.75);
    display: inline-flex;
    align-items: center;
    transition: transform 0.15s ease;
}
.tr-group-card:hover .tr-group-chevron {
    transform: translateX(2px);
    color: var(--pi-gold, #f5b93b);
}

/* ── Drill-down back header ── */
.tr-drill-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 2px 4px;
    padding: 4px 2px 8px;
    border-bottom: 1.5px solid rgba(245, 185, 59, 0.3);
}
.tr-drill-back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: rgba(245, 185, 59, 0.1);
    border: 1.5px solid rgba(245, 185, 59, 0.35);
    border-radius: 8px;
    color: var(--pi-gold-text, #fde68a);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.12s ease;
}
.tr-drill-back:hover {
    background: rgba(245, 185, 59, 0.2);
    border-color: rgba(245, 185, 59, 0.6);
}
.tr-drill-title {
    flex: 1 1 auto;
    text-align: center;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.07em;
    color: var(--pi-gold-text, #fde68a);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tr-drill-count {
    padding: 1px 8px;
    font-size: 10px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.55);
    background: rgba(245, 185, 59, 0.14);
    border-radius: 8px;
    border: 1px solid rgba(245, 185, 59, 0.25);
}

/* Add-to-Planner button inside the ledger drawer */
.tr-ledger-add-btn {
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    font-size: 12px;
    letter-spacing: 0.05em;
}
/* ═══════════════════════════════════════════════════════════════
   PLANNER OLD-UI FINAL OVERRIDES (2026-08-10)
   The legacy "Nocturnal Conquest - Refined Design System Overrides"
   block above force-applies the flat blue theme (--pi-panel #151b26 /
   --pi-border-color, with !important) onto shared classes the Planner
   uses: .builder-lane, .stat-box, .power-item. The Planner must match
   the Tracker's wood/parchment recipe instead. These later, higher-
   specificity !important rules win the cascade.
   ═══════════════════════════════════════════════════════════════ */
#pi-tab-planner .builder-lane,
#pi-tab-planner .stat-box,
#pi-tab-planner .power-item {
    background: #181411 !important;
    border: 2px solid var(--parchment-border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45) !important;
}

#pi-tab-planner .builder-lane:hover,
#pi-tab-planner .stat-box:hover,
#pi-tab-planner .power-item:hover {
    transform: translateY(-1px) !important;
    border-color: rgba(212, 175, 55, 0.5) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 5px 14px rgba(0, 0, 0, 0.5) !important;
}

#pi-tab-planner .builder-lane:active,
#pi-tab-planner .stat-box:active,
#pi-tab-planner .power-item:active {
    transform: translateY(0) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 2px 6px rgba(0, 0, 0, 0.4) !important;
}

#pi-tab-planner .builder-lane.drag-over {
    background: rgba(245, 185, 66, 0.18) !important;
    border-color: var(--pi-gold) !important;
}

/* Lane header chips: keep the gold ribbon, drop the legacy blue border + notched radius */
#pi-tab-planner .builder-num.banner {
    border: 2px solid #6b4d1e !important;
    border-bottom-width: 4px !important;
    border-radius: 6px !important;
    font-family: 'Baloo 2', 'Rubik', sans-serif !important;
}

/* Planner stat values/labels: restore Baloo 2 + gold value (legacy block forced Rubik/dim) */
#pi-tab-planner .stat-box-val {
    font-family: 'Baloo 2', sans-serif !important;
    color: var(--pi-gold-text) !important;
    font-size: 16px !important;
}
#pi-tab-planner .stat-box-lbl {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    color: var(--pi-ink-faint) !important;
    font-size: 8.5px !important;
}

/* ═══════════════════════════════════════════════════════════════
   Phase 1 — Planner trust foundation (2026-08-11)
   accountId loading state + sync preview (never silently mutate a plan)
   ═══════════════════════════════════════════════════════════════ */
.pi-planner-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
    border: 2px solid var(--pi-gold-deep);
    background: #181411;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
    font-size: 12px;
    font-weight: 700;
    color: var(--pi-text);
}
.pi-planner-loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--pi-gold-deep);
    border-top-color: var(--pi-gold);
    animation: pi-spin 0.9s linear infinite;
    flex-shrink: 0;
}
@keyframes pi-spin { to { transform: rotate(360deg); } }

.pi-sync-preview {
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
    border: 2px solid var(--pi-gold-deep);
    background: #181411;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.45);
}
.pi-sync-preview-title {
    font-size: 12.5px;
    font-weight: 800;
    color: var(--pi-gold);
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}
.pi-sync-preview-line {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--pi-text);
    line-height: 1.5;
}
.pi-sync-preview-note {
    font-size: 10.5px;
    color: var(--pi-ink-faint);
    margin-top: 6px;
}
.pi-sync-preview-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.pi-sync-review-btn, .pi-sync-apply-btn {
    font-size: 10.5px;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 7px;
    cursor: pointer;
}
.pi-sync-review-btn {
    background: transparent;
    color: var(--pi-gold);
    border: 2px solid var(--pi-gold-deep);
}
.pi-sync-apply-btn {
    background: var(--pi-gold);
    color: #1a1408;
    border: 2px solid var(--pi-gold-deep);
    box-shadow: 0 2px 0 var(--pi-gold-deep);
}
.pi-sync-apply-btn:hover { filter: brightness(1.08); }
.pi-sync-dismiss-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--pi-ink-faint);
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
}
.pi-sync-review-list {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--pi-gold-deep);
    font-size: 11px;
    color: var(--pi-ink-soft);
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* ═══════════════════════════════════════════════════════════════
   Phase 4 — Planner Card Density & Compact Action Rows (2026-08-14)
   Fixes vertical stacking bloat in Lab Economy and groups controls
   in Builder Slot cards into a single clean horizontal row.
   Scoped strictly to #pi-tab-planner so Tracker ledger is 100% safe.
   ═══════════════════════════════════════════════════════════════ */
#pi-tab-planner .lab-row.tr-upgrade-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    padding: 8px 12px !important;
    min-height: 46px !important;
    background: #181411 !important;
    border: 2px solid var(--parchment-border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 2px 6px rgba(0, 0, 0, 0.4) !important;
    cursor: grab !important;
    margin-bottom: 6px !important;
}

#pi-tab-planner .lab-row.tr-upgrade-card:hover {
    border-color: rgba(212, 175, 55, 0.5) !important;
    background: #1f1712 !important;
}

#pi-tab-planner .lab-row .lab-portrait {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: #0a0807;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    border: 2px solid #000;
    overflow: hidden;
}

#pi-tab-planner .lab-row .lab-info {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
}

#pi-tab-planner .lab-row .lab-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--pi-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#pi-tab-planner .lab-row .lab-lvl {
    font-size: 10px;
    color: var(--pi-ink-faint);
    margin-top: 1px;
}

#pi-tab-planner .lab-row .lab-time {
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--pi-gold-text, #fde68a);
    flex-shrink: 0;
    margin: 0 4px;
}

#pi-tab-planner .lab-row .lab-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}

#pi-tab-planner .lab-row .lab-remove-btn {
    border: none;
    background: transparent;
    color: var(--pi-red);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.15s;
    line-height: 1;
}

#pi-tab-planner .lab-row .lab-remove-btn:hover {
    background: rgba(248, 113, 113, 0.15);
}

/* Builder Slot compact layout & grouped action row */
#pi-tab-planner .builder-slot {
    position: relative;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 6px 6px;
    cursor: grab;
    background: #181411 !important;
    border: 2px solid var(--parchment-border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 2px 6px rgba(0, 0, 0, 0.4) !important;
}

#pi-tab-planner .builder-slot:hover {
    border-color: rgba(212, 175, 55, 0.5) !important;
    background: #1f1712 !important;
}

#pi-tab-planner .builder-slot .builder-portrait {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    background: var(--pi-bg-deep);
    margin: 0 auto 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    border: 2px solid var(--pi-gold-deep);
    overflow: hidden;
}

#pi-tab-planner .builder-slot .builder-name {
    font-size: 10px;
    font-weight: 700;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--pi-text);
}

#pi-tab-planner .builder-slot .builder-lvl {
    font-size: 9.5px;
    color: var(--pi-ink-soft);
    margin-top: 1px;
}

#pi-tab-planner .builder-slot .builder-time {
    font-size: 9.5px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--pi-gold-text, #fde68a);
    margin-top: 1px;
}

#pi-tab-planner .builder-slot-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    width: 100%;
}

#pi-tab-planner .builder-slot .pi-why-toggle,
#pi-tab-planner .builder-slot .pi-magic-toggle {
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

#pi-tab-planner .builder-slot .drag-handle {
    min-width: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: grab;
    touch-action: none;
    margin-top: 0;
}

#pi-tab-planner .builder-slot-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
    border: none;
    background: transparent;
    color: var(--pi-red);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    touch-action: manipulation;
}

#pi-tab-planner .builder-slot-remove:hover {
    background: rgba(248, 113, 113, 0.18);
}

@media (max-width: 480px) {
    .pi-main-container {
        padding: 0 8px !important;
    }
    .coc-wood-panel {
        padding: 26px 10px 14px !important;
    }
    .coc-parchment-panel {
        padding: 10px 8px !important;
    }
    #pi-tab-planner .lab-queue {
        padding: 0 4px !important;
    }
    #pi-tab-planner .lab-row.tr-upgrade-card {
        padding: 6px 8px !important;
        gap: 6px !important;
    }
    #pi-tab-planner .lab-row .lab-name {
        font-size: 11.5px !important;
    }
    #pi-tab-planner .lab-row .lab-lvl {
        font-size: 9.5px !important;
    }
    #pi-tab-planner .lab-row .lab-actions {
        gap: 4px !important;
    }
}

/* ════ Total Cost Remaining 3D Resource Chips ════ */
.coc-res-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: linear-gradient(180deg, #251713 0%, #150b08 100%);
    border: 2px solid #3d261e;
    border-bottom: 3.5px solid #140907;
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 3px 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s ease;
}

.coc-res-chip:hover {
    transform: translateY(-1px);
}

.coc-res-chip-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    transform: scale(1.35);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
    flex-shrink: 0;
}

.coc-res-chip-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    line-height: 1.1;
}

.coc-res-chip-val {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 14px;
    font-weight: 900;
    color: #fff;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.coc-res-chip-lbl {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--parchment-muted, #a89f91);
}

.coc-res-gold {
    border-color: rgba(255, 215, 0, 0.35);
}
.coc-res-gold .coc-res-chip-val {
    color: #ffd700;
}

.coc-res-elixir {
    border-color: rgba(224, 64, 251, 0.35);
}
.coc-res-elixir .coc-res-chip-val {
    color: #e040fb;
}

.coc-res-de {
    border-color: rgba(186, 104, 200, 0.35);
}
.coc-res-de .coc-res-chip-val {
    color: #ce93d8;
}

.coc-res-ores {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    border-color: rgba(0, 229, 255, 0.35);
    background: linear-gradient(180deg, #182226 0%, #0d1519 100%);
    padding: 6px 14px;
}

.coc-res-ore-subchip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.coc-res-chip-img-sm {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7));
    flex-shrink: 0;
}

.coc-res-ore-val {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: 12px;
    font-weight: 900;
    color: #00e5ff;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
.coc-res-ore-glowy {
    color: #d689ff !important;
}
.coc-res-ore-starry {
    color: #ffd700 !important;
}

/* ════ Time Remaining Stat Tiles (Vault Pedestal Style) ════ */
.pi-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.pi-stat-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 14px;
    text-align: center;
    background: linear-gradient(180deg, #221511 0%, #150d0a 100%) !important;
    border: 2px solid #3d261e !important;
    border-bottom: 4.5px solid #140907 !important;
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 16px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    cursor: default;
}

.pi-stat-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 215, 0, 0.3) 50%, transparent 100%);
    opacity: 0.7;
}

.pi-stat-tile:hover {
    transform: translateY(-3px);
    border-color: #5d3b2e !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px rgba(0, 0, 0, 0.65);
}

.pi-stat-tile:hover .pi-stat-avatar {
    transform: translateY(-2px) scale(1.08);
}

/* Category Theming */
.pi-stat-bld::before { background: linear-gradient(90deg, transparent, rgba(255, 177, 66, 0.7), transparent); }
.pi-stat-lab::before { background: linear-gradient(90deg, transparent, rgba(0, 210, 211, 0.7), transparent); }
.pi-stat-hero::before { background: linear-gradient(90deg, transparent, rgba(255, 107, 107, 0.7), transparent); }
.pi-stat-pet::before { background: linear-gradient(90deg, transparent, rgba(162, 155, 254, 0.7), transparent); }
.pi-stat-trap::before { background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.7), transparent); }
.pi-stat-equip::before { background: linear-gradient(90deg, transparent, rgba(236, 72, 153, 0.7), transparent); }

.pi-stat-bld:hover {
    border-color: rgba(255, 177, 66, 0.6) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px rgba(255, 177, 66, 0.2);
}
.pi-stat-lab:hover {
    border-color: rgba(0, 210, 211, 0.6) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px rgba(0, 210, 211, 0.2);
}
.pi-stat-hero:hover {
    border-color: rgba(255, 107, 107, 0.6) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px rgba(255, 107, 107, 0.2);
}
.pi-stat-pet:hover {
    border-color: rgba(162, 155, 254, 0.6) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px rgba(162, 155, 254, 0.2);
}
.pi-stat-trap:hover {
    border-color: rgba(99, 102, 241, 0.6) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px rgba(99, 102, 241, 0.2);
}
.pi-stat-equip:hover {
    border-color: rgba(236, 72, 153, 0.6) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px rgba(236, 72, 153, 0.2);
}

/* 3D Icon Pedestal */
.pi-stat-ico-pedestal {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 35%, #38221a 0%, #170c09 100%);
    border: 2px solid #4a2f24;
    border-bottom: 3px solid #0d0605;
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 4px 10px rgba(0, 0, 0, 0.6);
    margin-bottom: 10px;
    position: relative;
}

.pi-stat-bld .pi-stat-ico-pedestal {
    border-color: rgba(255, 177, 66, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 14px rgba(255, 177, 66, 0.25), 0 4px 10px rgba(0, 0, 0, 0.6);
}
.pi-stat-lab .pi-stat-ico-pedestal {
    border-color: rgba(0, 210, 211, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 14px rgba(0, 210, 211, 0.25), 0 4px 10px rgba(0, 0, 0, 0.6);
}
.pi-stat-hero .pi-stat-ico-pedestal {
    border-color: rgba(255, 107, 107, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 14px rgba(255, 107, 107, 0.25), 0 4px 10px rgba(0, 0, 0, 0.6);
}
.pi-stat-pet .pi-stat-ico-pedestal {
    border-color: rgba(162, 155, 254, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 14px rgba(162, 155, 254, 0.25), 0 4px 10px rgba(0, 0, 0, 0.6);
}
.pi-stat-trap .pi-stat-ico-pedestal {
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 14px rgba(99, 102, 241, 0.25), 0 4px 10px rgba(0, 0, 0, 0.6);
}
.pi-stat-equip .pi-stat-ico-pedestal {
    border-color: rgba(236, 72, 153, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 14px rgba(236, 72, 153, 0.25), 0 4px 10px rgba(0, 0, 0, 0.6);
}

.pi-stat-avatar {
    width: 42px;
    height: 42px;
    object-fit: contain;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.75));
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pi-stat-val {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-size: clamp(16px, 2.1vw, 22px);
    font-weight: 900;
    color: #ffd700;
    text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000, 0 3px 6px rgba(0, 0, 0, 0.8);
    line-height: 1.15;
    margin-bottom: 4px;
}

.pi-stat-lbl {
    font-family: 'ClashBold', sans-serif;
    font-size: 11.5px;
    font-weight: 800;
    color: #f1ece4;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 2px #000;
}

.pi-stat-bld .pi-stat-lbl { color: #ffd32a; }
.pi-stat-lab .pi-stat-lbl { color: #00d2d3; }
.pi-stat-hero .pi-stat-lbl { color: #ff7675; }
.pi-stat-pet .pi-stat-lbl { color: #d6a2e8; }
.pi-stat-trap .pi-stat-lbl { color: #818cf8; }
.pi-stat-equip .pi-stat-lbl { color: #f472b6; }

.pi-stat-sub {
    display: inline-block;
    font-size: 9.5px;
    font-weight: 800;
    color: var(--parchment-muted, #a89f91);
    margin-top: 6px;
    padding: 3px 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.pi-stat-bld .pi-stat-sub { color: #ffd32a; border-color: rgba(255, 177, 66, 0.3); background: rgba(255, 177, 66, 0.08); }
.pi-stat-lab .pi-stat-sub { color: #48dbfb; border-color: rgba(0, 210, 211, 0.3); background: rgba(0, 210, 211, 0.08); }
.pi-stat-hero .pi-stat-sub { color: #ff7675; border-color: rgba(255, 107, 107, 0.3); background: rgba(255, 107, 107, 0.08); }
.pi-stat-pet .pi-stat-sub { color: #a29bfe; border-color: rgba(162, 155, 254, 0.3); background: rgba(162, 155, 254, 0.08); }
.pi-stat-trap .pi-stat-sub { color: #818cf8; border-color: rgba(99, 102, 241, 0.3); background: rgba(99, 102, 241, 0.08); }
.pi-stat-equip .pi-stat-sub { color: #f472b6; border-color: rgba(236, 72, 153, 0.3); background: rgba(236, 72, 153, 0.08); }

/* ════════════════════════════════════════════════════════════
   ClashOS Mobile Responsiveness Pack (375px / 390px / 480px)
   ════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    /* Main container bounds */
    .pi-main-container {
        padding: 0 10px !important;
        margin: 14px auto 0 !important;
    }

    /* Top Tab Bar: 5-column touch grid */
    .pi-tab-bar {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 3px !important;
        padding: 4px 3px !important;
        margin: 0 0 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 12px !important;
        border-width: 2.5px !important;
    }
    .pi-tab-btn {
        min-width: 0 !important;
        padding: 6px 1px !important;
        min-height: 44px !important;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 3px !important;
        border-radius: 8px !important;
        border-width: 2px !important;
        border-bottom-width: 3.5px !important;
    }
    .pi-tab-btn.active {
        border-bottom-width: 3.5px !important;
    }
    .pi-tab-icon {
        line-height: 1 !important;
    }
    .pi-tab-icon svg {
        width: 13px !important;
        height: 13px !important;
    }
    .pi-tab-label {
        font-size: 9.5px !important;
        letter-spacing: 0.01em !important;
        line-height: 1.1 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }

    /* Stat Tiles: 2-column vault pedestal grid */
    .pi-stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .pi-stat-tile {
        padding: 12px 6px !important;
        border-radius: 12px !important;
        min-height: 140px;
    }
    .pi-stat-ico-pedestal {
        width: 42px !important;
        height: 42px !important;
        border-radius: 10px !important;
        margin-bottom: 6px !important;
    }
    .pi-stat-avatar {
        width: 32px !important;
        height: 32px !important;
    }
    .pi-stat-val {
        font-size: 14.5px !important;
        margin-bottom: 2px !important;
        word-break: normal !important;
    }
    .pi-stat-lbl {
        font-size: 10px !important;
        letter-spacing: 0.03em !important;
    }
    .pi-stat-sub {
        font-size: 8px !important;
        padding: 2px 6px !important;
        margin-top: 4px !important;
        border-radius: 6px !important;
    }

    /* Tracker Category & Breakdown Tabs: Mobile Horizontal Scroll with Edge Fade */
    .tr-cat-tabs,
    .tr-breakdown-tabs {
        display: flex !important;
        gap: 6px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-snap-type: x proximity !important;
        scroll-padding: 0 8px !important;
        padding: 2px 28px 8px 2px !important;
        margin-bottom: 10px !important;
        scrollbar-width: none !important;
        -webkit-mask-image: linear-gradient(to right, black calc(100% - 36px), transparent 100%) !important;
        mask-image: linear-gradient(to right, black calc(100% - 36px), transparent 100%) !important;
        transition: -webkit-mask-image 0.15s ease, mask-image 0.15s ease;
    }
    .tr-cat-tabs.is-scrolled-mid,
    .tr-breakdown-tabs.is-scrolled-mid {
        -webkit-mask-image: linear-gradient(to right, transparent 0%, black 28px, black calc(100% - 28px), transparent 100%) !important;
        mask-image: linear-gradient(to right, transparent 0%, black 28px, black calc(100% - 28px), transparent 100%) !important;
    }
    .tr-cat-tabs.is-scrolled-end,
    .tr-breakdown-tabs.is-scrolled-end {
        -webkit-mask-image: linear-gradient(to left, black calc(100% - 36px), transparent 100%) !important;
        mask-image: linear-gradient(to left, black calc(100% - 36px), transparent 100%) !important;
    }
    .tr-cat-tabs::-webkit-scrollbar,
    .tr-breakdown-tabs::-webkit-scrollbar {
        display: none !important;
    }
    .tr-cat-tab {
        flex-shrink: 0 !important;
        padding: 6px 12px !important;
        font-size: 11px !important;
        min-height: 36px !important;
        scroll-snap-align: start !important;
        gap: 5px !important;
    }
    .tr-bd-tab {
        flex-shrink: 0 !important;
        padding: 6px 11px !important;
        font-size: 10.5px !important;
        min-height: 34px !important;
        scroll-snap-align: start !important;
        gap: 4px !important;
    }

    /* Priorities List: compact mobile cards */
    .tr-priority-card {
        margin-bottom: 8px !important;
        border-radius: 10px !important;
    }
    .tr-pc-main {
        padding: 10px 10px !important;
        gap: 8px !important;
        min-height: 48px !important;
    }
    .tr-pc-main .tr-uc-portrait {
        width: 38px !important;
        height: 38px !important;
    }
    .tr-pc-name-text {
        font-size: 12.5px !important;
    }
    .tr-pc-lvl {
        font-size: 9.5px !important;
    }
    .tr-pc-reason {
        font-size: 10px !important;
        line-height: 1.25 !important;
    }
    .tr-pc-costline {
        font-size: 10px !important;
        gap: 6px !important;
    }
    .tr-pc-right {
        gap: 2px !important;
    }
    .tr-pc-right .tr-uc-time {
        font-size: 11px !important;
    }
    .tr-pc-right .tr-uc-badge {
        font-size: 7.5px !important;
        padding: 2px 6px !important;
    }
    .tr-pc-why {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
        min-height: 26px !important;
    }

    /* Time to Finish: Toggle bar & cost chips */
    .pi-eta-toggle-bar {
        padding: 3px !important;
        gap: 3px !important;
    }
    .pi-eta-mode-btn {
        padding: 8px 4px !important;
        min-height: 40px !important;
        font-size: 10px !important;
        gap: 4px !important;
    }
    .pi-eta-mode-btn svg {
        width: 12px !important;
        height: 12px !important;
    }
    .pi-eta-boxes {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .pi-eta-box {
        padding: 12px 6px !important;
        border-radius: 10px !important;
    }
    .pi-eta-card-header {
        font-size: 9px !important;
        gap: 4px !important;
        margin-bottom: 6px !important;
    }
    .pi-eta-dur-val {
        font-size: 16px !important;
    }
    .pi-eta-date-row {
        font-size: 9.5px !important;
        margin-top: 4px !important;
    }
    .pi-eta-lbl-pill {
        font-size: 8px !important;
        padding: 2px 6px !important;
        margin-top: 6px !important;
    }
    .db-cost-pills {
        gap: 6px !important;
    }
    .coc-res-chip {
        padding: 4px 8px !important;
        gap: 6px !important;
        border-radius: 8px !important;
    }
    .coc-res-chip-img-wrap {
        width: 20px !important;
        height: 20px !important;
    }
    .coc-res-chip-img {
        width: 42px !important;
        height: 42px !important;
    }
    .coc-res-chip-val {
        font-size: 12px !important;
    }
    .coc-res-chip-lbl {
        font-size: 8.5px !important;
    }
    .coc-res-ore-subchip {
        padding: 2px 5px !important;
        gap: 3px !important;
        font-size: 9.5px !important;
    }
    .coc-res-chip-img-sm {
        width: 14px !important;
        height: 14px !important;
    }

    /* ═══════════════════════════════════════════════════
       PLANNER MOBILE RESPONSIVENESS (<=480px)
       ═══════════════════════════════════════════════════ */

    /* Part 1: Top Control Cluster */
    .pi-planner-eta-row {
        margin-bottom: 12px !important;
    }
    .pi-planner-eta-boosts {
        display: flex !important;
        gap: 6px !important;
        width: 100% !important;
        padding: 3px !important;
        box-sizing: border-box !important;
    }
    .pi-planner-eta-chip {
        flex: 1 1 0 !important;
        min-height: 38px !important;
        padding: 6px 4px !important;
        font-size: 11px !important;
        font-weight: 800 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        border-radius: 8px !important;
    }
    #pi-planner-sticky-bar {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 12px 10px !important;
        border-radius: 10px !important;
        box-sizing: border-box !important;
    }
    #pi-planner-sticky-bar .pi-planner-goals {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 6px !important;
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(212, 175, 55, 0.2) !important;
        padding: 0 0 8px 0 !important;
        margin: 0 !important;
    }
    #pi-planner-sticky-bar .pi-planner-goals-label {
        font-size: 10px !important;
        font-weight: 800 !important;
        flex-shrink: 0 !important;
    }
    #pi-planner-sticky-bar .pi-goal-chip {
        flex: 1 1 0 !important;
        min-height: 38px !important;
        padding: 6px 4px !important;
        font-size: 11px !important;
        font-weight: 800 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        border-radius: 8px !important;
    }
    #pi-planner-autofill-balanced,
    #pi-planner-autofill-fast {
        flex: 1 1 calc(50% - 4px) !important;
        min-height: 42px !important;
        padding: 8px 4px !important;
        font-size: 11.5px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        gap: 5px !important;
        box-sizing: border-box !important;
    }
    #pi-planner-clear {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-height: 38px !important;
        padding: 6px 12px !important;
        font-size: 11px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        gap: 6px !important;
        margin-top: 2px !important;
        box-sizing: border-box !important;
    }
    #pi-planner-save-status {
        width: 100% !important;
        text-align: center !important;
        font-size: 10px !important;
        margin: 0 !important;
    }

    /* Part 2: Builder Economy Mobile Tap Targets & Cards */
    #pi-planner-builders {
        gap: 8px !important;
    }
    #pi-planner-builders .builder-lane {
        padding: 8px 6px !important;
        border-radius: 10px !important;
    }
    #pi-planner-builders .builder-slot {
        padding: 8px 6px !important;
        position: relative !important;
    }
    #pi-tab-planner .builder-slot .pi-why-toggle,
    #pi-tab-planner .builder-slot .pi-magic-toggle {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }
    #pi-tab-planner .builder-slot-remove {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        top: 2px !important;
        right: 2px !important;
    }

    /* Part 3: Lab Economy Mobile Row */
    #pi-tab-planner .lab-row.tr-upgrade-card {
        padding: 8px 6px !important;
        gap: 6px !important;
    }
    #pi-tab-planner .lab-name {
        font-size: 12px !important;
        max-width: 115px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    #pi-tab-planner .lab-actions {
        gap: 6px !important;
    }
    #pi-tab-planner .lab-actions .pi-why-toggle,
    #pi-tab-planner .lab-actions .pi-magic-toggle,
    #pi-tab-planner .lab-actions .lab-remove-btn {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }

    /* Part 4: Power Optimizer Mobile */
    #pi-instant-sort-toggle {
        min-height: 34px !important;
        padding: 4px 10px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        display: inline-flex !important;
        align-items: center !important;
        border-radius: 8px !important;
    }
    #pi-equipment-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }

    /* Part 5: Bottom Summary & Resources */
    #pi-planner-summary.stat-strip {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        padding: 0 !important;
    }
    #pi-planner-summary .stat-box {
        padding: 8px 4px !important;
        border-radius: 8px !important;
        min-width: 0 !important;
    }
    #pi-planner-summary .stat-box-val {
        font-size: 15px !important;
    }
    #pi-planner-summary .stat-box-lbl {
        font-size: 8px !important;
        letter-spacing: 0.02em !important;
    }
    .pi-resources-panel {
        padding: 12px 10px !important;
        border-radius: 10px !important;
        margin-top: 12px !important;
    }
    .pi-resources-title {
        font-size: 12px !important;
        font-weight: 800 !important;
    }
    .pi-resources-sub {
        font-size: 9.5px !important;
        margin-bottom: 6px !important;
    }
    .pi-resources-row {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    .pi-res-item {
        font-size: 11px !important;
        padding: 5px 8px !important;
        border-radius: 6px !important;
        background: rgba(0, 0, 0, 0.3) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 5px !important;
    }
    .pi-res-icon-sm {
        width: 16px !important;
        height: 16px !important;
    }
}

@media (max-width: 480px) {
    /* ═══════════════════════════════════════════════════
       COMPARE TAB MOBILE RESPONSIVENESS (<=480px)
       ═══════════════════════════════════════════════════
       Architectural Decision (Part 1):
       Full player detail cards remain 1-column STACKED on mobile (max-width: 768px).
       At 375px viewport, a 2-column layout yields only 150px card width, causing
       severe label, badge, and progress bar text collisions.
       Side-by-side comparison is exclusively provided by the top Summary Strip.
       ═══════════════════════════════════════════════════ */

    /* Part 2: Input Row & Action Buttons */
    #cp-input-row {
        gap: 8px !important;
    }
    .cp-tag-input-wrap {
        min-height: 44px !important;
        height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
    .cp-tag-input {
        font-size: 14px !important;
        padding: 8px 12px !important;
    }
    .cp-vs-badge {
        margin: 4px auto !important;
        padding: 5px 12px !important;
        font-size: 12px !important;
        min-height: 32px !important;
    }
    #cp-compare-btn {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-height: 44px !important;
        height: 44px !important;
        font-size: 13.5px !important;
        justify-content: center !important;
        order: 1 !important;
    }
    #cp-autofill-btn,
    #cp-swap-btn,
    #cp-history-toggle {
        flex: 1 1 calc(33.333% - 8px) !important;
        min-height: 40px !important;
        height: 40px !important;
        font-size: 11px !important;
        padding: 0 6px !important;
        justify-content: center !important;
        order: 2 !important;
        box-sizing: border-box !important;
    }

    /* Part 3: Quick-Glance Summary Strip (No overlap, clean fit) */
    .cp-summary-bar {
        min-height: 54px !important;
        padding: 0 !important;
    }
    .cp-summary-side {
        padding: 6px 6px !important;
        gap: 5px !important;
    }
    .cp-summary-th {
        width: 26px !important;
        height: 26px !important;
    }
    .cp-summary-name {
        font-size: 11px !important;
        max-width: 88px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    .cp-summary-clan {
        font-size: 8.5px !important;
        white-space: nowrap !important;
    }
    .cp-summary-pct {
        font-size: 17px !important;
        margin: 0 2px !important;
    }
    .cp-summary-vs-badge {
        padding: 2px 6px !important;
        font-size: 9px !important;
        gap: 2px !important;
    }

    /* Part 4: Winner Ribbon Banner + Share Duel Button */
    .cp-victory-ribbon-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 10px 12px !important;
        text-align: center !important;
    }
    .cp-victory-badge {
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    .cp-victory-title {
        font-size: 12px !important;
        line-height: 1.3 !important;
        text-align: center !important;
    }
    .cp-victory-pill {
        font-size: 10px !important;
        padding: 2px 6px !important;
        white-space: nowrap !important;
    }
    #cp-share-btn {
        width: 100% !important;
        min-height: 42px !important;
        height: 42px !important;
        justify-content: center !important;
        font-size: 12px !important;
    }

    /* Part 5: Detailed Village Cards (Stacked & Refined) */
    .cp-cards-row {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    .cp-player-card {
        padding: 14px 12px !important;
        border-radius: 12px !important;
    }
    .cp-card-header {
        gap: 10px !important;
        margin-bottom: 12px !important;
        padding-bottom: 10px !important;
    }
    .cp-th-wrap {
        width: 44px !important;
        height: 44px !important;
    }
    .cp-player-name {
        font-size: 16px !important;
    }
    .cp-player-clan {
        font-size: 11px !important;
    }
    .cp-metric-value {
        font-size: 18px !important;
        gap: 4px !important;
    }
    .cp-diff-badge {
        font-size: 9.5px !important;
        padding: 2px 6px !important;
        white-space: nowrap !important;
        margin-left: 4px !important;
    }
    .cp-stats-dual-row {
        gap: 6px !important;
        margin-top: 10px !important;
    }
    .cp-stat-box {
        padding: 8px 6px !important;
        border-radius: 8px !important;
    }
    .cp-stat-box-label {
        font-size: 8.5px !important;
    }
    .cp-stat-box-val {
        font-size: 17px !important;
    }
    .cp-wp-section {
        margin-top: 10px !important;
        padding: 8px 10px !important;
    }
    .cp-cat-list {
        margin-top: 12px !important;
        gap: 5px !important;
    }
    .cp-cat-item {
        padding: 6px 8px !important;
    }
    .cp-cat-title {
        font-size: 10px !important;
    }
    .cp-cat-minibar {
        max-width: 60px !important;
        min-width: 36px !important;
        margin: 0 4px !important;
    }
    .cp-cat-diff {
        font-size: 8.5px !important;
        padding: 1px 4px !important;
    }
    .cp-cat-pct {
        font-size: 12px !important;
        gap: 2px !important;
    }
    .cp-winner-badge {
        font-size: 9.5px !important;
        padding: 2px 8px !important;
        right: 10px !important;
    }
    .cp-card-footer {
        margin-top: 10px !important;
        padding-top: 8px !important;
    }
    .cp-legend-item {
        font-size: 9.5px !important;
    }
    .cp-legend-excluded {
        font-size: 9px !important;
    }
}

/* ============================================================
   MOBILE SCROLL & GPU PERFORMANCE OPTIMIZATIONS
   - Viewport content virtualization for offscreen cards (content-visibility)
   - Hardware momentum scrolling for touch carousels
   - Replaces expensive mobile backdrop-filter blur shaders with solid backgrounds
   ============================================================ */

/* Viewport content virtualization for heavy offscreen sections */
.pi-lane-section,
.pi-tracker-category,
.pi-journey-section,
.journey-history-card,
.journey-card,
.pi-stat-card-row,
.pi-category-card,
.pi-building-grid,
.pi-equip-grid {
    content-visibility: auto;
    contain-intrinsic-size: 0 280px;
}

/* Smooth momentum scrolling for all horizontal scroll containers */
.pi-categories-bar,
.pi-filter-chips,
.pi-steps-container,
.journey-streak-scroll,
.pi-cat-pills-row,
.pi-tabs-nav {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    transform: translateZ(0);
}

@media (max-width: 768px) {
    /* Disable GPU-heavy backdrop-filter blur passes on mobile; use clean opaque/semi-opaque dark styling */
    .pi-topnav,
    .pi-steps-wrapper,
    .pi-categories-bar,
    .pi-filter-chip,
    .pi-card,
    .pi-stat-card,
    .pi-lane-card,
    .journey-card,
    .journey-snapshot-card,
    .co-modal-sheet,
    .co-auth-card,
    .profile-panel,
    .pi-step-indicator {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .pi-topnav {
        background: rgba(10, 13, 20, 0.98) !important;
    }

    .pi-card,
    .journey-card,
    .journey-snapshot-card {
        background: #111622 !important;
    }

    .pi-filter-chip {
        background: #161c2b !important;
    }

    .co-auth-card,
    .co-modal-sheet {
        background: #0f131c !important;
    }
}

/* ============================================================
   MY VILLAGES (Villages tab) — multi-village card grid
   Reuses CoC-art recipe: coc-wood-panel card + coc-ribbon-banner
   header + parchment tokens. No new visual language.
   ============================================================ */
.mvg-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.mvg-count {
    font-size: 12px;
    font-weight: 800;
    color: var(--pi-ink-soft);
    letter-spacing: 0.3px;
}

.mvg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 28px 16px;
    margin-top: 10px;
}

.mvg-card {
    position: relative;
    padding: 34px 18px 18px;
    min-width: 0;
}

.mvg-card .coc-ribbon-banner {
    max-width: 86%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    padding: 5px 18px;
}

.mvg-card.mvg-current::after {
    content: 'CURRENT';
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.45);
    border-radius: 4px;
    padding: 2px 6px;
    background: rgba(255, 215, 0, 0.08);
}

.mvg-card-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mvg-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.mvg-th-img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.mvg-th-fallback {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 900;
    color: #ffd700;
    background: rgba(255, 215, 0, 0.08);
    border: 2px solid rgba(255, 215, 0, 0.35);
    border-radius: 10px;
}

.mvg-id-block {
    min-width: 0;
}

.mvg-name {
    font-size: 15px;
    font-weight: 900;
    color: var(--parchment-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mvg-tag {
    font-size: 11px;
    font-weight: 700;
    color: var(--pi-ink-soft);
    margin-top: 1px;
}

.mvg-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 7px;
}

.mvg-chip {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--parchment-text);
    letter-spacing: 0.3px;
}

.mvg-chip-mode {
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.35);
}

.mvg-chip-when {
    color: var(--pi-ink-soft);
}

.mvg-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mvg-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.mvg-stat-num {
    font-size: 16px;
    font-weight: 900;
    color: var(--parchment-text);
    white-space: nowrap;
}

.mvg-stat-na {
    color: var(--pi-ink-soft);
    opacity: 0.7;
}

.mvg-stat-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--pi-ink-soft);
}

.mvg-hint {
    font-size: 11px;
    font-weight: 700;
    color: var(--pi-ink-soft);
    text-align: center;
    padding: 2px 0 0;
}

/* Whole card is the click target */
.mvg-card {
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.mvg-card:hover {
    border-color: rgba(255, 215, 0, 0.55);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.mvg-card:focus-visible {
    outline: 2px solid #ffd700;
    outline-offset: 2px;
}

.mvg-add-json,
button.mvg-add-json {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    font-family: 'Baloo 2', 'Plus Jakarta Sans', sans-serif !important;
    font-size: 12.5px !important;
    font-weight: 800 !important;
    color: #ff9f1a !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    text-shadow: 0 1.5px 2px rgba(0, 0, 0, 0.85) !important;
    cursor: pointer !important;
    text-decoration: none !important;
    transition: color 0.15s, text-shadow 0.15s !important;
    display: inline-block !important;
}

.mvg-add-json:hover,
button.mvg-add-json:hover {
    color: #ffd32a !important;
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
    text-shadow: 0 0 8px rgba(255, 159, 26, 0.45), 0 1.5px 2px rgba(0, 0, 0, 0.95) !important;
}

.mvg-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 48px 20px;
    text-align: center;
}

.mvg-empty-icon {
    font-size: 40px;
}

.mvg-empty-title {
    font-size: 16px;
    font-weight: 900;
    color: var(--parchment-text);
}

.mvg-empty-sub {
    font-size: 12px;
    font-weight: 600;
    color: var(--pi-ink-soft);
    max-width: 340px;
    line-height: 1.5;
}

/* "+ Add Village" tile — dashed ghost card, same CoC-art palette */
.mvg-add-tile {
    position: relative;
    padding: 18px;
    min-width: 0;
    border: 2px dashed rgba(255, 215, 0, 0.35);
    background: rgba(255, 215, 0, 0.03);
    box-shadow: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.mvg-add-tile:hover {
    border-color: rgba(255, 215, 0, 0.6);
    background: rgba(255, 215, 0, 0.06);
}

.mvg-add-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 180px;
    text-align: center;
}

.mvg-add-icon {
    font-size: 34px;
    font-weight: 900;
    color: #ffd700;
    line-height: 1;
}

.mvg-add-title {
    font-size: 15px;
    font-weight: 900;
    color: var(--parchment-text);
}

.mvg-add-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--pi-ink-soft);
}

.mvg-add-form {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
    max-width: 280px;
}

.mvg-add-input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--parchment-text);
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    outline: none;
}

.mvg-add-input:focus {
    border-color: rgba(255, 215, 0, 0.6);
}

/* Mobile: single-column stack, same standard as other tabs */
@media (max-width: 640px) {
    #pi-tab-villages .coc-wood-panel {
        padding: 28px 10px 14px !important;
    }

    #pi-tab-villages .coc-parchment-panel {
        padding: 14px 10px !important;
    }

    .mvg-toolbar {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 8px;
        margin-bottom: 24px;
    }

    .mvg-toolbar-actions {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .mvg-toolbar-actions .coc-pillow-btn {
        min-height: 40px;
    }

    .mvg-grid {
        grid-template-columns: 1fr;
        gap: 28px;
        margin-top: 10px;
    }

    .mvg-card {
        padding: 30px 12px 14px;
    }

    .mvg-card .coc-ribbon-banner {
        font-size: 12px;
        padding: 4px 16px;
        top: -15px;
        max-width: 85%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mvg-th-img,
    .mvg-th-fallback {
        width: 48px;
        height: 48px;
    }

    .mvg-stats {
        gap: 4px;
        padding: 8px 0;
    }

    .mvg-stat-num {
        font-size: 14.5px;
    }

    .mvg-stat-label {
        font-size: 8.5px;
    }

    .mvg-add-form {
        flex-direction: column;
    }

    /* Column layout: flex:1 on the input makes flex-basis:0% win over its
       height in the vertical axis → 23px input. Pin it back to 44px. */
    .mvg-add-input {
        flex: 0 0 auto;
        width: 100%;
    }

    .mvg-add-form .mvg-add-go {
        width: 100%;
    }
}

/* ══════════════════════════════════════════════════════════════
   ScanDelta — "What's new since last scan" (wizard panel + Overview strip)
   ══════════════════════════════════════════════════════════════ */
.pi-delta-wrap {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 205, 92, 0.28);
    border-radius: 8px;
    text-align: left;
}
.pi-delta-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
}
.pi-delta-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #ffd766;
    opacity: 0.85;
}
.pi-delta-headline {
    font-size: 12.5px;
    color: var(--pi-text, #e8dcc0);
}
.pi-delta-when {
    opacity: 0.6;
    font-size: 11px;
}
.pi-delta-up { color: #6fdc6f; }
.pi-delta-down { color: #f28b6b; }
.pi-delta-flat { opacity: 0.75; }

.pi-delta-detail { margin-top: 8px; }
.pi-delta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    font-size: 12px;
    color: var(--pi-text, #e8dcc0);
    border-bottom: 1px dashed rgba(255, 205, 92, 0.12);
}
.pi-delta-item:last-of-type { border-bottom: none; }
.pi-delta-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pi-delta-arrow b { color: #ffd766; }
.pi-delta-maxed {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #0c2a0c;
    background: #6fdc6f;
    border-radius: 4px;
    padding: 1px 5px;
}
.pi-delta-extra { display: none; }
.pi-delta-open .pi-delta-extra { display: flex; }
.pi-delta-toggle { font-size: 11px; }
.pi-delta-note {
    margin-top: 6px;
    font-size: 10.5px;
    opacity: 0.55;
    font-style: italic;
}

/* Overview strip */
.pi-delta-strip-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: var(--pi-card-bg, rgba(20, 16, 10, 0.55));
    border: 1px solid rgba(255, 205, 92, 0.22);
    border-radius: 10px;
}
.pi-delta-strip-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #ffd766;
    opacity: 0.85;
}
.pi-delta-strip-detail { flex-basis: 100%; }
.pi-delta-strip-expand { font-size: 11px; }

@media (max-width: 480px) {
    .pi-delta-strip-card { padding: 9px 11px; }
    .pi-delta-item { font-size: 11.5px; }
}

/* ══════════════════════════════════════════════════════════
   MONTHLY PROGRESS SUMMARY (Journey) — mth-*
   Reuses the CoC-art recipe: dark wood backdrop, gold accents.
   ══════════════════════════════════════════════════════════ */
#journey-monthly {
    color: #e8dcc8;
}
#journey-monthly .mth-placeholder {
    color: #a0998e;
    font-size: 0.85rem;
    text-align: center;
    padding: 8px 0;
}
#journey-monthly .mth-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 14px;
}
#journey-monthly .mth-label {
    font-family: 'Baloo 2', 'ClashBold', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffd13b;
    min-width: 170px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-shadow:
        -1.5px -1.5px 0 #000,
        1.5px -1.5px 0 #000,
        -1.5px 1.5px 0 #000,
        1.5px 1.5px 0 #000,
        0 2px 4px rgba(0, 0, 0, 0.8);
}
#journey-monthly .mth-prev,
#journey-monthly .mth-next {
    font-family: 'Baloo 2', sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
    color: #ffd13b;
    background: linear-gradient(180deg, #2a2118, #18110b);
    border: 2px solid #4a3b2a;
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 5px rgba(0, 0, 0, 0.5);
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}
#journey-monthly .mth-prev:hover,
#journey-monthly .mth-next:hover {
    border-color: #ffd13b;
    color: #ffffff;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 209, 59, 0.35);
}
#journey-monthly .rcap-card {
    margin: 0 auto;
    width: min(440px, 100%);
    max-height: none;
    overflow: visible;
}
#journey-monthly .mth-card {
    border: 1px solid rgba(255, 215, 0, 0.18);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(43, 27, 22, 0.75), rgba(26, 15, 12, 0.9));
    padding: 14px 16px;
}
#journey-monthly .mth-head {
    text-align: center;
    margin-bottom: 10px;
}
#journey-monthly .mth-title {
    font-family: 'ClashBold', 'Baloo 2', sans-serif;
    color: #ffd700;
    letter-spacing: 0.08em;
    font-size: 0.95rem;
}
#journey-monthly .mth-sub {
    color: #94a3b8;
    font-size: 0.78rem;
    margin-top: 2px;
}
#journey-monthly .mth-guard {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.78rem;
    margin-bottom: 10px;
}
#journey-monthly .mth-overall {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 6px 0 10px;
}
#journey-monthly .mth-overall-lbl {
    color: #94a3b8;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
#journey-monthly .mth-overall-num {
    font-family: 'ClashBold', 'Baloo 2', sans-serif;
    font-size: 1.25rem;
    color: #e8dcc8;
}
#journey-monthly .mth-up { color: #2ecc71; }
#journey-monthly .mth-down { color: #ef4444; }
#journey-monthly .mth-flat2 { color: #94a3b8; }
#journey-monthly .mth-days {
    text-align: center;
    color: #a0998e;
    font-size: 0.75rem;
    margin-bottom: 12px;
}
#journey-monthly .mth-section {
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding-top: 10px;
    margin-top: 10px;
}
#journey-monthly .mth-sec-title {
    display: block;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
#journey-monthly .mth-cat-row {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.8rem;
}
#journey-monthly .mth-cat-name { color: #cbd5e1; }
#journey-monthly .mth-cat-val { color: #a0998e; font-size: 0.72rem; white-space: nowrap; }
#journey-monthly .mth-cat-delta { font-weight: 700; font-size: 0.78rem; }
#journey-monthly .mth-cat-delta.up { color: #2ecc71; }
#journey-monthly .mth-cat-delta.down { color: #ef4444; }
#journey-monthly .mth-cat-delta.flat { color: #94a3b8; }
#journey-monthly .mth-bar {
    grid-column: 1 / -1;
    height: 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}
#journey-monthly .mth-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #b8860b, #ffd700);
}
#journey-monthly .mth-na {
    color: #6b7280;
    font-size: 0.75rem;
}
#journey-monthly .mth-group {
    margin-bottom: 8px;
}
#journey-monthly .mth-group-label {
    display: inline-block;
    color: #ffd700;
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
#journey-monthly .mth-group-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
#journey-monthly .mth-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.75rem;
    color: #e8dcc8;
}
#journey-monthly .mth-maxed {
    color: #2ecc71;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
}
#journey-monthly .mth-note {
    color: #a0998e;
    font-size: 0.72rem;
    margin-top: 6px;
}
#journey-monthly .mth-flat {
    color: #a0998e;
    font-size: 0.8rem;
}
#journey-monthly .mth-res-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.85rem;
}
#journey-monthly .mth-res-lbl { font-weight: 700; }
#journey-monthly .mth-res-val { font-family: 'ClashBold', 'Baloo 2', sans-serif; color: #e8dcc8; }
#journey-monthly .mth-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}
#journey-monthly .mth-stat-lbl { color: #94a3b8; }
#journey-monthly .mth-stat-val { color: #38bdf8; font-weight: 700; }
#journey-monthly .mth-footer {
    color: #6b7280;
    font-size: 0.68rem;
    text-align: center;
    margin-top: 10px;
}
.rcap-actions,
#journey-monthly .mth-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.rcap-act-btn,
#journey-monthly .mth-act-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    font-family: 'Baloo 2', 'Plus Jakarta Sans', sans-serif;
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 7px;
    cursor: pointer;
    user-select: none;
    transition: all 0.12s ease;
    box-sizing: border-box;
}

.rcap-act-btn svg,
#journey-monthly .mth-act-btn svg {
    flex-shrink: 0;
}

.rcap-share,
#journey-monthly .mth-share {
    color: #ffffff;
    background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
    border: 2px solid #06080b;
    border-bottom: 3.5px solid #14532d;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 5px rgba(0, 0, 0, 0.5);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.rcap-share:hover,
#journey-monthly .mth-share:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 4px 10px rgba(34, 197, 94, 0.35);
}

.rcap-share:active,
#journey-monthly .mth-share:active {
    transform: translateY(1.5px);
    border-bottom-width: 2px;
}

.rcap-copy,
#journey-monthly .mth-copy {
    color: #ffd13b;
    background: linear-gradient(180deg, #2a2018 0%, #17110c 100%);
    border: 2px solid #4a3b2a;
    border-bottom: 3.5px solid #2d2016;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 5px rgba(0, 0, 0, 0.5);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.rcap-copy:hover,
#journey-monthly .mth-copy:hover {
    border-color: #ffd13b;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 4px 10px rgba(0, 0, 0, 0.6);
}

.rcap-copy:active,
#journey-monthly .mth-copy:active {
    transform: translateY(1.5px);
    border-bottom-width: 2px;
}

.rcap-anon,
#journey-monthly .mth-anon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #b5a593;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    padding: 0 10px;
    background: rgba(26, 19, 15, 0.8);
    border: 1.5px solid #3d2d20;
    border-radius: 7px;
    height: 34px;
    box-sizing: border-box;
    transition: border-color 0.15s, color 0.15s;
}

.rcap-anon:hover,
#journey-monthly .mth-anon:hover {
    border-color: #ffd13b;
    color: #ffffff;
}

.rcap-anon input,
#journey-monthly .mth-anon input {
    accent-color: #ffd13b;
    width: 14px;
    height: 14px;
    cursor: pointer;
    margin: 0;
}
@media (max-width: 480px) {
    #journey-monthly .mth-cat-row {
        grid-template-columns: 72px auto;
        grid-template-areas:
            "name delta"
            "val  delta";
    }
    #journey-monthly .mth-cat-name { grid-area: name; }
    #journey-monthly .mth-cat-delta { grid-area: delta; }
    #journey-monthly .mth-cat-val { grid-area: val; }
    #journey-monthly .mth-bar {
        grid-column: 1 / -1;
        max-width: 100%;
    }
    #journey-monthly .mth-overall-num {
        font-size: 1.05rem;
    }
    #journey-monthly .mth-label {
        min-width: 110px;
        font-size: 0.95rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   RecapPopups — What's New + Monthly Recap (progress-recap.js)
   Modal mechanics mirror .pi-json-modal (fixed inset backdrop,
   blur, z 9999). Visual language: existing pi-* palette.
   ═══════════════════════════════════════════════════════════════ */
.rcap-overlay {
    position: fixed;
    inset: 0;
    /* Above .fw-fab (10000): a recap popup is the user's own data moment —
       the feedback FAB must not sit on top of its backdrop or open a second
       modal over it (stacking rule: recaps > promo/feedback surfaces). */
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.rcap-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Card Frame: authentic CoC-art wood panel recipe */
.rcap-card {
    position: relative;
    width: min(440px, 100%);
    max-height: min(88vh, 720px);
    overflow-y: auto;
    background: linear-gradient(135deg, #251714 0%, #150b09 100%);
    border: 4px solid var(--ink-dark, #06080b);
    border-radius: var(--radius-lg, 18px);
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.06),
        inset 0 -3px 0 rgba(0, 0, 0, 0.5),
        0 8px 24px rgba(0, 0, 0, 0.8),
        0 24px 60px rgba(0, 0, 0, 0.95);
    padding: 24px 18px 18px;
    animation: rcap-pop 0.28s cubic-bezier(0.2, 1.2, 0.4, 1);
    scrollbar-width: thin;
    scrollbar-color: #4a3b2a transparent;
}

.rcap-card::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1.5px solid rgba(255, 255, 255, 0.04);
    border-radius: calc(var(--radius-lg, 18px) - 4px);
    pointer-events: none;
}

.rcap-card::-webkit-scrollbar {
    width: 6px;
}

.rcap-card::-webkit-scrollbar-track {
    background: transparent;
}

.rcap-card::-webkit-scrollbar-thumb {
    background: #4a3b2a;
    border-radius: 999px;
}

.rcap-card::-webkit-scrollbar-thumb:hover {
    background: #6b5538;
}

@keyframes rcap-pop {
    from { opacity: 0; transform: scale(0.92) translateY(14px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.rcap-overlay.rcap-closing {
    animation: rcap-out 0.22s ease forwards;
}

@keyframes rcap-out {
    to { opacity: 0; }
}

/* Close Button: dark pillow circular button */
.rcap-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border: 2.5px solid var(--ink-dark, #06080b);
    border-radius: 50%;
    background: linear-gradient(180deg, #2a2118, #18110b);
    box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.15), 0 2px 6px rgba(0, 0, 0, 0.6);
    color: var(--parchment-muted, #9c8a7e);
    font-family: 'Baloo 2', sans-serif;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.rcap-close:hover {
    color: #ffd13b;
    border-color: #ffd13b;
    box-shadow: 0 0 10px rgba(255, 209, 59, 0.4), inset 0 1.5px 0 rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* Header Area: Baloo 2 + Gold text with dark outline stroke */
.rcap-head {
    text-align: center;
    margin-bottom: 12px;
}

.rcap-brand {
    font-family: 'Baloo 2', sans-serif;
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--parchment-muted, #9c8a7e);
    font-weight: 800;
    text-transform: uppercase;
    display: inline-block;
}

.rcap-title {
    font-family: 'Baloo 2', 'ClashBold', sans-serif;
    font-size: 24px;
    font-weight: 800;
    color: #ffd700;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-shadow:
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0px 3.5px 0 #000,
        0px 6px 12px rgba(0, 0, 0, 0.85);
}

.rcap-sub {
    font-family: 'Baloo 2', 'Plus Jakarta Sans', sans-serif;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--parchment-muted, #9c8a7e);
    margin-top: 2px;
}

/* Overall Hero Stat: Parchment panel with circular forge crest visual language */
.rcap-hero {
    text-align: center;
    background: var(--parchment, #1d1814);
    border: 2.5px solid var(--parchment-border, #4a3b2a);
    border-radius: var(--radius-md, 12px);
    padding: 10px 14px 8px;
    margin-bottom: 14px;
    position: relative;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8), 0 3px 8px rgba(0, 0, 0, 0.5);
    background-image: radial-gradient(circle at 50% 35%, rgba(255, 209, 59, 0.08) 0%, transparent 65%);
}

.rcap-hero-num {
    font-family: 'Baloo 2', 'ClashBold', sans-serif;
    font-size: 32px;
    font-weight: 800;
    color: #ffd700;
    line-height: 1.1;
    text-shadow:
        -1.5px -1.5px 0 #000,
        1.5px -1.5px 0 #000,
        -1.5px 1.5px 0 #000,
        1.5px 1.5px 0 #000,
        0 3px 6px rgba(0, 0, 0, 0.9);
}

.rcap-hero-arrow {
    color: #ff9f1a;
    margin: 0 6px;
    font-size: 24px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.rcap-hero-unit {
    font-size: 18px;
    color: #ffd700;
    margin-left: 2px;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.rcap-delta {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 800;
    border: 1.5px solid transparent;
}

.rcap-delta.up {
    color: #4ade80;
    background: rgba(34, 197, 94, 0.16);
    border-color: rgba(74, 222, 128, 0.4);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.25);
}

.rcap-delta.down {
    color: #f87171;
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(248, 113, 113, 0.4);
}

.rcap-delta.flat {
    color: var(--parchment-muted, #9c8a7e);
    background: rgba(0, 0, 0, 0.4);
    border-color: #3b2c21;
}

.rcap-hero-lbl {
    margin-top: 5px;
    font-family: 'Baloo 2', sans-serif;
    font-size: 10px;
    letter-spacing: 2.5px;
    color: var(--parchment-muted, #9c8a7e);
    font-weight: 800;
    text-transform: uppercase;
}

/* Section Headers: Gold Ribbon-Banner Style matching coc-ribbon-banner */
.rcap-sec-title,
.rcap-res-lbl {
    display: table;
    margin: 14px auto 8px;
    background: linear-gradient(to bottom, #ffd13b 0%, #d97706 100%);
    border: 3px solid #000;
    border-bottom: 5.5px solid #000;
    border-radius: 6px;
    padding: 4px 20px;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        0 4px 12px rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-family: 'ClashBold', 'Baloo 2', 'Rubik', sans-serif;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-shadow:
        -1.5px -1.5px 0 #000,
        1.5px -1.5px 0 #000,
        -1.5px 1.5px 0 #000,
        1.5px 1.5px 0 #000,
        0 2px 4px rgba(0, 0, 0, 0.8);
    text-align: center;
}

/* Item Grid: Tracker Unit Breakdown Portrait Cards with depth */
.rcap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
}

.rcap-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: linear-gradient(180deg, #1c1510 0%, #120b08 100%);
    border: 2.5px solid #4a3b2a;
    border-radius: 10px;
    padding: 7px 4px 5px;
    min-width: 0;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8), 0 3px 6px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    animation: rcap-card-in 0.32s cubic-bezier(0.2, 1.1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 45ms);
}

.rcap-cell:hover {
    transform: translateY(-2px);
    border-color: #ffd13b;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8), 0 6px 14px rgba(0, 0, 0, 0.7);
}

.rcap-cell.maxed {
    border-color: #276749;
}

.rcap-cell.maxed:hover {
    border-color: #4ade80;
}

@keyframes rcap-card-in {
    from {
        opacity: 0;
        transform: scale(0.88) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.rcap-portrait,
.rcap-portrait-fallback {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: contain;
    background: #150f0c;
    border: 2px solid #2d2016;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.rcap-portrait.maxed {
    border-color: var(--green-accent, #2ecc71);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.45), inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.rcap-portrait-fallback {
    font-family: 'ClashBold', 'Rubik', sans-serif;
    font-weight: 900;
    font-size: 20px;
    color: var(--parchment-muted, #9c8a7e);
}

.rcap-name {
    max-width: 100%;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 10px;
    font-weight: 800;
    color: var(--parchment-text, #f5eedb);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
}

.rcap-lvl {
    font-family: 'Baloo 2', 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    font-weight: 800;
    color: var(--parchment-muted, #9c8a7e);
    display: flex;
    align-items: center;
    gap: 3px;
    line-height: 1;
}

.rcap-arrow {
    color: #d97706;
    font-size: 10px;
}

/* Category-specific color accents for level text */
.rcap-cell.rcap-cat-heroes .rcap-lvl b { color: #ffd13b; }
.rcap-cell.rcap-cat-equipment .rcap-lvl b { color: #f472b6; }
.rcap-cell.rcap-cat-troops .rcap-lvl b { color: #60a5fa; }
.rcap-cell.rcap-cat-spells .rcap-lvl b { color: #c084fc; }
.rcap-cell.rcap-cat-pets .rcap-lvl b { color: #34d399; }
.rcap-cell.rcap-cat-sieges .rcap-lvl b { color: #fb923c; }
.rcap-cell.rcap-cat-buildings .rcap-lvl,
.rcap-cell.rcap-cat-traps .rcap-lvl,
.rcap-cell.rcap-cat-walls .rcap-lvl {
    color: #ffd13b;
    font-weight: 800;
}

/* MAX Badge: Green-Glow Border Treatment matching Tracker */
.rcap-maxed {
    position: absolute;
    top: 3px;
    right: 3px;
    font-family: 'Baloo 2', 'ClashBold', sans-serif;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #ffffff;
    background: linear-gradient(180deg, #15803d 0%, #166534 100%);
    border: 1.5px solid #4ade80;
    border-radius: 4px;
    padding: 1px 4px;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
    line-height: 1.1;
    z-index: 1;
}

/* +N More button */
.rcap-more {
    display: block;
    margin: 10px auto 0;
    font-family: 'Baloo 2', 'ClashBold', sans-serif;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #ffd13b;
    background: linear-gradient(180deg, #2a2118, #18110b);
    border: 2px solid #4a3b2a;
    border-bottom-width: 4px;
    border-radius: 6px;
    padding: 4px 14px;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 3px 6px rgba(0, 0, 0, 0.4);
    transition: all 0.15s ease;
}

.rcap-more:hover {
    border-color: #ffd13b;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 5px 12px rgba(0, 0, 0, 0.6);
}

.rcap-more:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

/* Resources Spent Row & Chips: matching Total Resources Needed */
.rcap-res-row {
    margin-top: 12px;
}

.rcap-res-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.rcap-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(180deg, #2a2118 0%, #1c1510 100%);
    border: 2px solid #4a3b2a;
    border-radius: 999px;
    padding: 4px 12px;
    font-family: 'JetBrains Mono', 'Baloo 2', monospace;
    font-size: 12.5px;
    font-weight: 800;
    color: var(--parchment-text, #f5eedb);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 5px rgba(0, 0, 0, 0.5);
}

.rcap-res {
    display: inline-flex;
    align-items: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.7));
}

.rcap-res img,
.rcap-res .tr-res-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.rcap-note {
    margin-top: 12px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    line-height: 1.45;
    color: var(--parchment-muted, #9c8a7e);
    background: rgba(22, 16, 12, 0.75);
    border: 1.5px solid #38281c;
    border-radius: 8px;
    padding: 7px 12px;
    text-align: center;
}

/* Story Narrative Line: authentic symmetrical recessed plaque */
.rcap-story {
    margin-top: 13px;
    font-family: 'Baloo 2', 'Plus Jakarta Sans', sans-serif;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--parchment-text, #f5eedb);
    background: linear-gradient(180deg, #19120e 0%, #110c08 100%);
    border: 2px solid #3d2d20;
    border-radius: 10px;
    padding: 10px 14px;
    text-align: center;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Footer Link */
.rcap-foot {
    margin-top: 12px;
    text-align: center;
}

.rcap-foot .coc-link-btn {
    font-family: 'Baloo 2', 'Plus Jakarta Sans', sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: #ffd13b;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    transition: color 0.15s, text-shadow 0.15s;
}

.rcap-foot .coc-link-btn:hover {
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 209, 59, 0.6), 0 2px 4px rgba(0, 0, 0, 0.9);
}

/* Respect Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .rcap-card,
    .rcap-cell {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .rcap-overlay {
        padding: 12px;
        align-items: flex-end;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .rcap-card {
        width: 100%;
        max-height: 82vh;
        border-radius: 16px;
        padding: 22px 14px 16px;
    }

    .rcap-hero-num {
        font-size: 26px;
    }

    .rcap-grid {
        grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
        gap: 6px;
    }

    /* Tap-target floor: desktop keeps the compact 34px action buttons,
       mobile bumps to the 44px standard. */
    .rcap-act-btn,
    #journey-monthly .mth-act-btn {
        height: 44px;
        padding: 0 16px;
    }

    .rcap-more {
        min-height: 44px;
        padding: 8px 16px;
    }

    .rcap-cell {
        padding: 6px 3px 5px;
    }

    .rcap-portrait,
    .rcap-portrait-fallback {
        width: 42px;
        height: 42px;
    }
}

/* ══════════════════════════════════════════════════════════
   Post-Max block — Supercharge · Guardians · Crafted Defenses
   JSON-import-only surface. Kept visually separate from Village Health
   because these mechanics sit OUTSIDE the progress % (supercharge charges
   are removed without refund when a building gains a level; Crafted
   Defenses are seasonal and are replaced each Crafting Phase).
   ══════════════════════════════════════════════════════════ */
.pm-wrap {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pm-panel-off {
    display: none !important;
}

/* ── Collapse control (native button bar) ── */
.pm-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding: 5px 8px;
    background: rgba(10, 14, 22, 0.65);
    border: 1px solid rgba(245, 185, 59, 0.18);
    border-radius: 7px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.pm-toggle:hover {
    background: rgba(245, 185, 59, 0.09);
    border-color: rgba(245, 185, 59, 0.35);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.pm-toggle:focus-visible {
    outline: 2px solid #f5b93b;
    outline-offset: 1px;
}

.pm-toggle-badge {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.pm-toggle-label {
    font-family: 'Rubik', sans-serif;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pi-ink, #f8fafc);
    background: rgba(255, 255, 255, 0.07);
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1.4;
}

.pm-toggle-summary {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    color: #f5b93b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.pm-toggle-chevron {
    font-size: 11px;
    line-height: 1;
    color: #f5b93b;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotate(180deg);
}

.pm-wrap.pm-collapsed .pm-toggle-chevron {
    transform: rotate(0deg);
}

.pm-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pm-wrap.pm-collapsed .pm-body {
    display: none;
}

/* ── Section Blocks ── */
.pm-sec {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.pm-sec-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.pm-sec-title {
    font-family: 'Rubik', sans-serif;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--pi-ink, #f8fafc);
}

.pm-sec-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    color: #f5b93b;
    white-space: nowrap;
}

/* ── Progress Bars (Theme Authenticity: No AI Slop Gradients) ── */
.pm-bar {
    height: 7px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.pm-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #d97706, #fbbf24);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transition: width 0.3s ease;
}

/* Supercharge: Electric Lightning Cyan */
.pm-bar-fill.pm-bar-supercharge {
    background: linear-gradient(90deg, #0284c7, #38bdf8);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 6px rgba(56, 189, 248, 0.25);
}

/* Guardians: Max Emerald or Treasury Gold */
.pm-bar-fill.pm-bar-guardians {
    background: linear-gradient(90deg, #059669, #10b981);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 6px rgba(16, 185, 129, 0.25);
}

/* Crafted Defenses: Seasonal Forge Ember */
.pm-bar-fill.pm-bar-crafted {
    background: linear-gradient(90deg, #d97706, #f59e0b);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.pm-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ── Standard Post-Max List Rows ── */
.pm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 24px;
    padding: 3px 6px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.pm-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.pm-row-name {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--pi-ink, #f8fafc);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pm-row-meta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--pi-ink-soft, #94a3b8);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pm-chip {
    display: inline-flex;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #f5b93b;
    background: rgba(245, 185, 59, 0.12);
    border: 1px solid rgba(245, 185, 59, 0.32);
    border-radius: 4px;
    padding: 0 5px;
    line-height: 16px;
}

.pm-note {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    line-height: 1.45;
    color: var(--pi-ink-soft, #94a3b8);
    opacity: 0.85;
    padding: 1px 2px;
}

/* ── Crafted Defense Cards ── */
.pm-cd-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pm-cd-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(18, 24, 35, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
}

.pm-cd-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.pm-cd-name {
    font-family: 'Rubik', sans-serif;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--pi-ink, #f8fafc);
}

.pm-cd-cap-pill {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    color: #f5b93b;
    background: rgba(245, 185, 59, 0.14);
    border: 1px solid rgba(245, 185, 59, 0.3);
    border-radius: 4px;
    padding: 1px 6px;
    line-height: 15px;
}

.pm-cd-modules {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pm-cd-mod-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 4px 6px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.pm-cd-mod-main {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: wrap;
}

.pm-cd-mod-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.pm-cd-role-tag {
    font-family: 'Rubik', sans-serif;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 5px;
    border-radius: 3px;
    line-height: 13px;
}

/* Themed Role Badges */
.pm-cd-mod-row.mod-hp .pm-cd-role-tag {
    color: #f472b6;
    background: rgba(244, 114, 182, 0.18);
    border: 1px solid rgba(244, 114, 182, 0.3);
}

.pm-cd-mod-row.mod-atk .pm-cd-role-tag {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.18);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.pm-cd-mod-row.mod-eff .pm-cd-role-tag {
    color: #22d3ee;
    background: rgba(34, 211, 238, 0.18);
    border: 1px solid rgba(34, 211, 238, 0.3);
}

.pm-cd-mod-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    color: var(--pi-ink, #f8fafc);
}

.pm-cd-mod-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    font-weight: 500;
    color: var(--pi-ink-soft, #94a3b8);
    text-align: right;
    margin-left: auto;
}

.pm-cd-mod-bar {
    height: 4px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.pm-cd-mod-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.25s ease;
}

/* Themed Module Fills */
.pm-cd-mod-fill.mod-hp {
    background: linear-gradient(90deg, #c026d3, #ec4899);
}

.pm-cd-mod-fill.mod-atk {
    background: linear-gradient(90deg, #d97706, #fbbf24);
}

.pm-cd-mod-fill.mod-eff {
    background: linear-gradient(90deg, #0891b2, #06b6d4);
}

.pm-cd-mod-fill.mod-generic {
    background: linear-gradient(90deg, #d97706, #fbbf24);
}

/* Card Rollup Footer */
.pm-cd-foot {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.pm-cd-foot-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--pi-ink-soft, #94a3b8);
}

.pm-cd-foot-costs {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #f5b93b;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pm-cd-foot-costs img {
    width: 12px;
    height: 12px;
    vertical-align: -2px;
    margin-right: 2px;
}

/* Mobile Responsiveness (320px to 480px) */
@media (max-width: 480px) {
    .pm-toggle {
        padding: 5px 8px;
    }

    .pm-toggle-summary {
        font-size: 9.5px;
    }

    .pm-row {
        flex-wrap: wrap;
        row-gap: 2px;
    }

    .pm-row-name {
        flex-shrink: 0;
        min-width: unset;
        max-width: 100%;
    }

    .pm-row-meta {
        white-space: normal;
        width: 100%;
    }

    .pm-cd-card {
        padding: 8px 10px;
    }

    .pm-cd-mod-main {
        flex-wrap: wrap;
        row-gap: 2px;
    }

    .pm-cd-mod-sub {
        font-size: 9.5px;
        width: 100%;
        text-align: left;
    }
}

