:root {
  color-scheme: dark;
  font: 15px/1.5 Inter, system-ui, sans-serif;
  color: #edf0f7;
  background: #0d1016;
  --muted: #a1abbe;
  --surface: #151a24;
  --border: #293141;
  --positive: #6ae4ac;
  --negative: #ff919d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main { max-width: 1200px; margin: auto; padding: 44px clamp(16px, 5vw, 56px); }
h1, h2, h3, p, dl, dd { margin: 0; }
.brand { display: flex; align-items: center; gap: 9px; color: #b9c8ff; font-weight: 650; font-size: .93rem; }
.mark { width: 17px; height: 17px; background: #91a8ff; clip-path: polygon(0 66%, 100% 4%, 100% 96%, 0 96%); }
h1 { font-size: clamp(2.15rem, 6vw, 3.45rem); line-height: 1.1; letter-spacing: -.055em; margin: 12px 0 26px; }
form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; max-width: 650px; }
.field { flex: 1 1 300px; min-width: 0; }
label { display: block; margin-bottom: 6px; font-size: .88rem; font-weight: 600; }
#wallet, button { height: 44px; border: 1px solid var(--border); border-radius: 9px; }
#wallet { width: 100%; background: var(--surface); color: inherit; padding: 0 12px; font: .88rem ui-monospace, monospace; }
input[aria-invalid="true"] { border-color: var(--negative); }
button { padding: 0 16px; background: #a9bbff; color: #101a36; font: 650 .93rem system-ui; cursor: pointer; }
button span { margin-right: 4px; }
button:hover { background: #c0cdff; }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 2px solid #b8c8ff; outline-offset: 3px; }
.muted { color: var(--muted); }
#wallet-help, .note { margin-top: 10px; font-size: .84rem; }
#totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 24px 0 30px; }
#totals > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; min-width: 0; }
dt { color: var(--muted); font-size: .83rem; }
dd { margin-top: 3px; font-size: clamp(1rem, 3vw, 1.5rem); font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
section { margin-top: 24px; }
.section-heading { display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; }
h2 { font-size: 1.35rem; letter-spacing: -.022em; }
#count { display: inline-block; vertical-align: 2px; margin-left: 5px; padding: 1px 8px; border-radius: 16px; background: var(--surface); color: var(--muted); font-size: .8rem; }
#status { font-size: .83rem; }
#error, .empty { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
#error { color: var(--negative); }
table { width: 100%; border-collapse: separate; border-spacing: 0 4px; font-variant-numeric: tabular-nums; }
th, td { padding: 13px 12px; text-align: right; }
th { padding-top: 0; padding-bottom: 5px; color: var(--muted); font-size: .82rem; font-weight: 600; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; width: 42%; }
td { white-space: nowrap; }
td:first-child { white-space: normal; border-radius: 10px 0 0 10px; }
td:last-child { border-radius: 0 10px 10px 0; }
tbody tr:nth-child(odd) { background: var(--surface); }
.market { display: flex; align-items: center; gap: 12px; }
.icon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 8px; object-fit: cover; background: var(--border); }
.title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.meta { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin-top: 4px; color: var(--muted); font-size: .84rem; }
.side { background: #2a3243; padding: 1px 7px; border-radius: 5px; }
.side.yes { color: var(--positive); background: #16332c; }
.side.no { color: var(--negative); background: #3f242e; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.pnl { display: block; font-size: .84rem; }

.secondary-button {
  background: var(--surface);
  color: #c8d3ff;
  white-space: nowrap;
}
.secondary-button:hover, .secondary-button[aria-expanded="true"] {
  border-color: #586b9e;
  background: #252e49;
}
#scenario-tools {
  padding: 14px 16px 8px;
  border: 1px solid #384665;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: #151b2b;
}
#scenario-tools h3 { font-size: 1rem; }
#scenario-help { margin-top: 3px; font-size: .86rem; }
.scenario-options { display: flex; align-items: center; flex-wrap: wrap; gap: 0 18px; }
.scope-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-height: 44px;
  cursor: pointer;
  font-size: .82rem;
}
#results input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: #a9bbff; cursor: pointer; }
.text-button { background: transparent; border: 0; color: #c8d3ff; padding: 0 6px; font-size: .82rem; }
.text-button:hover { background: #252e49; }
.text-button:disabled { opacity: .45; cursor: default; background: transparent; }
#scenario-summary {
  position: sticky;
  z-index: 1;
  top: 0;
  margin-bottom: 12px;
  padding: 10px 16px;
  border: 1px solid #384665;
  border-radius: 0 0 12px 12px;
  background: #1a2236;
}
.scenario-values { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; align-items: center; }
.scenario-scope { font-size: .88rem; font-weight: 600; }
#scenario-scope { font-size: .79rem; font-weight: 400; }
.scenario-values dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.scenario-values dd { margin-top: 0; line-height: 1.3; }
#scenario-conflict { color: var(--negative); font-size: .84rem; margin-top: 6px; overflow-wrap: anywhere; }
.win-toggle { display: none; }
.is-simulating .win-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  min-height: 44px;
  margin: 0;
  cursor: pointer;
}
.is-simulating tbody tr:has(.win-toggle input:checked) { background: #212c45; }
.is-simulating .win-toggle:has(:hover) { border-radius: 7px; background: #283552; }
.is-simulating .market { gap: 8px; }
.win-toggle input { scroll-margin-top: 170px; }

@media (max-width: 760px) {
  main { padding-top: 24px; }
  #totals > div { padding: 8px; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; padding: 12px; margin-bottom: 7px; border-radius: 10px; }
  tbody td { padding: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  tbody td:first-child { grid-column: 1 / -1; width: auto; padding-bottom: 7px; border-bottom: 1px solid var(--border); }
  .cell-label { display: block; color: var(--muted); font-size: .76rem; }
  .is-simulating .win-toggle { flex-basis: 44px; margin-left: -6px; }
}
@media (max-width: 520px) {
  .section-actions { flex-direction: row-reverse; justify-content: space-between; width: 100%; }
  .scenario-values { grid-template-columns: 1fr; }
  .scenario-values dd { font-size: 1.2rem; }
}
@media (min-width: 761px) {
  .cell-label { display: none; }
}
