:root {
  --bg: #0b1210;
  --bg2: #111b18;
  --panel: #15211d;
  --panel2: #1b2a25;
  --line: #2a3b35;
  --text: #e8eee9;
  --muted: #93a49c;
  --accent: #e7c46b;
  --accent-ink: #231a05;
  --felt1: #20684b;
  --felt2: #134433;
  --rail: #2b2018;
  --danger: #e2675a;
  --ok: #58c48a;
  --blue: #5aa2e6;
  --card: #fbfaf6;
  --s-spade: #1b1b1b;
  --s-heart: #d2352b;
  --s-diamond: #2a6fd6;
  --s-club: #23874f;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #17302a 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); }

/* ---------- Buttons & Inputs ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel2); padding: 10px 16px; border-radius: 10px;
  font-weight: 600; transition: transform .05s, background .15s, border-color .15s;
}
.btn:hover { border-color: #3d5a50; background: #20332c; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #f0d385; }
.btn.danger { background: #3a1d1a; border-color: #6a2f29; color: #ffc9c2; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 8px; width: 34px; height: 34px; font-size: 18px; }
.icon-btn:hover { border-color: var(--line); }

label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 12px; }
label input, label select {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 9px;
  background: var(--bg2); border: 1px solid var(--line); outline: none;
}
label input:focus, label select:focus { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: 13px; min-height: 1em; margin: -6px 0 10px; }
.error { color: var(--danger); text-align: center; min-height: 1.2em; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }

/* ---------- Startseite ---------- */
#home { max-width: 980px; margin: 0 auto; padding: 48px 16px 40px; }
.brand { display: flex; gap: 18px; align-items: center; margin-bottom: 32px; }
.brand-mark {
  width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; font-size: 38px;
  background: linear-gradient(160deg, var(--felt1), var(--felt2)); color: #f2e6c9; box-shadow: 0 6px 24px #0008;
}
.brand h1 { margin: 0; font-size: 34px; letter-spacing: .5px; }
.brand p { margin: 4px 0 0; color: var(--muted); }
.home-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 20px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 10px 30px #0005; }
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.code-input { text-transform: uppercase; letter-spacing: 6px; font-size: 22px !important; font-weight: 700; text-align: center; }
details.settings { border-top: 1px solid var(--line); margin: 6px 0 16px; padding-top: 12px; }
details.settings summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.blind-editor { margin: 6px 0 14px; }
.blind-editor .bl-head, .blind-editor .bl-row { display: grid; grid-template-columns: 34px 1fr 1fr 1fr 30px; gap: 6px; align-items: center; }
.blind-editor .bl-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.blind-editor .bl-row { margin-bottom: 5px; }
.blind-editor .bl-row span { color: var(--muted); font-size: 12px; text-align: right; }
.blind-editor input { width: 100%; padding: 6px 8px; border-radius: 7px; background: var(--bg2); border: 1px solid var(--line); }
.blind-editor .bl-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.bl-list { max-height: 230px; overflow: auto; padding-right: 4px; }

/* ---------- Tischansicht ---------- */
#tableView { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px;
  border-bottom: 1px solid var(--line); background: #0d1613cc; backdrop-filter: blur(8px);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; }
.tb-title { font-weight: 700; }
.code-chip { border: 1px dashed #4a6359; background: transparent; border-radius: 6px; padding: 1px 7px; font-size: 12px; color: var(--muted); }
.code-chip span:first-child { color: var(--accent); font-weight: 700; letter-spacing: 2px; }
.tb-blinds { text-align: center; font-size: 13px; color: var(--muted); }
.tb-blinds b { color: var(--text); font-size: 15px; }

.table-layout { display: grid; grid-template-columns: 1fr 310px; min-height: 0; }
.table-area { position: relative; display: grid; place-items: center; padding: 16px; min-height: 0; overflow: hidden; }
.table-wrap { position: relative; width: min(100%, calc((100dvh - 230px) * 1.9)); aspect-ratio: 1.9; }
.felt {
  position: absolute; inset: 9% 7%; border-radius: 999px;
  background: radial-gradient(ellipse at 50% 40%, var(--felt1) 0%, var(--felt2) 75%);
  box-shadow: 0 0 0 12px var(--rail), 0 0 0 14px #4a3626, 0 25px 60px #000a, inset 0 0 60px #0006;
}
.felt-logo { position: absolute; inset: 0; display: grid; place-items: center; transform: translateY(26%); font-weight: 800; letter-spacing: 10px; color: #ffffff10; font-size: clamp(14px, 2.4vw, 28px); pointer-events: none; }
.center { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: 70%; }
.pots { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; min-height: 24px; }
.pot { background: #0007; border-radius: 999px; padding: 3px 12px; font-weight: 700; font-size: 14px; }
.pot small { color: var(--muted); font-weight: 500; margin-right: 4px; }
.boards { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.board { display: flex; gap: 6px; min-height: calc(var(--cw) * 1.4); }
.board .slot { width: var(--cw); height: calc(var(--cw) * 1.4); border-radius: 7px; border: 1px dashed #ffffff22; }
.board-label { font-size: 11px; color: #ffffffa0; width: 18px; align-self: center; }
.result { min-height: 20px; text-align: center; font-weight: 700; color: var(--accent); text-shadow: 0 1px 2px #000; font-size: 14px; }
.table-wrap { --cw: clamp(30px, 4.4vw, 58px); }

/* Karten */
.card {
  width: var(--cw); height: calc(var(--cw) * 1.4); border-radius: 7px; background: var(--card);
  box-shadow: 0 2px 6px #0007; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; user-select: none; animation: deal .25s ease-out;
}
.card .r { font-size: calc(var(--cw) * .5); line-height: 1; }
.card .s { font-size: calc(var(--cw) * .44); line-height: 1; margin-top: 1px; }
.card.s-s { color: var(--s-spade); } .card.s-h { color: var(--s-heart); } .card.s-d { color: var(--s-diamond); } .card.s-c { color: var(--s-club); }
.card.win { outline: 3px solid var(--accent); outline-offset: -1px; transform: translateY(-4px); }
.card.dim { filter: brightness(.55); }
.card.back {
  background: repeating-linear-gradient(45deg, #8e2b2b 0 5px, #a73a35 5px 10px); border: 3px solid #f4efe4;
}
@keyframes deal { from { transform: translateY(-10px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

/* Plätze */
.seat { position: absolute; transform: translate(-50%, -50%); width: clamp(96px, 12vw, 150px); text-align: center; z-index: 2; }
.seat .cards { display: flex; justify-content: center; gap: 3px; margin-bottom: -14px; position: relative; z-index: 1; --cw: clamp(28px, 3.3vw, 46px); }
.seat .cards .card { animation: none; }
.seat.folded .cards { opacity: .25; }
.seat .box {
  position: relative; z-index: 2; background: #101916f0; border: 2px solid var(--line); border-radius: 12px; padding: 7px 8px 6px;
  box-shadow: 0 6px 16px #0008;
}
.seat .name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .stack { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; font-size: 14px; }
.seat .status { font-size: 11px; color: var(--muted); min-height: 14px; text-transform: uppercase; letter-spacing: .6px; }
.seat .avatar {
  position: absolute; left: -16px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(160deg, #3c5a4f, #22352e); display: grid; place-items: center; font-weight: 800; font-size: 14px; border: 2px solid var(--line); overflow: hidden;
}
.seat .avatar video { width: 100%; height: 100%; object-fit: cover; }
.seat.acting .box { border-color: var(--accent); box-shadow: 0 0 0 3px #e7c46b40, 0 6px 16px #0008; }
.seat.me .box { background: #13241ef2; }
.seat.winner .box { border-color: var(--ok); box-shadow: 0 0 22px #58c48a90; }
.seat.out .box { opacity: .55; }
.seat.offline .name::after { content: " ⦸"; color: var(--danger); }
.seat .timer { position: absolute; left: 6px; right: 6px; bottom: 2px; height: 3px; border-radius: 3px; background: #ffffff15; overflow: hidden; }
.seat .timer i { display: block; height: 100%; background: var(--accent); transform-origin: left; }
.seat .timer i.low { background: var(--danger); }
.seat .owner { color: var(--accent); font-size: 10px; margin-left: 2px; }
.seat .won { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); background: var(--ok); color: #062012; font-weight: 800; padding: 2px 9px; border-radius: 999px; font-size: 13px; white-space: nowrap; animation: pop .3s; z-index: 3; }
.seat .hand-name { font-size: 11px; color: #cfe; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); } to { transform: translateX(-50%) scale(1); } }
.seat.empty .box { background: #0d1513aa; border-style: dashed; color: var(--muted); padding: 14px 8px; }
.seat.empty button { background: transparent; border: none; color: var(--accent); font-weight: 700; }
.bet { position: absolute; transform: translate(-50%, -50%); z-index: 1; display: flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13px; background: #0008; padding: 2px 9px 2px 3px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.chip { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle, #fff 0 28%, #c33 30% 60%, #fff 62% 70%, #c33 72%); box-shadow: 0 1px 2px #000; }
.dealer { position: absolute; transform: translate(-50%, -50%); width: 24px; height: 24px; border-radius: 50%; background: #f6f2e6; color: #222; font-weight: 900; font-size: 12px; display: grid; place-items: center; box-shadow: 0 2px 4px #0009; z-index: 1; }

.banner { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 8px 24px #000a; z-index: 5; max-width: calc(100% - 32px); }

/* Seitenleiste */
.side { border-left: 1px solid var(--line); background: #0e1714; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: none; padding: 10px 4px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; }
.tab-body { flex: 1; overflow: auto; min-height: 0; display: flex; flex-direction: column; }
.log, .chat { list-style: none; margin: 0; padding: 10px 12px; font-size: 13px; flex: 1; }
.log li { padding: 2px 0; color: #c8d3ce; }
.log li.hand { margin-top: 10px; color: var(--muted); font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; }
.log li.win { color: var(--ok); font-weight: 600; }
.log li.board { color: #fff; }
.log li.level { color: var(--accent); font-weight: 700; }
.log li.rebuy { color: var(--blue); }
.chat li { margin-bottom: 6px; } .chat b { color: var(--accent); }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; padding: 8px 10px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); }
.ledger { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); }
.ledger th:first-child, .ledger td:first-child { text-align: left; }
.ledger th { color: var(--muted); font-weight: 600; }
.pos { color: var(--ok); } .neg { color: var(--danger); }

/* Aktionsleiste */
.actions { border-top: 1px solid var(--line); background: #0d1613; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr auto; grid-template-areas: "info buttons" "raise buttons" "pre pre"; gap: 6px 16px; align-items: center; min-height: 74px; }
.action-info { grid-area: info; color: var(--muted); font-size: 13px; }
.action-buttons { grid-area: buttons; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.action-buttons .btn { min-width: 110px; padding: 13px 16px; font-size: 15px; }
.btn.fold { background: #2a1917; border-color: #5a2d27; }
.btn.call { background: #18324a; border-color: #2e5a80; }
.btn.raise { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.raise-box { grid-area: raise; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.presets button { background: var(--panel2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 7px; font-size: 12px; font-weight: 600; }
.raise-row { display: flex; gap: 10px; align-items: center; }
.raise-row input[type=range] { flex: 1; accent-color: var(--accent); }
.raise-input { width: 110px; padding: 8px 10px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); text-align: right; font-weight: 700; }
.pre-actions { grid-area: pre; display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.pre-actions label { white-space: nowrap; display: flex; gap: 6px; align-items: center; margin: 0; color: var(--text); font-size: 13px; }
.pre-actions input { accent-color: var(--accent); }

/* Dialoge */
.dlg { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(640px, calc(100% - 24px)); max-height: calc(100dvh - 40px); }
.dlg.small { width: min(400px, calc(100% - 24px)); }
.dlg::backdrop { background: #000a; backdrop-filter: blur(2px); }
.dlg-inner { padding: 20px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dlg h2 { margin: 0 0 10px; font-size: 18px; }
.dlg h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.owner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.plist { list-style: none; padding: 0; margin: 0; }
.plist li { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); gap: 8px; }
.rit-timer { height: 4px; background: #ffffff15; border-radius: 4px; overflow: hidden; margin: 14px 0; }
.rit-timer div { height: 100%; background: var(--accent); }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); background: #2a1917; border: 1px solid #6a2f29; color: #ffd9d3; padding: 10px 16px; border-radius: 10px; z-index: 50; box-shadow: 0 8px 20px #000a; max-width: calc(100% - 32px); }
.toast.info { background: var(--panel2); border-color: var(--line); color: var(--text); }

/* ---------- Responsiv ---------- */
@media (max-width: 1100px) {
  .table-layout { grid-template-columns: 1fr; }
  .side { position: fixed; right: 0; top: 52px; bottom: 0; width: min(340px, 90vw); z-index: 20; transform: translateX(105%); transition: transform .2s; box-shadow: -10px 0 30px #000a; }
  .side.open { transform: none; }
}
@media (min-width: 1101px) { #btnSide { display: none; } }
@media (max-width: 760px) {
  .home-grid { grid-template-columns: 1fr; }
  #home { padding-top: 24px; }
  .topbar { flex-wrap: wrap; padding: 6px 10px; }
  .tb-blinds { order: 3; width: 100%; text-align: left; }
  .table-area { padding: 6px; }
  .table-wrap { width: min(100%, calc((100dvh - 260px) * .72)); aspect-ratio: .72; --cw: clamp(26px, 8vw, 44px); }
  .felt { inset: 10% 12%; }
  .seat { width: 88px; }
  .seat .cards { --cw: 26px; }
  .seat .avatar { width: 26px; height: 26px; left: -10px; font-size: 11px; }
  .seat .name { font-size: 12px; } .seat .stack { font-size: 12px; }
  .actions { grid-template-columns: 1fr; grid-template-areas: "info" "raise" "buttons" "pre"; }
  .action-buttons { justify-content: stretch; }
  .action-buttons .btn { flex: 1; min-width: 0; padding: 12px 6px; }
  .grid2 { grid-template-columns: 1fr; }
  .tb-right .btn.ghost { display: none; }
}

.blind-editor.no-ante .ante-col { visibility: hidden; }
.seat .equity { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); display: flex; gap: 4px; z-index: 3; }
.seat .equity span { background: #0b1210e6; border: 1px solid var(--accent); color: var(--accent); font-weight: 800; font-size: 13px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }
