:root {
  --bg: #f3ece0;
  --card: #fffaf2;
  --text: #2b2420;
  --muted: #7a6d62;
  --line: #e3d6c3;
  --accent: #c0392b;
  --accent-text: #fff;
  --board: #f6dca0;
  --board-edge: #d9b56b;
  --field: #fffdf6;
  --field-stroke: #5b4a3a;
  --shadow: 0 2px 10px rgba(60, 40, 20, .12);
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --card: #292524;
    --text: #f5f0ea;
    --muted: #a8a29e;
    --line: #44403c;
    --board: #4a3a26;
    --board-edge: #6b5436;
    --field: #f4ead6;
    --field-stroke: #1c1917;
    --shadow: 0 2px 10px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
h1, h2 { margin: 0; }
h2 { font-size: 1rem; color: var(--muted); font-weight: 600; margin-bottom: .5rem; }

.btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: .6rem 1rem; border-radius: 10px; cursor: pointer; font-weight: 600;
  transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: .35rem .7rem; font-size: .875rem; }
.btn.big { padding: .8rem 1.4rem; font-size: 1.1rem; }

input {
  font: inherit; padding: .6rem .8rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); min-width: 0; flex: 1;
}
.row { display: flex; gap: .5rem; }
.row > .btn { flex: 1; }
form.row > .btn { flex: 0 0 auto; }
.col { display: flex; flex-direction: column; gap: .5rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.error { color: var(--accent); min-height: 1.2em; margin: .5rem 0 0; }
.hint { color: var(--muted); font-size: .875rem; margin: .5rem 0 0; }

/* Start */
#home { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.home-card { width: 100%; max-width: 420px; padding: 2rem 1.5rem; }
.home-card h1 { font-size: 2.2rem; line-height: 1.05; letter-spacing: -.02em; }
.sub { color: var(--muted); margin: .6rem 0 1.5rem; }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.25rem; }
.field span { font-weight: 600; font-size: .9rem; }
.block { margin-bottom: 1.25rem; }
#join-code { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }

/* Raum */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .5rem 16px; flex-wrap: wrap;
}
.code strong { letter-spacing: .15em; font-size: 1.1rem; }
.top-right { display: flex; align-items: center; gap: .25rem; }
.conn { font-size: .8rem; color: var(--muted); min-width: 6rem; text-align: right; }
.conn.bad { color: var(--accent); }

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px;
  padding: 0 16px 16px; max-width: 1280px; margin: 0 auto; align-items: start;
}
@media (max-width: 860px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.side { display: flex; flex-direction: column; gap: 12px; }

.board-wrap { position: relative; }
#board { width: 100%; height: auto; max-height: calc(100vh - 80px); display: block; margin: 0 auto; }
.banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--card); padding: 1rem 1.5rem; border-radius: var(--radius);
  box-shadow: 0 6px 30px rgba(0,0,0,.25); text-align: center; font-size: 1.1rem; max-width: 90%;
}
.banner ol { text-align: left; margin: .5rem 0 0; padding-left: 1.4rem; }

/* Brett */
.b-bg { fill: var(--board); stroke: var(--board-edge); stroke-width: .12; }
.f { stroke: var(--field-stroke); stroke-width: .06; }
.f.plain { fill: var(--field); }
.f.target { stroke: var(--text); stroke-width: .12; stroke-dasharray: .15 .1; }
.lbl { font-size: .45px; font-weight: 700; fill: var(--muted); text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.seat-name { font-size: .5px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }

.pc { transition: transform .24s ease-in-out; }
.pc .body { stroke: rgba(0,0,0,.55); stroke-width: .05; }
.pc .shine { fill: rgba(255,255,255,.45); pointer-events: none; }
.pc.movable { cursor: pointer; }
.pc.movable .ring { stroke: var(--text); stroke-width: .07; fill: none; animation: pulse 1s infinite; }
.pc .ring { fill: none; }
@keyframes pulse { 0%,100% { stroke-opacity: 1; } 50% { stroke-opacity: .15; } }
.ghost-target { fill: none; stroke: var(--text); stroke-width: .08; stroke-dasharray: .12 .08; pointer-events: none; }
.turn-glow { fill: none; stroke-width: .12; animation: pulse 1.4s infinite; }

/* Lobby */
.seg-control { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: .75rem; }
.seg-control button { flex: 1; font: inherit; border: 0; padding: .5rem; background: transparent; color: var(--text); cursor: pointer; }
.seg-control button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg-control.disabled button { cursor: default; }
.seats, .players, .log { list-style: none; margin: 0; padding: 0; }
.seats li, .players li {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem; border-radius: 10px;
}
.seats li + li, .players li + li { margin-top: 2px; }
.dot { width: 18px; height: 18px; border-radius: 50%; flex: 0 0 auto; border: 2px solid rgba(0,0,0,.25); }
.seat-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-label .tag { color: var(--muted); font-size: .8rem; margin-left: .3rem; }
.seat-label.empty { color: var(--muted); font-style: italic; }
.seats .btn { padding: .25rem .55rem; font-size: .8rem; }
#host-controls { margin-top: .75rem; }

/* Spiel */
.dice-area { display: flex; gap: 1rem; align-items: center; margin-bottom: .75rem; }
.dice-info { flex: 1; display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.turn-label { font-weight: 700; }
.dice {
  width: 76px; height: 76px; border-radius: 16px; background: #fff; border: 4px solid var(--line);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 10px; flex: 0 0 auto;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.08);
}
.dice.rolling { animation: shake .7s; }
@keyframes shake {
  0% { transform: rotate(0) } 25% { transform: rotate(-18deg) scale(1.08) }
  50% { transform: rotate(14deg) } 75% { transform: rotate(-8deg) } 100% { transform: rotate(0) }
}
.pip { width: 12px; height: 12px; border-radius: 50%; background: #222; place-self: center; }
.players li.turn { background: var(--bg); font-weight: 700; }
.players .rank { font-size: .8rem; color: var(--muted); }
.progress { display: flex; gap: 3px; }
.progress i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.progress i.home { background: currentColor; }
#over-controls { margin-top: .75rem; }

/* Log */
.log-card { display: flex; flex-direction: column; gap: .5rem; }
.log { max-height: 240px; overflow-y: auto; font-size: .875rem; display: flex; flex-direction: column; gap: 3px; }
.log li { line-height: 1.35; padding-left: .6rem; border-left: 3px solid transparent; }
.log li.chat b { font-weight: 700; }
.log li.sys { color: var(--muted); font-style: italic; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 10; max-width: calc(100% - 32px);
}
