@font-face { font-family: 'Alfa Slab One'; src: url(/fonts/alfa-slab-one.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url(/fonts/atkinson-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url(/fonts/atkinson-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  /* Tisch: nächtliches Kap */
  --sea: #10303a;
  --sea-2: #173f4a;
  --sea-3: #235563;
  --foam: #e8f0ec;
  --mist: #9ab5b2;
  --lamp: #f4b942;
  --lamp-soft: rgba(244, 185, 66, .2);
  --danger: #ef7a5a;
  /* Karten */
  --paper: #f4eee1;
  --ink: #1c2427;
  --t0: #2c8c73;
  --tlow: #2f5e8c;
  --tpeek: #3e8a4e;
  --tspy: #7a4e9e;
  --tswap: #c35b2b;
  --t13: #af2b3e;

  --slab: 'Alfa Slab One', 'Rockwell', 'Roboto Slab', Georgia, serif;
  --ui: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-card: 9px;
  --r-panel: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.45;
  color: var(--foam);
  background:
    radial-gradient(120% 80% at 50% 0%, #17424e 0%, transparent 60%),
    radial-gradient(90% 60% at 50% 110%, #0b2730 0%, transparent 70%),
    var(--sea);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: 0; border-radius: 999px;
  padding: .62rem 1.15rem;
  background: var(--sea-3); color: var(--foam);
  font-weight: 700; line-height: 1.2;
  transition: transform .08s ease, background .15s ease;
  white-space: nowrap;
}
.btn:hover { background: #2b6576; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--lamp); color: #2a1d02; }
.btn.primary:hover { background: #ffc955; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--sea-3); }
.btn.ghost:hover { background: rgba(255,255,255,.05); }
.btn.danger { background: transparent; box-shadow: inset 0 0 0 2px var(--danger); color: var(--danger); }
.btn.cabo { background: var(--t13); color: #fff; font-family: var(--slab); font-weight: 400; letter-spacing: .02em; }
.btn.cabo.armed { background: #fff; color: var(--t13); }
.btn.small { padding: .38rem .8rem; font-size: 13px; }

/* ---------- Kopfzeile ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(16, 48, 58, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--sea-3);
}
.brand { font-family: var(--slab); font-size: 25px; line-height: 1; color: var(--lamp); text-decoration: none; }
.status { flex: 1; min-width: 0; font-size: 14px; color: var(--mist); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status b { color: var(--foam); }
.nav { display: flex; gap: 6px; }
.nav .btn { padding: .4rem .75rem; font-size: 14px; }
@media (max-width: 560px) {
  .nav .btn { padding: .4rem .55rem; font-size: 13px; }
  .status { display: none; }
  .bar { justify-content: space-between; }
}

.offline-banner {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 40;
  background: var(--danger); color: #2a0d05; font-weight: 700;
  padding: .5rem 1rem; border-radius: 999px; font-size: 14px;
}
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  max-width: min(92vw, 520px);
  background: var(--paper); color: var(--ink); font-weight: 700;
  padding: .7rem 1.1rem; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

main { max-width: 1080px; margin: 0 auto; padding: 16px 16px 140px; }

/* ---------- Karten ---------- */
.card {
  --w: 74px;
  --tier: var(--tlow);
  position: relative;
  width: var(--w); aspect-ratio: 5 / 7;
  flex: 0 0 auto;
  border: 0; padding: 0;
  border-radius: var(--r-card);
  background: var(--paper);
  color: var(--tier);
  box-shadow: 0 2px 0 rgba(0,0,0,.25), 0 6px 14px rgba(0,0,0,.25);
  display: grid; place-items: center;
  user-select: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card.t0 { --tier: var(--t0); }
.card.tpeek { --tier: var(--tpeek); }
.card.tspy { --tier: var(--tspy); }
.card.tswap { --tier: var(--tswap); }
.card.t13 { --tier: var(--t13); }
.card.face { box-shadow: inset 0 0 0 3px var(--tier), 0 2px 0 rgba(0,0,0,.25), 0 6px 14px rgba(0,0,0,.25); }
.card .num {
  font-family: var(--slab);
  font-size: calc(var(--w) * .5);
  line-height: 1;
  margin-top: -8%;
}
.card .corner {
  position: absolute; top: 6%; left: 9%;
  font-family: var(--slab); font-size: calc(var(--w) * .16); line-height: 1;
}
.card .corner.br { top: auto; left: auto; bottom: 6%; right: 9%; transform: rotate(180deg); }
.card.u .num, .card.u .corner { text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .08em; }
.card .ab {
  position: absolute; left: 8%; right: 8%; bottom: 17%;
  background: var(--tier); color: #fff;
  border-radius: 4px;
  font-family: var(--ui); font-weight: 700;
  font-size: calc(var(--w) * .13); line-height: 1.5;
  text-align: center;
}
.card.back {
  background:
    radial-gradient(circle at 50% 50%, var(--lamp) 0 7%, transparent 7.5%),
    repeating-radial-gradient(circle at 50% 50%, transparent 0 9%, rgba(244,185,66,.28) 9% 10.5%),
    linear-gradient(160deg, #1d5262, #123844);
  box-shadow: inset 0 0 0 3px #0d2a33, inset 0 0 0 5px rgba(244,185,66,.35), 0 2px 0 rgba(0,0,0,.25), 0 6px 14px rgba(0,0,0,.25);
}
.card.sm { --w: 40px; border-radius: 6px; }
.card.sm .corner, .card.sm .ab { display: none; }
.card.sm .num { font-size: calc(var(--w) * .55); margin-top: 0; }
.card.lg { --w: 92px; }
.card.xs { --w: 30px; border-radius: 5px; }
.card.xs .corner, .card.xs .ab { display: none; }
.card.xs .num { font-size: calc(var(--w) * .55); margin-top: 0; }
@media (max-width: 560px) {
  .card { --w: 66px; }
  .card.sm { --w: 32px; }
  .card.lg { --w: 78px; }
}

/* offen liegende Karten (jeder sieht sie) bekommen eine kleine Markierung */
.card.public::after {
  content: ''; position: absolute; top: -4px; right: -4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--mist); border: 2px solid var(--sea);
}
.card.sm.public::after { width: 9px; height: 9px; }

/* nur du siehst sie gerade */
.card.secret { outline: 3px dashed var(--lamp); outline-offset: 3px; animation: flip .35s ease; }
@keyframes flip { from { transform: rotateY(90deg); } to { transform: rotateY(0); } }

.card.pick { cursor: pointer; }
.card.pick:hover { transform: translateY(-4px); }
.card.sel { transform: translateY(-8px); outline: 3px solid var(--lamp); outline-offset: 3px; }
.card.sel.pick:hover { transform: translateY(-10px); }
.card.dim { opacity: .5; }

/* zuletzt betroffene Karten leuchten kurz auf */
.card.hl { animation: beacon 5s ease-out forwards; }
.card.secret.hl { animation: flip .35s ease, beacon 5s ease-out forwards; }
@keyframes beacon {
  0%, 60% { box-shadow: 0 0 0 4px var(--lamp), 0 0 26px 6px rgba(244,185,66,.55); }
  100% { box-shadow: 0 0 0 0 transparent, 0 6px 14px rgba(0,0,0,.25); }
}
.card.watched::before {
  content: '👁'; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-size: 16px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}

.slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot .pos { font-size: 12px; color: var(--mist); font-weight: 700; }

/* ---------- Lobby ---------- */
.lobby { padding-top: 12px; }
.hero { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 32px; margin: 8px 0 28px; }
.wordmark { font-family: var(--slab); font-size: clamp(64px, 15vw, 132px); line-height: .9; color: var(--lamp); margin: 0; letter-spacing: -.01em; }
.hero p { margin: 8px 0 0; color: var(--mist); max-width: 34ch; }
.fan { position: relative; height: 150px; width: 250px; justify-self: end; }
.fan .card { position: absolute; bottom: 0; left: 70px; transform-origin: 50% 120%; }
.fan .card:nth-child(1) { transform: rotate(-24deg); }
.fan .card:nth-child(2) { transform: rotate(-8deg); }
.fan .card:nth-child(3) { transform: rotate(8deg); }
.fan .card:nth-child(4) { transform: rotate(24deg); }
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr auto; gap: 8px 12px; margin-bottom: 18px; }
  .hero p { font-size: 15px; }
  .fan { height: 96px; width: 120px; align-self: start; margin-top: 4px; }
  .fan .card { --w: 46px; left: 37px; }
}

.cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
.panel { background: var(--sea-2); border-radius: var(--r-panel); padding: 18px; border: 1px solid var(--sea-3); }
.panel h2 { font-family: var(--slab); font-weight: 400; font-size: 20px; margin: 0 0 12px; }
.plist { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.15); }
.plist .name { flex: 1; font-weight: 700; }
.plist .you { color: var(--lamp); font-weight: 400; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #5c7774; flex: 0 0 auto; }
.dot.on { background: #6fd39b; box-shadow: 0 0 8px rgba(111,211,155,.6); }
.empty { color: var(--mist); font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.input {
  flex: 1; min-width: 150px;
  border-radius: 999px; border: 2px solid var(--sea-3);
  background: rgba(0,0,0,.2);
  padding: .55rem 1rem;
}
.input:focus { border-color: var(--lamp); outline: none; }
.toggle { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--sea-3); cursor: pointer; }
.toggle:first-of-type { border-top: 0; padding-top: 0; }
.toggle input { width: 20px; height: 20px; accent-color: var(--lamp); margin-top: 2px; flex: 0 0 auto; }
.toggle b { display: block; }
.toggle span { font-size: 14px; color: var(--mist); }
.hint { font-size: 14px; color: var(--mist); margin: 10px 0 0; }

/* ---------- Tisch ---------- */
.opponents {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
}
.seat {
  position: relative;
  background: var(--sea-2); border: 1px solid var(--sea-3);
  border-radius: var(--r-panel);
  padding: 10px 12px 12px;
  transition: box-shadow .3s ease, border-color .3s ease;
}
.seat.active {
  border-color: var(--lamp);
  box-shadow: 0 0 0 1px var(--lamp), 0 0 34px rgba(244,185,66,.28);
  background: linear-gradient(180deg, rgba(244,185,66,.10), transparent 70%), var(--sea-2);
}
.seat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.seat-head .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-head .pts { margin-left: auto; font-family: var(--slab); color: var(--mist); font-size: 16px; white-space: nowrap; }
.badge { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--sea-3); white-space: nowrap; }
.badge.turn { background: var(--lamp); color: #2a1d02; }
.badge.cabo { background: var(--t13); color: #fff; font-family: var(--slab); font-weight: 400; }
.badge.ok { background: #2f6b4f; }
.hand { display: flex; flex-wrap: wrap; gap: 6px; }
.seat.mine .hand { gap: 10px; }

.center {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  flex-wrap: wrap;
  margin: 18px 0;
  padding: 16px;
  border-radius: 999px;
  background: radial-gradient(closest-side, rgba(0,0,0,.18), transparent);
}
.pile { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; padding: 0; color: var(--mist); font-size: 13px; }
.pile .card { --w: 82px; }
.pile.can .card { cursor: pointer; }
.pile.can:hover .card { transform: translateY(-4px); }
.pile.can .lbl { color: var(--lamp); font-weight: 700; }
.pile .placeholder { width: 82px; aspect-ratio: 5/7; border-radius: var(--r-card); border: 2px dashed var(--sea-3); }
.drawn { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--lamp); font-weight: 700; }
.drawn .card { --w: 96px; animation: flip .35s ease; }
.arrow { font-size: 22px; color: var(--sea-3); }
@media (max-width: 560px) {
  .pile .card, .pile .placeholder { --w: 68px; width: 68px; }
  .drawn .card { --w: 80px; }
  .center { gap: 14px; }
}

.seat.mine { padding: 12px 14px 14px; }
.seat.mine .seat-head .name { font-size: 18px; }

/* Handy: alles muss ohne viel Scrollen auf einen Bildschirm passen */
@media (max-width: 560px) {
  main { padding: 10px 10px 150px; }
  .bar { padding: 8px 10px; gap: 8px; }
  .brand { font-size: 22px; }
  .opponents { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .opponents .seat { padding: 7px 8px 9px; border-radius: 11px; }
  .opponents .seat-head { gap: 5px; margin-bottom: 6px; font-size: 14px; }
  .opponents .seat-head .pts { font-size: 14px; }
  .opponents .badge { font-size: 11px; padding: 0 6px; }
  .opponents .hand { gap: 4px; }
  .card.sm { --w: 29px; border-radius: 5px; }
  .center { margin: 10px 0; padding: 8px; gap: 12px; }
  .pile .card, .pile .placeholder { --w: 58px; width: 58px; }
  .drawn .card { --w: 70px; }
  .seat.mine { padding: 9px 10px 10px; }
  .seat.mine .seat-head { margin-bottom: 6px; }
  .seat.mine .hand { gap: 8px; }
  .card { --w: 60px; }
  .ticker { margin-top: 10px; font-size: 13px; }
  .ticker div:not(:last-child) { display: none; }
  .actionbar { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .prompt { font-size: 15px; line-height: 1.35; }
  .actions .btn { padding: .55rem .9rem; }
  .d-only { display: none; }
}
/* sehr schmale Geräte */
@media (max-width: 360px) {
  .opponents { grid-template-columns: 1fr; }
}

.ticker { margin-top: 16px; display: grid; gap: 4px; font-size: 14px; color: var(--mist); }
.ticker div:last-child { color: var(--foam); }

/* Aktionsleiste unten */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: rgba(13, 40, 48, .96);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--sea-3);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.actionbar .inner { max-width: 1080px; margin: 0 auto; display: flex; gap: 10px 16px; align-items: center; flex-wrap: wrap; }
.prompt { flex: 1 1 260px; min-width: 0; }
.prompt b { color: var(--lamp); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actionbar.mine { border-top: 2px solid var(--lamp); }

/* ---------- Bögen (Wertung, Verlauf, Regeln) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(4, 16, 20, .6); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 720px) { .scrim { align-items: center; } }
.sheet {
  width: min(100%, 720px); max-height: 88vh; overflow: auto;
  background: var(--sea-2); border: 1px solid var(--sea-3);
  border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-in .22s ease;
}
@media (min-width: 720px) { .sheet { border-radius: 18px; } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet h2 { font-family: var(--slab); font-weight: 400; font-size: 25px; margin: 0 0 4px; }
.sheet h3 { font-size: 16px; margin: 18px 0 6px; }
.sheet p, .sheet li { color: #cfdcd8; }
.sheet ul { padding-left: 20px; }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.sheet-head > div { flex: 1; }
.sheet-head p { margin: 0; color: var(--mist); }
.sheet .foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

.results { display: grid; gap: 8px; }
.res {
  display: grid; grid-template-columns: 1fr auto;
  grid-template-areas: "who score" "hand score" "notes notes";
  gap: 6px 12px; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.18);
}
.res.win { box-shadow: inset 0 0 0 2px var(--lamp); }
.res .who { grid-area: who; font-weight: 700; }
.res .who small { font-weight: 400; color: var(--mist); }
.res .score { grid-area: score; align-self: center; font-family: var(--slab); font-size: 25px; line-height: 1.1; text-align: right; }
.res .score small { display: block; font-family: var(--ui); font-size: 13px; color: var(--mist); }
.res .hand { grid-area: hand; gap: 4px; }
.res .notes { grid-area: notes; font-size: 13px; color: var(--lamp); font-weight: 700; }
.winner { font-family: var(--slab); color: var(--lamp); font-size: 31px; line-height: 1.1; margin: 4px 0 12px; }

table.scores { width: 100%; border-collapse: collapse; font-size: 15px; }
table.scores th, table.scores td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--sea-3); white-space: nowrap; }
table.scores th:first-child, table.scores td:first-child { text-align: left; color: var(--mist); }
table.scores tfoot td { font-family: var(--slab); font-size: 18px; border-bottom: 0; color: var(--foam); }
.scroll-x { overflow-x: auto; }

.log { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 15px; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--sea-3); }

.menu { position: absolute; right: 16px; top: 52px; z-index: 25; background: var(--sea-2); border: 1px solid var(--sea-3); border-radius: 12px; padding: 6px; display: grid; min-width: 200px; box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.menu button { text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px; }
.menu button:hover { background: var(--sea-3); }
.menu .warn { color: var(--danger); font-weight: 700; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(100%, 380px); display: grid; gap: 14px; }
.login .wordmark { font-size: 96px; }
.login p { margin: 0; color: var(--mist); }
.login .err { color: var(--danger); font-weight: 700; min-height: 1.4em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .card.hl { animation: none; box-shadow: 0 0 0 4px var(--lamp); }
}
