* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;

    --bg: #0b0d09;
    --surface: #171b10;
    --panel-bg: rgba(255, 255, 255, .055);
    --panel-bg-strong: rgba(255, 255, 255, .09);
    --panel-border: rgba(255, 255, 255, .1);
    --input-bg: rgba(255, 255, 255, .06);
    --input-border: #2a2f20;

    --text: #ecefe4;
    --muted: #98a084;

    --olive-bright: #8ba653;
    --amber: #dd9a35;
    --amber-bright: #f2b356;

    --danger: #c9563c;

    --silhouette-fill: rgba(255, 255, 255, .07);
    --silhouette-stroke: rgba(255, 255, 255, .25);
    --silhouette-selected: var(--amber);

    --font-head: "Oswald", "Segoe UI", sans-serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.5;
}

a {
    color: var(--amber-bright);
}

/* =========================
   HEADER
   ========================= */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 2rem;
    background: rgba(15, 17, 11, .5);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border-bottom: 1px solid var(--panel-border);
}

.brand {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.brand h1 {
    margin: 0;
    font-family: var(--font-head);
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-size: 1.25rem;
}

.brand p {
    margin: 0;
    color: var(--muted);
    font-size: .85rem;
    max-width: 46ch;
}

/* =========================
   SHARED CONTROLS
   ========================= */

input, button, select {
    font: inherit;
    color: var(--text);
}

select, input[type="text"] {
    min-height: 38px;
    padding: 0 .7rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    transition: border-color .15s ease, box-shadow .15s ease;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--amber) 50%),
        linear-gradient(135deg, var(--amber) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 13px) 50%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    padding-right: 34px;
    cursor: pointer;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--amber) 20%, transparent);
}

/* The select box itself picks up --input-bg/--text above, but the native
   dropdown popup (the open option list) is drawn by the OS, not by us.
   On Windows/Chromium in particular, the popup background stays white no
   matter what CSS says (color-scheme and option background are both
   ignored there) — but our light --text color WAS still being applied to
   the option text, which is what actually made it unreadable: light text
   on a background we can't turn dark. Forcing dark, high-contrast text
   here (rather than fighting the unstylable white background) is what
   actually fixes it, even though it means this one native popup doesn't
   match the app's dark theme. */
select option {
    background: #ffffff;
    color: #17190f;
    padding: .4rem;
}

button {
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel-bg);
    padding: .5rem .8rem;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}

button:hover {
    border-color: var(--amber);
}

button:active {
    transform: translateY(1px);
}

/* =========================
   LAYOUT
   ========================= */

.content {
    max-width: none;
    margin: 0;
    padding: 1.75rem 2.5rem 3rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 980px) {
    .content {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border: 1px solid var(--panel-border);
    border-left: 3px solid var(--panel-border);
    border-radius: 14px;
    padding: 1.4rem 1.4rem 1.2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .25);
}

.panel h2 {
    margin: 0 0 1rem;
    font-family: var(--font-head);
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-size: .95rem;
    color: var(--amber-bright);
}

.weapon-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 110px;
    border-radius: 10px;
    background: var(--panel-bg-strong);
    border: 1px solid var(--panel-border);
    margin-bottom: .35rem;
    overflow: hidden;
}

.weapon-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.weapon-credit {
    text-align: right;
    font-size: .68rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.weapon-credit a {
    color: var(--muted);
}

.field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-bottom: 1rem;
}

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

.field label {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}

.field-value {
    font-variant-numeric: tabular-nums;
    color: var(--amber-bright);
}

/* =========================
   DISTANCE SLIDER
   ========================= */

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--olive-bright), var(--amber));
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--amber-bright);
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 1px var(--amber);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--amber-bright);
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 1px var(--amber);
    cursor: pointer;
}

input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--olive-bright), var(--amber));
}

/* =========================
   SILHOUETTE
   ========================= */

.silhouette-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}

.silhouette-zone-name {
    font-family: var(--font-head);
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--amber-bright);
    min-height: 1.4em;
}

svg.silhouette {
    width: 100%;
    max-width: 240px;
    height: auto;
}

svg.silhouette [data-zone] {
    fill: var(--silhouette-fill);
    stroke: var(--silhouette-stroke);
    stroke-width: 1.5;
    cursor: pointer;
    transition: fill .12s ease, stroke .12s ease;
}

svg.silhouette [data-zone]:hover {
    fill: color-mix(in srgb, var(--amber) 35%, var(--silhouette-fill));
    stroke: var(--amber);
}

svg.silhouette [data-zone].zone-selected {
    fill: var(--silhouette-selected);
    stroke: var(--amber-bright);
}

svg.silhouette [data-zone]:focus-visible {
    outline: 2px solid var(--amber-bright);
    outline-offset: 2px;
}

.zone-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .4rem;
    margin-top: .75rem;
}

.zone-legend button {
    padding: .3rem .65rem;
    border-radius: 999px;
    font-size: .78rem;
    background: var(--panel-bg-strong);
}

.zone-legend button.zone-selected {
    background: var(--amber);
    border-color: var(--amber-bright);
    color: #201705;
}

/* =========================
   RESULTS
   ========================= */

.results-grid {
    display: grid;
    gap: .8rem;
}

.result-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--panel-border);
}

.result-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.result-row .label {
    font-size: .82rem;
    color: var(--muted);
}

.result-row .value {
    font-family: var(--font-head);
    font-size: 1.2rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.result-row.headline .value {
    font-size: 1.6rem;
    color: var(--amber-bright);
}

.confidence-badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    background: var(--panel-bg-strong);
    color: var(--muted);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* =========================
   DATA DISCLAIMER
   ========================= */

.disclaimer {
    grid-column: 1 / -1;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-left: 3px solid var(--danger);
    border-radius: 12px;
    padding: .9rem 1.2rem;
    font-size: .85rem;
    color: var(--muted);
}

.disclaimer strong {
    color: var(--text);
}

/* =========================
   FOOTER
   ========================= */

footer {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: 1.5rem 2rem 2rem;
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
    border-top: 1px solid var(--input-border);
}

.footer-meta a {
    text-decoration: none;
}

.footer-version {
    margin-left: .3rem;
}
