:root {
  --bg: #0a0e14; --panel: #111823; --panel-2: #0d131c; --line: #1f2a3a;
  --text: #d7e3f1; --muted: #8296ae; --accent: #38d0ff; --accent-2: #b98cff;
  --up: #3ddc84; --down: #ff5d6c; --warn: #ffc857;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font: 15px/1.45 var(--mono); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: radial-gradient(1200px 600px at 20% -10%, #14213a 0%, transparent 60%), var(--bg); }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 700; letter-spacing: .04em; }
h1 { color: var(--accent); text-shadow: 0 0 12px rgba(56, 208, 255, .5); font-size: 1.25rem; }
h2 { font-size: .85rem; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: .35rem; margin-bottom: .75rem; }
h3 { font-size: .8rem; text-transform: uppercase; color: var(--muted); margin-top: 1.25rem; }
a { color: var(--accent); }
p { margin: .25rem 0 .75rem; }
small { color: var(--muted); font-size: .75em; }
code { color: var(--accent-2); word-break: break-all; }
[hidden] { display: none !important; }

button, .btn {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .45rem .8rem; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--accent); color: #041018; border-color: var(--accent); font-weight: 700; }
button.sell { background: var(--warn); color: #1a1200; border-color: var(--warn); font-weight: 700; }
button.ghost { background: transparent; }
button.link { background: none; border: 0; padding: 0; color: var(--down); text-decoration: underline; font-size: .8rem; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
input {
  font: inherit; color: var(--text); background: #060a10; border: 1px solid var(--line);
  border-radius: var(--radius); padding: .45rem .6rem; width: 100%;
}
input:focus { border-color: var(--accent); outline: none; }
input[readonly] { color: var(--muted); }
label { display: block; font-size: .75rem; color: var(--muted); margin: .75rem 0 .25rem; text-transform: uppercase; }

.num { font-variant-numeric: tabular-nums; text-align: right; }
.hint { color: var(--muted); font-size: .85rem; }
.alert { background: rgba(255, 93, 108, .12); border: 1px solid var(--down); color: #ffb3ba; padding: .6rem .8rem; border-radius: var(--radius); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; min-width: 0; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.num, td.num { text-align: right; }
thead th { font-size: .75rem; text-transform: uppercase; color: var(--muted); }
tbody th { font-weight: 400; }
tr.me td { color: var(--accent); }
.trend.up { color: var(--up); }
.trend.down { color: var(--down); }
.trend.flat { color: var(--muted); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: #3a4656; vertical-align: middle; flex: none; }
.dot.on { background: var(--up); box-shadow: 0 0 6px var(--up); }

/* landing */
.landing { max-width: 720px; margin: 0 auto; padding: 3rem 1rem; }
.brand { text-align: center; margin-bottom: 2rem; }
.brand h1 { font-size: 2.2rem; }
.brand p { color: var(--muted); }
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card button { width: 100%; margin-top: 1.25rem; }
fieldset.modes { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .75rem .25rem; margin: .75rem 0 0; }
fieldset.modes legend { font-size: .75rem; color: var(--muted); text-transform: uppercase; padding: 0 .3rem; }
label.mode { display: flex; gap: .5rem; align-items: baseline; text-transform: none; font-size: .95rem; color: var(--text); margin: .3rem 0 .6rem; cursor: pointer; }
label.mode input { width: auto; margin: 0; flex: none; }
label.mode small { display: block; color: var(--muted); }
.rules { margin-top: 2rem; color: var(--muted); font-size: .9rem; }
.rules ul { padding-left: 1.2rem; }

/* game */
#game { max-width: 1200px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.topbar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; }
.meta { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.clock { font-size: 1.3rem; font-weight: 700; color: var(--up); min-width: 5ch; text-align: right; }
.clock.urgent { color: var(--down); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.dash { display: grid; gap: 1rem; grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); }
@media (max-width: 860px) { .dash { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; }
.travel, .players, .standings, .events, .news { list-style: none; margin: 0; padding: 0; }
.travel { display: grid; gap: .4rem; }
.travel button { width: 100%; text-align: left; display: flex; justify-content: space-between; gap: .5rem; }
.travel button.here { border-style: dashed; }
.ready { color: var(--up); font-weight: 700; }
.travel button.going { border-color: var(--warn); color: var(--warn); }
.players li, .standings li { display: flex; gap: .6rem; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.standings .rank { color: var(--muted); width: 2ch; }
.standings .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.standings .loc { color: var(--muted); font-size: .85rem; }
.standings li.me .name { color: var(--accent); }
.events li { color: var(--warn); padding: .3rem 0; }
.news li { padding: .3rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.news .turn { color: var(--muted); margin-right: .4rem; }
.news li.event { color: var(--warn); }
.news li.system { color: var(--accent-2); }
.news.you li.police, .news.you li.mugging { color: var(--down); }
.news.you li.find, .news.you li.gun, .news.you li.storage { color: var(--up); }
.news.you li.flavor { color: var(--muted); font-style: italic; }
[data-health].low, [data-debt].low { color: var(--down); }
.out, small.out { color: var(--down); }
tr.out td { color: var(--muted); text-decoration: line-through; }
tr.out td small { text-decoration: none; }
.results .winner.nobody { color: var(--down); }
.services { margin: .75rem 0 .25rem; }
.services button { font-size: .9rem; }
dialog.encounter { border-color: var(--warn); }
.enc-log { list-style: none; margin: .5rem 0; padding: .5rem .75rem; border-left: 3px solid var(--line); color: var(--muted); font-size: .9rem; max-height: 12rem; overflow-y: auto; }
.enc-log li { padding: .15rem 0; }
.enc-log li:last-child { color: var(--text); }
.results .winner { font-size: 1.4rem; color: var(--up); text-align: center; margin: .5rem 0 1rem; }
.results .btn { margin-top: 1rem; }
.lobby .primary { margin-top: .5rem; }

/* dialog */
dialog.trade { background: var(--panel); color: var(--text); border: 1px solid var(--accent); border-radius: var(--radius); padding: 1.25rem; width: min(92vw, 400px); }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
.row { display: flex; gap: .5rem; margin: .5rem 0; align-items: center; flex-wrap: wrap; }
.row input { flex: 1; min-width: 6rem; }

/* toasts */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; max-width: min(90vw, 360px); z-index: 10; }
.toast { background: var(--panel); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: .6rem .8rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); font-size: .9rem; transition: opacity .4s, transform .4s; }
.toast.error { border-color: var(--down); }
.toast.ok { border-color: var(--up); }
.toast.event { border-color: var(--warn); }
.toast.market { border-color: var(--accent-2); }
.toast.out { opacity: 0; transform: translateX(20px); }
