:root {
  --bg: #0f141c;
  --panel: #171e29;
  --line: #263142;
  --text: #e8edf4;
  --muted: #8b97a8;
  --accent: #e0b44c;
  --sea: #0c1621;
  --neutral: #3a4354;
  --danger: #e2685a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }
.screen[hidden] { display: none !important; }

/* Karten-Bildschirme (Login, Wahl) */
#auth, #pick { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.card.wide { max-width: 720px; }
h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.02em; }
h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sub { margin: 0 0 20px; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 7px; color: var(--muted); }
.tabs button.on { background: var(--line); color: var(--text); }
form { display: grid; gap: 10px; }
input { font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.primary { border: 0; padding: 12px; border-radius: 10px; background: var(--accent); color: #1b1404; font-weight: 600; }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0 0; font-size: 14px; }
.only-register { display: none; }
form.register .only-register { display: block; }

.nations { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.nation-btn { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 16px; display: grid; gap: 6px; border-top: 4px solid var(--c); }
.nation-btn:disabled { opacity: .4; cursor: not-allowed; }
.nation-btn strong { font-size: 17px; }
.nation-btn small { color: var(--muted); }

/* Spiel */
#game { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.logo { color: var(--accent); white-space: nowrap; }
.ticker { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; overflow: hidden; }
.live { font-size: 11px; font-weight: 700; color: var(--danger); border: 1px solid var(--danger); border-radius: 4px; padding: 1px 5px; }
#ticker-track { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 14px; }
#me-badge { font-size: 14px; white-space: nowrap; }
#me-badge i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 340px; }
.map-wrap { min-height: 0; background: #06090e; display: grid; place-items: center; overflow: hidden; }
#map { width: 100%; height: 100%; touch-action: none; user-select: none; }
#map path { vector-effect: non-scaling-stroke; } /* Linien bleiben beim Zoomen gleich dick */
#map .region-labels { display: none; }
#map.labels .region-labels { display: block; }
#map.labels .country-labels { display: none; }
#map .country-border { fill: none; stroke: #05080d; stroke-width: 1.6; pointer-events: none; }
#map #own-glow { fill: none; stroke: #fff; stroke-width: 6; stroke-opacity: .35; stroke-linejoin: round; pointer-events: none; }
#map #own-border { fill: none; stroke-width: 2.5; stroke-linejoin: round; pointer-events: none; }
#map .country-labels text { font-weight: 700; letter-spacing: .12em; fill: rgba(255,255,255,.85); stroke-width: 2px; }
.map-wrap { position: relative; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: grid; gap: 6px; }
.zoom button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-size: 20px; line-height: 1; }
.zoom button:hover { background: var(--line); }
#map path { stroke: var(--bg); stroke-width: .5; fill-rule: evenodd; transition: fill .4s; cursor: pointer; }
#map path:hover { filter: brightness(1.25); }
#map path.sel { stroke: #fff; stroke-width: 2; }
#map path.nb { filter: brightness(1.15); }
#map text { font-size: var(--fs, 5.5px); fill: rgba(255,255,255,.75); pointer-events: none; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.55); stroke-width: calc(var(--fs, 5.5px) * .22); }
#map .capital { fill: var(--accent); stroke: #000; stroke-width: .8; }

.side { border-left: 1px solid var(--line); overflow-y: auto; padding: 12px; display: grid; gap: 12px; align-content: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.panel h3 { margin: 0 0 6px; font-size: 18px; }
.panel p { margin: 4px 0; color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.row .n { margin-left: auto; color: var(--muted); }
#online-list { list-style: none; margin: 0; padding: 0; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .top .logo { display: none; }
}

/* Meer & Hinterland */
#map .graticule { fill: none; stroke: rgba(150, 190, 230, .08); stroke-width: .6; pointer-events: none; }
#map .coast-halo { fill: none; stroke: #4f86b8; stroke-opacity: .28; stroke-width: 7; stroke-linejoin: round; pointer-events: none; }
#map .sheet { stroke: none; pointer-events: none; }
#map .world-edge-outer { fill: none; stroke: #c9a24a; stroke-opacity: .35; stroke-width: 7; pointer-events: none; }
#map .world-edge { fill: none; stroke: #e0b44c; stroke-width: 1.6; pointer-events: none; }

/* ── Seitenleiste: Reiter & Wirtschaft ── */
.side-tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; position: sticky; top: 0; z-index: 2; }
.side-tabs button { flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.side-tabs button.on { background: var(--line); color: var(--text); }
[data-pane] { display: grid; gap: 12px; }
[data-pane][hidden] { display: none; }
.panel h2:not(:first-child) { margin-top: 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.warn { color: var(--danger); font-weight: 600; }
.bar { position: relative; height: 22px; border-radius: 11px; background: var(--bg); overflow: hidden; border: 1px solid var(--line); }
.bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #3bb36f, #8ad84c); transition: width .4s; }
.bar span { position: relative; display: block; text-align: center; font-size: 13px; line-height: 20px; font-weight: 600; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.stats div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.stats small { display: block; color: var(--muted); font-size: 12px; }
.stats strong { font-size: 18px; }
.btns { display: flex; gap: 8px; margin-top: 8px; }
.btns button:not(.primary), .side button:not(.primary) { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.side button.primary { padding: 9px 12px; font-size: 14px; }
.side button:disabled { opacity: .4; cursor: not-allowed; }
table.inv, table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.inv td, table.list td { padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
table.list small { color: var(--muted); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td:last-child { text-align: right; }
tr.mine td { background: rgba(224, 180, 76, .08); }
.company { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 8px; background: var(--bg); }
.company small { color: var(--muted); }
.company p { margin: 6px 0; font-size: 14px; color: var(--text); }
.row-in { display: flex; gap: 6px; margin-top: 6px; }
.row-in input { flex: 1; min-width: 0; padding: 7px 8px; font-size: 13px; border-radius: 8px; }
.found { display: grid; gap: 8px; }
.found select { font: inherit; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.good { border-top: 1px solid var(--line); padding: 10px 0; }
.good-head { display: flex; justify-content: space-between; align-items: baseline; }
.good-head span { color: var(--muted); font-size: 13px; }
.book { font-size: 13px; margin: 4px 0; font-variant-numeric: tabular-nums; }
#region-info button { margin-top: 8px; width: 100%; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2a38; border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 50; max-width: calc(100vw - 32px); font-size: 14px; }
#toast.bad { border-color: var(--danger); color: #ffd5cf; }
/* Seitenleiste darf nie breiter werden als ihre Spalte (Grid-Kinder haben sonst min-width:auto) */
.side { overflow-x: hidden; }
.side > *, [data-pane] > *, .panel { min-width: 0; }
.row-in button { flex: none; }
.row-in input[data-f="bqty"] { flex: 0 1 80px; }
.row-in input[data-f="sqty"], .row-in input[data-f="price"] { flex: 1 1 0; }

/* Startland-Wahl: 87 Länder */
.card.wide { max-width: 980px; }
.search { width: 100%; margin-bottom: 14px; }
#pick .nations { max-height: 62vh; overflow-y: auto; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); padding-right: 4px; }
.nation-btn { padding: 12px 14px; }
.nation-btn strong { font-size: 15px; }
