:root {
  --felt: #13573a;
  --felt-dark: #0d3b26;
  --ink: #f3f1e8;
  --muted: #b9c9bd;
  --accent: #f2c14e;
  --danger: #ff8a7a;
  --panel: #fbfaf5;
  --panel-ink: #1c2420;
  --red: #c8102e;
  --black: #1a1a1a;
  --blue: #1d4fb8;
  --green: #12813a;
  --cw: 80px;
  --tcw: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 40%, var(--felt) 0%, var(--felt-dark) 75%) fixed;
  background-color: var(--felt-dark);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
.hidden { display: none !important; }
button {
  font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 18px;
  background: #e9e6da; color: var(--panel-ink); cursor: pointer; touch-action: manipulation;
}
button.primary { background: var(--accent); color: #2b2100; }
button:disabled { opacity: .45; cursor: default; }
button.link { background: none; color: #557; text-decoration: underline; padding: 6px; }
input {
  font: inherit; font-size: 18px; padding: 10px 12px; border-radius: 10px; border: 1px solid #c9c5b5;
  width: 100%; margin-top: 4px; background: #fff; color: var(--panel-ink);
}
.muted { color: #66706a; }
.small { font-size: 13px; }
.err { color: #b3261e; min-height: 1.2em; margin: 4px 0 0; }

/* Start und Lobby */
.screen { height: 100dvh; overflow: auto; }
#start, #lobby { display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; }
.panel {
  background: var(--panel); color: var(--panel-ink); border-radius: 18px; padding: 22px 20px;
  width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 14px 40px rgba(0,0,0,.35); margin: auto 0;
}
.panel h1 { font-size: 24px; margin: 0 0 6px; text-align: center; }
.panel h2 { margin: 0; }
.panel label { font-weight: 600; font-size: 14px; }
.suits { display: block; font-size: 30px; letter-spacing: 6px; color: var(--red); }
.version { align-self: flex-end; font-size: 11px; color: #9a9f98; margin-top: -4px; }
.or { text-align: center; color: #888; font-size: 13px; }
.code { font-family: ui-monospace, Menlo, monospace; letter-spacing: 3px; font-weight: 700; }
.panel .code { background: #1c2420; color: var(--accent); padding: 2px 8px; border-radius: 8px; }
.row { display: flex; gap: 8px; }
.row button { flex: 1; }
.plist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.plist li { background: #eeebe0; padding: 10px 12px; border-radius: 10px; display: flex; gap: 8px; align-items: center; }
.plist li .tag { margin-left: auto; font-size: 12px; color: #6a6; }
.plist li .rm { padding: 2px 10px; font-size: 18px; line-height: 1; background: #ddd8c8; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #5c5; flex: none; }
.dot.off { background: #c55; }
fieldset { border: 1px solid #d9d5c5; border-radius: 12px; padding: 8px 12px 10px; }
fieldset[disabled] { opacity: .7; }
legend { font-weight: 700; padding: 0 6px; }
label.radio { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; padding: 5px 0; }
label.radio input { width: auto; margin-top: 3px; }

/* Spieltisch */
#game { display: grid; grid-template-rows: auto 1fr auto auto; height: 100dvh; overflow: hidden; }
.bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top));
  background: rgba(0,0,0,.25);
}
.bar .code { color: var(--accent); }
.ginfo { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.icon { background: rgba(255,255,255,.12); color: var(--ink); padding: 6px 12px; font-size: 18px; border-radius: 10px; }
#table { position: relative; min-height: 0; }
#seats, #trick, #felt, #banner { position: absolute; inset: 0; }
#felt { margin: 8% 10%; border-radius: 50%; border: 2px solid rgba(255,255,255,.07); pointer-events: none; }
#banner { pointer-events: none; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; }
#banner span {
  background: rgba(0,0,0,.55); padding: 5px 12px; border-radius: 20px; font-size: 14px; font-weight: 600;
  animation: fade .3s;
}

.seat {
  position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center;
  gap: 3px; min-width: 76px; max-width: 120px;
}
.seat .name {
  background: rgba(0,0,0,.35); padding: 4px 10px; border-radius: 14px; font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; border: 2px solid transparent;
  display: flex; gap: 6px; align-items: center;
}
.seat.turn .name { border-color: var(--accent); background: rgba(242,193,78,.25); animation: pulse 1.4s infinite; }
.seat .meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.badge { background: rgba(255,255,255,.15); padding: 1px 6px; border-radius: 8px; color: var(--ink); }
.badge.dealer { background: #3b6fb6; }
.badge.alte { background: #6b3fa0; }
.badge.watch { background: #6c6c6c; }
.badge.hz { background: #b5527a; }
.badge.ans { background: #d35400; font-weight: 700; }
button.announce { margin-left: 10px; padding: 4px 14px; font-size: 15px; background: #d35400; color: #fff; border-radius: 16px; vertical-align: middle; }
.badge.vf { background: #c0392b; font-weight: 700; }
select { font: inherit; font-size: 16px; padding: 8px 10px; border-radius: 10px; border: 1px solid #c9c5b5; width: 100%; margin: 4px 0 6px; background: #fff; color: var(--panel-ink); }
.req { background: #fff3cd; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.backs { display: flex; height: 22px; }
.backs i {
  width: 14px; height: 21px; border-radius: 3px; margin-left: -8px; border: 1px solid #fff;
  background: repeating-linear-gradient(45deg, #8a1d2c 0 3px, #a8293c 3px 6px);
}
.backs i:first-child { margin-left: 0; }

/* Karten: das Kartenbild ist ein SVG (siehe cardHTML), Farbe kommt über currentColor */
.card {
  position: absolute; width: var(--cw); height: calc(var(--cw) * 1.45); border-radius: calc(var(--cw) * .07);
  box-shadow: -1px 1px 4px rgba(0,0,0,.35); color: var(--black); overflow: hidden; background: #fff;
  transition: transform .18s ease, filter .18s, box-shadow .18s;
}
.card svg { display: block; width: 100%; height: 100%; }
.card .court { font: 700 30px Georgia, "Times New Roman", serif; fill: currentColor; }
.card .rank { font: 700 24px Georgia, "Times New Roman", serif; fill: currentColor; }
.card.suit-h { color: var(--red); }
.card.suit-d { color: var(--red); }
body.four .card.suit-s { color: var(--green); }
body.four .card.suit-d { color: var(--blue); }
.card.trumpmark { box-shadow: 0 0 0 2px rgba(214,160,30,.9), -1px 1px 4px rgba(0,0,0,.35); }

#hand { position: relative; height: calc(var(--cw) * 1.75 + 10px); overflow: hidden; margin-bottom: env(safe-area-inset-bottom); }
#hand .card { bottom: 6px; left: 50%; cursor: pointer; transform-origin: 50% 100%; }
#hand.myturn .card.illegal { filter: brightness(.62) saturate(.6); }
#hand .card.sel { box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(0,0,0,.5); }

#trick .card { width: var(--tcw); height: calc(var(--tcw) * 1.45); --cw: var(--tcw); transform: translate(-50%, -50%); animation: drop .25s ease-out; }
#trick .card.win { box-shadow: 0 0 0 3px var(--accent), 0 6px 18px rgba(0,0,0,.5); z-index: 10; }
#trick.collect .card { opacity: .0; transition: opacity .3s .1s; }

#status { text-align: center; min-height: 26px; padding: 2px 10px; font-size: 15px; font-weight: 600; }
#status .mine { display: flex; gap: 6px; justify-content: center; font-size: 11px; font-weight: 400; margin-bottom: 2px; }
#status .hint { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
#status.myturn { color: var(--accent); }

/* Dialoge */
#overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
#overlay.pass { background: transparent; pointer-events: none; align-items: flex-start; padding-top: 60px; }
#overlay.pass .modal { pointer-events: auto; }
.modal {
  background: var(--panel); color: var(--panel-ink); border-radius: 16px; padding: 18px; width: 100%; max-width: 460px;
  max-height: 88dvh; overflow: auto; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.4);
}
.modal h3 { margin: 0; }
.modal .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.modal .btns button { flex: 1; }
.choice { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.choice button { padding: 10px 4px; }
.choice button.on { background: var(--accent); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 10px 4px; }
.seg button.on { background: var(--accent); }
table.score { width: 100%; border-collapse: collapse; font-size: 14px; }
table.score th, table.score td { padding: 5px 4px; text-align: right; border-bottom: 1px solid #e3dfd0; }
table.score th:first-child, table.score td:first-child { text-align: left; }
table.score tfoot td { font-weight: 800; border-top: 2px solid #333; }
.pos { color: #1d7a3a; } .neg { color: #b3261e; }
.lines { margin: 0; padding-left: 18px; }
.mini { display: flex; gap: 4px; flex-wrap: wrap; position: relative; }
.mini .card { position: relative; --cw: 48px; }
.lt { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
.big { font-size: 22px; font-weight: 800; }

#toast {
  position: fixed; left: 50%; bottom: 30%; transform: translateX(-50%); background: #222; color: #fff;
  padding: 10px 16px; border-radius: 12px; z-index: 60; max-width: 90vw; text-align: center; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

@keyframes pulse { 50% { box-shadow: 0 0 12px 2px rgba(242,193,78,.6); } }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -50%) scale(1.25); } }
@keyframes fade { from { opacity: 0; } }
/* Sprachumschalter oben rechts (Start und Lobby), im Spiel steht die Wahl im Menü */
button.lang {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 30;
  padding: 6px 10px; font-size: 13px; border-radius: 8px;
  background: rgba(255, 255, 255, .14); color: var(--ink); border: 1px solid rgba(255, 255, 255, .3);
}
.langsw { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.langsw button { padding: 6px 12px; font-size: 14px; }
/* Abrechnung: Wert jeder Zeile rechtsbündig */
.lines.calc { list-style: none; padding-left: 0; max-width: 340px; }
.lines.calc li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; border-bottom: 1px dotted #d8d4c4; }
.lines.calc li > span:last-child { font-weight: 700; min-width: 2.5em; text-align: right; }
.lines.calc .mul { color: #555; }
