:root {
  --bg: #0e1116; --bg-2: #161b22; --surface: #1c2230; --surface-2: #232b3a; --border: #2b3242;
  --text: #e6e9ef; --text-muted: #8b93a7; --accent: #ff9d3a; --accent-2: #ffb865;
  --good: #4ade80; --bad: #eb4b4b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: radial-gradient(1200px 500px at 50% -100px, #1a2130, var(--bg)) fixed;
  color: var(--text); min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.wrap { width: 100%; max-width: 1150px; margin: 0 auto; padding: 0 1.25rem; }
.muted { color: var(--text-muted); font-weight: 400; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.15rem; margin-bottom: 1rem; }

header { border-bottom: 1px solid var(--border); background: rgba(14,17,22,.85); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.25rem; }
h1 { font-size: 1.25rem; font-weight: 750; }
h1::before { content: "⚖️ "; }
.port-link { color: var(--text-muted); text-decoration: none; font-size: .9rem; }
.port-link:hover { color: var(--accent); }
h2 { font-size: 1.05rem; font-weight: 680; }
main { padding: 1.5rem 0 3rem; }

.btn { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: .5rem .9rem; transition: all .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #10131a; border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: var(--accent-2); }
.btn.primary:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn.big { width: 100%; padding: .7rem; font-size: 1.05rem; margin-top: .75rem; }

/* controls */
.controls { display: flex; gap: 1.5rem; align-items: flex-end; flex-wrap: wrap; }
.ctrl { display: flex; flex-direction: column; gap: .4rem; }
.ctrl.grow { flex: 1; min-width: 240px; }
.ctrl > label { font-size: .8rem; color: var(--text-muted); }
.rarity-tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.rtab { font: inherit; cursor: pointer; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); padding: .35rem .7rem; border-radius: 7px; font-size: .85rem; border-bottom: 3px solid var(--rc, var(--border)); }
.rtab.active { color: var(--text); background: var(--bg-2); }
#float-slider { width: 100%; accent-color: var(--accent); }
.switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: .15s; }
.switch .slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: var(--text-muted); border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(22px); background: #10131a; }

.layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.search { background: var(--bg-2); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: .4rem .7rem; font: inherit; font-size: .85rem; min-width: 160px; }
.search:focus { outline: none; border-color: var(--accent); }

/* input slots */
.input-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
.slot { aspect-ratio: 4/3; border: 1px dashed var(--border); border-radius: 7px; display: flex; align-items: center; justify-content: center; background: var(--bg-2); position: relative; }
.slot.filled { border-style: solid; border-bottom: 3px solid var(--rc, var(--border)); cursor: pointer; }
.slot img { max-width: 90%; max-height: 74%; object-fit: contain; }
.slot .x { position: absolute; top: 2px; right: 4px; font-size: .7rem; color: var(--text-muted); }
.slot.filled:hover .x { color: var(--bad); }

/* picker */
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; max-height: 420px; overflow-y: auto; }
.pick { background: var(--bg-2); border: 1px solid var(--border); border-bottom: 3px solid var(--rc, var(--border)); border-radius: 8px; padding: .5rem; cursor: pointer; text-align: left; transition: all .12s; }
.pick:hover { border-color: var(--accent); }
.pick:disabled { opacity: .4; cursor: default; }
.pick img { width: 100%; height: 54px; object-fit: contain; }
.pick .pn { font-size: .72rem; line-height: 1.2; margin-top: .25rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pick .pc { font-size: .64rem; color: var(--text-muted); margin-top: .15rem; }
.pick .pp { font-size: .72rem; color: var(--good); font-weight: 700; }

/* summary */
.summary-card .sum-row { display: flex; justify-content: space-between; padding: .3rem 0; font-size: .95rem; }
.sum-row b { font-variant-numeric: tabular-nums; }
.sum-row.big { border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .55rem; font-size: 1.1rem; }
.net.pos { color: var(--good); } .net.neg { color: var(--bad); }

/* outcomes */
.outcomes { display: flex; flex-direction: column; gap: .4rem; max-height: 460px; overflow-y: auto; }
.oc { display: grid; grid-template-columns: 52px 1fr auto; gap: .6rem; align-items: center; background: var(--bg-2); border: 1px solid var(--border); border-left: 4px solid var(--rc, var(--border)); border-radius: 8px; padding: .4rem .6rem; }
.oc img { width: 52px; height: 40px; object-fit: contain; }
.oc .on { font-size: .8rem; line-height: 1.2; }
.oc .osub { font-size: .68rem; color: var(--text-muted); }
.oc .oright { text-align: right; }
.oc .oprob { font-weight: 700; font-variant-numeric: tabular-nums; }
.oc .oprice { font-size: .75rem; color: var(--good); }
.warn { background: rgba(235,75,75,.1); border: 1px solid var(--bad); color: var(--accent-2); border-radius: 7px; padding: .5rem .7rem; font-size: .82rem; margin-bottom: .6rem; }

/* roll animation */
.reel-viewport { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: linear-gradient(var(--bg-2), var(--surface)); height: 108px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); }
.marker { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; background: var(--accent); transform: translateX(-50%); z-index: 3; box-shadow: 0 0 12px var(--accent); }
.reel { display: flex; height: 100%; align-items: center; will-change: transform; }
.reel-item { flex: 0 0 96px; height: 84px; margin: 0 4px; border-radius: 7px; background: var(--surface); border-bottom: 4px solid var(--rc, var(--border)); display: flex; align-items: center; justify-content: center; }
.reel-item img { max-width: 90%; max-height: 80%; object-fit: contain; }
.roll-result { text-align: center; margin-top: .8rem; }
.roll-result.show { animation: pop .35s ease; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.roll-result img { width: 200px; max-width: 70vw; height: 120px; object-fit: contain; }
.roll-result .rr-name { font-size: 1.1rem; font-weight: 700; }
.roll-result .rr-sub { color: var(--text-muted); font-size: .85rem; }
.roll-result .rr-net { font-weight: 700; margin-top: .3rem; }

footer { color: var(--text-muted); font-size: .8rem; padding: 1.5rem 1.25rem 2.5rem; text-align: center; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
