:root {
  --rot: #e5383b; --rot2: #9d0b14;
  --gelb: #f7c948; --gelb2: #d98e04;
  --gruen: #2dbf6c; --gruen2: #0f6b37;
  --blau: #2f80ed; --blau2: #123f9c;
  --tisch1: #17304d; --tisch2: #08111f;
  --text: #eef3ff; --text2: #9fb0cc;
  --gold: #ffd166;
  --akzent: #8ab4ff;
  --kw: clamp(52px, min(16vw, 12.5vh), 104px);
  --kw-mitte: clamp(62px, min(19vw, 14vh), 112px);
  --kw-mini: 20px;
  --oben: env(safe-area-inset-top, 0px);
  --unten: env(safe-area-inset-bottom, 0px);
  --glut: transparent;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--tisch2); color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: manipulation; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Karten ---------- */
.karte { --w: var(--kw); width: var(--w); height: calc(var(--w) * 1.5); border-radius: calc(var(--w) * .12);
  font-size: calc(var(--w) / 5); position: relative; flex: none; padding: calc(var(--w) * .045);
  background: #fbfbfd; box-shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.25); }
.karte .k-innen { position: absolute; inset: calc(var(--w) * .045); border-radius: calc(var(--w) * .085); overflow: hidden;
  background: linear-gradient(150deg, var(--c1), var(--c2)); color: #fff; }
.karte .k-innen::before { content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.07) 0 3px, transparent 3px 9px),
    radial-gradient(circle at 25% 15%, rgba(255,255,255,.35), transparent 55%); }
.f-r { --c1: var(--rot); --c2: var(--rot2); --ci: #b3121c; }
.f-y { --c1: var(--gelb); --c2: var(--gelb2); --ci: #b07000; }
.f-g { --c1: var(--gruen); --c2: var(--gruen2); --ci: #0d7a3d; }
.f-b { --c1: var(--blau); --c2: var(--blau2); --ci: #1650c4; }
.f-w { --c1: #34344a; --c2: #0d0d16; --ci: #1b1b24; }
.karte .raute { position: absolute; left: 50%; top: 50%; width: 64%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 22%; background: rgba(255,255,255,.94); box-shadow: inset 0 0 0 calc(var(--w) * .018) rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.25); }
.f-w .raute { background: conic-gradient(from 45deg, var(--gelb), var(--gruen), var(--blau), var(--rot), var(--gelb)); opacity: .95; }
.karte .mitte { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ci); }
.karte .zahl { font-size: 2.55em; font-weight: 900; line-height: 1; letter-spacing: -.04em;
  text-shadow: 0 1px 0 rgba(255,255,255,.6); font-variant-numeric: tabular-nums; }
.karte .zahl.unter { text-decoration: underline; text-decoration-thickness: .09em; text-underline-offset: .08em; }
.karte .icon { width: 50%; height: auto; grid-area: 1/1; }
.karte .plus { grid-area: 1/1; align-self: end; margin-bottom: 21%; font-size: .95em; font-weight: 900;
  background: var(--ci); color: #fff; padding: .05em .3em; border-radius: .4em; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.f-w .mitte { color: #fff; }
.f-w.w-farb .icon { width: 56%; filter: drop-shadow(0 1px 3px rgba(0,0,0,.4)); }
.f-w .plus { background: #1b1b24; }
.karte .ecke { position: absolute; display: flex; flex-direction: column; align-items: center; gap: .1em;
  font-weight: 900; font-size: .78em; line-height: 1; z-index: 1; text-shadow: 0 1px 2px rgba(0,0,0,.45); }
.karte .ecke.o { left: .32em; top: .32em; }
.karte .ecke.u { right: .32em; bottom: .32em; transform: rotate(180deg); }
.karte .form { width: .62em; height: .62em; fill: rgba(255,255,255,.95); filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.f-y .ecke { text-shadow: 0 1px 2px rgba(120,60,0,.6); }

.karte.ruecken { background: #fbfbfd; }
.karte.ruecken .k-innen { background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 2px, transparent 2px 8px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.05) 0 2px, transparent 2px 8px),
    radial-gradient(circle at 50% 45%, #2c3d78, #121a3a 75%); }
.karte.ruecken .k-innen::before { background: none; box-shadow: inset 0 0 0 calc(var(--w) * .03) rgba(255,255,255,.12); border-radius: inherit; }
.emblem { position: absolute; left: 50%; top: 50%; width: 46%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(45deg);
  display: grid; grid-template-columns: 1fr 1fr; gap: 7%; }
.emblem i { border-radius: 22%; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.emblem i:nth-child(1) { background: var(--rot); } .emblem i:nth-child(2) { background: var(--gelb); }
.emblem i:nth-child(3) { background: var(--blau); } .emblem i:nth-child(4) { background: var(--gruen); }

/* ---------- Grundgerüst ---------- */
#app { position: fixed; inset: 0; display: flex; flex-direction: column;
  background: radial-gradient(ellipse 120% 80% at 50% 45%, var(--tisch1), var(--tisch2) 75%); }
#app::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: radial-gradient(circle at 50% 45%, var(--glut), transparent 45%); transition: --glut .6s, background .6s; }
#kopf { position: relative; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(var(--oben) + 6px) 10px 4px; min-height: 44px; }
#kopf h1 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: .02em; flex: 1; display: flex; align-items: center; gap: 8px; }
.logo-mini { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 16px; height: 16px; transform: rotate(45deg); }
.logo-mini i { border-radius: 2px; } .logo-mini i:nth-child(1){background:var(--rot)} .logo-mini i:nth-child(2){background:var(--gelb)} .logo-mini i:nth-child(3){background:var(--blau)} .logo-mini i:nth-child(4){background:var(--gruen)}
.kopf-knopf { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 12px;
  padding: 6px 11px; font-size: 14px; font-weight: 700; }
.kopf-knopf:active { transform: scale(.95); }

#tisch { position: relative; flex: 1; min-height: 0; }
#zone { position: absolute; left: 0; right: 0; top: 0; }
#mitte { position: absolute; display: flex; gap: calc(var(--kw-mitte) * .35); align-items: center; transform: translate(-50%, -50%); z-index: 1; }
#ring { position: absolute; left: 50%; top: 50%; width: calc(var(--kw-mitte) * 3.4); aspect-ratio: 1; translate: -50% -50%;
  pointer-events: none; opacity: .5; transition: scale .5s; }
#ring svg { width: 100%; height: 100%; animation: drehen 18s linear infinite; }
#ring.links svg { animation-direction: reverse; }
#ring.flip { scale: 1.25; }
@keyframes drehen { to { transform: rotate(360deg); } }
#stapel, #ablage { position: relative; width: var(--kw-mitte); height: calc(var(--kw-mitte) * 1.5); }
#stapel .karte, #ablage .karte { --w: var(--kw-mitte); position: absolute; left: 0; top: 0; }
#stapel { cursor: pointer; border: 0; padding: 0; background: none; }
#stapel.lockt .karte:last-child { animation: locken 1.4s ease-in-out infinite; }
@keyframes locken { 0%,100% { box-shadow: 0 0 0 0 rgba(138,180,255,0), 0 4px 10px rgba(0,0,0,.3); translate: 0 0; }
  50% { box-shadow: 0 0 0 5px rgba(138,180,255,.55), 0 8px 20px rgba(0,0,0,.35); translate: 0 -4px; } }
#stapel .anzahl { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text2); }
#farbe { position: absolute; left: 50%; bottom: calc(var(--kw-mitte) * -.45 - 14px); translate: -50% 0; display: flex; gap: 6px; align-items: center;
  font-size: 12px; font-weight: 700; color: var(--text2); white-space: nowrap; }
#farbe i { width: 12px; height: 12px; border-radius: 50%; background: var(--fc, #555); box-shadow: 0 0 10px var(--fc, transparent); transition: background .4s; }

/* Sitze der Gegner */
.sitz { position: absolute; width: 74px; translate: -50% -50%; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: left .4s, top .4s; z-index: 2; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 25px; position: relative;
  background: radial-gradient(circle at 35% 30%, #3a4f78, #1b2847); border: 2px solid rgba(255,255,255,.18);
  box-shadow: 0 3px 10px rgba(0,0,0,.35); transition: transform .3s, border-color .3s, box-shadow .3s; }
.sitz.dran .avatar, #ich.dran .avatar { border-color: var(--gold); transform: scale(1.12);
  box-shadow: 0 0 0 4px rgba(255,209,102,.25), 0 0 22px rgba(255,209,102,.55); animation: dranpuls 1.3s ease-in-out infinite; }
@keyframes dranpuls { 50% { box-shadow: 0 0 0 7px rgba(255,209,102,.12), 0 0 30px rgba(255,209,102,.7); } }
.sitz .name { font-size: 11px; font-weight: 700; max-width: 80px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
.sitz .punkte { font-size: 10px; color: var(--text2); }
.facher { position: relative; height: calc(var(--kw-mini) * 1.5 + 4px); display: flex; justify-content: center; }
.facher .karte { --w: var(--kw-mini); padding: 1px; box-shadow: 0 1px 2px rgba(0,0,0,.5);
  transform-origin: 50% 120%; }
.facher .karte:first-child { margin-left: 0; }
.facher .karte .k-innen { inset: 1px; }
.zahlmarke { position: absolute; right: -10px; top: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #fff; color: #10182a; font-size: 12px; font-weight: 900; display: grid; place-items: center; box-shadow: 0 2px 5px rgba(0,0,0,.4); }
.sitz.eins .zahlmarke, #ich.eins .zahlmarke { background: var(--gold); animation: wackeln .9s ease-in-out infinite; }
@keyframes wackeln { 25% { rotate: -10deg; } 75% { rotate: 10deg; } }
.erwischt-knopf { position: absolute; top: -12px; left: 50%; translate: -50% 0; z-index: 4; white-space: nowrap;
  background: #ff4d6d; border: 0; border-radius: 99px; padding: 5px 10px; font-size: 12px; font-weight: 900;
  box-shadow: 0 3px 12px rgba(255,77,109,.6); animation: pochen .6s ease-in-out infinite alternate; }
@keyframes pochen { to { transform: scale(1.12); } }

/* Eigener Platz + Hand */
#info { position: absolute; left: 0; right: 0; text-align: center; font-size: 14px; font-weight: 700; color: var(--text2);
  padding: 0 12px; z-index: 3; transition: color .3s; }
#info.du { color: var(--gold); }
#ich { position: absolute; left: 10px; display: flex; align-items: center; gap: 8px; z-index: 3; }
#ich .avatar { width: 36px; height: 36px; font-size: 19px; }
#ich .name { font-size: 12px; font-weight: 800; }
#ich .punkte { font-size: 10px; color: var(--text2); }
#hand { position: absolute; left: 0; right: 0; bottom: calc(var(--unten) + 14px); height: calc(var(--kw) * 1.5 + 26px); }
#hand .karte { position: absolute; bottom: 0; transition: transform .28s cubic-bezier(.2,.8,.3,1.2), left .28s, filter .2s; cursor: pointer;
  transform-origin: 50% 140%; }
#hand .karte.passt { box-shadow: 0 0 0 2px rgba(255,255,255,.9), 0 0 16px rgba(255,255,255,.45), 0 8px 18px rgba(0,0,0,.35); }
#hand .karte.passt .k-innen::after { content: ""; position: absolute; inset: -50%; background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.35) 50%, transparent 60%);
  animation: glanz 2.6s ease-in-out infinite; }
@keyframes glanz { 0% { translate: -60% 0; } 60%,100% { translate: 60% 0; } }
#hand.aktiv .karte:not(.passt) { filter: brightness(.55) saturate(.7); }
#hand .karte.kommt { visibility: hidden; }
#hand .karte.gezogen { box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(255,209,102,.8); }
#hand .karte.nein { animation: nein .35s; }
@keyframes nein { 25% { translate: -6px 0; } 50% { translate: 6px 0; } 75% { translate: -3px 0; } }

#leiste { position: absolute; right: 10px; display: flex; gap: 8px; z-index: 6; }
.knopf { border: 0; border-radius: 14px; padding: 9px 14px; font-weight: 800; font-size: 15px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15); box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.knopf:active { transform: scale(.95); }
.knopf.haupt { background: linear-gradient(135deg, #ffd166, #f59e0b); color: #2b1600; border: 0; }
.knopf.letzte { background: linear-gradient(135deg, #ff6b6b, #e5383b); color: #fff; border: 0; animation: pochen .55s ease-in-out infinite alternate; }

/* Fliegende Karten + Effekte */
#flug { position: fixed; inset: 0; pointer-events: none; z-index: 40; perspective: 900px; }
.flieger { position: absolute; left: 0; top: 0; transform-style: preserve-3d; will-change: transform; }
.flieger .dreh { position: relative; transform-style: preserve-3d; }
.flieger .dreh > .karte { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flieger .dreh > .karte.hinten { position: absolute; left: 0; top: 0; transform: rotateY(180deg); }
.flieger .karte { box-shadow: 0 14px 30px rgba(0,0,0,.45); }
.blase { position: fixed; z-index: 45; pointer-events: none; translate: -50% -100%; padding: 7px 13px; border-radius: 16px;
  background: #fff; color: #10182a; font-weight: 900; font-size: 15px; white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.blase::after { content: ""; position: absolute; left: 50%; bottom: -7px; translate: -50% 0; border: 8px solid transparent; border-bottom: 0; border-top-color: inherit; border-top-color: #fff; }
.blase.gold { background: var(--gold); } .blase.gold::after { border-top-color: var(--gold); }
.blase.rot { background: #ff4d6d; color: #fff; } .blase.rot::after { border-top-color: #ff4d6d; }
.stempel { position: fixed; z-index: 45; pointer-events: none; translate: -50% -50%; width: 74px; height: 74px; color: #ff4d6d;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
.schwebe { position: fixed; z-index: 45; pointer-events: none; translate: -50% -50%; font-size: 30px; font-weight: 900;
  color: #fff; text-shadow: 0 2px 0 #b3121c, 0 4px 14px rgba(0,0,0,.6); }
.welle { position: fixed; z-index: 0; pointer-events: none; border-radius: 50%; translate: -50% -50%; width: 40px; height: 40px; }
#konfetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
.toast { position: fixed; left: 50%; top: 40%; translate: -50% -50%; z-index: 46; pointer-events: none;
  font-size: 30px; font-weight: 900; letter-spacing: .02em; text-shadow: 0 3px 16px rgba(0,0,0,.7); white-space: nowrap; }

/* Dialoge */
#dialog { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(3,7,15,.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.box { width: min(420px, 100%); max-height: calc(100% - 20px); overflow: auto; background: linear-gradient(180deg, #1d2c4a, #121c33);
  border: 1px solid rgba(255,255,255,.12); border-radius: 22px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: aufpoppen .35s cubic-bezier(.2,.9,.3,1.3); }
@keyframes aufpoppen { from { transform: scale(.8) translateY(20px); opacity: 0; } }
.box h2 { margin: 0 0 6px; font-size: 21px; }
.box p { margin: 6px 0 12px; color: var(--text2); line-height: 1.4; }
.box .knoepfe { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.farbrad { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px auto 4px; width: min(260px, 100%); }
.farbrad button { aspect-ratio: 1; border: 0; border-radius: 22px; font-weight: 900; font-size: 16px; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.4); box-shadow: inset 0 -6px 0 rgba(0,0,0,.18), 0 6px 14px rgba(0,0,0,.35);
  animation: aufpoppen .4s backwards cubic-bezier(.2,.9,.3,1.4); display: grid; place-items: center; gap: 2px; }
.farbrad button:nth-child(2) { animation-delay: .05s; } .farbrad button:nth-child(3) { animation-delay: .1s; } .farbrad button:nth-child(4) { animation-delay: .15s; }
.farbrad button:active { transform: scale(.94); }
.farbrad .zahl { font-size: 12px; opacity: .85; font-weight: 700; }
.tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabelle td { padding: 7px 4px; border-bottom: 1px solid rgba(255,255,255,.08); vertical-align: middle; }
.tabelle td.r { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; }
.tabelle tr.sieger td { color: var(--gold); }
.minihand { display: flex; flex-wrap: wrap; gap: 2px; }
.minihand .karte { --w: 22px; padding: 1px; } .minihand .karte .k-innen { inset: 1px; }
.balken { height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: 3px; }
.balken i { display: block; height: 100%; background: linear-gradient(90deg, #ffd166, #f59e0b); width: 0; transition: width 1.2s cubic-bezier(.2,.8,.3,1); }

/* Startseite */
#start { position: fixed; inset: 0; z-index: 30; overflow: auto; padding: calc(var(--oben) + 18px) 16px calc(var(--unten) + 24px);
  background: radial-gradient(ellipse 120% 70% at 50% 20%, #20407a, #08111f 70%); }
.start-innen { max-width: 460px; margin: 0 auto; }
.logo { position: relative; height: 170px; margin: 4px auto 6px; width: 260px; }
.logo .karte { --w: 78px; position: absolute; left: 50%; top: 18px; margin-left: -39px; transform-origin: 50% 160%;
  animation: logofacher 1s cubic-bezier(.2,.9,.3,1.2) backwards; }
@keyframes logofacher { from { transform: rotate(0) translateY(40px); opacity: 0; } }
.titel { text-align: center; font-size: 34px; font-weight: 900; margin: 0; letter-spacing: .01em;
  background: linear-gradient(90deg, #ff6b6b, #ffd166, #4ade80, #60a5fa, #ff6b6b); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: titelglanz 6s linear infinite; }
@keyframes titelglanz { to { background-position: 200% 0; } }
.untertitel { text-align: center; color: var(--text2); margin: 4px 0 18px; font-size: 14px; }
.karte-feld { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 18px; padding: 14px; margin-bottom: 12px; }
.feld-titel { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text2); margin-bottom: 10px; }
.zaehler { display: flex; align-items: center; gap: 12px; }
.zaehler button { width: 42px; height: 42px; border-radius: 14px; border: 0; background: rgba(255,255,255,.12); font-size: 22px; font-weight: 900; }
.zaehler .wert { font-size: 28px; font-weight: 900; min-width: 30px; text-align: center; }
.gegnerliste { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; min-height: 36px; }
.gegnerliste span { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  background: radial-gradient(circle at 35% 30%, #3a4f78, #1b2847); animation: aufpoppen .35s cubic-bezier(.2,.9,.3,1.4); }
.wahl { display: flex; gap: 6px; flex-wrap: wrap; }
.wahl button { flex: 1; min-width: 80px; border-radius: 12px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06);
  padding: 9px 8px; font-weight: 700; font-size: 14px; }
.wahl button.an { background: linear-gradient(135deg, #ffd166, #f59e0b); color: #2b1600; border-color: transparent; }
.schalter { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.schalter input { width: 22px; height: 22px; accent-color: #f59e0b; flex: none; }
.schalter small { display: block; color: var(--text2); font-size: 12px; }
.gross { width: 100%; padding: 15px; font-size: 18px; border-radius: 16px; margin-top: 6px; }
.regeln { line-height: 1.5; font-size: 14px; color: #d5def0; }
.regeln h3 { font-size: 15px; margin: 14px 0 4px; color: #fff; }
.regeln ul { padding-left: 18px; margin: 4px 0; }
.regeln .karten-reihe { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.regeln .karten-reihe .karte { --w: 46px; }

@media (min-width: 700px) and (min-height: 600px) {
  :root { --kw-mini: 24px; }
  .sitz { width: 92px; } .avatar { width: 52px; height: 52px; font-size: 29px; }
  .sitz .name { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  #ring svg, .titel, #hand .karte.passt .k-innen::after { animation: none; }
}
