/* 15 obe – Aussehen: grüner Spieltisch, große Karten, fürs Handy im Hochformat gemacht */
:root {
  --felt-1: #2f8a4c;
  --felt-2: #1d6236;
  --felt-3: #0f3820;
  --gold: #f2c14e;
  --gold-2: #d99a1e;
  --cream: #fbf6ea;
  --ink: #2b2118;
  --muted: #7a6c5a;
  --good: #2e7d32;
  --bad: #c62828;
  --cw: clamp(62px, 19vw, 108px); /* Kartenbreite */
  --ch: calc(var(--cw) * 1.5);
  --radius: calc(var(--cw) * 0.07);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--felt-3);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
input { -webkit-user-select: text; user-select: text; }
#app { min-height: 100%; height: 100%; }

.felt {
  min-height: 100%;
  background:
    radial-gradient(ellipse 120% 80% at 50% 42%, rgba(255,255,255,.07), transparent 60%),
    radial-gradient(ellipse at 50% 45%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Karten ---------- */
.card {
  width: var(--cw);
  height: calc(var(--cw) * 1.5);
  border-radius: calc(var(--cw) * .07);
  box-shadow: 0 2px 6px rgba(0,0,0,.35), 0 0 0 .5px rgba(0,0,0,.2);
  background: #fffdf7;
  flex: none;
}
.card svg { display: block; width: 100%; height: 100%; border-radius: inherit; }
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.13) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.13) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, #a3242a, #6e1218);
  border: calc(var(--cw) * .05) solid #fffdf7;
}

/* ---------- Knöpfe & Felder ---------- */
.btn {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 13px 16px;
  font: 600 16px/1.2 inherit;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d9cdb8;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  border-color: #b57d12;
  color: #3b2606;
  box-shadow: 0 2px 0 #9a6a0c;
}
.btn.danger { color: var(--bad); }
.btn.link { background: none; border: 0; text-decoration: underline; color: var(--muted); font-weight: 500; }
.btn.link.light { color: rgba(255,255,255,.8); width: auto; margin: 18px auto 0; }
.icon-btn {
  border: 0; background: rgba(0,0,0,.25); color: #fff; width: 38px; height: 38px; border-radius: 50%;
  font-size: 18px; cursor: pointer; flex: none;
}

.panel {
  width: min(380px, calc(100% - 32px));
  margin: 0 auto;
  background: var(--cream);
  color: var(--ink);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.field { display: block; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .join-row input {
  width: 100%;
  font: 500 17px/1.2 inherit;
  font-family: inherit;
  padding: 12px 14px;
  border: 1px solid #d9cdb8;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.join-row { display: flex; gap: 8px; align-items: stretch; }
.join-row input { width: 7.5em; text-align: center; letter-spacing: .25em; font-weight: 700; text-transform: uppercase; }
.join-row .btn { margin: 0; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 16px 0 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: #e2d7c3; }
.hint { color: var(--muted); font-size: 14px; text-align: center; margin: 12px 0 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); translate: -50% 20px;
  background: rgba(20,20,20,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s; z-index: 50; max-width: calc(100% - 32px);
  text-align: center;
}
#toast.show { opacity: 1; translate: -50% 0; }
.offline-banner {
  position: fixed; top: env(safe-area-inset-top); left: 0; right: 0; z-index: 40;
  background: #e65100; color: #fff; text-align: center; font-size: 14px; padding: 6px;
}

/* ---------- Start ---------- */
.start, .lobby, .rules-page {
  display: flex; flex-direction: column; justify-content: center; padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.logo { text-align: center; margin-bottom: 22px; }
.logo-cards { position: relative; height: calc(var(--cw) * 1.45); margin-bottom: 8px; --cw: clamp(64px, 18vw, 92px); }
.logo-cards .card { position: absolute; left: 50%; top: 0; margin-left: calc(var(--cw) / -2); transform-origin: 50% 120%; }
.logo-cards .c1 { rotate: -16deg; }
.logo-cards .c3 { rotate: 16deg; }
.logo h1 {
  font-family: Georgia, "Times New Roman", serif; font-size: 46px; margin: 0; letter-spacing: .02em;
  color: var(--gold); text-shadow: 0 2px 0 #6b4a0a, 0 4px 14px rgba(0,0,0,.4);
}
.logo h1 span { color: #fff; font-style: italic; }
.logo p { margin: 4px 0 0; color: rgba(255,255,255,.8); }

/* ---------- Regeln ---------- */
.rules h2 { margin: 0 0 4px; font-family: Georgia, serif; }
.rules .note { margin: 0 0 10px; font-size: 13px; color: #a5660a; }
.rules ul { padding-left: 18px; margin: 0; line-height: 1.45; font-size: 15px; }
.rules li { margin-bottom: 6px; }

/* ---------- Warteraum ---------- */
.kicker { margin: 0; text-align: center; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.code { display: flex; justify-content: center; gap: 8px; margin: 8px 0 4px; }
.code span {
  width: 52px; height: 62px; display: grid; place-items: center; border-radius: 10px;
  background: #fff; border: 1px solid #d9cdb8; font: 700 32px Georgia, serif; color: var(--ink);
  box-shadow: 0 2px 0 #e2d7c3;
}
.seats { list-style: none; padding: 0; margin: 16px 0 6px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid #ebe1cf; }
.seat:first-child { border-top: 0; }
.seat.empty { color: #b3a58e; }
.seat-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-name em { font-weight: 400; color: var(--muted); font-style: normal; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 99px; background: #f3e3b6; color: #7a5208; }
.tag.bot { background: #dfe9f6; color: #24508a; }
.tag.off { background: #eee; color: #888; }
.seat .icon-btn { background: #eee3d0; color: var(--muted); width: 30px; height: 30px; font-size: 14px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--c, #888); color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 0 0 2px rgba(255,255,255,.85);
}
.avatar.ghost { background: none; border: 2px dashed #d3c5ad; box-shadow: none; color: #c4b498; }
.avatar.small { width: 24px; height: 24px; font-size: 12px; display: inline-grid; vertical-align: middle; margin-right: 6px; }
.avatar.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 0 0 2px var(--gold), 0 0 0 0 rgba(242,193,78,.7); }
  50% { box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 0 0 2px var(--gold), 0 0 0 8px rgba(242,193,78,0); }
}

/* ---------- Spieltisch ---------- */
.table {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  position: relative;
}
.bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,0));
}
.bar-title { flex: 1; text-align: center; font-weight: 700; letter-spacing: .02em; }
.bar-code { font: 700 14px Georgia, serif; letter-spacing: .15em; background: rgba(0,0,0,.25); padding: 6px 10px; border-radius: 99px; }
.menu {
  position: absolute; top: calc(54px + env(safe-area-inset-top)); left: 12px; z-index: 30; width: 220px;
  background: var(--cream); padding: 6px 12px 12px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

.arena { position: relative; min-height: 0; }

.plate {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.32); border: 1px solid rgba(255,255,255,.12);
  padding: 5px 6px 5px 5px; border-radius: 99px; backdrop-filter: blur(2px);
}
.plate-text { min-width: 0; }
.plate-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9em; }
.plate-tricks { font-size: 11px; color: rgba(255,255,255,.75); display: flex; align-items: center; gap: 3px; height: 14px; }
.plate-tricks .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--gold); display: inline-block; box-shadow: 0 1px 0 #8a6110; }
.plate-tricks .tricks-n { margin-left: 3px; }
.score {
  min-width: 34px; height: 34px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center;
  background: linear-gradient(180deg, #fff6dc, #f2d48a); color: #4a2f05; font: 800 17px Georgia, serif;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}
.score.big { min-width: 42px; height: 42px; font-size: 21px; }
.dealer {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; color: var(--felt-2); font-size: 10px; font-weight: 800; vertical-align: 1px;
}

.opp { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 2; transition: opacity .3s; }
.opp.away { opacity: .55; }
.opp .away-tag { font-size: 11px; background: rgba(0,0,0,.5); padding: 2px 8px; border-radius: 99px; }
.opp.turn .plate { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(242,193,78,.45); }
.opp.pos-top { top: 6px; left: 50%; translate: -50% 0; }
.opp.pos-left { left: 8px; top: 40%; translate: 0 -50%; }
.opp.pos-right { right: 8px; top: 40%; translate: 0 -50%; }
.players-4 .opp.pos-left, .players-4 .opp.pos-right { top: 46%; }
.mini-hand { display: flex; height: calc(var(--cw) * .5); }
.mini-hand .card.mini { --cw: clamp(24px, 7vw, 36px); width: var(--cw); height: calc(var(--cw) * 1.5); margin-left: calc(var(--cw) * -.55); border-width: 2px; }
.mini-hand .card.mini:first-child { margin-left: 0; }
.pos-left .plate, .pos-right .plate {
  flex-direction: column; gap: 3px; border-radius: 16px; padding: 7px 8px 8px; text-align: center; width: 84px;
}
.pos-left .plate-text, .pos-right .plate-text { width: 100%; }
.pos-left .plate-name, .pos-right .plate-name { max-width: none; font-size: 13px; }
.pos-left .plate-tricks, .pos-right .plate-tricks { justify-content: center; }
.pos-left .tricks-n, .pos-right .tricks-n { display: none; }
.pos-left .no-tricks, .pos-right .no-tricks { display: none; }
.pos-left .score, .pos-right .score { min-width: 30px; height: 30px; font-size: 15px; }

.center { position: absolute; inset: 0; pointer-events: none; }
.talon {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.22); padding: 6px 12px 6px 6px; border-radius: 12px;
  --cw: clamp(34px, 10vw, 56px);
}
.talon .card { box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.trump-label { font-size: 11px; line-height: 1.2; color: rgba(255,255,255,.75); display: flex; flex-direction: column; }
.trump-label b { color: #fff; font-size: 15px; }

.trick { position: absolute; left: 50%; top: 47%; width: 0; height: 0; }
.players-2 .trick { top: 50%; }
.trick .card {
  position: absolute; left: calc(var(--cw) / -2); top: calc(var(--ch) / -2);
  translate: var(--tx, 0) var(--ty, 0); rotate: var(--r, 0deg);
  transition: translate .45s cubic-bezier(.4,0,.6,1), opacity .45s, scale .45s, box-shadow .3s;
}
.trick .from-bottom { --tx: 0px; --ty: calc(var(--ch) * .28); --r: 3deg; --sx: 0px; --sy: 60vh; }
.trick .from-top { --tx: 0px; --ty: calc(var(--ch) * -.28); --r: -6deg; --sx: 0px; --sy: -40vh; }
.trick .from-left { --tx: calc(var(--cw) * -.62); --ty: 0px; --r: -12deg; --sx: -60vw; --sy: 0px; }
.trick .from-right { --tx: calc(var(--cw) * .62); --ty: 0px; --r: 11deg; --sx: 60vw; --sy: 0px; }
.trick .card.enter { animation: enter .38s cubic-bezier(.2,.8,.3,1) both; }
@keyframes enter { from { translate: var(--sx) var(--sy); rotate: 0deg; opacity: .3; } }
.trick .card.won { box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(242,193,78,.8); z-index: 5; }
.trick.collect-top .card { translate: 0 -45vh; scale: .4; opacity: 0; }
.trick.collect-bottom .card { translate: 0 45vh; scale: .4; opacity: 0; }
.trick.collect-left .card { translate: -55vw 0; scale: .4; opacity: 0; }
.trick.collect-right .card { translate: 55vw 0; scale: .4; opacity: 0; }

.status {
  position: absolute; left: 50%; bottom: 8px; translate: -50% 0; white-space: nowrap;
  font-size: 14px; font-weight: 600; color: rgba(255,255,255,.9); background: rgba(0,0,0,.3);
  padding: 6px 14px; border-radius: 99px; z-index: 3;
}
.status:empty { display: none; }
.status.mine { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #3b2606; }

/* Eigener Platz unten */
.me { padding: 4px 8px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.me .plate { align-self: center; }
.me.turn .plate { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(242,193,78,.45); }
.hand { display: flex; justify-content: center; align-items: flex-start; height: calc(var(--ch) + 30px); padding-top: 14px; }
.hand-card {
  appearance: none; border: 0; padding: 0; background: none; cursor: default;
  margin-left: calc(var(--cw) * -.22);
  transform-origin: 50% 130%;
  rotate: calc(var(--off) * 4deg);
  translate: 0 calc(var(--abs) * var(--abs) * 2px);
  transition: translate .15s, filter .2s, rotate .2s;
  border-radius: var(--radius);
}
.hand-card:first-child { margin-left: 0; }
.hand-card.playable { cursor: pointer; }
.hand-card.playable .card { box-shadow: 0 0 0 2px var(--gold), 0 4px 10px rgba(0,0,0,.4); }
@media (hover: hover) { .hand-card.playable:hover { translate: 0 -14px; } }
.hand-card.playable:active, .hand-card.playing { translate: 0 -18px; }
.hand-card.blocked { filter: brightness(.6) saturate(.6); }
.hand-card:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* Ergebnis-Blatt */
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  animation: fade .25s both;
}
.sheet {
  width: min(460px, 100%); background: var(--cream); color: var(--ink);
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 30px rgba(0,0,0,.35); animation: up .3s cubic-bezier(.2,.8,.3,1) both;
}
.sheet h2 { margin: 0 0 12px; text-align: center; font-family: Georgia, serif; }
.results { width: 100%; border-collapse: collapse; font-size: 15px; }
.results th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; padding: 4px; }
.results th:first-child, .results td:first-child { text-align: left; }
.results td { padding: 8px 4px; border-top: 1px solid #ebe1cf; text-align: center; }
.results td.good { color: var(--good); font-weight: 700; }
.results td.bad { color: var(--bad); font-weight: 700; }
.results tr.winner td { background: #fbefc7; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { translate: 0 100%; } }

/* Breitere Bildschirme */
@media (min-width: 700px) {
  :root { --cw: clamp(80px, 9vw, 112px); }
  .opp.pos-left { left: 24px; top: 46%; }
  .opp.pos-right { right: 24px; top: 46%; }
  .talon { left: 24px; bottom: 20px; }
  .pos-left .plate, .pos-right .plate { width: 110px; }
  .sheet { border-radius: 22px; margin-bottom: 40px; }
  .sheet-backdrop { align-items: center; }
}
@media (max-height: 640px) {
  :root { --cw: clamp(54px, 15vw, 86px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
