:root {
  --felt-1: #0e5138;
  --felt-2: #07291d;
  --gold: #e7c25a;
  --gold-dim: #b9952f;
  --cream: #f5efe0;
  --ink: #16110a;
  --danger: #e06a5a;
  --ok: #5fd08a;
  --panel: rgba(0, 0, 0, 0.34);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden-Attribut muss IMMER gewinnen – sonst überschreibt z. B.
   .overlay{display:grid} das Verstecken und das Overlay klebt fest. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--cream);
  background:
    radial-gradient(120% 90% at 50% 8%, var(--felt-1) 0%, var(--felt-2) 70%, #041109 100%);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 700; border: none; cursor: pointer;
  padding: 0.85em 1.4em; border-radius: 12px; color: var(--ink);
  background: linear-gradient(180deg, #f3dd92, var(--gold) 60%, var(--gold-dim));
  box-shadow: var(--shadow); transition: transform .12s ease, filter .12s ease, opacity .12s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }
.btn-primary { width: 100%; }
.btn-secondary {
  background: linear-gradient(180deg, #3a5d4e, #21392f);
  color: var(--cream); border: 1px solid rgba(231,194,90,0.4);
}
.btn-mini {
  font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer;
  background: rgba(255,255,255,0.1); color: var(--cream);
  border: 1px solid rgba(231,194,90,0.45); border-radius: 8px; padding: .35em .7em;
  transition: background .15s;
}
.btn-mini:hover { background: rgba(231,194,90,0.25); }

/* ---------- Landing ---------- */
#screen-landing { align-items: center; justify-content: center; padding: 20px; }
.landing-card {
  width: min(420px, 100%); background: var(--panel); backdrop-filter: blur(6px);
  border: 1px solid rgba(231,194,90,0.35); border-radius: 20px; padding: 28px 26px;
  box-shadow: var(--shadow);
}
.logo {
  font-size: clamp(1.8rem, 6vw, 2.6rem); text-align: center; letter-spacing: 1px;
  color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.subtitle { text-align: center; opacity: .8; margin: 6px 0 22px; font-size: .92rem; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1; font: inherit; font-weight: 700; cursor: pointer; padding: .6em;
  background: transparent; color: var(--cream); opacity: .6;
  border: none; border-bottom: 3px solid transparent; transition: .15s;
}
.tab.active { opacity: 1; border-bottom-color: var(--gold); color: var(--gold); }
.pane { display: none; flex-direction: column; gap: 14px; }
.pane.active { display: flex; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; opacity: .9; }
input {
  font: inherit; padding: .75em .9em; border-radius: 10px; border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.3); color: var(--cream); outline: none;
}
input:focus { border-color: var(--gold); }
#join-code { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }
.form-error { color: var(--danger); font-size: .85rem; min-height: 1.1em; text-align: center; }
.credit { position: fixed; bottom: 12px; width: 100%; text-align: center; font-size: .75rem; opacity: .5; }

/* ---------- Game topbar / message ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; gap: 10px;
}
.room { display: flex; align-items: center; gap: 10px; }
.room-label { font-size: .7rem; text-transform: uppercase; letter-spacing: 2px; opacity: .6; }
.room-code { font-size: 1.3rem; font-weight: 800; letter-spacing: 4px; color: var(--gold); }
.variant-badge {
  font-weight: 800; padding: .4em 1em; border-radius: 999px; font-size: .85rem;
  background: rgba(231,194,90,0.18); border: 1px solid var(--gold); color: var(--gold);
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.resume-box {
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  background: rgba(231,194,90,0.12); border: 1px solid rgba(231,194,90,0.4);
  border-radius: 12px; padding: 12px; margin-bottom: 16px; font-size: .85rem; text-align: center;
}
.message {
  text-align: center; font-size: clamp(.95rem, 2.4vw, 1.15rem); font-weight: 600;
  padding: 6px 16px 10px; min-height: 1.6em; transition: opacity .2s;
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.message.flash { animation: flash .6s ease; }
@keyframes flash { 0%{ color: var(--gold); transform: scale(1.06);} 100%{ transform: scale(1);} }

/* ---------- Table ---------- */
.table {
  flex: 1; position: relative; display: flex; flex-direction: column;
  justify-content: space-between; align-items: center; padding: 8px 10px 10px;
  min-height: 0;
}
.seat { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.seat-opponent { padding-top: 4px; }
.seat-self { padding-bottom: 4px; }
.seat-info { display: flex; align-items: center; gap: 10px; }
.seat-name { font-weight: 700; font-size: 1.02rem; }
.seat-status { font-size: .8rem; opacity: .75; }
.seat-status.off { color: var(--danger); }
.seat-status.ready { color: var(--ok); }
.dealer-chip {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff, var(--gold) 70%); color: var(--ink);
  font-weight: 900; font-size: .82rem; box-shadow: 0 2px 6px rgba(0,0,0,.5);
  border: 2px solid #fff;
}
.hand { display: flex; gap: 10px; min-height: 96px; align-items: center; justify-content: center; flex-wrap: wrap; }

/* Board / Gemeinschaftskarten */
.board {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; width: 100%; position: relative;
  border-radius: 50%/22%;
  background: radial-gradient(80% 120% at 50% 50%, rgba(255,255,255,0.05), transparent 70%);
}
.board::before {
  content: ""; position: absolute; inset: 6% 4%; border-radius: 50%/40%;
  border: 2px solid rgba(231,194,90,0.18); pointer-events: none;
}
.community { display: flex; gap: 8px; min-height: 110px; align-items: center; flex-wrap: wrap; justify-content: center; }
.burn-pile { display: flex; gap: 3px; height: 18px; opacity: .5; }
.burn-pile .burn { width: 22px; height: 16px; border-radius: 3px; background: rgba(0,0,0,.4); border: 1px solid rgba(231,194,90,.3); }

/* Auslosung */
.draw-area {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; background: rgba(4,17,9,0.6); backdrop-filter: blur(2px);
  z-index: 5;
}
.draw-title { font-size: clamp(1.1rem,3vw,1.5rem); font-weight: 800; color: var(--gold); text-align:center; }
.draw-rows { display: flex; flex-direction: column; gap: 14px; }
.draw-row { display: flex; align-items: center; gap: 18px; justify-content: center; opacity: 0; }
.draw-row.show { opacity: 1; }
.draw-vs { font-weight: 800; opacity: .7; }
.draw-row .seat-tag { width: 70px; text-align: center; font-size: .8rem; opacity: .85; }
.draw-row.winner-0 .seat-tag:first-child,
.draw-row.winner-1 .seat-tag:last-child { color: var(--gold); font-weight: 800; }

/* ---------- Controls ---------- */
.controls {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 80px; justify-content: center;
}
.controls .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; max-width: 560px; }
.controls .btn { flex: 1; min-width: 140px; }
.hint { font-size: .85rem; opacity: .7; text-align: center; }

/* Spielwahl-Buttons */
.variant-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 640px; }
.variant-btn {
  display: flex; flex-direction: column; gap: 4px; align-items: center; cursor: pointer;
  background: rgba(0,0,0,0.3); border: 1px solid rgba(231,194,90,0.4); color: var(--cream);
  border-radius: 14px; padding: 14px 8px; transition: .15s; text-align: center;
}
.variant-btn:hover { background: rgba(231,194,90,0.16); transform: translateY(-2px); }
.variant-btn b { color: var(--gold); font-size: 1.05rem; }
.variant-btn small { opacity: .75; font-size: .72rem; line-height: 1.25; }
@media (max-width: 520px) { .variant-grid { grid-template-columns: 1fr; } }

/* ---------- Overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(2,10,6,0.78); backdrop-filter: blur(4px); animation: fade .3s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.overlay-card {
  width: min(440px, 92%); text-align: center; padding: 32px 26px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(20,55,40,0.96), rgba(7,30,21,0.96));
  border: 1px solid var(--gold); box-shadow: var(--shadow);
}
.overlay-trophy { font-size: 3.4rem; animation: pop .5s ease; }
@keyframes pop { 0%{ transform: scale(0) rotate(-20deg);} 70%{ transform: scale(1.25);} 100%{ transform: scale(1);} }
.overlay-card h2 { color: var(--gold); font-size: 1.7rem; margin: 8px 0; }
.overlay-card p { opacity: .9; margin-bottom: 20px; }
.overlay-buttons { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Verbindungsanzeige ---------- */
.conn {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; text-align: center;
  background: var(--danger); color: #fff; font-size: .8rem; padding: 4px; font-weight: 700;
}

/* Glüh-Effekt für Gewinnerkarten */
.winning { animation: glow 1.4s ease-in-out infinite alternate; z-index: 2; }
@keyframes glow {
  from { box-shadow: 0 0 4px rgba(231,194,90,.6), 0 6px 14px rgba(0,0,0,.4); }
  to   { box-shadow: 0 0 22px 6px rgba(231,194,90,.85), 0 6px 14px rgba(0,0,0,.4); }
}
.dimmed { opacity: 0.5; filter: grayscale(0.3); }

/* ---------- Landing-Panes ---------- */
.pane-hint { font-size: .82rem; opacity: .75; line-height: 1.35; margin-bottom: 4px; }

/* ---------- Virtueller Dealer (Croupier) ---------- */
/* Dealer sitzt SEITLICH (links, mittig) – nicht auf einem Spielerplatz. */
.dealer {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  z-index: 6; display: flex; flex-direction: column; align-items: center; pointer-events: none;
}
.dealer-svg { width: 74px; height: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,.45)); }
.dealer-name {
  margin-top: -2px; font-size: .68rem; font-weight: 800; color: var(--gold);
  background: rgba(0,0,0,0.5); border: 1px solid rgba(231,194,90,0.45);
  border-radius: 999px; padding: 1px 9px;
}
@media (min-width: 700px) { .dealer-svg { width: 96px; } }
.d-shadow { fill: rgba(0,0,0,0.3); }
.d-arm { fill: none; stroke: #1f2d3d; stroke-width: 7; stroke-linecap: round; }
.d-hand { fill: #f0c39b; }
.d-deck { fill: #fbfaf5; stroke: var(--gold); stroke-width: 1; }
.d-vest { fill: #1f2d3d; }
.d-shirt { fill: #f5f1e6; }
.d-lapel { fill: #16212e; }
.d-bow { fill: #b23a2e; }
.d-bowknot { fill: #7e241b; }
.d-head { fill: #f0c39b; }
.d-hair { fill: #2b2018; }
.d-eye { fill: #2b2018; }
.d-smile { fill: none; stroke: #94503a; stroke-width: 1.6; stroke-linecap: round; }

/* Austeil-Bewegung: der Wurfarm „schnipst" einmal pro ausgeteilter Karte */
.deal-arm { transform-box: fill-box; transform-origin: 20% 10%; }
.deal-arm.flick { animation: dealflick .34s ease-in-out; }
@keyframes dealflick {
  0%, 100% { transform: rotate(0) translate(0, 0); }
  45%      { transform: rotate(-24deg) translate(-4px, -5px); }
}

/* ---------- Hand + Abwurf (Muck) ---------- */
.hand-row { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.muck {
  display: flex; gap: 4px; align-items: center; padding-left: 12px; margin-left: 6px;
  border-left: 1px dashed rgba(255,255,255,0.2); position: relative; align-self: center;
}
.muck::before {
  content: "Abwurf"; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-size: .58rem; letter-spacing: 1px; text-transform: uppercase; opacity: .55;
}
.muck .card { --cw: 40px; }
.muck .card.discarded::after { display: none; } /* Label nicht doppelt – der Bereich sagt es schon */
.muck .card.discarded { filter: none; opacity: .92; transform: rotate(6deg); }

/* ---------- Gewinnwahrscheinlichkeit ---------- */
.seat-equity {
  font-size: .76rem; font-weight: 800; color: var(--ink); background: var(--gold);
  border-radius: 999px; padding: 1px 8px;
}
.equity-bar { width: min(420px, 86%); margin-top: 6px; }
.equity-track {
  display: flex; height: 14px; border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(231,194,90,0.4); background: rgba(0,0,0,.3);
}
.equity-fill { flex: 0 0 auto; transition: width .6s cubic-bezier(.2,.8,.3,1.2); }
.equity-fill.self { background: linear-gradient(90deg, #f3dd92, var(--gold)); }
.equity-fill.opp { background: linear-gradient(90deg, #6b3f3f, #b95a4a); }
.equity-legend { display: flex; justify-content: space-between; align-items: center; font-size: .76rem; margin-top: 3px; }
.equity-legend b { color: var(--cream); }
.equity-title { opacity: .6; text-transform: uppercase; letter-spacing: 1px; font-size: .66rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.self { background: var(--gold); }
.dot.opp { background: #b95a4a; margin-right: 0; margin-left: 4px; }

/* ---------- Einladungslink (Lobby) ---------- */
.invite {
  width: min(520px, 94%); background: rgba(0,0,0,0.32); border: 1px solid rgba(231,194,90,0.4);
  border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.invite-title { font-size: .85rem; opacity: .85; }
.invite-link {
  font-size: .8rem; word-break: break-all; background: rgba(0,0,0,0.4); padding: 8px 10px;
  border-radius: 8px; width: 100%; text-align: center; color: var(--gold); border: 1px dashed rgba(231,194,90,0.4);
}

/* Spannung: Karte glüht, bevor sie umgedreht wird (Turn/River) */
.card.suspense { animation: suspense 1s ease-in-out infinite alternate; }
@keyframes suspense {
  from { filter: drop-shadow(0 0 2px rgba(231,194,90,.5)); }
  to   { filter: drop-shadow(0 0 12px rgba(231,194,90,.95)); transform: translateY(-4px); }
}

/* Toast-Hinweise */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: rgba(8,28,20,0.96); color: var(--cream); border: 1px solid var(--gold);
  padding: .7em 1.2em; border-radius: 12px; font-weight: 600; font-size: .9rem;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity .25s, transform .25s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Auf großen Schirmen Karten größer */
@media (min-height: 760px) and (min-width: 700px) {
  .hand { min-height: 130px; }
}
