.tpp-pf-tool {
    --tpp-pf-red: #FF3333;
    --tpp-pf-red-dark: #D92A2A;
    --tpp-pf-black: #171717;
    --tpp-pf-white: #FFFFFF;
    --tpp-pf-surface: #F6F7F9;
    --tpp-pf-surface-dark: #ECEFF3;
    --tpp-pf-border: #E1E4E8;
    --tpp-pf-text: #171717;
    --tpp-pf-text-secondary: #666666;
    --tpp-pf-text-muted: #8A8F98;

    width: 100%;
    max-width: 860px;
    margin: 34px auto;
    padding: 26px;
    background: var(--tpp-pf-white);
    border: 1px solid var(--tpp-pf-border);
    border-top: 4px solid var(--tpp-pf-red);
    border-radius: 24px;
    font-family: "DM Sans", Arial, sans-serif;
    color: var(--tpp-pf-text);
    box-sizing: border-box;
}

.tpp-pf-tool *,
.tpp-pf-tool *::before,
.tpp-pf-tool *::after {
    box-sizing: border-box;
}

.tpp-pf-header {
    width: 100%;
    max-width: 790px;
    margin: 0 auto 18px;
}

.tpp-pf-logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.tpp-pf-logo {
    display: block;
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.tpp-pf-title {
    margin: 0;
    text-align: center;
    color: var(--tpp-pf-black);
    font-size: clamp(25px, 3vw, 36px);
    font-weight: 800;
    line-height: 1.15;
}

.tpp-pf-interface {
    width: 100%;
    max-width: 790px;
    margin: 0 auto;
}

.tpp-pf-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
    padding: 15px;
    background: var(--tpp-pf-surface);
    border: 1px solid var(--tpp-pf-border);
    border-radius: 14px;
}

.tpp-pf-control-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.tpp-pf-control-group label {
    font-size: 12px;
    color: var(--tpp-pf-text-secondary);
    font-weight: 700;
}

.tpp-pf-control-group select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--tpp-pf-border);
    border-radius: 9px;
    background-color: var(--tpp-pf-white);
    color: var(--tpp-pf-text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.tpp-pf-control-group select:focus {
    border-color: var(--tpp-pf-red);
    box-shadow: 0 0 0 3px rgba(255, 51, 51, 0.14);
}

.tpp-pf-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
    padding: 11px 14px;
    background: var(--tpp-pf-surface);
    border: 1px solid var(--tpp-pf-border);
    border-radius: 11px;
    color: var(--tpp-pf-text-secondary);
    font-size: 12px;
}

.tpp-pf-stats-bar strong {
    color: var(--tpp-pf-black);
}

#tpp-pf-range-pct {
    color: var(--tpp-pf-red);
}

.tpp-pf-legend {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    margin: 0 0 13px;
    padding: 9px 12px;
    border: 1px solid var(--tpp-pf-border);
    border-radius: 10px;
    background: var(--tpp-pf-white);
}

.tpp-pf-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--tpp-pf-text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.tpp-pf-legend-swatch {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    border-radius: 4px;
    border: 1px solid var(--tpp-pf-border);
}

.tpp-pf-legend-swatch.is-push {
    background: var(--tpp-pf-red);
    border-color: var(--tpp-pf-red-dark);
}

.tpp-pf-legend-swatch.is-fold {
    background: var(--tpp-pf-surface-dark);
}

.tpp-pf-matrix-wrap {
    width: 100%;
    overflow-x: auto;
    padding: 3px 2px 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tpp-pf-matrix-grid {
    display: grid;
    grid-template-columns: repeat(13, minmax(42px, 1fr));
    gap: 4px;
    width: 100%;
    min-width: 620px;
    max-width: 790px;
    margin: 0 auto;
}

.tpp-pf-cell {
    aspect-ratio: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--tpp-pf-border);
    border-radius: 7px;
    background-color: var(--tpp-pf-surface-dark);
    color: var(--tpp-pf-text-muted);
    font-size: clamp(10px, 1.05vw, 12px);
    font-weight: 700;
    line-height: 1;
    user-select: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.tpp-pf-cell:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.tpp-pf-cell.is-push {
    background-color: var(--tpp-pf-red);
    border-color: var(--tpp-pf-red-dark);
    color: var(--tpp-pf-white);
}

.tpp-pf-cell.is-pair {
    border-width: 1.5px;
}

.tpp-pf-mobile-hint {
    display: none;
    margin: 7px 0 0;
    text-align: center;
    color: var(--tpp-pf-text-muted);
    font-size: 11px;
    line-height: 1.45;
}


.tpp-pf-strategy-info,
.tpp-pf-range-info {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

button.tpp-pf-tooltip-trigger {
    position: relative;
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    padding: 0 !important;
    border: 1px solid #777777 !important;
    border-radius: 50%;
    background: #ffffff !important;
    color: #171717 !important;
    -webkit-text-fill-color: #171717 !important;
    font-family: inherit;
    font-size: 11px;
    font-weight: 900;
    line-height: 17px;
    text-align: center;
    text-shadow: none !important;
    cursor: help;
}

button.tpp-pf-tooltip-trigger:hover,
button.tpp-pf-tooltip-trigger:focus-visible,
button.tpp-pf-tooltip-trigger:focus {
    border-color: #171717 !important;
    background: #ffffff !important;
    color: #171717 !important;
    -webkit-text-fill-color: #171717 !important;
    outline: none;
}

.tpp-pf-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    z-index: 30;
    width: 260px;
    padding: 10px 12px;
    border-radius: 9px;
    background: #171717 !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    text-shadow: none !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(4px);
    transition:
        opacity 0.15s ease,
        transform 0.15s ease,
        visibility 0.15s ease;
}

.tpp-pf-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    border: 6px solid transparent;
    border-top-color: var(--tpp-pf-black);
    transform: translateX(-50%);
}

.tpp-pf-tooltip-trigger:hover .tpp-pf-tooltip,
.tpp-pf-tooltip-trigger:focus .tpp-pf-tooltip,
.tpp-pf-tooltip-trigger:focus-visible .tpp-pf-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.tpp-pf-disclaimer {
    max-width: 760px;
    margin: 12px auto 0;
    padding: 11px 14px;
    border-left: 3px solid var(--tpp-pf-red);
    border-radius: 8px;
    background: var(--tpp-pf-surface);
    color: var(--tpp-pf-text-secondary);
    font-size: 11px;
    line-height: 1.55;
}

@media (max-width: 760px) {
    .tpp-pf-tool {
        margin: 22px auto;
        padding: 20px 16px;
        border-radius: 20px;
    }

    .tpp-pf-controls {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 14px;
    }

    .tpp-pf-stats-bar {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .tpp-pf-matrix-grid {
        grid-template-columns: repeat(13, 39px);
        min-width: 555px;
        max-width: none;
        width: max-content;
    }

    .tpp-pf-cell {
        width: 39px;
        height: 39px;
        aspect-ratio: auto;
        font-size: 10px;
    }

    .tpp-pf-mobile-hint {
        display: block;
    }

    .tpp-pf-tooltip {
        left: 0;
        width: min(250px, calc(100vw - 52px));
        transform: translateY(4px);
    }

    .tpp-pf-tooltip::after {
        left: 10px;
        transform: none;
    }

    .tpp-pf-tooltip-trigger:hover .tpp-pf-tooltip,
    .tpp-pf-tooltip-trigger:focus .tpp-pf-tooltip,
    .tpp-pf-tooltip-trigger:focus-visible .tpp-pf-tooltip {
        transform: translateY(0);
    }

    .tpp-pf-disclaimer {
        font-size: 10.5px;
    }
}

@media (max-width: 420px) {
    .tpp-pf-tool {
        margin: 16px auto;
        padding: 17px 11px;
        border-radius: 17px;
    }

    .tpp-pf-logo {
        width: 58px;
        height: 58px;
    }

    .tpp-pf-title {
        font-size: 25px;
    }

    .tpp-pf-legend {
        gap: 14px;
        padding: 8px 10px;
    }

    .tpp-pf-legend-item {
        font-size: 11px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tpp-pf-cell {
        transition: none;
    }
}

/* Keep horizontal scrolling inside the matrix only */

.tpp-pf-tool {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
}

.tpp-pf-interface {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.tpp-pf-matrix-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.tpp-pf-matrix-grid {
    flex: none;
}

@media (max-width: 760px) {
    .tpp-pf-matrix-wrap {
        position: relative;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
    }
}
