:root {
  --felt: #1d5c3a;
  --felt-dark: #154a2e;
  --ink: #f4f1e8;
  --muted: #b9c9bd;
  --accent: #f2c14e;
  --red: #c8102e;
  --black: #1b1b1b;
  --card: #fffdf7;
  --panel: rgba(0, 0, 0, 0.35);
  --cw: 62px;
  --ch: 90px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
button {
  font: inherit; cursor: pointer; border: 0; border-radius: 8px;
  padding: 8px 14px; background: var(--accent); color: #222; font-weight: 600;
}
button.ghost { background: rgba(255,255,255,0.12); color: var(--ink); font-weight: 500; }
button:disabled { opacity: 0.45; cursor: default; }
input, select {
  font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.25); color: var(--ink);
}
select option { color: #222; }
h1 { font-size: 28px; margin: 0 0 4px; letter-spacing: 1px; }
.muted { color: var(--muted); }
.center-page { max-width: 460px; margin: 0 auto; padding: 40px 16px; display: grid; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel { background: var(--panel); border-radius: 12px; padding: 14px; }
.err { color: #ffb3b3; min-height: 1.2em; }

/* top bar */
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(0,0,0,0.25); flex-wrap: wrap; }
.bar .title { font-weight: 700; margin-right: auto; }
.bar button { padding: 6px 10px; font-size: 14px; }

/* table */
.table { position: relative; height: calc(100vh - 52px - 150px); min-height: 330px; }
.seat { position: absolute; text-align: center; min-width: 120px; }
.seat.top { top: 10px; left: 50%; transform: translateX(-50%); }
.seat.left { left: 10px; top: 42%; transform: translateY(-50%); }
.seat.right { right: 10px; top: 42%; transform: translateY(-50%); }
.seat.bottom { bottom: 6px; left: 50%; transform: translateX(-50%); }
.seat .name { font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--panel); display: inline-block; }
.seat.turn .name { background: var(--accent); color: #222; }
.seat .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin: 2px 2px 0; }
.badge.re { background: #e8e1c9; color: #222; }
.badge.kontra { background: #2d2d2d; color: #fff; }
.badge.ann { background: var(--red); color: #fff; }
.badge.off { background: #777; color: #fff; }
.backs { display: flex; justify-content: center; margin-top: 4px; }
.back { width: 16px; height: 24px; border-radius: 3px; margin-left: -8px; background: repeating-linear-gradient(45deg, #8b1e2d, #8b1e2d 3px, #a8323f 3px, #a8323f 6px); border: 1px solid #fff8; }

.trick { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: 230px; height: 200px; }
.trick .card { position: absolute; transition: transform 0.2s; }
.trick .pos-bottom { left: calc(50% - var(--cw) / 2); bottom: 0; }
.trick .pos-top { left: calc(50% - var(--cw) / 2); top: 0; }
.trick .pos-left { left: 0; top: calc(50% - var(--ch) / 2); }
.trick .pos-right { right: 0; top: calc(50% - var(--ch) / 2); }
.info { position: absolute; left: 50%; top: 42%; transform: translate(-50%, 120px); text-align: center; width: 90%; color: var(--muted); font-size: 13px; }
.gamelabel { position: absolute; left: 12px; top: 10px; font-size: 13px; color: var(--muted); }

/* cards */
.card {
  width: var(--cw); height: var(--ch); border-radius: 7px; background: var(--card);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4); position: relative; color: var(--black);
  user-select: none; flex: none;
}
.card.red { color: var(--red); }
.card .ix { position: absolute; left: 5px; top: 3px; font-weight: 800; font-size: 16px; line-height: 1; text-align: center; }
.card .ix small { display: block; font-size: 14px; }
.card .pip { position: absolute; right: 6px; bottom: 2px; font-size: 32px; line-height: 1; }
.card.trump::after { content: ""; position: absolute; inset: 0; border-radius: 7px; box-shadow: inset 0 -4px 0 var(--accent); }

.hand { display: flex; justify-content: center; padding: 8px 10px 14px; min-height: 120px; }
.hand .card { margin-left: calc(var(--overlap, -18px)); transition: transform 0.12s; }
.hand .card:first-child { margin-left: 0; }
.hand .card.legal { cursor: pointer; }
.hand .card.legal:hover { transform: translateY(-14px); }
.hand.myturn .card:not(.legal) { filter: brightness(0.6); }
.actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 38px; padding: 0 10px; }
.actions button.ann { background: var(--red); color: #fff; }

/* speech bubbles */
.bubble {
  position: absolute; z-index: 20; max-width: 240px; background: #fff; color: #222; padding: 8px 12px;
  border-radius: 14px; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,0.35); animation: pop 0.2s ease-out;
}
.bubble::after { content: ""; position: absolute; width: 12px; height: 12px; background: #fff; transform: rotate(45deg); }
.bubble.top { top: 64px; left: 50%; translate: -50% 0; }
.bubble.top::after { top: -5px; left: calc(50% - 6px); }
.bubble.left { left: 14px; top: calc(42% + 40px); }
.bubble.left::after { top: -5px; left: 30px; }
.bubble.right { right: 14px; top: calc(42% + 40px); }
.bubble.right::after { top: -5px; right: 30px; }
.bubble.bottom { bottom: 70px; left: 50%; translate: -50% 0; }
.bubble.bottom::after { bottom: -5px; left: calc(50% - 6px); }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: grid; place-items: center; z-index: 30; padding: 16px; }
.sheet { background: #183f2a; border-radius: 14px; padding: 18px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.sheet h2 { margin: 0 0 10px; font-size: 20px; }
table.list { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
table.list th, table.list td { padding: 5px 6px; text-align: right; border-bottom: 1px solid rgba(255,255,255,0.1); }
table.list th:first-child, table.list td:first-child, table.list td.lbl, table.list th.lbl { text-align: left; }
table.list tfoot td { font-weight: 800; border-top: 2px solid rgba(255,255,255,0.4); }
.pos { color: #a6f0b6; } .neg { color: #ffb3b3; }
.seats { display: grid; gap: 8px; }
.seats .row { justify-content: space-between; background: rgba(0,0,0,0.2); padding: 8px 10px; border-radius: 8px; }
.code { font-size: 26px; font-weight: 800; letter-spacing: 4px; color: var(--accent); }

@media (max-width: 640px) {
  :root { --cw: 46px; --ch: 68px; }
  .card .ix { font-size: 13px; } .card .ix small { font-size: 11px; } .card .pip { font-size: 22px; }
  .seat { min-width: 80px; } .seat .name { font-size: 13px; }
  .seat.left, .seat.right { top: 24%; }
  .seat.left { left: 4px; } .seat.right { right: 4px; }
  .trick, .info { top: 50%; }
  .trick { width: 170px; height: 160px; }
  .table { height: calc(100vh - 52px - 130px); }
  .hand { min-height: 90px; }
}
