:root {
  --bg: #0b1422;
  --panel: rgba(17, 27, 44, .86);
  --panel-solid: #142036;
  --panel-2: rgba(30, 44, 68, .9);
  --line: rgba(255, 255, 255, .09);
  --text: #e9eef6;
  --muted: #93a4bb;
  --accent: #f5b942;
  --accent-2: #ffcf6b;
  --ok: #34c06a;
  --err: #ef5350;
  --blue: #3d8bfd;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% 40%, #16325a 0%, transparent 60%),
    radial-gradient(900px 600px at 85% 100%, #0f3b4a 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0 0 .5em; font-weight: 700; letter-spacing: .01em; }
button { font: inherit; color: inherit; }
a { color: var(--accent-2); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(255,255,255,.07); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 13px; cursor: pointer; font-weight: 600; font-size: 14px;
  transition: background .15s, transform .05s, box-shadow .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,.13); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #2a1c00; border-color: transparent; box-shadow: 0 4px 14px rgba(245,185,66,.3); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ffe08f, var(--accent-2)); }
.btn.ok { background: linear-gradient(180deg, #4fd283, var(--ok)); color: #04220f; border-color: transparent; }
.btn.danger { background: rgba(239,83,80,.15); border-color: rgba(239,83,80,.4); color: #ff8a87; }
.btn.active { background: rgba(245,185,66,.2); border-color: var(--accent); color: var(--accent-2); box-shadow: 0 0 0 3px rgba(245,185,66,.18); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 12px 18px; font-size: 16px; width: 100%; }
.btn.icon { width: 34px; height: 34px; padding: 0; border-radius: 50%; }
select, input {
  font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(0,0,0,.25); color: var(--text); outline: none;
}
select option { background: var(--panel-solid); }
select:focus, input:focus { border-color: var(--accent); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 16px;
}
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.sec-title { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }

/* Login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login .logo { font-size: 46px; text-align: center; line-height: 1; }
.login h1 { font-size: 30px; text-align: center; margin: 0; }
.login .sub { text-align: center; margin: -8px 0 6px; color: var(--muted); }
.login label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; color: var(--muted); }
.err { color: var(--err); min-height: 1.2em; font-size: 14px; }

/* Topbar */
.topbar {
  min-height: 58px; display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: rgba(8, 14, 24, .7); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
  position: relative; z-index: 5; flex-wrap: wrap;
}
.topbar .brand { font-size: 20px; font-weight: 800; letter-spacing: .02em; }
.topbar .title { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.topbar .spacer { flex: 1; }

/* Lobby */
.lobby-main { max-width: 960px; margin: 24px auto; padding: 0 16px; display: grid; gap: 16px; grid-template-columns: 330px 1fr; align-items: start; }
@media (max-width: 780px) { .lobby-main { grid-template-columns: 1fr; } }
#createForm { display: flex; flex-direction: column; gap: 12px; }
#createForm label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.game-item { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.game-item:last-child { border-bottom: none; }
.game-item .info { flex: 1; min-width: 180px; }
.game-item .name { font-weight: 700; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.badge.lobby { background: rgba(245,185,66,.18); color: var(--accent-2); }
.badge.playing { background: rgba(52,192,106,.18); color: #6fe39b; }
.badge.finished { background: rgba(255,255,255,.1); color: var(--muted); }

/* Spiel-Layout */
.game { display: flex; flex-direction: column; height: 100vh; }
.stage { flex: 1; min-height: 0; position: relative; overflow: hidden; display: flex; }
.board-wrap { flex: 1; min-width: 0; position: relative; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; touch-action: none; }
.dock {
  position: relative; z-index: 4; display: flex; gap: 14px; align-items: stretch; padding: 10px 14px;
  background: linear-gradient(180deg, rgba(10,17,29,.75), rgba(8,13,22,.95)); border-top: 1px solid var(--line);
  overflow-x: auto;
}
.dock-sec { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.dock-sec.grow { flex: 1; min-width: 200px; }
.dock .divider { width: 1px; background: var(--line); flex-shrink: 0; }

/* Spieler-Chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; justify-content: center; }
.chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 11px 5px 6px; border-radius: 99px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line); font-size: 13px; transition: box-shadow .2s;
}
.chip.current { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,185,66,.2), 0 0 18px rgba(245,185,66,.25); background: rgba(245,185,66,.1); }
.chip .avatar { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0,0,0,.4); display: grid; place-items: center; font-weight: 800; font-size: 12px; color: rgba(0,0,0,.65); }
.chip .nm { font-weight: 700; }
.chip .st { color: var(--muted); display: flex; gap: 7px; }
.chip .vp { font-weight: 800; color: var(--accent-2); }

/* HUD über dem Brett */
.hud { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(560px, calc(100% - 24px)); pointer-events: none; }
.hud > * { pointer-events: auto; }
.status-pill {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 99px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(10px); font-size: 14px;
}
.status-pill .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0,0,0,.5); }
.status-pill b { font-size: 15px; }
.status-pill.mine { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,185,66,.2), var(--shadow); }
.prompt { width: 100%; border-color: rgba(245,185,66,.55); }
.prompt h4 { margin: 0 0 6px; font-size: 15px; }
.winner { text-align: center; font-size: 24px; font-weight: 800; }

/* Würfel */
.dice-row { display: flex; align-items: center; gap: 10px; }
.die {
  width: 44px; height: 44px; border-radius: 10px; background: linear-gradient(145deg, #ffffff, #dfe4ea);
  box-shadow: inset -3px -3px 6px rgba(0,0,0,.15), 0 4px 10px rgba(0,0,0,.4);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 7px; gap: 2px;
}
.die span.pip { background: #1d2733; border-radius: 50%; box-shadow: inset 0 1px 1px rgba(0,0,0,.5); }
.die.red { background: linear-gradient(145deg, #ff6b6b, #c62828); }
.die.red span.pip { background: #fff7e0; }
.die.big { width: 70px; height: 70px; padding: 11px; border-radius: 14px; }
.die.rolling { animation: roll .65s cubic-bezier(.2,.8,.3,1); }
@keyframes roll { 0% { transform: rotate(-200deg) scale(.5); opacity: .3; } 70% { transform: rotate(15deg) scale(1.08); } 100% { transform: rotate(0) scale(1); } }
.dice-sum { font-size: 24px; font-weight: 800; }

/* Handkarten */
.hand { display: flex; gap: 7px; }
.rcard {
  width: 54px; height: 74px; border-radius: 9px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,.45), inset 0 0 0 2px rgba(255,255,255,.18); transition: transform .15s;
}
.rcard:hover { transform: translateY(-4px); }
.rcard .ic { font-size: 28px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.rcard .lbl { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: rgba(255,255,255,.92); text-shadow: 0 1px 2px rgba(0,0,0,.5); margin-top: 2px; }
.rcard .cnt { position: absolute; top: 3px; right: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: rgba(0,0,0,.6); font-size: 13px; font-weight: 800; display: grid; place-items: center; }
.rcard.zero { opacity: .32; filter: grayscale(.5); }
.devs { display: flex; gap: 6px; flex-wrap: wrap; }
.dcard {
  width: 54px; height: 74px; border-radius: 9px; background: linear-gradient(160deg, #3b2e6b, #1f1840);
  box-shadow: 0 4px 10px rgba(0,0,0,.45), inset 0 0 0 2px rgba(190,170,255,.3); position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: default; padding: 2px;
}
.dcard .ic { font-size: 22px; }
.dcard .lbl { font-size: 9px; font-weight: 700; text-align: center; line-height: 1.1; margin-top: 3px; }
.dcard .cnt { position: absolute; top: 3px; right: 4px; font-size: 11px; font-weight: 800; background: rgba(0,0,0,.5); border-radius: 99px; padding: 0 5px; }
.dcard.playable { cursor: pointer; box-shadow: 0 0 0 2px var(--accent), 0 4px 14px rgba(245,185,66,.35); }
.dcard.playable:hover { transform: translateY(-4px); }

/* Figurenvorrat (Drag & Drop) */
.supply { display: flex; gap: 8px; }
.piece {
  width: 70px; height: 74px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: grab; position: relative;
  transition: background .15s, transform .1s; touch-action: none;
}
.piece:hover { background: rgba(255,255,255,.1); }
.piece.active { border-color: var(--accent); background: rgba(245,185,66,.15); }
.piece.off { opacity: .35; cursor: not-allowed; }
.piece svg { width: 44px; height: 38px; overflow: visible; }
.piece .cnt { font-size: 12px; font-weight: 800; }
.piece .cost { font-size: 11px; color: var(--muted); }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; width: 70px; height: 60px; transform: translate(-50%, -60%); filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)); }
.drag-ghost svg { width: 100%; height: 100%; overflow: visible; }

.actions-col { display: flex; flex-direction: column; gap: 6px; justify-content: center; }

/* SVG-Elemente */
.tile.editable { cursor: pointer; }
.tile.editable:hover { filter: brightness(1.15); }
.hot-v { fill: rgba(255,255,255,.55); stroke: var(--accent); stroke-width: 3; cursor: pointer; animation: hotpulse 1.1s ease-in-out infinite; }
.hot-v:hover, .hot-v.hover { fill: #fff3c4; animation: none; r: 13; }
.hot-e { stroke: rgba(255, 207, 107, .8); stroke-linecap: round; cursor: pointer; animation: hotpulse 1.1s ease-in-out infinite; }
.hot-e:hover, .hot-e.hover { stroke: #fff3c4; animation: none; }
.hot-h { fill: rgba(255,207,107,.12); stroke: var(--accent); stroke-width: 4; stroke-dasharray: 10 7; cursor: pointer; }
.hot-h:hover { fill: rgba(255,207,107,.35); }
.sel-h { fill: rgba(255,255,255,.2); stroke: #fff; stroke-width: 5; pointer-events: none; }
.pulse { animation: pulse 1s ease-out 4; transform-box: fill-box; transform-origin: center; pointer-events: none; }
@keyframes hotpulse { 50% { opacity: .5; } }
@keyframes pulse { 0% { opacity: 1; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.7); } }

/* Zähler */
.res-counters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0; }
.rc { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rc-icon { width: 100%; text-align: center; border-radius: 8px; padding: 4px 0; font-size: 20px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.rc-ctrl { display: flex; align-items: center; gap: 3px; }
.rc-ctrl button { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.08); cursor: pointer; padding: 0; line-height: 1; }
.rc-ctrl button:disabled { opacity: .3; cursor: default; }
.rc-ctrl b { min-width: 16px; text-align: center; }

/* Overlays */
.overlay-back { position: absolute; inset: 0; background: rgba(3,8,16,.55); z-index: 10; display: grid; place-items: center; padding: 16px; animation: fadein .15s; }
.modal { width: min(520px, 100%); max-height: 100%; overflow-y: auto; position: relative; animation: popin .2s cubic-bezier(.2,.9,.3,1.2); }
.modal.wide { width: min(900px, 100%); }
.modal .close { position: absolute; top: 10px; right: 10px; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); z-index: 9; border-radius: var(--radius) 0 0 var(--radius); overflow-y: auto; animation: slidein .2s ease-out; }
.drawer .close { position: absolute; top: 10px; right: 10px; }
@keyframes fadein { from { opacity: 0; } }
@keyframes popin { from { opacity: 0; transform: scale(.9); } }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }

.log { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.log div { padding: 6px 2px; border-bottom: 1px solid var(--line); }

.cost-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cost-row svg { width: 46px; height: 40px; overflow: visible; flex-shrink: 0; }
.cost-row .name { font-weight: 700; }
.cost-res { display: flex; gap: 4px; }
.mini-card { width: 26px; height: 34px; border-radius: 5px; display: grid; place-items: center; font-size: 15px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2), 0 2px 4px rgba(0,0,0,.4); }

.gain-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.04); margin-top: 8px; }
.gain-row .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(0,0,0,.5); flex-shrink: 0; }
.gain-row .nm { font-weight: 700; min-width: 90px; }
.gain-row .cards { display: flex; gap: 4px; flex-wrap: wrap; }
.gain-row.none { opacity: .5; }

.stats-chart { display: flex; align-items: flex-end; gap: 8px; height: 240px; padding: 22px 4px 0; }
.stats-chart .bar-col { flex: 1; display: flex; flex-direction: column; height: 100%; }
.stats-chart .bar-area { flex: 1; position: relative; }
.stats-chart .bar { position: absolute; bottom: 0; left: 8%; right: 8%; background: linear-gradient(180deg, var(--accent-2), #c98a1d); border-radius: 6px 6px 0 0; min-height: 3px; }
.stats-chart .bar.seven { background: linear-gradient(180deg, #ff7a7a, #b71c1c); }
.stats-chart .exp { position: absolute; left: 0; right: 0; border-top: 2px dashed rgba(110, 200, 255, .8); }
.stats-chart .val { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 700; }
.stats-chart .num { text-align: center; font-weight: 800; padding-top: 6px; }
table.st { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
table.st th, table.st td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); }
table.st th:first-child, table.st td:first-child { text-align: left; }

.palette { display: flex; flex-wrap: wrap; gap: 5px; }
.color-pick { display: flex; gap: 8px; }
.swatch-btn { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); cursor: pointer; padding: 0; position: relative; }
.swatch-btn.mine { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,185,66,.3); }
.swatch-btn:disabled { opacity: .25; cursor: not-allowed; }
.swatch-btn .who { font-size: 14px; font-weight: 800; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.lobby-players { display: flex; gap: 8px; flex-wrap: wrap; }

#toasts { position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 200; align-items: center; pointer-events: none; }
.toast { background: rgba(14,22,36,.95); border: 1px solid var(--line); color: var(--text); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: popin .2s; }
.toast.error { background: rgba(120, 25, 25, .95); border-color: rgba(239,83,80,.6); }
.toast.turn { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #2a1c00; font-weight: 800; font-size: 16px; }
.loading { color: var(--muted); text-align: center; margin-top: 30vh; font-size: 18px; }

@media (max-width: 900px) {
  .dock { flex-wrap: wrap; }
  .topbar .title { max-width: 120px; }
}

/* Zug-Anzeige: Kreis links neben dem Brett – eigene Spalte, verdeckt nichts */
.turn {
  width: 250px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 22px 12px; position: relative; z-index: 3;
}
.turn-ring {
  --pc: #888; width: 200px; height: 200px; border-radius: 50%; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 22px; gap: 4px;
  background: radial-gradient(circle at 50% 35%, rgba(30,44,68,.95), rgba(10,17,29,.95) 70%);
  border: 6px solid var(--pc);
  box-shadow: 0 0 0 3px rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.45), inset 0 0 24px rgba(0,0,0,.5);
}
.turn.mine .turn-ring { animation: turnglow 2.2s ease-in-out infinite; }
@keyframes turnglow {
  0%, 100% { box-shadow: 0 0 0 3px rgba(0,0,0,.35), 0 0 18px 2px var(--pc), inset 0 0 24px rgba(0,0,0,.5); }
  50% { box-shadow: 0 0 0 3px rgba(0,0,0,.35), 0 0 34px 8px var(--pc), inset 0 0 24px rgba(0,0,0,.5); }
}
.turn-ring .ic { font-size: 30px; line-height: 1; }
.turn-ring .who { font-size: 19px; font-weight: 800; color: #fff; }
.turn.mine .turn-ring .who { color: var(--accent-2); }
.turn-ring .act { font-size: 13.5px; color: var(--text); opacity: .88; line-height: 1.3; }
.turn-ring .rnd { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }
.turn-ring.win .who { color: var(--accent-2); font-size: 21px; }
.turn-extra { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 220px; }
.turn-extra .btn { width: 100%; justify-content: center; }
@media (max-width: 900px) {
  .stage { flex-direction: column; }
  .turn { width: auto; flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 8px; gap: 8px; }
  .turn-ring { width: auto; height: auto; border-radius: 99px; flex-direction: row; padding: 6px 16px; gap: 8px; border-width: 4px; }
  .turn-ring .ic { font-size: 18px; }
  .turn-ring .who { font-size: 15px; }
  .turn-ring .rnd { display: none; }
  .turn-extra { flex-direction: row; flex-wrap: wrap; max-width: none; width: auto; }
  .turn-extra .btn { width: auto; }
}
.dot-s { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid rgba(0,0,0,.5); margin-right: 2px; }

/* Klare Spieler-Infos */
.chip .tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.08); color: var(--text); white-space: nowrap; }
.chip .tag.gold { background: rgba(245,185,66,.18); color: var(--accent-2); }

/* Würfel rollen */
.die.spin { animation: dieshake .18s linear infinite; }
@keyframes dieshake { 0% { transform: rotate(-12deg) translateY(-3px); } 50% { transform: rotate(10deg) translateY(2px); } 100% { transform: rotate(-12deg) translateY(-3px); } }
.big-sum { font-size: 40px; }
.center { text-align: center; }
.trade-line { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.trade-line .muted { min-width: 100px; }
.rcard.big-card { width: 80px; height: 108px; }
.rcard.big-card .ic { font-size: 42px; }
.rcard.big-card .lbl { font-size: 12px; }
.hot-h.hover { fill: rgba(255,207,107,.4); }

/* Gleiches Fenster neu gezeichnet: nicht erneut einblenden */
#overlay.still .overlay-back, #overlay.still .modal, #overlay.still .drawer { animation: none; }

.dcard.played { background: linear-gradient(160deg, #4a4f5c, #2a2e38); opacity: .9; cursor: default; }
