:root {
  --bg: #0b2a1e;
  --filz: #14573a;
  --filz-dunkel: #0f4630;
  --rand: #6b4a2b;
  --leiste: #08201a;
  --text: #eef5f0;
  --text-2: #a9c7b6;
  --gold: #ffd54a;
  --karte: #ffffff;
  --rot: #c62828;
  --schwarz: #15181b;
  --gruen: #2ecc71;
  --gelb: #f4c430;
  --ampel-rot: #e74c3c;
  --fold: #b23b3b;
  --raise: #e9a23b;
  --call: #2fbf6a;
  --popup: #ffffff;
  --popup-text: #13221b;
  --akzent: #0f6b45;
  --seat-w: 84px;
  --mini-w: 21px;
  --mini-h: 29px;
  --board-w: 38px;
  --board-h: 53px;
  --held-w: 46px;
  --held-h: 64px;
}
@media (max-width: 420px) {
  :root { --seat-w: 82px; --mini-w: 19px; --mini-h: 26px; --board-w: 34px; --board-h: 48px; --held-w: 42px; --held-h: 58px; }
}
@media (max-height: 700px) {
  :root { --mini-w: 17px; --mini-h: 23px; --board-w: 30px; --board-h: 42px; --held-w: 36px; --held-h: 50px; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { display: block; }

#app { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto auto; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }

/* Kopfzeile */
.kopf { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--leiste); }
.titel { font-weight: 700; flex: 1; white-space: nowrap; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--text); }
.icon-btn:active { background: #ffffff1a; }
.icon-btn svg { width: 22px; height: 22px; }
.schalter { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; padding: 4px 6px; border-radius: 10px; }
.sw { width: 30px; height: 18px; border-radius: 9px; background: #2a4a3c; position: relative; transition: background .2s; flex: none; }
.sw::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #cfe; transition: left .2s; }
[aria-pressed="true"] .sw { background: var(--gold); }
[aria-pressed="true"] .sw::after { left: 14px; background: #111; }
[aria-pressed="true"] { color: var(--gold); }

/* Tisch */
.tisch-bereich { position: relative; min-height: 0; overflow: hidden; }
.oval { position: absolute; left: 7%; right: 7%; top: 9%; bottom: 9%; border-radius: 50%; background: radial-gradient(ellipse at center, var(--filz) 55%, var(--filz-dunkel)); border: 4px solid var(--rand); box-shadow: inset 0 0 30px #0006; }
.mitte { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.board { display: flex; gap: 3px; height: var(--board-h); }
.pot { font-size: 13px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.meldung { font-size: 12px; color: var(--text); white-space: nowrap; max-width: 64vw; overflow: hidden; text-overflow: ellipsis; text-align: center; min-height: 16px; }

.sitz { position: absolute; width: var(--seat-w); transform: translate(-50%, -50%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: opacity .3s; }
.sitz.gefoldet { opacity: .38; }
.sitz.am-zug .pos { color: var(--gold); }
.pos { font-size: 10px; letter-spacing: -0.2px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-decoration: underline dotted #ffffff70; text-underline-offset: 2px; }
.typ { font-size: 10px; height: 17px; line-height: 17px; padding: 0 7px; border-radius: 9px; background: var(--leiste); color: #bfe8d2; white-space: nowrap; text-decoration: underline dotted #ffffff50; text-underline-offset: 2px; }
.karten-zeile { display: flex; align-items: center; gap: 2px; height: var(--mini-h); }
.zeile4 { display: flex; gap: 3px; align-items: center; height: 16px; font-size: 10px; color: var(--text-2); white-space: nowrap; }
.pill { display: inline-block; background: #000c; color: var(--gold); border-radius: 8px; padding: 0 5px; height: 16px; line-height: 16px; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.chip-akt { height: 16px; line-height: 16px; padding: 0 5px; border-radius: 8px; font-size: 10px; font-weight: 700; background: #ffffff22; color: var(--text); }
.chip-akt.fold { background: #b23b3b55; }
.chip-akt.raise { background: #e9a23b; color: #2b1800; }
.chip-akt.call, .chip-akt.check { background: #2fbf6a55; }
.dealer { width: 15px; height: 15px; border-radius: 50%; background: #fff; color: #111; font-size: 9px; font-weight: 800; line-height: 15px; }

/* Karten */
.k { width: var(--mini-w); height: var(--mini-h); border-radius: 3px; background: var(--karte); color: var(--schwarz); font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: .95; font-size: calc(var(--mini-h) * .38); box-shadow: 0 1px 2px #0007; }
.k.rot { color: var(--rot); }
.k.zu { background: repeating-linear-gradient(45deg, #2b4fa0 0 4px, #24448a 4px 8px); border: 1.5px solid #fff; }
.k.board { width: var(--board-w); height: var(--board-h); font-size: calc(var(--board-h) * .36); border-radius: 5px; }
.k.leer { background: #ffffff10; box-shadow: none; border: 1px dashed #ffffff30; }
.k.gross { width: var(--held-w); height: var(--held-h); font-size: calc(var(--held-h) * .36); border-radius: 6px; }
.k.gewinner { outline: 2px solid var(--gold); }

/* Eigener Bereich */
.held { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 6px 12px; background: linear-gradient(#0b2a1e00, #08201a); min-height: calc(var(--held-h) + 12px); }
.held .links { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-width: 0; }
.held .links .pos { font-size: 12px; }
.held .karten { display: flex; gap: 4px; }
.held .rechts { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; min-width: 0; font-size: 11px; color: var(--text-2); }
.held .rechts .pill { font-size: 13px; height: 20px; line-height: 20px; padding: 0 8px; }
.held .info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stack { font-size: 11px; color: var(--text-2); white-space: nowrap; }

/* Aktionsleiste */
.aktionen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 12px 10px; background: var(--leiste); min-height: 64px; }
.aktionen.eins { grid-template-columns: 1fr; }
.akt { height: 46px; border-radius: 12px; font-weight: 800; font-size: 15px; white-space: nowrap; }
.akt.fold { background: var(--fold); color: #fff; }
.akt.call { background: var(--call); color: #062b14; }
.akt.raise { background: var(--raise); color: #2b1800; }
.akt.neutral { background: #ffffff22; color: var(--text); }
.akt:disabled { opacity: .35; }
.warte { grid-column: 1 / -1; display: grid; place-items: center; color: var(--text-2); font-size: 13px; }

.raise-panel { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.raise-panel .wert { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.raise-panel input[type=range] { flex: 1; accent-color: var(--raise); height: 28px; }
.raise-panel .betrag { font-weight: 800; color: var(--gold); min-width: 64px; text-align: right; white-space: nowrap; }
.mini-btn { height: 34px; border-radius: 10px; background: #ffffff1c; font-size: 13px; font-weight: 700; white-space: nowrap; }

/* Analyse-Blatt */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--popup); color: var(--popup-text); border-radius: 18px 18px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px #0008; animation: hoch .22s ease-out; z-index: 20; }
@keyframes hoch { from { transform: translateY(100%); } }
.sheet-kopf { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.score { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; font-weight: 900; color: #fff; }
.score.gruen { background: #27ae60; } .score.gelb { background: #e0a800; } .score.rot { background: #d64535; }
.sheet .kat { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; overflow: hidden; }
.chip { height: 22px; line-height: 22px; padding: 0 9px; border-radius: 11px; background: #e3efe8; color: #0f4630; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.uebung { background: #fff1c2; color: #6a4b00; }
.sheet .text { margin-top: 10px; font-size: 14.5px; line-height: 1.4; min-height: 40px; }
.sheet .text.laedt { color: #6a7c72; }
.sheet .weiter { margin-top: 10px; width: 100%; height: 44px; border-radius: 12px; background: var(--akzent); color: #fff; font-weight: 800; }
.sheet .beste { font-size: 12px; color: #4b5d53; white-space: nowrap; }

/* Popup */
.overlay { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; padding: 16px; z-index: 30; }
.popup { background: var(--popup); color: var(--popup-text); border-radius: 16px; padding: 16px; width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow: hidden; box-shadow: 0 10px 40px #000a; }
.popup h3 { font-size: 16px; margin-bottom: 8px; }
.popup p { font-size: 13.5px; margin-bottom: 7px; line-height: 1.4; }
.popup b { color: var(--akzent); }
.popup .zu { margin-top: 6px; width: 100%; height: 42px; border-radius: 12px; background: var(--akzent); color: #fff; font-weight: 800; }

/* Vollbild-Screens: Profil, Einstellungen */
.screen { position: fixed; inset: 0; background: var(--bg); z-index: 25; display: grid; grid-template-rows: auto auto 1fr auto; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px calc(14px + env(safe-area-inset-bottom)); }
.screen-kopf { display: flex; align-items: center; gap: 8px; }
.screen-kopf h2 { flex: 1; font-size: 18px; }
.kacheln { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.kachel { height: 86px; border-radius: 12px; background: var(--filz-dunkel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; }
.kachel .wert { font-size: 24px; font-weight: 900; color: var(--gold); }
.kachel .name { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 95%; }
.kachel .balken { width: 70%; height: 4px; border-radius: 2px; background: #ffffff20; overflow: hidden; }
.kachel .balken i { display: block; height: 100%; background: var(--gold); }
.verlauf { min-height: 0; border-radius: 12px; background: var(--filz-dunkel); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.verlauf .kopfzeile { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.verlauf svg { flex: 1; width: 100%; min-height: 0; }
.leer-hinweis { flex: 1; display: grid; place-items: center; color: var(--text-2); font-size: 13px; text-align: center; }
.unten { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.einst-liste { display: grid; gap: 10px; align-content: start; min-height: 0; }
.einst { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; background: var(--filz-dunkel); border-radius: 12px; }
.einst .l { min-width: 0; }
.einst .l b { display: block; font-size: 14px; }
.einst .l span { display: block; font-size: 11.5px; color: var(--text-2); }
.einst select, .einst input[type=password], .einst input[type=text] { font: inherit; background: #0b2a1e; color: var(--text); border: 1px solid #2d5c47; border-radius: 8px; height: 34px; padding: 0 8px; }
.einst.schluessel { grid-template-columns: 1fr; }
.einst.schluessel input { width: 100%; }

@media (min-width: 900px) {
  :root { --seat-w: 120px; --mini-w: 28px; --mini-h: 39px; --board-w: 52px; --board-h: 72px; --held-w: 58px; --held-h: 80px; }
  .pos { font-size: 13px; } .typ { font-size: 12px; height: 20px; line-height: 20px; }
  .pill { font-size: 12px; height: 18px; line-height: 18px; }
  .zeile4 { font-size: 12px; height: 18px; } .chip-akt { font-size: 12px; height: 18px; line-height: 18px; }
  .pot { font-size: 16px; } .meldung { font-size: 14px; }
  .akt { height: 52px; font-size: 17px; }
  .sheet { left: 50%; right: auto; width: 560px; transform: translateX(-50%); animation: none; }
  .kachel { height: 120px; } .kachel .wert { font-size: 34px; } .kachel .name { font-size: 13px; }
}
.einst input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--gold); }
