:root {
  --bg: #f3efe6;
  --panel: #fffdf8;
  --ink: #23201b;
  --muted: #7a7266;
  --line: #ddd5c6;
  --accent: #1f6b3a;
  --accent-ink: #fff;
  --danger: #a23a2c;
  --felt: #1e7a3c;
  --felt-dark: #145a2b;
  --wood: #6b4423;
  --red: #c0262d;
  --gold: #f2c94c;
  --chip: #ece6d8;
  --chip-muted: #e4ded2;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
}

/* Mørkt tema: vælges med knappen i topbjælken, ellers følges systemets indstilling.
   Kortene forbliver hvide, ligesom rigtige spillekort. */
:root[data-theme="dark"] {
  --bg: #1a1916;
  --panel: #262420;
  --ink: #ebe6db;
  --muted: #a39b8c;
  --line: #3e3a33;
  --accent: #3f9a5c;
  --danger: #e2735f;
  --chip: #35322b;
  --chip-muted: #2e2b25;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1916;
    --panel: #262420;
    --ink: #ebe6db;
    --muted: #a39b8c;
    --line: #3e3a33;
    --accent: #3f9a5c;
    --danger: #e2735f;
    --chip: #35322b;
    --chip-muted: #2e2b25;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button {
  font: inherit;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary, button.toggle.on, button.selected:not(.card) { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.link { border: none; background: none; text-decoration: underline; padding: 0 4px; }
.muted { color: var(--muted); }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--gold); color: #3b2d00; margin-left: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #bbb; margin-right: 6px; }
.dot.on { background: #2ea44f; }
.connecting { text-align: center; margin-top: 30vh; color: var(--muted); }

/* ---------- Navn ---------- */
.name-screen { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.name-screen form { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: min(360px, 100%); text-align: center; }
.name-screen h1 { margin-top: 0; }
.name-screen input { font: inherit; background: var(--bg); color: var(--ink); width: 100%; padding: 8px 10px; margin: 12px 0; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- Topbjælke ---------- */
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: var(--felt-dark); color: #fff; }
header.top h1 { font-size: 20px; margin: 0; }
header.top nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
header.top .me { font-weight: 600; }
header.top button.link { color: #fff; }
header.top .contract { font-size: 15px; }

/* ---------- Venterum ---------- */
.lobby { display: grid; grid-template-columns: 1fr 260px; gap: 16px; padding: 0 16px 16px; max-width: 1600px; margin: 0 auto; align-items: start; }
.lobby-main { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; min-width: 0; }
@media (max-width: 1200px) { .lobby-main { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .lobby { grid-template-columns: 1fr; } }
.lobby .menu { display: flex; flex-direction: column; gap: 8px; }
.lobby .menu h2 { margin: 0; }
.lobby .menu .online { margin-bottom: 8px; }
/* Forsiden (intet bord): bordkassen højst 800 px og midt på siden, med menuen ved siden af til højre. */
.lobby.front { grid-template-columns: 260px minmax(0, 800px) 260px; justify-content: center; }
.lobby.front .lobby-main { grid-column: 2; }
@media (max-width: 1400px) { .lobby.front { grid-template-columns: minmax(0, 800px) 260px; } .lobby.front .lobby-main { grid-column: 1; } }
@media (max-width: 900px) { .lobby.front { grid-template-columns: 1fr; } .lobby.front .lobby-main { grid-column: auto; } }
.lobby-main > .full { grid-column: 1 / -1; } /* bordet og kortvalget i fuld bredde, reglerne side om side */

/* Stor titel midt på siden med fire esser i vifte. */
.title { display: flex; justify-content: center; align-items: center; gap: 28px; padding: 28px 16px 22px; }
.title h1 { margin: 0; font-size: clamp(36px, 5vw, 64px); letter-spacing: .5px; }
.title-cards { display: flex; }
.title-cards img { width: 58px; height: 81px; border-radius: 5px; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .35); }
.title-cards img + img { margin-left: -30px; }
.title-cards img:nth-child(1) { transform: rotate(-12deg) translateY(6px); }
.title-cards img:nth-child(2) { transform: rotate(-4deg); }
.title-cards img:nth-child(3) { transform: rotate(4deg); }
.title-cards img:nth-child(4) { transform: rotate(12deg) translateY(6px); }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.box h2 { margin-top: 0; font-size: 18px; }
.online, .seats, .saved { list-style: none; margin: 0; padding: 0; }
.online li { padding: 4px 0; }
.seats li { display: flex; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; }
.seats li .state { margin-left: auto; color: var(--muted); }
.seats li.ready { border-color: var(--accent); }
.seats li.ready .state { color: var(--accent); font-weight: 600; }
.seats li.empty { color: var(--muted); border-style: dashed; }
.saved li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.rules h2 { margin-bottom: 4px; }
.rules h4 { margin: 14px 0 6px; }
.rules label.opt { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.rules label.opt input { margin-top: 4px; }
.rules ul { margin: 4px 0; padding-left: 20px; }
.rules li { margin-bottom: 4px; }
table.grid { border-collapse: collapse; margin: 8px 0; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tfoot td { font-weight: 700; }

.countdown { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #fff; font-size: 30vmin; font-weight: 800; z-index: 50; }

/* ---------- Spillet ---------- */
.game { display: grid; grid-template-rows: minmax(300px, 1fr); height: 100vh; overflow: hidden; } /* siden scroller aldrig – så hopper bordet ikke */
/* Bordet og panelet står samlet med 200 px imellem i stedet for at panelet ligger helt ude til højre. */
/* Mellemrummet skrumper fra 200 px til 24 px på smalle skærme, så bordet får pladsen. */
.table-area { --gap: clamp(24px, calc(100vw - 1700px), 200px); display: flex; justify-content: center; gap: var(--gap); min-height: 0; background: #2b2118; }
.felt-wrap { flex: none; display: flex; justify-content: center; align-items: center; min-height: 0; min-width: 0; padding: 10px; }
.felt-wrap .felt { height: min(100%, calc(100vw - 420px - var(--gap))); }
.side { width: 360px; flex: none; display: flex; flex-direction: column; gap: 10px; padding: 10px 10px 10px 0; overflow-y: auto; scrollbar-gutter: stable; }
.side > * { flex-shrink: 0; } /* hellere scroll i kolonnen end afskårne knapper */
/* Lave skærme (fx 1440×768 med browserens faner og proceslinjen): kompakt højrekolonne. */
@media (max-height: 720px) {
  .side { gap: 6px; padding-top: 6px; }
  .side .panel { padding: 6px 12px; }
  .side .panel p { margin: 2px 0 6px; }
  .bidgrid { gap: 3px; }
  .bidgrid .bidrow { gap: 3px; }
  .bidgrid button { padding: 2px 6px; }
  .round-head { padding: 5px 12px; }
  .round-buttons { gap: 6px; padding: 6px 12px 8px; }
  .round-buttons button { padding-top: 4px; padding-bottom: 4px; }
}
/* Højre kolonne: giver øverst, handlinger og stik i midten, runde og knapper nederst. */
.dealer-info { color: #f3efe6; font-size: 17px; padding: 4px 2px; }
.round-box { margin-top: auto; background: var(--panel); border-radius: 8px; overflow: hidden; }
.round-head { padding: 8px 12px; font-weight: 700; font-size: 17px; border-bottom: 1px solid var(--line); }
.round-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px 12px; }

/* ---------- Webcams: kolonne til venstre for bordet ---------- */
#cams { display: none; }
body.with-cams #cams {
  position: fixed; left: 10px; top: 10px; bottom: 10px; width: 255px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px; overflow-y: auto;
}
/* Venterum og bord rykker til højre, så kolonnen ikke dækker for noget. */
body.with-cams #app { padding-left: 275px; }
body.with-cams .felt-wrap .felt { height: min(100%, calc(100vw - 695px - var(--gap))); }
.cam-tile { position: relative; flex: none; width: 255px; height: 191px; border-radius: 8px; overflow: hidden;
  background: #1a140f; color: #f3efe6; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
.cam-tile video { width: 100%; height: 100%; object-fit: cover; display: block; visibility: hidden; }
.cam-tile.has-video video { visibility: visible; }
.cam-tile.offline { opacity: .5; }
.cam-info { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; opacity: .7; pointer-events: none; }
.cam-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: 15px; font-weight: 700;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-mute { position: absolute; top: 4px; right: 6px; display: none; text-shadow: 0 0 3px #000; }
.cam-tile.muted .cam-mute { display: block; }
.cam-tile.mine.muted .cam-mute { display: none; } /* egen mikrofon vises på knappen */
.cam-controls { position: absolute; top: 4px; left: 4px; right: 4px; display: flex; gap: 4px; }
.cam-controls button { padding: 3px 8px; font-size: 15px; }
.cam-controls button.primary { margin: 60px auto 0; }
.cam-messages { display: flex; flex-direction: column; gap: 6px; }
.cam-message { background: #222; color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 1.35;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4); cursor: pointer; }
.side .panel { border-radius: 8px; border-top: none; }
@media (max-width: 900px) {
  .game { height: auto; min-height: 100vh; overflow: visible; }
  .table-area { flex-direction: column; }
  .felt-wrap { height: min(100vw, 70vh); }
  .side { width: auto; padding: 0 10px 10px; }
}
.felt {
  position: relative;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 45%, var(--felt) 0%, var(--felt-dark) 100%);
  border: 14px solid var(--wood);
  border-radius: 8px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .45), 0 6px 18px rgba(0, 0, 0, .5);
  color: #fff;
}
.seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, .25); min-width: 120px; text-align: center; }
.seat .name { font-weight: 700; font-size: 16px; }
.seat.turn { outline: 3px solid var(--gold); background: rgba(0, 0, 0, .4); }
.seat.offline { opacity: .5; }
.seat .info { font-size: 13px; opacity: .9; }
.seat .tags .tag { margin: 0 2px; }
.seat.pos-bottom, .seat-wrap.pos-bottom { bottom: 8px; left: 50%; transform: translateX(-50%); }
.seat.pos-top, .seat-wrap.pos-top { top: 8px; left: 50%; transform: translateX(-50%); }
.seat.pos-left, .seat-wrap.pos-left { left: 8px; top: 50%; transform: translateY(-50%); }
.seat.pos-right, .seat-wrap.pos-right { right: 8px; top: 50%; transform: translateY(-50%); flex-direction: row-reverse; }
/* Navneboks og stikbunke side om side. */
.seat-wrap { position: absolute; display: flex; align-items: center; gap: 8px; }
.seat-wrap .seat { position: static; }
.seat .tag { font-size: 12px; }
/* Bordlægger: åbne kort som kortrække under navnet. Øverst som egen kortrække, i siderne lodret. */
.seat-wrap.has-open { flex-direction: column; gap: 8px; }
.seat-row { position: relative; display: flex; align-items: center; gap: 8px; }
.seat-wrap.pos-right .seat-row { flex-direction: row-reverse; }
.open-hand { display: flex; }
.seat-wrap.pos-top .open-hand { margin-top: 30px; } /* fri af meldingsboksen i hjørnet */
.seat-wrap.pos-top .open-hand .card { width: 100px; height: 140px; }
.seat-wrap.pos-top .open-hand .card + .card { margin-left: -50px; }
.seat-wrap.pos-left .open-hand, .seat-wrap.pos-right .open-hand { flex-direction: column; }
.seat-wrap.pos-left .open-hand .card, .seat-wrap.pos-right .open-hand .card { width: 63px; height: 88px; }
.seat-wrap.pos-left .open-hand .card + .card, .seat-wrap.pos-right .open-hand .card + .card { margin-top: -64px; }

/* Bordets indhold i spillet: 900×900 px, skaleret til bordet (--k sættes af fitFelt i app.js). */
.felt-inner { position: absolute; left: 0; top: 0; width: 900px; height: 900px; transform-origin: 0 0; transform: scale(var(--k, 1)); }

/* Spillede kort placeres ud fra midten med --x/--y (cqw/cqh er procent af .center). */
.center { position: absolute; inset: 27%; container-type: size; }
.played { position: absolute; left: 50%; top: 50%; z-index: 1; --x: 0px; --y: 0px; transform: translate(-50%, -50%) translate(var(--x), var(--y)); }
.played.pos-bottom { --y: calc(50cqh - 50%); }
.played.pos-top { --y: calc(-50cqh + 50%); }
.played.pos-left { --x: calc(-50cqw + 50%); }
.played.pos-right { --x: calc(50cqw - 50%); }
.played.winner { z-index: 5; }
.kat { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; }
.kat .cards { display: flex; gap: 6px; }

.panel { padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line); text-align: center; }
.panel p { margin: 4px 0 8px; }
.panel .row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0; align-items: center; }
.bidlog { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px; }
.chip { background: var(--chip); border-radius: 12px; padding: 2px 10px; font-size: 14px; }
.bidgrid { display: inline-grid; gap: 4px; }
.bidgrid .bidrow { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.bidgrid button { min-width: 54px; padding: 4px 6px; }
.bidgrid button:hover:not(:disabled):not(.primary) { background: color-mix(in srgb, var(--accent) 35%, var(--panel)); } /* tydelig grøn tone i både lyst og mørkt tema */
.choice-label { font-weight: 600; margin-top: 8px; }
.contract-cols { display: flex; gap: 16px; justify-content: center; margin-top: 4px; }
.choice-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.choice-col .choice-label { margin: 0 0 2px; }
.choice-col.mid { position: relative; justify-content: flex-end; min-width: 90px; }
.choice-col .til { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 20px; font-weight: 600; }
.contract-cols .suit-btn { width: 58px; height: 58px; min-width: 0; padding: 0; font-size: 36px; }
/* Kulørknapper som små hvide kort, så sort er sort og rød er rød i begge temaer. */
.suit-btn { font-size: 38px; min-width: 90px; padding: 6px 12px; line-height: 1.1; background: #fff; color: #111; border: 2px solid #ccc; }
.suit-btn.red { color: var(--red); }
button.suit-btn.selected { background: #fff; color: #111; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent); }
button.suit-btn.selected.red { color: var(--red); }
.suit-btn:disabled { opacity: .3; }
/* Når der er valgt i en kolonne, bliver de andre grå, så valget står tydeligt. */
button.suit-btn.dim { background: #9a968e; border-color: #8a867e; color: #3a3833; }
button.suit-btn.dim.red { color: #6e2a2a; }
.choice-col.fixed .suit-btn:disabled { opacity: 1; } /* fast trumf: klør valgt, de andre grå */

/* Spillerens egne kort ligger på bordet lige over navneboksen og overlapper 50 %. */
.my-hand { position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%); display: flex; z-index: 6; }
.my-hand .card + .card { margin-left: -50px; }
.my-hand.split .card + .card { margin-left: calc(var(--step) - 100px); }
.my-hand.split .card.gap { margin-left: 8px; }
.my-hand .covered-card { position: relative; margin-left: 14px; }
.my-hand .covered-card > span { position: absolute; left: 0; right: 0; top: -20px; text-align: center; font-size: 12px; font-weight: bold;
  color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .7); }
.my-hand button.card:hover:not(:disabled) { z-index: 2; }

/* ---------- Kort ---------- */
.card {
  width: 62px; height: 88px; padding: 4px 6px;
  border: 1px solid #999; border-radius: 6px;
  background: #fff; color: #111;
  display: flex; flex-direction: column; align-items: flex-start;
  font-weight: 700; line-height: 1; flex: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .3);
  position: relative;
}
.card .r { font-size: 20px; }
.card .s { font-size: 24px; }
.card .s.big { position: absolute; right: 6px; bottom: 6px; font-size: 30px; }
.card.red { color: var(--red); }
.card.joker { background: linear-gradient(135deg, #fff 60%, #fde9a8); color: #6a3fb5; }
.card.joker .s { font-size: 11px; }
.card.back { padding: 0; border: none; background: none; overflow: hidden; }
.card.back img { width: 100%; height: 100%; display: block; pointer-events: none; }
.card-choices { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0 10px; }
.card-choice { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.card-choice input { position: absolute; opacity: 0; pointer-events: none; }
.card-choice .card { width: 60px; height: 84px; }
.card-choice.on .card { outline: 3px solid var(--accent); outline-offset: 3px; }
.card-modal { text-align: left; }
.card.small { width: 36px; height: 50px; padding: 2px 3px; }
.card.small .r { font-size: 13px; }
.card.small .s { font-size: 14px; }
.card.small .s.big { display: none; }
.card.small.joker .s { font-size: 7px; }
button.card { cursor: pointer; transition: transform .1s; }
button.card:hover:not(:disabled) { transform: translateY(-10px); z-index: 2; }
button.card:disabled { opacity: 1; filter: brightness(.7); }
.card.selected { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--danger), 0 4px 10px rgba(0, 0, 0, .4); }
.card.fromkat { background: #fff8dd; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .55); z-index: 40; padding: 16px; }
.overlay .box { max-width: 420px; text-align: center; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal.hidden { display: none; }
.modal .box { max-width: 960px; width: 100%; max-height: 90vh; overflow: auto; position: relative; }
.modal .close { position: absolute; top: 10px; right: 10px; }
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 70; }
.toast { background: #222; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); max-width: 320px; }

/* ---------- Meldinger, hjørne, stikpanel og score ---------- */
.felt-wrap { gap: 12px; }
.bubble { position: absolute; background: #fff; color: #23201b; padding: 7px 15px; border-radius: 18px; font-weight: 700; font-size: 20px; box-shadow: 0 3px 8px rgba(0, 0, 0, .35); white-space: nowrap; animation: pop .25s ease-out; }
.bubble.pass { background: var(--chip-muted); color: var(--muted); font-weight: 500; }
.bubble.thinking { background: rgba(255, 255, 255, .55); }
.bubble.pos-bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.bubble.pos-top { top: 0; left: 50%; transform: translateX(-50%); }
.bubble.pos-left { left: 0; top: 50%; transform: translateY(-50%); }
.bubble.pos-right { right: 0; top: 50%; transform: translateY(-50%); }
@keyframes pop { from { opacity: 0; scale: .6; } to { opacity: 1; scale: 1; } }

.contract-corner { position: absolute; top: 8px; left: 8px; background: var(--panel); color: var(--ink); border-radius: 8px; padding: 6px 12px 10px; line-height: 1.6; max-width: 34%; box-shadow: 0 3px 10px rgba(0, 0, 0, .4); }
.contract-corner .big { font-size: 20px; font-weight: 800; white-space: nowrap; }
.contract-corner .pending { color: var(--muted); }
/* Kulørtegn på en lys plade, så sort også kan ses i mørkt tema. */
.suit { display: inline-block; background: #fff; border-radius: 6px; padding: 0 4px; font-size: 1.6em; line-height: 1.1; vertical-align: -0.12em; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.suit.red { color: var(--red); }
.suit.black { color: #111; }
.stik-boxes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.stik-box { width: 16px; height: 16px; border-radius: 3px; background: #9a958b; }
.stik-box.won { background: #2ea44f; }
.stik-box.lost { background: #d0453a; }
.stik-box.over { box-shadow: 0 0 0 2px var(--gold); }

.trick-panel { background: var(--panel); color: var(--ink); border-radius: 8px; padding: 8px 10px; max-height: 100%; overflow: auto; font-size: 13px; }
.trick-panel:empty { display: none; }
.trick-panel h4 { margin: 0 0 6px; }
.trick-panel table { width: 100%; border-collapse: collapse; text-align: center; }
.trick-panel th, .trick-panel td { padding: 2px 3px; border-bottom: 1px solid var(--line); }
.trick-panel th { font-weight: 600; font-size: 12px; white-space: nowrap; }

.result-box { position: absolute; inset: -4%; background: var(--panel); color: var(--ink); border-radius: 12px; padding: 12px 16px; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; animation: pop .3s ease-out; }
.result-box h3 { margin: 0; }
.result-box p { margin: 2px 0; }
/* Nedtællingen: to linjers luft over, og tallet springer op i 250 % og skrumper til tekstens størrelse. */
.result-box p.next-round { margin-top: 2.8em; height: 1.6em; display: flex; align-items: center; justify-content: center; gap: .3em; }
.next-round b { display: inline-block; min-width: 1.2em; line-height: 1; }
.next-round b.tick { animation: count-tick .9s ease-out; }
@keyframes count-tick { from { font-size: 250%; } to { font-size: 100%; } }
.result-box table.pts td { padding: 2px 10px; font-size: 17px; }
.result-box td.num { text-align: right; font-weight: 700; color: var(--accent); }
.result-box td.num.neg { color: var(--danger); }

/* ---------- Venterum: AI ---------- */
.bot { margin-right: 6px; }
.seats li .link { margin-left: 8px; }
/* "Tilføj AI" på en ledig plads */
.ai-menu { position: relative; margin-left: auto; }
.ai-menu > button { padding: 3px 10px; font-size: 14px; }
.ai-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; width: 280px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); overflow: hidden; }
.ai-menu-list button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border: none;
  border-bottom: 1px solid var(--line); border-radius: 0; padding: 8px 12px; color: var(--ink); }
.ai-menu-list button:last-child { border-bottom: none; }
.ai-menu-list button:hover { background: var(--chip); }
.ai-menu-list span { font-weight: 600; }
.ai-menu-list small { font-size: 12px; color: var(--muted); }

/* ---------- Historik ---------- */
.sessions { list-style: none; padding: 0; margin: 0; }
.sessions > li { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.sessions > li.open { border-color: var(--accent); }
.session-head { display: flex; flex-wrap: wrap; gap: 4px 16px; width: 100%; text-align: left; border: none; border-radius: 0; padding: 10px 12px; }
.session-head .when { min-width: 260px; }
.session-body { padding: 4px 12px 12px; }
table.rounds td.result { font-size: 18px; }
table.rounds tr:not(.lost) td.result { color: var(--accent); }
.play-btn { padding: 2px 10px; border-radius: 50%; }

/* ---------- Klassiske kort ---------- */
.card.classic { padding: 0; border: none; background: #fff; overflow: hidden; }
.card.classic img { width: 100%; height: 100%; display: block; pointer-events: none; }
.card.classic.small { height: 50px; padding: 0; }
.card.classic.back { background: none; }
.card.classic.fromkat { box-shadow: 0 0 0 3px var(--gold), 0 2px 5px rgba(0, 0, 0, .3); }

/* ---------- Stikbunke og stikanimation ---------- */
.pile { position: relative; display: inline-block; margin-top: 2px; }
.pile .card { box-shadow: 1px 1px 0 #fff, 2px 2px 0 rgba(0, 0, 0, .3), 0 2px 5px rgba(0, 0, 0, .4); }
.pile span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 800; color: #fff; text-shadow: 0 0 4px #000, 0 0 2px #000; }
.pile.bump { animation: pop .5s ease-out; }
/* Egne kort: 100×140 (samme for klassiske og simple kort). */
.my-hand .card { width: 100px; height: 140px; }
.my-hand .card.simple .r, .seat-wrap.pos-top .open-hand .card.simple .r { font-size: 28px; }
.my-hand .card.simple .s, .seat-wrap.pos-top .open-hand .card.simple .s { font-size: 32px; }
.my-hand .card.simple .s.big, .seat-wrap.pos-top .open-hand .card.simple .s.big { font-size: 46px; right: 9px; bottom: 9px; }
.my-hand .card.simple.joker .s, .seat-wrap.pos-top .open-hand .card.simple.joker .s { font-size: 13px; }

/* ---------- Større spillede kort og den nye stikanimation ---------- */
.center .played .card { width: 90px; height: 126px; }
.center .played .card.simple .r { font-size: 26px; }
.center .played .card.simple .s { font-size: 30px; }
.center .played .card.simple .s.big { font-size: 42px; right: 8px; bottom: 8px; }
.center .played .card.simple.joker .s, .last-card .card.simple.joker .s { font-size: 14px; }
.played.lifting .card { animation: lift .3s ease-out forwards; }
.played.lifted .card { transform: scale(1.1); box-shadow: 0 0 0 4px var(--gold), 0 14px 26px rgba(0, 0, 0, .55); }
@keyframes lift {
  to { transform: scale(1.1); box-shadow: 0 0 0 4px var(--gold), 0 14px 26px rgba(0, 0, 0, .55); }
}
.to-bottom { --tx: 0px; --ty: calc(50cqh - 50%); --mx: 0px; --my: 45cqh; }
.to-top { --tx: 0px; --ty: calc(-50cqh + 50%); --mx: 0px; --my: -45cqh; }
.to-left { --tx: calc(-50cqw + 50%); --ty: 0px; --mx: -45cqw; --my: 0px; }
.to-right { --tx: calc(50cqw - 50%); --ty: 0px; --mx: 45cqw; --my: 0px; }
.played.gather { animation: gather .5s ease-in-out forwards; }
@keyframes gather { to { transform: translate(-50%, -50%) translate(calc(var(--tx) + 4px), calc(var(--ty) + 4px)); } }
.played.stack .card { box-shadow: 3px 3px 0 #fff, 4px 4px 0 rgba(0, 0, 0, .35), 6px 6px 0 #fff, 7px 7px 0 rgba(0, 0, 0, .35), 0 8px 18px rgba(0, 0, 0, .5); }
.flipper { position: relative; transform-style: preserve-3d; animation: flip .4s ease-in-out forwards; }
.flipper .face-front, .flipper .face-back { backface-visibility: hidden; }
.flipper .face-back { position: absolute; inset: 0; transform: rotateY(180deg); }
.flipper .face-back .card { width: 100%; height: 100%; }
@keyframes flip { from { transform: scale(1.1) rotateY(0); } to { transform: scale(1) rotateY(180deg); } }
.center .played.stack .card.back { width: 90px; height: 126px; }
.played.moving { animation: move .6s ease-in forwards; }
@keyframes move {
  from { transform: translate(-50%, -50%) translate(var(--x), var(--y)) scale(1); opacity: 1; }
  to { transform: translate(-50%, -50%) translate(calc(var(--x) + var(--mx)), calc(var(--y) + var(--my))) scale(.35); opacity: .3; }
}

/* ---------- Se sidste stik ---------- */
.pile.peek { cursor: pointer; }
.pile.peek:hover .card { box-shadow: 0 0 0 3px var(--gold), 0 2px 5px rgba(0, 0, 0, .4); }
.felt.show-last .felt-inner > :not(.last-trick) { filter: blur(3px) brightness(.8); }
.last-trick { position: absolute; inset: 0; z-index: 20; cursor: pointer; }
.last-card { position: absolute; }
.last-card .card { width: 90px; height: 126px; }
.last-card.pos-bottom { bottom: 200px; left: 50%; transform: translateX(-50%); }
.last-card.pos-top { top: 110px; left: 50%; transform: translateX(-50%); }
.last-card.pos-left { left: 200px; top: 50%; transform: translateY(-50%); }
.last-card.pos-right { right: 200px; top: 50%; transform: translateY(-50%); }
.last-card.winner .card { box-shadow: 0 0 0 4px var(--gold), 0 10px 22px rgba(0, 0, 0, .5); }
.last-caption { position: absolute; left: 50%; top: 33%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, .6); color: #fff; padding: 8px 14px; border-radius: 8px; white-space: nowrap; }

/* ---------- Valg efter meldingen, på bordet over spillerens kort ---------- */
.table-choice { position: absolute; left: 50%; bottom: 226px; transform: translateX(-50%); z-index: 7; max-width: 90%;
  background: var(--panel); color: var(--ink); border-radius: 10px; padding: 10px 18px 12px; text-align: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); }
.table-choice p { margin: 4px 0 8px; }
.table-choice .row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0; align-items: center; }

/* ---------- Bred modal (statistik): tre kolonner, så det kan være på en 1920×1080-skærm ---------- */
.modal .box.wide { max-width: 1800px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; align-items: start; }
.stats-col h3 { margin: 4px 0 6px; }
.stats-col h3:not(:first-child) { margin-top: 18px; }
.stats-col table.grid { width: 100%; font-size: 14px; }
.stats-col p { margin: 0 0 6px; font-size: 14px; }
@media (max-width: 1200px) { .stats-grid { grid-template-columns: 1fr; } }

/* ---------- Afspilning på bordet ---------- */
.rp-player { position: absolute; display: flex; align-items: center; gap: 8px; }
.rp-player .seat-wrap { position: static; transform: none; }
.rp-player.pos-bottom { bottom: 8px; left: 50%; transform: translateX(-50%); flex-direction: column-reverse; }
.rp-player.pos-top { top: 8px; left: 50%; transform: translateX(-50%); flex-direction: column; }
.rp-player.pos-left { left: 10px; top: 50%; transform: translateY(-50%); flex-direction: column; }
.rp-player.pos-right { right: 10px; top: 50%; transform: translateY(-50%); flex-direction: column; }
.rp-hand { display: flex; }
/* Genafspilningen viser alle fire hænder, så kortene er mindre end ved bordet (ellers dækker de for hinanden). */
#rp-table .card { width: 50px; height: 70px; }
#rp-table .card.small { width: 32px; height: 45px; }
#rp-table .rp-hand .card { width: 63px; height: 88px; }
#rp-table .center .played .card { width: 72px; height: 101px; }
/* Top og bund: vandret med 50 % overlap som i spillet. Venstre og højre: lodret, så hjørnet med værdi og
   kulør stadig kan ses (det fylder knap en fjerdedel af kortets højde). */
.rp-player.pos-top .rp-hand .card + .card, .rp-player.pos-bottom .rp-hand .card + .card { margin-left: -32px; }
.rp-player.pos-left .rp-hand, .rp-player.pos-right .rp-hand { flex-direction: column; }
.rp-player.pos-left .rp-hand .card + .card, .rp-player.pos-right .rp-hand .card + .card { margin-top: -64px; }
.rp-controls { text-align: center; }
.rp-controls .row { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; margin: 8px 0; }
/* Styring og hastighed på én linje. */
.rp-controls .row:has(#rp-play) { flex-wrap: nowrap; gap: 4px; }
.rp-controls .row:has(#rp-play) button { padding: 6px 8px; white-space: nowrap; }
.rp-controls .rp-speeds { display: inline-flex; gap: 4px; margin-left: 8px; }
.rp-controls .rp-speeds button { padding: 6px 7px; font-size: 14px; }
.rp-controls input[type=range] { width: 100%; }
.rp-caption { min-height: 2.8em; margin: 4px 0 8px; }
.rp-show { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-top: 8px; text-align: left; }

/* ---------- Historik: faner og graf ---------- */
.hist-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 14px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tab { border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 8px 16px; font-weight: 600; color: var(--muted); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.hist-bar select { font: inherit; padding: 6px 8px; margin-bottom: 6px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; max-width: 100%; }
.hist-chart { position: relative; }
/* Højden begrænses, så grafen altid kan være i vinduet uden scroll; den skaleres og centreres. */
.hist-chart svg { width: 100%; height: auto; max-height: calc(90vh - 210px); display: block; }
.hist-chart .gridline { stroke: var(--line); stroke-width: 1; }
.hist-chart .zero { stroke: var(--muted); stroke-width: 1; }
.hist-chart .axis { fill: var(--muted); font-size: 12px; }
.hist-chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.hist-chart .mark-declarer { stroke: var(--panel); stroke-width: 2; }
.hist-chart .mark-partner { fill: var(--panel); stroke-width: 2; }
.hist-chart .end-label { fill: var(--ink); font-size: 13px; }
.hist-chart .hit { fill: transparent; }
.hist-chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 6px; font-size: 14px; }
.chart-legend i, .chart-tip i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.chart-legend .key { color: var(--muted); }
.chart-tip { position: absolute; width: 220px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); pointer-events: none; }
.chart-tip div { margin-top: 3px; }

/* Firkanterne i stiktabellen (samme som meldingspanelets felter). */
.trick-panel td .stik-box { display: inline-block; width: 13px; height: 13px; vertical-align: middle; }

/* ---------- Hvis tur det er ---------- */
.turn-hint { position: absolute; left: 50%; bottom: 298px; transform: translateX(-50%); z-index: 7; white-space: nowrap;
  background: rgba(0, 0, 0, .55); color: #fff; padding: 6px 14px; border-radius: 16px; font-weight: 600; }
/* Tre prikker der tændes én ad gangen over navneboksen hos den spiller, der er i gang. */
.seat-wrap .thinking-dots { position: absolute; left: 0; right: 0; top: -22px; display: flex; justify-content: center; gap: 5px; }
.seat-wrap.pos-left .thinking-dots, .seat-wrap.pos-right .thinking-dots { top: -20px; }
.seat-wrap.pos-top .thinking-dots { top: auto; bottom: -16px; }
.thinking-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); opacity: .25; animation: dot 1.2s infinite; }
.thinking-dots span:nth-child(2) { animation-delay: .4s; }
.thinking-dots span:nth-child(3) { animation-delay: .8s; }
@keyframes dot { 0%, 60%, 100% { opacity: .25; } 20%, 40% { opacity: 1; } }

/* ---------- Makkerpar (cirkeldiagram) ---------- */
.pairs-chart { display: flex; align-items: center; justify-content: center; gap: 48px; flex-wrap: wrap; padding: 8px 0; }
.pairs-chart svg { width: min(340px, 80vw); height: auto; }
.pairs-chart .slice { stroke: var(--panel); stroke-width: 2; }
.pairs-chart .donut-total { fill: var(--ink); font-size: 40px; font-weight: 700; }
.pairs-chart .donut-label { fill: var(--muted); font-size: 15px; }
.pairs-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.pairs-legend tr.none td { color: var(--muted); }

/* Nolo med flere spillere: navn foran hver spillers felter i meldingspanelet. */
.stik-boxes .who { font-size: 12px; margin-right: 6px; color: var(--muted); }
