:root {
  --bg: #f7f6f3;
  --panel: #fff;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e2e0da;
  --accent: #8a5a00;
  --pos: #1f7a3a;
  --neg: #b3261e;
  --warn-bg: #fff3d6;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --panel: #1e1e1c;
    --text: #ecebe7;
    --muted: #9c9a94;
    --line: #34332f;
    --accent: #e0a63a;
    --pos: #5cc77d;
    --neg: #f07b72;
    --warn-bg: #3a2f14;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand { font-weight: 700; color: var(--accent); text-decoration: none; font-size: 1.1rem; }
/* The game switcher sits with the brand, small and quiet, rather than among the controls on the right. */
.brand-group { display: inline-flex; align-items: center; gap: 0.4rem; }
#game { font-size: 0.8rem; font-weight: 600; color: var(--accent); background: none; border: 1px solid var(--line);
  border-radius: 999px; padding: 0.05rem 0.4rem; cursor: pointer; }
nav { display: flex; gap: 1rem; }
nav a { color: var(--muted); text-decoration: none; }
nav a.active { color: var(--text); font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-left: auto; }
.controls input { width: calc(6ch + 2.2rem); } /* up to 6 digits, plus padding and the spinner */
.controls [hidden] { display: none; }
.start { display: inline-flex; align-items: center; gap: 0.4rem; }
.controls .league { margin-left: 1rem; } /* on top of the 1rem gap, to set League apart from the toggle */
.base-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.base-toggle button { display: inline-flex; border: 0; border-radius: 0; padding: 0.15rem 0.4rem; background: none; }
.base-toggle button + button { border-left: 1px solid var(--line); }
.base-toggle button .icon { margin: 0; }
.base-toggle button:not(.active) .icon { opacity: 0.4; }
.base-toggle button.active { background: var(--accent); }

main { max-width: 64rem; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.4rem; margin: 0.5rem 0; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.guide { max-width: 44rem; line-height: 1.6; }
.guide section { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0.25rem 1.25rem 0.5rem; margin: 1rem 0; }
.guide h2 { color: var(--accent); margin: 0.75rem 0 0.75rem; padding-bottom: 0.35rem; border-bottom: 2px solid var(--accent); }
.guide li { margin: 0.3rem 0; }
.guide .disclaimer {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 0.5rem 0 0; padding: 0.6rem 1rem;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 8px;
}
/* The link to the other game's site, at the top above the disclaimer. */
.guide .game-link { margin: 0.5rem 0 0; font-weight: 600; }
.guide .disclaimer .info { flex: none; width: 1.25rem; height: 1.25rem; color: var(--accent); }
.guide code { font-size: 0.95em; }
.icon { width: 1.4em; height: 1.4em; vertical-align: -0.35em; margin: 0 0.15em; }
.icon:first-child { margin-left: 0; } /* line up with text above, e.g. table headers */
p.split { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.25rem 1rem; }
h1 .icon { width: 1.6em; height: 1.6em; margin-right: 0.35em; }
/* The item page's volume, beside its heading but in body text style. */
h3 .sep { margin: 0 0.75rem; color: var(--muted); } /* between a route box's profit, gold and fill time */
h1 .item-volume { margin-left: 0.75rem; font-size: 0.9rem; font-weight: normal; vertical-align: middle; }
h1 .item-volume .icon { width: 1.4em; height: 1.4em; margin: 0 0.15em; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.profit { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.gold { color: var(--accent); white-space: nowrap; font-size: 0.9em; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.card.best { border-color: var(--accent); }
.card h2 { margin-top: 0; }
.big { font-size: 1.6rem; font-weight: 700; margin: 0.25rem 0; }

/* Trade summaries: each row stays one line high. Route, profit, gold, fill time and volume never wrap; the
   item name takes the slack and wraps instead. Too wide for the screen, the .scroll wrapper scrolls. */
table.summary th, table.summary td { white-space: nowrap; }
table.summary td:first-child { white-space: normal; min-width: 10rem; }
table.steps { margin-top: 0.75rem; width: auto; min-width: 100%; }
table.steps td, table.steps th { white-space: nowrap; }
/* Want / Have amounts copy their number on click (app.js); "copied" flashes a highlight. */
/* Cursor: the usual copy icon, two overlapping pages (the back one grey, the front white) with a dark outline
   so it shows on both themes; the hand if custom cursors aren't supported. */
.copy {
  cursor: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2224%22%20height=%2224%22%20viewBox=%220%200%2024%2024%22%3E%3Crect%20x=%223%22%20y=%223%22%20width=%2212%22%20height=%2214%22%20rx=%222%22%20fill=%22%23c8c8c8%22%20stroke=%22%23222%22%20stroke-width=%221.6%22/%3E%3Crect%20x=%229%22%20y=%227%22%20width=%2212%22%20height=%2214%22%20rx=%222%22%20fill=%22%23fff%22%20stroke=%22%23222%22%20stroke-width=%221.6%22/%3E%3C/svg%3E") 12 12, pointer;
  border-radius: 3px; transition: background-color 0.2s;
}
.copy:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.copy.copied { background: color-mix(in srgb, var(--accent) 35%, transparent); }
table.steps tr.sell td, table.steps tr.convert td { background: var(--bg); }
/* From the first main trade with a problem (can't trade a lot, no orders, thin stock) to the end. */
table.steps tr.bad td { background: color-mix(in srgb, var(--neg) 16%, var(--panel)); }

section.other {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  margin: 1.75rem 0;
}
section.other.top { border: 2px solid var(--accent); }
section.other h3 { margin: 0; font-size: 1rem; }
section.other.losing { opacity: 0.55; }
section.other.losing:hover, section.other.losing:focus-within { opacity: 0.85; }
button.save-trade, a.save-trade { margin-left: 0.75rem; padding: 0.1rem 0.5rem; font-size: 0.85rem; font-weight: 400; }
section.trade.done { opacity: 0.7; }
button.trade-toggle { padding: 0.1rem 0.5rem; font-size: 0.85rem; }
section.trade .trade-meta { margin: 0 0 0.4rem; font-size: 0.85rem; }
section.trade h3.trade-item a { color: inherit; text-decoration: none; }
section.trade h3.trade-item a:hover { color: var(--accent); text-decoration: underline; }
section.trade input[data-actual] { width: 7rem; margin-left: 0.4rem; }
section.trade .trade-actions { display: flex; align-items: center; gap: 0.35rem; }
button.icon-button { display: inline-flex; padding: 0.2rem; border: 0; background: none; color: var(--muted); }
button.icon-button svg { width: 1.25rem; height: 1.25rem; }
button.icon-button.complete { color: var(--pos); }
button.icon-button.delete { color: var(--neg); }
button.icon-button:hover { background: var(--line); }
h3.split { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; }
tr.losing { opacity: 0.5; }

.tag { display: inline-block; padding: 0 0.4rem; border-radius: 4px; font-size: 0.8rem; }
.tag.manual { background: var(--line); color: inherit; text-decoration: none; }
a.tag.manual:hover { background: var(--accent); color: var(--panel); }
button.reset { padding: 0.1rem 0.5rem; font-size: 0.85rem; }
.tag.warn { background: var(--warn-bg); }

.ratio-input { display: inline-flex; align-items: center; gap: 0.25rem; }
.ratio-input input { width: 6rem; }
table.ratios td.side { white-space: nowrap; }
table.ratios .vol { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.ratios tr.group th { padding-top: 1.5rem; color: var(--text); font-size: 0.95rem; border-bottom: 1px solid var(--line); }
table.ratios tbody:first-of-type tr.group th { padding-top: 0.6rem; }
.group-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; }
.group-head a { color: inherit; text-decoration: none; } /* a heading that links, not a blue link */
.group-head a:hover { color: var(--accent); text-decoration: underline; }
.group-head .muted { font-weight: 400; font-size: 0.85rem; text-align: right; }

input, select, button, .button {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
}
button, .button { cursor: pointer; padding: 0.3rem 0.8rem; }
button.danger { border-color: var(--neg); color: var(--neg); }

.confirm {
  background: var(--warn-bg);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin: 0.5rem 0 1rem;
}
.confirm .choices { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

.ratio-link {
  background: none;
  border: 0;
  border-bottom: 1px dashed var(--muted);
  border-radius: 0;
  padding: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ratio-link:hover { border-bottom-color: var(--accent); color: var(--accent); }
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  max-width: min(56rem, calc(100vw - 2rem));
}
dialog::backdrop { background: rgb(0 0 0 / 0.7); }
dialog { position: relative; padding-top: 2.25rem; }
dialog .close {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  border: 0;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.1rem 0.4rem;
  color: var(--muted);
}
dialog .close:hover { color: var(--text); }
dialog .dialog-title { font-weight: 600; font-size: 1.05rem; margin-bottom: 0.5rem; }
dialog .dialog-pair + .dialog-pair tr.group th { padding-top: 1.25rem; }
dialog tr.group th { border-bottom: 0; padding-left: 0; }
.tag.placeholder, button.reset.placeholder { visibility: hidden; }
th .ratio-link { font-weight: inherit; color: inherit; }
td.gold .ratio-link { color: inherit; }
select.method { padding: 0.1rem 0.3rem; font-size: 0.9rem; }
#search { width: min(24rem, 100%); }
table.gold-fees input { width: 7rem; }
table.gold-fees td:nth-child(2) { white-space: nowrap; } /* keep the "modified" tag beside the box */
button:disabled { opacity: 0.45; cursor: default; }
/* Tabs under a page heading, e.g. Rates: Modified | All. */
.tabs { display: flex; border-bottom: 1px solid var(--line); margin: 0.5rem 0 1rem; }
.tabs a { padding: 0.4rem 1rem; margin-bottom: -1px; border: 1px solid transparent; border-bottom: 0;
  border-radius: 6px 6px 0 0; color: var(--muted); text-decoration: none; }
.tabs a.active { background: var(--panel); border-color: var(--line); color: var(--text); font-weight: 600; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
button.destructive { background: var(--neg); border-color: var(--neg); color: #fff; }
.ratio-input input:first-child { text-align: right; } /* left box hugs the colon */
/* Space between the number and the spinner arrows (Chrome, Safari, Edge; Firefox can't style them). */
.ratio-input input::-webkit-inner-spin-button { margin-left: 0.4rem; }
.no-orders { margin-top: 0.2rem; }
.icon.unknown {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 700;
}
.route-tags { margin-top: 0.2rem; }
button.sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
button.sort:hover, button.sort.active { color: var(--text); }
.small { font-size: 0.8rem; white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
