:root {
    color-scheme: dark;
    --bg: #101115;
    --panel: #1d2025;
    --panel-soft: #24262a;
    --gold: #c8a84e;
    --gold-light: #f0d66d;
    --line: rgba(200, 168, 78, 0.52);
    --text: #f2ead2;
    --muted: #aca58e;
    --danger: #db6971;
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--text); background: radial-gradient(circle at 54% -20%, rgba(200,168,78,.12), transparent 36rem), linear-gradient(145deg, #111216, #0b0c0f 75%); }
a { color: inherit; }

.site-header { display: flex; min-height: 70px; align-items: center; justify-content: space-between; padding: 0 clamp(18px, 4vw, 64px); background: rgba(27,29,34,.94); border-bottom: 1px solid var(--gold); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--gold-light); font-weight: 800; letter-spacing: .12em; text-decoration: none; text-transform: uppercase; }
.brand-mark { font-size: 1.2rem; }
.site-label { color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }

.viewer-shell { width: min(1460px, calc(100% - 32px)); margin: 22px auto 44px; }
.build-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 14px; padding: 4px 3px 13px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--gold-light); font-size: .69rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin: 5px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.55rem, 3vw, 2.35rem); font-weight: 500; }
.build-meta { display: flex; align-items: end; flex-direction: column; gap: 4px; color: var(--gold-light); }
.build-meta small { color: var(--muted); }
.build-heading-actions { display: grid; justify-items: end; gap: 7px; }
.open-in-app-button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 8px; padding: 8px 13px; color: #111216; background: var(--gold-light); border: 1px solid var(--gold-light); border-radius: 4px; box-shadow: 0 5px 16px rgba(0,0,0,.24); font-size: .7rem; font-weight: 900; letter-spacing: .055em; text-decoration: none; text-transform: uppercase; transition: background-color .15s ease, border-color .15s ease, transform .15s ease; }
.open-in-app-button:hover { background: #ffe783; border-color: #ffe783; transform: translateY(-1px); }
.open-in-app-button:focus-visible { outline: 2px solid #fff1a3; outline-offset: 3px; }
.open-in-app-button span { font-size: .95rem; line-height: 1; }
.open-in-app-hint { max-width: 250px; color: var(--muted); font-size: .61rem; line-height: 1.3; text-align: right; }

.viewer-grid { display: grid; grid-template-columns: minmax(245px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.panel { min-width: 0; overflow: hidden; background: rgba(29,32,37,.94); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 14px 35px rgba(0,0,0,.22); }
.equipment-panel { overflow: visible; }
.panel > header { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 13px; background: rgba(200,168,78,.07); border-bottom: 1px solid rgba(200,168,78,.34); color: var(--gold-light); font-size: .68rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.panel > header strong { color: var(--muted); font-size: .65rem; }

.equipment-identity { padding: 24px 16px 20px; text-align: center; }
.equipment-identity img, .equipment-fallback { width: 126px; height: 126px; margin: 0 auto 12px; object-fit: contain; border: 1px solid var(--line); border-radius: 50%; background: #15171b; }
.equipment-fallback { display: grid; place-items: center; color: var(--gold); font-size: 2.4rem; }
.equipment-identity h2 { margin-bottom: 4px; color: var(--gold-light); font-family: Georgia, "Times New Roman", serif; font-size: 1.55rem; }
.equipment-identity p { margin: 0; color: var(--muted); font-size: .78rem; }
.shard-section, .stats { padding: 13px; border-top: 1px solid rgba(200,168,78,.32); }
.shard-section h3, .stats h3 { margin: 0 0 9px; color: var(--gold-light); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; }
.shard-row { display: flex; justify-content: center; gap: 6px; }
.shard { position: relative; display: grid; width: 34px; height: 34px; place-items: center; color: #746a4f; border: 1px solid #5e5130; background: #14161a; }
.shard.filled { color: var(--gold-light); box-shadow: inset 0 0 12px rgba(200,168,78,.12); }
.shard.filled { cursor: help; }
.shard .shared-shard-icon { display: block; width: 27px !important; height: 27px !important; max-width: 27px !important; max-height: 27px !important; margin: 0 !important; object-fit: contain; }
.shard small { position: absolute; right: 2px; bottom: 0; font-size: .48rem; }
.shared-shard-tooltip { position: absolute; z-index: 30; top: calc(100% + 9px); left: 50%; display: none; width: min(255px, calc(100vw - 30px)); flex-direction: column; gap: 5px; padding: 11px 12px; color: var(--text); background: #111318; border: 1px solid var(--gold); border-radius: 5px; box-shadow: 0 12px 30px rgba(0,0,0,.55); text-align: left; transform: translateX(-50%); pointer-events: none; }
.shard:hover > .shared-shard-tooltip, .shard:focus-visible > .shared-shard-tooltip { display: flex; }
.shared-shard-tooltip::before { content: ""; position: absolute; top: -5px; left: calc(50% - 5px); width: 9px; height: 9px; background: #111318; border-top: 1px solid var(--gold); border-left: 1px solid var(--gold); transform: rotate(45deg); }
.shared-shard-tooltip strong { color: var(--gold-light); font-size: .72rem; }
.shared-shard-tooltip b { color: #8ee59b; font-size: .72rem; }
.shared-shard-tooltip em, .shared-shard-tooltip i { color: #d1cab6; font-size: .65rem; font-style: normal; line-height: 1.35; }
.shared-shard-tooltip i { color: var(--muted); }
.capacity { display: flex; align-items: center; justify-content: space-between; margin: 0 13px 12px; padding: 8px; border: 1px solid var(--line); color: var(--gold-light); font-size: .77rem; text-transform: uppercase; }
.stat-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-height: 23px; padding: 3px 7px; font-size: .76rem; }
.stat-row:nth-of-type(even) { background: rgba(255,255,255,.035); }
.stat-row span { color: #e6ca67; }
.stat-row strong { color: #fff7d7; text-align: right; }
.mode-title, .section-title { margin: 11px 0 3px; padding: 5px 7px; background: #14151a; color: var(--gold-light); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; }
.section-title { border-top: 1px solid rgba(200,168,78,.22); }

.loadout-panel { padding-bottom: 15px; }
.special-slots { display: grid; grid-template-columns: repeat(2, minmax(125px, 190px)); justify-content: center; gap: 20px; padding: 26px 18px 15px; }
.mod-grid { display: grid; grid-template-columns: repeat(4, minmax(125px, 1fr)); gap: 15px 12px; padding: 12px 18px 24px; }
.mod-card { position: relative; display: flex; min-height: 112px; flex-direction: column; align-items: center; justify-content: center; padding: 16px 10px 24px; overflow: hidden; border: 1px solid rgba(183,194,203,.55); border-radius: 4px 4px 14px 14px; background: linear-gradient(155deg, rgba(102,120,127,.16), rgba(8,10,13,.95) 70%); text-align: center; box-shadow: inset 0 -3px 0 rgba(93,164,202,.48), 0 5px 10px rgba(0,0,0,.25); }
.mod-card::after { content: ""; position: absolute; right: 15%; bottom: 8px; left: 15%; height: 1px; background: var(--line); }
.mod-card.empty { min-height: 96px; opacity: .46; border-style: dashed; box-shadow: none; }
.mod-card.special { min-height: 88px; }
.mod-card small { color: var(--muted); font-size: .57rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.mod-card strong { margin-top: 5px; color: #f7edd0; font-size: clamp(.75rem, 1.2vw, .94rem); }
.mod-card p { display: -webkit-box; margin: 6px 0 0; overflow: hidden; color: #ccc5b1; font-size: .62rem; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.mod-card span { position: absolute; bottom: 10px; color: var(--gold-light); font-size: .58rem; font-weight: 700; text-transform: uppercase; }
.loadout-panel { overflow: visible; }
.mod-card.has-image { min-height: 142px; padding: 14px 7px 27px; overflow: visible; border-color: transparent; background: transparent; box-shadow: none; }
.mod-card.has-image::after { display: none; }
.mod-card.has-image > small { position: absolute; top: 1px; z-index: 1; padding: 2px 5px; color: var(--muted); background: rgba(12,13,16,.82); }
.shared-mod-image { display: block; width: min(100%, 190px); height: auto; max-height: 120px; object-fit: contain; filter: drop-shadow(0 6px 7px rgba(0,0,0,.38)); }
.mod-card.has-image > span { bottom: 3px; padding: 3px 7px; background: rgba(12,13,16,.9); border: 1px solid rgba(200,168,78,.42); border-radius: 3px; white-space: nowrap; }
.mod-card.special.has-image { min-height: 142px; }
.shared-mod-tooltip { position: absolute; z-index: 40; top: calc(100% + 7px); left: 50%; display: none; width: min(280px, calc(100vw - 28px)); padding: 12px; color: var(--text); background: #111318; border: 1px solid var(--gold); border-radius: 5px; box-shadow: 0 14px 32px rgba(0,0,0,.58); text-align: left; transform: translateX(-50%); pointer-events: none; }
.mod-card.filled:hover > .shared-mod-tooltip, .mod-card.filled:focus-visible > .shared-mod-tooltip { display: block; }
.shared-mod-tooltip::before { content: ""; position: absolute; top: -5px; left: calc(50% - 5px); width: 9px; height: 9px; background: #111318; border-top: 1px solid var(--gold); border-left: 1px solid var(--gold); transform: rotate(45deg); }
.shared-mod-tooltip strong { display: block; margin: 0 0 3px; color: var(--gold-light); font-size: .8rem; }
.shared-mod-tooltip b { display: block; margin-bottom: 7px; color: var(--muted); font-size: .62rem; text-transform: uppercase; }
.shared-mod-tooltip p { display: block; margin: 0; overflow: visible; color: #ded7c3; font-size: .7rem; line-height: 1.4; -webkit-line-clamp: unset; }
.rarity-rare { border-color: rgba(218,184,75,.7); box-shadow: inset 0 -3px 0 rgba(218,184,75,.62), 0 5px 10px rgba(0,0,0,.25); }
.rarity-legendary { border-color: rgba(185,205,219,.78); box-shadow: inset 0 -3px 0 rgba(124,205,229,.72), 0 5px 10px rgba(0,0,0,.25); }

.arcane-section, .notes { margin: 0 18px; padding: 15px 0 0; border-top: 1px solid rgba(200,168,78,.35); }
.arcane-section h2, .notes h2 { margin-bottom: 11px; color: var(--gold-light); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; }
.arcane-grid { display: grid; grid-template-columns: repeat(2, minmax(160px, 250px)); justify-content: space-around; gap: 18px; }
.arcane-card { display: flex; min-height: 100px; flex-direction: column; align-items: center; justify-content: center; gap: 5px; text-align: center; }
.arcane-emblem { display: grid; width: 66px; height: 50px; place-items: center; color: var(--gold-light); border: 2px solid var(--gold); border-radius: 48% 48% 34% 34%; box-shadow: inset 0 0 15px rgba(200,168,78,.15), 0 0 7px rgba(200,168,78,.2); font-size: 1.35rem; }
.arcane-card strong { color: var(--gold-light); font-size: .73rem; }
.arcane-card span { color: var(--muted); font-size: .62rem; }
.notes { margin-top: 20px; }
.notes p { min-height: 70px; padding: 13px; border: 1px solid rgba(200,168,78,.32); background: #15171b; color: #d3ccb7; font-size: .78rem; line-height: 1.55; white-space: normal; }
.calculation-notice { margin: 16px 18px 0; color: var(--muted); font-size: .68rem; }

.landing-shell, .state-shell { display: grid; min-height: calc(100vh - 130px); place-items: center; padding: 30px 16px; }
.landing-panel, .state-panel { width: min(620px, 100%); padding: clamp(28px, 6vw, 58px); background: rgba(29,32,37,.92); border: 1px solid var(--line); border-radius: 9px; text-align: center; box-shadow: 0 22px 60px rgba(0,0,0,.35); }
.landing-panel p, .state-panel p { color: #d0c8b2; line-height: 1.6; }
.landing-panel .muted { color: var(--muted); font-size: .82rem; }
.gold-rule { width: 80px; height: 1px; margin: 18px auto; background: var(--gold); }
.gold-button { display: inline-block; margin-top: 12px; padding: 10px 18px; border: 1px solid var(--gold); border-radius: 4px; color: var(--gold-light); background: rgba(200,168,78,.08); font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-decoration: none; text-transform: uppercase; }
.gold-button:hover { background: rgba(200,168,78,.16); }
footer { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 20px; padding: 14px clamp(18px, 4vw, 64px); color: #817b6b; border-top: 1px solid rgba(200,168,78,.22); font-size: .66rem; }

@media (max-width: 900px) {
    .viewer-grid { grid-template-columns: 1fr; }
    .equipment-panel { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(250px, 1fr); }
    .equipment-panel > header { grid-column: 1 / -1; }
    .equipment-identity { grid-row: span 3; }
    .mod-grid { grid-template-columns: repeat(2, minmax(125px, 1fr)); }
}

@media (max-width: 560px) {
    .site-header { min-height: 58px; }
    .site-label { display: none; }
    .viewer-shell { width: min(100% - 18px, 1460px); margin-top: 12px; }
    .build-heading { align-items: start; flex-direction: column; }
    .build-heading-actions { width: 100%; justify-items: start; }
    .build-meta { align-items: start; }
    .open-in-app-button { width: 100%; }
    .open-in-app-hint { max-width: none; text-align: left; }
    .equipment-panel { display: block; }
    .special-slots, .mod-grid, .arcane-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-right: 10px; padding-left: 10px; }
    .mod-card { min-height: 105px; }
    footer { align-items: start; flex-direction: column; }
}
