:root {
  --beton: #c9c6bd;
  --platte: #e6e3db;
  --platte-2: #d8d5cc;
  --ink: #26292d;
  --stahl: #5f6b74;
  --gelb: #f2b300;
  --rost: #a4432a;
  --gruen: #2e6b5e;
  /* Bauwerke */
  --putz: #ece3d0;
  --ziegel: #b8634a;
  --dach: #7d3a2a;
  --glas: #a9c3cf;
  --tuer: #4b4036;
  --wasser: #8fb0bd;

  --font: 'Archivo', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  --r: 3px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--beton);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { margin: 0; font-stretch: 118%; line-height: 1.1; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gelb); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--gelb);
  border: 2px solid var(--ink);
  border-radius: var(--r);
  padding: .5em 1em;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.btn.sm { padding: .3em .7em; font-size: 13px; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: var(--stahl); font-size: 13px; }
.chip {
  border: 2px solid var(--ink); background: transparent; border-radius: var(--r);
  padding: .15em .6em; font-weight: 700; font-size: 13px; cursor: pointer; margin-left: 4px;
}
.chip.on { background: var(--ink); color: var(--platte); }

/* ---------- Anmeldung ---------- */
#join { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.join-box { max-width: 460px; background: var(--platte); border: 2px solid var(--ink); border-radius: var(--r); padding: 28px; }
.join-box h1 { font-size: 56px; font-weight: 800; font-stretch: 125%; letter-spacing: -.01em; }
.join-box p { max-width: 60ch; }
.join-art { border-bottom: 2px solid var(--ink); margin: -28px -28px 20px; background: var(--platte-2); }
.join-art svg { display: block; width: 100%; height: auto; }
#joinForm label { display: block; font-weight: 700; margin-bottom: 6px; }
#joinForm input {
  width: 100%; font: inherit; font-size: 18px; padding: .5em .6em; margin-bottom: 12px;
  border: 2px solid var(--ink); border-radius: var(--r); background: #fff;
}

/* ---------- Kopf ---------- */
.top {
  display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: end; justify-content: space-between;
  padding: 16px 18px 12px; background: var(--ink); color: var(--platte);
}
.brand h1 { font-size: clamp(26px, 4vw, 40px); font-weight: 800; font-stretch: 125%; }
.brand .linkbtn { color: #b8bcbf; }
.hud { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0; }
.hud div { display: flex; flex-direction: column-reverse; }
.hud dt { font-size: 12px; color: #b8bcbf; }
.hud dd { margin: 0; font-size: 22px; font-weight: 700; font-stretch: 110%; }
.hud dd.neg { color: #ff9b85; }

.ticker {
  display: flex; flex-wrap: wrap; gap: 4px 24px;
  padding: 8px 18px; background: var(--gelb); border-bottom: 2px solid var(--ink); font-weight: 600;
}
.ticker em { font-style: normal; font-weight: 400; opacity: .75; margin-left: 4px; }
.ticker .calm { font-weight: 400; }

/* ---------- Raster ---------- */
.board {
  display: grid;
  grid-template-columns: minmax(380px, 1.15fr) minmax(340px, 1.2fr) minmax(320px, 1fr);
  gap: 14px; padding: 14px; align-items: start;
}
.col-right { display: grid; gap: 14px; }
.skyline { grid-column: 1 / -1; }
@media (max-width: 1250px) {
  .board { grid-template-columns: 1fr 1fr; }
  .col-right { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
}
@media (max-width: 780px) {
  .board { grid-template-columns: 1fr; padding: 10px; }
  .col-right { grid-template-columns: 1fr; }
}

.panel { background: var(--platte); border: 2px solid var(--ink); border-radius: var(--r); min-width: 0; }
.phead {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 2px solid var(--ink);
}
.phead h2 { font-size: 20px; font-weight: 800; }
.panel > div:not(.phead):not(.hazard), .panel > ol { padding: 12px 14px; }
.panel > .scrollx { padding: 0; overflow-x: auto; }
.hint { color: var(--stahl); font-size: 13px; margin: 8px 0 0; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.num { text-align: right; }

.qty { display: flex; align-items: center; font-size: 13px; }

/* ---------- Markt ---------- */
.mt { width: 100%; border-collapse: collapse; }
.mt th, .mt td { padding: 6px 8px; text-align: left; vertical-align: middle; }
.mt thead th { font-size: 12px; font-weight: 600; color: var(--stahl); border-bottom: 1px solid var(--ink); }
.mt thead th.num { text-align: right; }
.mt tbody tr + tr { border-top: 1px solid var(--platte-2); }
.mt tr.grp th { background: var(--platte-2); font-size: 13px; font-weight: 700; padding: 4px 8px; }
.mt tbody th[scope="row"] { font-weight: 700; }
.mt td.num strong { display: block; font-weight: 700; }
.mt small { display: block; font-size: 11px; color: var(--stahl); }
.mt .trend { white-space: nowrap; }
.mt .trade { white-space: nowrap; text-align: right; }
.spark { width: 72px; height: 22px; display: block; }
.spark polyline { fill: none; stroke-width: 1.6; stroke-linejoin: round; }
.spark.up polyline { stroke: var(--rost); }
.spark.down polyline { stroke: var(--gruen); }
small.up { color: var(--rost); }
small.down { color: var(--gruen); }

/* ---------- Betrieb ---------- */
.wg { font-size: 14px; margin: 14px 0 8px; }
.wg:first-child { margin-top: 0; }
.wlist { display: grid; gap: 8px; }
.bld { border: 2px solid var(--ink); border-radius: var(--r); padding: 8px 10px; background: #f3f1eb; }
.bld header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.bld h4 { font-size: 16px; }
.bld .lv { font-size: 12px; font-weight: 700; background: var(--ink); color: var(--platte); padding: 1px 6px; border-radius: 2px; }
.bld .recipe { margin: 4px 0 6px; font-size: 13px; }
.bld .per { color: var(--stahl); }
.bld .cost { margin: 0; font-size: 13px; color: var(--stahl); }
.bld .status { margin: 4px 0 0; font-size: 12px; font-weight: 600; }
.bld .prod { font-weight: 400; color: var(--stahl); margin-left: 6px; }
.bld .max { font-size: 12px; color: var(--stahl); }
.bld.new { background: transparent; border-style: dashed; border-color: var(--stahl); }
.bld.new .acts { margin-top: 6px; }
.bld.stuck { border-color: var(--rost); }
.bld.stuck .status { color: var(--rost); }
.bld.off { opacity: .7; }
.bld.constructing { background: repeating-linear-gradient(-45deg, #f3f1eb 0 12px, #efe6c8 12px 24px); }

.bar { height: 8px; background: var(--platte-2); border: 1px solid var(--ink); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); transition: width .9s linear; }
.bld.constructing .bar i { background: var(--gelb); }
.bar.hot i { background: var(--rost); }

/* ---------- Baustelle ---------- */
.hazard { height: 10px; background: repeating-linear-gradient(-45deg, var(--gelb) 0 12px, var(--ink) 12px 24px); border-bottom: 2px solid var(--ink); }
.site-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.site-head h3 { font-size: 22px; font-weight: 800; }
.reward { font-weight: 700; color: var(--gruen); }
.site-art { position: relative; margin: 10px 0; background: linear-gradient(#dfe4e3, var(--platte)); border: 1px solid var(--ink); border-radius: 2px; }
.site-art .pp { position: absolute; left: 10px; top: 6px; font-size: 32px; font-weight: 800; font-stretch: 125%; }
.site-art svg, .empty svg { display: block; width: 100%; height: auto; }
.empty p { margin: 8px 0 0; }
.needs { width: 100%; border-collapse: collapse; font-size: 13px; }
.needs th, .needs td { padding: 4px 6px; text-align: left; }
.needs thead th { color: var(--stahl); font-weight: 600; border-bottom: 1px solid var(--ink); }
.needs thead th.num { text-align: right; }
.needs tr.full { color: var(--stahl); text-decoration: line-through; }
.needs .miss { color: var(--rost); font-weight: 600; }

/* ---------- Aufträge ---------- */
.offer { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; }
.offer + .offer { border-top: 1px solid var(--platte-2); }
.othumb svg { width: 70px; height: auto; display: block; }
.offer h4 { font-size: 15px; }
.oneeds { margin: 2px 0; font-size: 12px; color: var(--stahl); }
.oreward { margin: 0; font-size: 13px; font-weight: 700; color: var(--gruen); }

/* ---------- Lager ---------- */
.cap span { font-size: 13px; display: block; margin-top: 4px; }
.stock { list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; }
.stock li { display: grid; grid-template-columns: 1fr 60px 90px; padding: 3px 0; }
.stock li + li { border-top: 1px solid var(--platte-2); }
.stock .val { color: var(--stahl); }

/* ---------- Skyline ---------- */
.sky { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: end; gap: 0 4px; border-bottom: 3px solid var(--ink); }
.sky li { width: 120px; text-align: center; font-size: 12px; }
.sky svg { width: 120px; height: auto; display: block; }
.sky svg .ground { display: none; }

/* ---------- Buch & Rangliste ---------- */
.log { list-style: none; margin: 0; max-height: 260px; overflow-y: auto; font-size: 13px; }
.log li { padding: 4px 0; }
.log li + li { border-top: 1px solid var(--platte-2); }
.log .t { color: var(--stahl); margin-right: 8px; font-size: 12px; }
.rank { margin: 0; padding-left: 34px !important; font-size: 14px; }
.rank li { padding: 4px 0; }
.rank .n { font-weight: 700; margin-right: 8px; }
.rank .v { font-weight: 700; }
.rank .s { display: block; font-size: 12px; color: var(--stahl); }
.rank li.me .n { background: var(--gelb); padding: 0 4px; }

/* ---------- SVG-Bauwerke ---------- */
.bsvg .w { fill: var(--putz); stroke: var(--ink); stroke-width: 1.2; }
.bsvg .b { fill: var(--ziegel); stroke: var(--ink); stroke-width: 1.2; }
.bsvg .r { fill: var(--dach); stroke: var(--ink); stroke-width: 1.2; }
.bsvg .c { fill: #bdb7aa; stroke: var(--ink); stroke-width: 1.2; }
.bsvg .d { fill: var(--tuer); stroke: var(--ink); stroke-width: 1; }
.bsvg .g { fill: var(--glas); stroke: var(--ink); stroke-width: 1; }
.bsvg .l { fill: none; stroke: var(--ink); stroke-width: 1; }
.bsvg .arch { fill: none; stroke: var(--dach); stroke-width: 5; }
.bsvg .water { fill: var(--wasser); }
.bsvg .ground { stroke: var(--ink); stroke-width: 2; }
.bsvg .ghost * { fill: none !important; stroke: var(--stahl) !important; stroke-width: .8 !important; stroke-dasharray: 3 3; }
.bsvg .crane path { fill: none; stroke: var(--gelb); stroke-width: 3; stroke-linecap: square; }
.bsvg .crane .hook { stroke: var(--ink); stroke-width: 1; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--platte); padding: 10px 16px; border-radius: var(--r);
  border-left: 6px solid var(--gelb); max-width: min(560px, calc(100vw - 24px));
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-weight: 600;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-left-color: var(--rost); }

@media (prefers-reduced-motion: reduce) {
  *, #toast { transition: none !important; }
}

/* Nachschliff: kompakte Karten für noch nicht gebaute Gebäude, keine Umbrüche in Preisen */
.mt td.num, .mt td.num strong, .mt small { white-space: nowrap; }
.bld.new { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; align-items: center; padding: 6px 10px; }
.bld.new header, .bld.new .recipe, .bld.new .cost { grid-column: 1; }
.bld.new .recipe { margin: 2px 0; }
.bld.new .acts { grid-column: 2; grid-row: 1 / span 3; margin: 0; }
.mt .trade { width: 1%; }
.mt .trade .btn { display: block; width: 100%; }
.mt .trade .btn + .btn { margin-top: 3px; }
.mt th, .mt td { padding: 6px 6px; }

/* ---------- Mehrspieler: Kopf, Chat, Neuigkeiten ---------- */
.who { margin: 4px 0 0; font-size: 13px; color: #b8bcbf; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.who #who { color: var(--platte); font-weight: 700; }
.conn::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; background: var(--stahl); }
.conn.on::before { background: #6fcf97; }
.conn.off::before { background: #ff9b85; }
.conn.wait::before { background: var(--gelb); }

.col-stack { display: grid; gap: 14px; align-content: start; }
.online { font-size: 12px; color: var(--stahl); max-width: 60%; text-align: right; }
.chatpanel .chatwrap { display: flex; flex-direction: column; gap: 8px; }
.chat { list-style: none; margin: 0; padding: 0; height: 300px; overflow-y: auto; font-size: 14px; }
.chat li { padding: 3px 0; overflow-wrap: anywhere; }
.chat li b { margin-right: 4px; }
.chat li .t { color: var(--stahl); font-size: 11px; margin-right: 6px; }
.chat li.mine b { background: var(--gelb); padding: 0 3px; }
.chatform { display: flex; gap: 6px; }
.chatform input {
  flex: 1; min-width: 0; font: inherit; padding: .35em .5em;
  border: 2px solid var(--ink); border-radius: var(--r); background: #fff;
}
