/* Reset and base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --ui-scale: 1.0;
    --bg: #08090f;
    --surface: #0f1120;
    --surface2: #181a2e;
    --border: rgba(190, 148, 28, 0.22);
    --gold: #d4a820;
    --gold-light: #f2c843;
    --text: #e2d9c5;
    --muted: #7a7092;
    --c-daigoro: #c0392b;
    --c-kozuka: #b37a14;
    --c-ws: #1e6fa0;
    --c-wm: #7d3c98;
}

html {
    font-size: calc(20px * var(--ui-scale));
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Open Sans', 'Segoe UI', system-ui, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse 60% 40% at 15% 10%, rgba(110, 70, 12, .09) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 85% 90%, rgba(70, 20, 110, .09) 0%, transparent 60%);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.component-slot:empty {
    min-height: 2rem;
}

header {
    text-align: center;
    padding: 1rem 1rem 1rem;
    position: relative;
    border-bottom: 1px solid var(--border);
}

header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.h-sup {
    font-size: .7rem;
    letter-spacing: .35em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: .7rem;
}

h1 {
    font-size: 2.6rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--gold-light);
    text-shadow: 0 0 40px rgba(240, 200, 70, .3);
    margin-bottom: .35rem;
}

.h-sub {
    font-size: .9rem;
    color: var(--muted);
    letter-spacing: .12em;
}

main {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1rem 2rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
}

.panel-title {
    font-size: .66rem;
    letter-spacing: .3em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 1.4rem;
    padding-bottom: .7rem;
    border-bottom: 1px solid var(--border);
}

.panel-title-static {
    margin: 0;
    padding: 0;
    border: 0;
}

.panel-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    text-align: left;
}

.panel-toggle-icon {
    width: .5rem;
    height: .5rem;
    border-right: 2px solid var(--gold);
    border-bottom: 2px solid var(--gold);
    transform: rotate(45deg);
    transition: transform .2s ease;
    flex-shrink: 0;
    margin-top: -.25rem;
}

.panel-collapsible.is-collapsed .panel-toggle-icon {
    transform: rotate(-45deg);
    margin-top: .1rem;
}

.panel-content {
    padding-top: 1.2rem;
}

.panel-content[hidden] {
    display: none;
}

.panel-collapsible.is-collapsed {
    padding-bottom: 1rem;
}

.ig {
    margin-bottom: 1.5rem;
}

.ig:last-child {
    margin-bottom: 0;
}

.ig>.lbl-main {
    display: block;
    font-size: .85rem;
    color: var(--text);
    margin-bottom: .2rem;
}

.ig>.lbl-sub {
    display: block;
    font-size: .69rem;
    color: var(--muted);
    margin-bottom: .55rem;
    line-height: 1.4;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: .7rem;
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--surface2);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    touch-action: pan-y;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--gold-light);
    box-shadow: 0 0 6px rgba(212, 168, 32, .5);
    cursor: pointer;
    transition: box-shadow .2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 14px rgba(212, 168, 32, .8);
}

.num-input {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    padding: .42rem .65rem;
    font-size: max(.9rem, 16px);
    font-family: inherit;
    outline: none;
    transition: border-color .2s;
    width: 100%;
}

.num-input:focus {
    border-color: var(--gold);
}

.num-sm {
    width: 72px;
}





.gil-val {
    color: var(--gold);
}

.radio-list {
    display: flex;
    flex-direction: column;
    gap: .45rem;
}

.radio-opt {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .5rem .65rem;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.radio-opt:hover {
    background: var(--surface2);
}

.radio-opt.is-active {
    background: rgba(212, 168, 32, .07);
    border-color: rgba(212, 168, 32, .3);
}

.radio-opt input[type="radio"] {
    width: 14px;
    height: 14px;
    accent-color: var(--gold);
    margin-top: 3px;
    flex-shrink: 0;
    cursor: pointer;
}

.radio-text {
    font-size: .8rem;
    color: var(--text);
    line-height: 1.35;
}

.radio-sub {
    font-size: .68rem;
    color: var(--muted);
    margin-top: .1rem;
}

.radio-star {
    color: var(--gold);
}

.zl-select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    padding: .5rem .6rem;
    font-size: max(.83rem, 16px);
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
}

.zl-select:focus {
    border-color: var(--gold);
}

.zl-select option {
    background: #181a2e;
}

.zl-examples {
    margin-top: .4rem;
    font-size: .68rem;
    color: var(--muted);
    font-style: italic;
    line-height: 1.45;
}

.toggle-row {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
}

.toggle {
    position: relative;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tslider {
    position: absolute;
    inset: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: background .25s, border-color .25s;
}

.tslider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--muted);
    top: 4px;
    left: 4px;
    transition: transform .25s, background .25s;
}

.toggle input:checked+.tslider {
    background: rgba(212, 168, 32, .2);
    border-color: var(--gold);
}

.toggle input:checked+.tslider::before {
    background: var(--gold);
    transform: translateX(22px);
}

.toggle-lbl {
    font-size: .83rem;
    color: var(--text);
    cursor: pointer;
    line-height: 1.4;
}

.toggle-sub {
    font-size: .68rem;
    color: var(--muted);
    margin-top: .15rem;
}

.results-panel {
    display: flex;
    flex-direction: column;
}

.stats-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: 1.3rem;
}

.chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: .35rem .7rem;
    flex: 1;
    min-width: 0;
    text-align: center;
}

.chip-lbl {
    font-size: .63rem;
    color: var(--muted);
    margin-bottom: .08rem;
}

.chip-val {
    font-size: .88rem;
    font-weight: 600;
    color: var(--gold);
}

.bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

.bar-row {
    display: flex;
    flex-direction: column;
    gap: .28rem;
}

.bar-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    flex-wrap: wrap;
}

.bar-name {
    display: flex;
    align-items: center;
    gap: .4rem;
    min-width: 0;
    flex-wrap: wrap;
}

.bdot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bname-text {
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
}

.bdesc {
    font-size: .67rem;
    color: var(--muted);
    white-space: normal;
}

.bpct {
    font-size: .93rem;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.bar-track {
    height: 7px;
    background: var(--surface2);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .38s cubic-bezier(.4, 0, .2, 1);
}

.bar-row.zan-active .bpct {
    text-shadow: 0 0 10px rgba(242, 200, 67, .6);
}

.bar-row.zan-active .bar-track {
    box-shadow: 0 0 6px rgba(242, 200, 67, .25);
}

.cl-zan {
    color: var(--gold-light);
}

.cl-wm {
    color: #a25bc9;
}

.cl-ws {
    color: #3d9cd8;
}

.cl-ko {
    color: #d4ad3a;
}

.cl-da {
    color: #e05050;
}

.bg-zan {
    background: linear-gradient(90deg, var(--gold), var(--gold-light), #fff6c8);
}

.bg-wm {
    background: var(--c-wm);
}

.bg-ws {
    background: var(--c-ws);
}

.bg-ko {
    background: var(--c-kozuka);
}

.bg-da {
    background: var(--c-daigoro);
}

.dot-zan {
    background: var(--gold-light);
}

.dot-wm {
    background: var(--c-wm);
}

.dot-ws {
    background: var(--c-ws);
}

.dot-ko {
    background: var(--c-kozuka);
}

.dot-da {
    background: var(--c-daigoro);
}

.dismiss-notice {
    background: rgba(192, 57, 43, .12);
    border: 1px solid rgba(192, 57, 43, .4);
    border-radius: 7px;
    padding: 1.1rem 1.2rem;
    text-align: center;
    font-size: .85rem;
    color: #e74c3c;
    line-height: 1.6;
    margin-top: .3rem;
}

.formula-note {
    margin-top: 1.4rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: .67rem;
    color: var(--muted);
    line-height: 1.65;
}

.formula-note a {
    color: var(--gold);
    text-decoration: none;
}

.formula-note a:hover {
    text-decoration: underline;
}

footer {
    text-align: center;
    padding: 1.8rem 1rem;
    font-size: .68rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

.sources {
    margin-top: 0.2rem;
    padding-top: 1rem;
    font-size: .67rem;
    color: var(--muted);
    line-height: 1.65;
}

.sources a {
    color: var(--gold);
    text-decoration: none;
}

.sources a:hover {
    text-decoration: underline;
}

/* ── Overdrive inline ── */
.toggle-inline {
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    margin-top: 0;
}

.overdrive-inline-lbl {
    font-size: .72rem;
    color: var(--text);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    line-height: 1;
}

/* ── Compatibility event buttons ── */
.compat-events {
    margin-top: 1.25rem;
}

.compat-events-lbl {
    display: block;
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: .22em;
    color: var(--muted);
    margin-bottom: .55rem;
}

.compat-btns {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}

.compat-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .18rem;
    flex: 1;
    min-width: 0;
    padding: .5rem .25rem .42rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    transition: background .15s, border-color .15s;
    outline-offset: 2px;
}

.compat-btn:hover,
.compat-btn:focus-visible {
    background: rgba(212, 168, 32, .08);
    border-color: var(--border-hi);
}

.compat-btn-icon {
    font-size: 1rem;
    line-height: 1;
}

.compat-btn-name {
    font-size: .62rem;
    color: var(--muted);
    white-space: nowrap;
}

.compat-btn-delta {
    font-size: .76rem;
    font-weight: 700;
}

.compat-neg .compat-btn-delta {
    color: #e05050;
}

.compat-neutral .compat-btn-delta {
    color: var(--muted);
}

.compat-pos .compat-btn-delta {
    color: var(--gold-light);
}

.compat-btn::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1b1e35;
    border: 1px solid var(--border-hi);
    border-radius: 6px;
    padding: .5rem .7rem;
    font-size: .7rem;
    color: var(--text);
    white-space: normal;
    width: 190px;
    text-align: center;
    line-height: 1.5;
    pointer-events: none;
    opacity: 0;
    transition: opacity .18s;
    z-index: 10;
}

.compat-btn:hover::after,
.compat-btn:focus-visible::after {
    opacity: 1;
}

@media (max-width: 860px) {
    html {
        font-size: 18px;
    }

    main {
        max-width: 100%;
        padding: 0 .9rem 1.4rem;
    }

    .panel {
        padding: 1.1rem;
        border-radius: 12px;
    }
}

@media (max-width: 660px) {
    html {
        font-size: 17px;
    }

    body {
        background-image:
            radial-gradient(ellipse 70% 45% at 50% 0%, rgba(110, 70, 12, .11) 0%, transparent 62%),
            radial-gradient(ellipse 60% 40% at 50% 100%, rgba(70, 20, 110, .1) 0%, transparent 60%);
    }

    header {
        padding: 2.1rem .9rem 1.6rem;
    }

    main {
        margin: 1rem auto;
        padding: 0 .75rem 1rem;
        gap: 1.25rem;
    }

    h1 {
        font-size: 1.9rem;
    }

    .h-sup {
        letter-spacing: .24em;
    }

    .h-sub {
        letter-spacing: .08em;
    }

    .panel,
    .chip {
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .panel {
        padding: 0;
    }

    .panel-toggle {
        padding-bottom: .6rem;
        border-bottom: 1px solid var(--border);
    }

    .panel-content {
        padding-top: 1rem;
    }

    .slider-row {
        gap: .55rem;
    }

    .num-sm {
        width: 84px;
    }

    .radio-opt {
        padding: .7rem 0;
    }

    .toggle-row {
        gap: .65rem;
    }

    .stats-chips {
        gap: .45rem;
        margin-bottom: .9rem;
    }

    .chip {
        flex: 1 1 calc(50% - .45rem);
        padding: .15rem 0;
    }

    .bpct {
        width: 100%;
        text-align: left;
    }

    .bar-track {
        height: 9px;
    }

    .formula-note {
        margin-top: 1.1rem;
    }

    footer {
        padding: 1.2rem .9rem calc(1.2rem + env(safe-area-inset-bottom, 0));
    }
}