:root {
  --bg: #0f2233;
  --panel: #172f45;
  --panel-2: #1f3b56;
  --line: #2c4d6c;
  --text: #eef3f8;
  --muted: #9db2c7;
  --accent: #f2b33d;
  --accent-ink: #2a1d05;
  --good: #3fb871;
  --bad: #e25b5b;
  --sea: #2b6ca3;
  --radius: 12px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 12px; cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { border-color: var(--bad); color: #ffd9d9; }
button.active { outline: 2px solid var(--accent); outline-offset: 1px; }
button.small { padding: 4px 8px; font-size: 13px; }
input, select {
  background: #0c1b29; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:disabled, select:disabled { opacity: .75; }
h1, h2, h3 { margin: 0 0 10px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}

/* ---------- Start & Lobby */
.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.start { width: min(420px, 100%); display: grid; gap: 14px; }
.logo { font-size: 34px; font-weight: 800; letter-spacing: .5px; display: flex; gap: 10px; align-items: center; }
.logo img { width: 42px; height: 42px; }
.start label { display: grid; gap: 6px; }
.lobby { width: min(960px, 100%); display: grid; gap: 14px; grid-template-columns: 1fr 1fr; padding: 16px; margin: 0 auto; }
.lobby .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .lobby { grid-template-columns: 1fr; } }
.code { font-size: 30px; font-weight: 800; letter-spacing: 6px; color: var(--accent); }
.plist { display: grid; gap: 6px; }
.pitem { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 9px; background: var(--panel-2); }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0,0,0,.4); flex: none; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.swatch.sel { border-color: var(--text); }
.swatch:disabled { opacity: .2; }
.settings { display: grid; gap: 10px; }
.setting { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.setting small { display: block; color: var(--muted); font-size: 12px; }
.setting input[type=number] { width: 80px; }
.setting input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.badge { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: #0c1b29; color: var(--muted); }
.offline { opacity: .5; }

/* ---------- Chat */
.chat { display: grid; grid-template-rows: 1fr auto; gap: 8px; min-height: 0; }
.chatlog, .log { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.chatlog { max-height: 220px; }
.log .own { color: var(--accent); }
.sys { color: var(--muted); font-style: italic; }

/* ---------- Spiel */
.game {
  height: 100dvh; display: grid; gap: 8px; padding: 8px;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top side" "board side" "hand side";
}
.topbar { grid-area: top; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.status { font-weight: 600; flex: 1; min-width: 180px; }
.status.me { color: var(--accent); }
.boardwrap { grid-area: board; min-height: 0; background: radial-gradient(circle at 50% 45%, #2f78b3, #1b4a75 70%); border-radius: var(--radius); position: relative; overflow: hidden; }
.boardwrap svg { width: 100%; height: 100%; display: block; touch-action: manipulation; }
.side { grid-area: side; display: grid; gap: 8px; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.hand { grid-area: hand; display: grid; gap: 8px; }
@media (max-width: 900px) {
  .game {
    height: auto; min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "top" "board" "hand" "side";
    padding: 6px;
  }
  .boardwrap svg { height: auto; }
  .side { grid-template-rows: auto 340px; }
  .rcard { min-width: 48px; padding: 4px 6px; }
}
.dice { display: flex; gap: 4px; }
.die {
  width: 32px; height: 32px; border-radius: 7px; background: #fff; color: #222; display: grid; place-items: center;
  font-weight: 800; font-size: 18px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15);
}
.die.red { background: #e9483f; color: #fff; }

.players { display: grid; gap: 6px; }
.player { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 4px; }
.player.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.player .top { display: flex; gap: 8px; align-items: center; }
.player .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .vp { font-weight: 800; font-size: 18px; }
.player .stats { display: flex; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.player .stats .on { color: var(--accent); font-weight: 700; }

.tabs { display: flex; gap: 4px; }
.tabs button { flex: 1; padding: 6px; }
.tabbox { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 6px; min-height: 0; }

.cards { display: flex; gap: 6px; flex-wrap: wrap; }
.rcard {
  min-width: 54px; padding: 6px 8px; border-radius: 9px; text-align: center; background: var(--panel-2);
  border: 1px solid var(--line); display: grid; gap: 1px;
}
.rcard .em { font-size: 20px; line-height: 1.1; }
.rcard .n { font-weight: 800; }
.rcard .lbl { font-size: 10px; color: var(--muted); }
.rcard.zero { opacity: .35; }
.rcard.dev { background: #2c2350; border-color: #4f3f8a; }
.rcard.dev.new { opacity: .55; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions .cost { font-size: 11px; opacity: .8; margin-left: 4px; }

/* Handelsbanner */
.offer { background: #2a3f1f; border: 1px solid #4f7a35; border-radius: 10px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- SVG-Brett */
.hex { stroke: #f2e6c4; stroke-width: 2.5; stroke-linejoin: round; }
.hex.hit { animation: glow 1.4s ease-out 1; }
@keyframes glow { 0% { filter: brightness(1.6); } 100% { filter: none; } }
.token { fill: #f5ecd2; stroke: #6b5a3a; stroke-width: 1.5; }
.tnum { font-weight: 800; text-anchor: middle; dominant-baseline: central; fill: #2a2015; }
.tnum.red { fill: #c62828; }
.pip { fill: #2a2015; }
.pip.red { fill: #c62828; }
.road { stroke-linecap: round; }
.target { cursor: pointer; }
.vtarget { fill: rgba(255,255,255,.85); stroke: #1b1b1b; stroke-width: 2; animation: pulse 1.1s ease-in-out infinite; }
.etarget { stroke: rgba(255,255,255,.75); stroke-linecap: round; animation: pulse 1.1s ease-in-out infinite; }
.htarget { fill: rgba(255,255,255,.18); stroke: #fff; stroke-width: 3; stroke-dasharray: 8 6; }
.htarget:hover { fill: rgba(255,255,255,.35); }
@keyframes pulse { 50% { opacity: .45; } }
.harbor text { font-size: 13px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }

/* ---------- Dialoge & Meldungen */
.modal-bg { position: fixed; inset: 0; background: rgba(4, 12, 20, .65); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal { width: min(480px, 100%); max-height: 90dvh; overflow: auto; display: grid; gap: 12px; }
.picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 6px; }
.picker .rcard { cursor: pointer; user-select: none; }
.picker .rcard.sel { border-color: var(--accent); background: #3d3313; }
.stepper { display: flex; justify-content: center; gap: 4px; }
.stepper button { padding: 2px 8px; }
#toasts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: grid; gap: 6px; z-index: 20; width: min(420px, calc(100% - 32px)); }
.toast { background: #3a1f24; border: 1px solid var(--bad); padding: 10px 12px; border-radius: 10px; animation: fade 4s forwards; }
.toast.info { background: #1f3a2b; border-color: var(--good); }
@keyframes fade { 85% { opacity: 1; } 100% { opacity: 0; } }
.winner { font-size: 26px; font-weight: 800; color: var(--accent); }
.bars { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; align-items: end; height: 90px; }
.bars div { background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars span { font-size: 11px; text-align: center; color: var(--muted); }
.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--bad); text-align: center; padding: 4px; font-size: 13px; z-index: 30; }

/* ---------- Städte & Ritter */
.die.yellow { background: #f2cf3a; color: #2a2015; }
.barb { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btrack { display: inline-flex; gap: 3px; }
.bstep { width: 12px; height: 12px; border-radius: 3px; background: #0c1b29; border: 1px solid var(--line); }
.bstep.on { background: #c0392b; border-color: #e66; }
.evdie { width: 30px; height: 30px; border-radius: 7px; background: #fff; display: grid; place-items: center; font-size: 17px; }
.lvls { display: inline-flex; gap: 3px; margin-left: auto; }
.lvl { min-width: 20px; padding: 0 4px; border-radius: 5px; color: #fff; font-weight: 700; font-size: 11px; text-align: center; text-shadow: 0 1px 1px rgba(0,0,0,.5); }
.improve { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.impbtn { border-left: 5px solid var(--ic); display: grid; text-align: left; gap: 1px; padding: 5px 10px; }
.impname { font-weight: 600; font-size: 13px; letter-spacing: .5px; }
.impbtn .cost { margin: 0; font-size: 11px; }
.rcard.com { background: #2a2a40; }
.rcard.prog { width: 132px; text-align: left; background: #1d2a3d; border-width: 2px; align-content: start; }
.pname { font-weight: 700; font-size: 13px; }
.ptext { font-size: 10px; line-height: 1.25; max-height: 3.8em; overflow: hidden; }
.vtarget.sel { fill: #ffe27a; }
.offer.pend { background: #3a2f12; border-color: #a8862c; }
.knight.active circle { filter: drop-shadow(0 0 3px #ffe27a); }
select.small { padding: 3px 6px; font-size: 13px; }
.badge.danger { background: #5a1f1f; color: #ffd0d0; animation: pulse 1.4s ease-in-out infinite; }

/* ---------- Grafiken (Blender) */
.ico { width: 1.35em; height: 1.35em; vertical-align: -0.35em; object-fit: contain; }
.em .ico { width: 34px; height: 34px; vertical-align: middle; }
.rcard .em { line-height: 1; height: 34px; }
.cost .ico { width: 1.2em; height: 1.2em; margin-left: -2px; }
image.hit { animation: glow 1.4s ease-out 1; }
.tnum { font-family: Georgia, 'Times New Roman', serif; }
.hlabel { font: 800 15px Georgia, serif; fill: #2a2015; text-anchor: middle; dominant-baseline: central; }
.hlabel.small { font-size: 12px; }
.kglow { fill: #ffe27a; opacity: .75; filter: blur(3px); }
.boardwrap { background: #0b2f4f url(/assets/sea-bg.webp) center / 420px repeat; }
