/* ============================================================
   Kegel-App – Kegelbahn-Look (Holz / Retro)
   Mobile-first, ein Gerät = ein schmaler Streifen
   ============================================================ */

:root {
  --wood-0:  #24160c;
  --wood-1:  #3a2515;
  --wood-2:  #5a3a20;
  --wood-3:  #7a5230;
  --lane:    #d8a45a;
  --lane-2:  #c8913f;
  --cream:   #f6ead0;
  --cream-2: #efdcb8;
  --ink:     #2b1a0e;
  --ink-soft:#6b5238;
  --red:     #c0392b;
  --red-2:   #9c2b20;
  --green:   #3b7a3b;
  --gold:    #f2c14e;
  --silver:  #cfd3d8;
  --bronze:  #cd8a4b;
  --shadow:  0 6px 18px rgba(0,0,0,.35);
  --radius:  16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background-color: var(--wood-1);
  /* Holzdielen: vertikale Planken der Kegelbahn */
  background-image:
    repeating-linear-gradient(90deg,
      rgba(0,0,0,.22) 0px, rgba(0,0,0,.22) 2px,
      rgba(255,255,255,.03) 2px, rgba(255,255,255,.03) 4px,
      transparent 4px, transparent 46px),
    repeating-linear-gradient(90deg,
      var(--lane) 0px, var(--lane) 46px,
      var(--lane-2) 46px, var(--lane-2) 92px);
  background-attachment: fixed;
  overscroll-behavior-y: contain;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(var(--safe-top) + 10px) 12px calc(var(--safe-bot) + 24px);
}

/* ---------- Typo & Grundbausteine ---------- */
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: .5px; }
button { font-family: inherit; cursor: pointer; border: none; }
input {
  font-family: inherit; font-size: 16px; width: 100%;
  padding: 14px 16px; border-radius: 12px;
  border: 2px solid var(--wood-2); background: #fff; color: var(--ink);
}
input:focus { outline: none; border-color: var(--red); }

.panel {
  background: var(--cream);
  border: 3px solid var(--wood-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 16px 18px; font-size: 18px; font-weight: 800;
  color: #fff; background: linear-gradient(180deg, var(--red), var(--red-2));
  border-radius: 14px; box-shadow: 0 4px 0 var(--red-2), var(--shadow);
  transition: transform .06s ease, box-shadow .06s ease; letter-spacing: .3px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-2), var(--shadow); }
.btn.secondary {
  color: var(--ink); background: linear-gradient(180deg, #fff, var(--cream-2));
  box-shadow: 0 4px 0 var(--wood-2), var(--shadow);
}
.btn.secondary:active { box-shadow: 0 1px 0 var(--wood-2), var(--shadow); }
.btn.ghost {
  color: var(--cream); background: rgba(0,0,0,.28);
  box-shadow: none; border: 2px solid rgba(255,255,255,.25);
}
.btn.small { width: auto; padding: 10px 14px; font-size: 15px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.muted { color: var(--ink-soft); }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }

/* ---------- Logo / Kegel-Schild ---------- */
.logo {
  text-align: center; margin: 18px 0 20px;
}
.logo .ball { font-size: 64px; line-height: 1; filter: drop-shadow(0 6px 6px rgba(0,0,0,.4)); }
.logo h1 {
  color: var(--cream); font-size: 46px; margin-top: 4px;
  text-transform: uppercase; letter-spacing: 4px;
  text-shadow: 0 2px 0 var(--wood-0), 0 4px 8px rgba(0,0,0,.5);
}
.logo .sub {
  display: inline-block; margin-top: 8px; padding: 4px 14px; border-radius: 999px;
  background: var(--red); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: 1px;
  box-shadow: var(--shadow);
}

/* ---------- Foto-Aufnahme ---------- */
.photo-pick {
  display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 6px 0 14px;
}
.avatar-big {
  width: 108px; height: 108px; border-radius: 50%; overflow: hidden;
  border: 4px solid var(--wood-2); background: var(--cream-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; box-shadow: var(--shadow);
}
.avatar-big img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Meine Runden Liste ---------- */
.round-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 14px; background: #fff;
  border: 2px solid var(--wood-2); margin-bottom: 10px; cursor: pointer;
  transition: transform .08s ease;
}
.round-item:active { transform: scale(.98); }
.round-item .code-badge {
  font-weight: 900; font-size: 20px; letter-spacing: 2px; color: var(--red);
  background: var(--cream-2); padding: 8px 10px; border-radius: 10px; min-width: 66px; text-align: center;
}
.round-item .meta { flex: 1; min-width: 0; }
.round-item .meta .t { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.tag.active { background: var(--green); color: #fff; }
.tag.finished { background: var(--wood-2); color: var(--cream); }

/* ---------- Topbar (Room) ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.topbar .brand { font-weight: 900; color: var(--cream); font-size: 18px; text-shadow: 0 2px 3px rgba(0,0,0,.5);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: rgba(0,0,0,.3); color: var(--cream); border: 2px solid rgba(255,255,255,.25);
  border-radius: 12px; padding: 8px 12px; font-weight: 800; font-size: 15px;
}
.icon-btn:active { transform: scale(.95); }

/* ---------- Section-Titel ---------- */
.sec-title {
  color: var(--cream); font-size: 14px; letter-spacing: 2px; text-transform: uppercase;
  margin: 4px 4px 8px; text-shadow: 0 1px 2px rgba(0,0,0,.5); font-weight: 800;
}

/* ============================================================
   LEADERBOARD
   ============================================================ */
.leaderboard { position: relative; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--cream); border: 3px solid var(--wood-2); border-radius: 14px;
  padding: 10px 12px; margin-bottom: 10px; position: relative;
  box-shadow: var(--shadow); will-change: transform;
}
.lb-row.me { border-color: var(--red); background: #fff7ea; }
.lb-row.current { box-shadow: 0 0 0 3px var(--gold), var(--shadow); }
.lb-row .rank {
  font-size: 22px; font-weight: 900; width: 34px; text-align: center; color: var(--ink-soft);
}
.lb-row .rank .medal { font-size: 26px; }
.lb-avatar {
  width: 48px; height: 48px; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  border: 3px solid var(--wood-2); background: var(--cream-2);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: var(--wood-2);
}
.lb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lb-main { flex: 1; min-width: 0; }
.lb-name { font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-sub { font-size: 12px; color: var(--ink-soft); display: flex; gap: 8px; align-items: center; }
.lb-total { font-size: 30px; font-weight: 900; color: var(--red); min-width: 48px; text-align: right; }
.turn-pill {
  font-size: 11px; font-weight: 900; background: var(--gold); color: var(--ink);
  padding: 2px 8px; border-radius: 999px; animation: softpulse 1.1s ease-in-out infinite;
}
.mover { font-size: 13px; font-weight: 900; margin-left: 2px; }
.mover.up { color: var(--green); }
.mover.down { color: var(--red); }

/* Überhol-Effekt */
@keyframes rankup {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0 rgba(59,122,59,0), var(--shadow); }
  30%  { transform: scale(1.05); box-shadow: 0 0 22px 4px rgba(59,122,59,.75), var(--shadow); }
  100% { transform: scale(1);   box-shadow: 0 0 0 0 rgba(59,122,59,0), var(--shadow); }
}
.lb-row.flash-up { animation: rankup .9s ease; z-index: 3; }
@keyframes softpulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* Punkte-Zuwachs */
@keyframes pop {
  0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); }
}
.pop { animation: pop .4s ease; }

/* ============================================================
   MEIN PANEL (Punkteingabe)
   ============================================================ */
.mypanel .who {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; -webkit-overflow-scrolling: touch;
}
.who-chip {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px; border-radius: 12px; background: #fff; border: 2px solid var(--wood-2); min-width: 66px;
}
.who-chip.active { border-color: var(--red); background: #fff7ea; }
.who-chip.turn { box-shadow: 0 0 0 3px var(--gold); }
.who-chip .av {
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--cream-2);
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--wood-2);
  border: 2px solid var(--wood-2);
}
.who-chip .av img { width: 100%; height: 100%; object-fit: cover; }
.who-chip .nm { font-size: 11px; font-weight: 800; max-width: 60px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-chip.add { justify-content: center; color: var(--red); font-weight: 900; }
.who-chip.add .plus { font-size: 30px; line-height: 1; }

.myscore {
  display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0 12px;
}
.myscore .val { font-size: 58px; font-weight: 900; color: var(--red); line-height: 1; }
.myscore .lbl { font-size: 13px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 1px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  aspect-ratio: 1 / 1; border-radius: 16px; font-size: 30px; font-weight: 900; color: var(--ink);
  background: linear-gradient(180deg, #fff, var(--cream-2));
  box-shadow: 0 4px 0 var(--wood-2), var(--shadow);
  display: flex; align-items: center; justify-content: center; transition: transform .05s ease, box-shadow .05s ease;
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood-2), var(--shadow); }
.key.zero { grid-column: span 2; aspect-ratio: auto; padding: 16px; }
.key.undo {
  color: #fff; background: linear-gradient(180deg, var(--wood-3), var(--wood-2));
  box-shadow: 0 4px 0 var(--wood-1), var(--shadow); font-size: 20px;
}
.hist { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.hist .chip {
  background: var(--wood-2); color: var(--cream); font-weight: 800; font-size: 13px;
  padding: 4px 9px; border-radius: 999px;
}

/* ---------- Zug-Banner ---------- */
.turn-banner {
  border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-weight: 900; text-align: center;
  background: rgba(0,0,0,.35); color: var(--cream); border: 2px solid rgba(255,255,255,.2);
}
.turn-banner.me {
  background: linear-gradient(180deg, var(--gold), #e0a92f); color: var(--ink);
  border-color: #fff; animation: bannerpulse 1s ease-in-out infinite;
}
@keyframes bannerpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }
.next-btn { margin-top: 10px; }

/* ---------- Host-Panel / Reihenfolge ---------- */
.order-list { list-style: none; padding: 0; margin: 10px 0 0; }
.order-item {
  display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--wood-2);
  border-radius: 12px; padding: 8px 10px; margin-bottom: 8px;
}
.order-item .oi-name { flex: 1; font-weight: 800; }
.order-item .oi-idx { font-weight: 900; color: var(--red); width: 22px; text-align: center; }
.mini {
  width: 38px; height: 34px; border-radius: 9px; font-size: 18px; font-weight: 900;
  background: var(--cream-2); color: var(--ink); box-shadow: 0 2px 0 var(--wood-2);
}
.mini:active { transform: translateY(2px); box-shadow: none; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.switch {
  position: relative; width: 52px; height: 30px; background: var(--wood-2); border-radius: 999px; flex: 0 0 auto;
  transition: background .2s ease;
}
.switch.on { background: var(--green); }
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  transition: left .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.switch.on .knob { left: 25px; }

/* ============================================================
   BLINK-OVERLAY – "DU BIST DRAN"
   ============================================================ */
.blink-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  flex-direction: column; text-align: center; color: #fff; pointer-events: none;
  animation: blinkbg .5s steps(1) infinite;
}
.blink-overlay .blink-inner {
  padding: 24px; animation: blinkscale .5s ease-in-out infinite; pointer-events: auto;
}
.blink-overlay .big { font-size: 40px; font-weight: 900; text-shadow: 0 3px 8px rgba(0,0,0,.6); letter-spacing: 2px; }
.blink-overlay .who-name { font-size: 30px; font-weight: 900; margin-top: 6px; }
.blink-overlay .ball { font-size: 90px; }
@keyframes blinkbg {
  0%   { background: rgba(192,57,43,.92); }
  50%  { background: rgba(242,193,78,.92); }
  100% { background: rgba(192,57,43,.92); }
}
@keyframes blinkscale { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* ============================================================
   QR / SHARE MODAL
   ============================================================ */
.modal {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal .card {
  background: var(--cream); border: 3px solid var(--wood-2); border-radius: 20px; padding: 20px;
  width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow);
}
.modal .qr {
  width: 220px; height: 220px; margin: 12px auto; background: #fff; border-radius: 12px;
  border: 3px solid var(--wood-2); display: block;
}
.modal .code-big {
  font-size: 40px; font-weight: 900; letter-spacing: 6px; color: var(--red); margin: 4px 0;
}
.modal .link {
  font-size: 13px; color: var(--ink-soft); word-break: break-all; margin: 8px 0 14px;
}

/* ============================================================
   SIEGEREHRUNG / PODIUM
   ============================================================ */
.podium-overlay {
  position: fixed; inset: 0; z-index: 65; overflow-y: auto;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(242,193,78,.25), transparent 60%),
    linear-gradient(180deg, var(--wood-1), var(--wood-0));
  padding: calc(var(--safe-top) + 20px) 16px calc(var(--safe-bot) + 24px);
}
.podium-title { text-align: center; color: var(--gold); font-size: 30px; text-transform: uppercase;
  letter-spacing: 3px; text-shadow: 0 3px 6px rgba(0,0,0,.6); margin-bottom: 6px; }
.podium-sub { text-align: center; color: var(--cream); margin-bottom: 22px; }

.podium {
  display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 10px 0 20px;
}
.pod { flex: 1; max-width: 130px; display: flex; flex-direction: column; align-items: center; }
.pod .pod-av {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden; border: 3px solid var(--gold);
  background: var(--cream-2); display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 900;
  margin-bottom: 6px;
}
.pod .pod-av img { width: 100%; height: 100%; object-fit: cover; }
.pod .pod-name { color: var(--cream); font-weight: 800; font-size: 14px; text-align: center; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod .pod-total { color: var(--gold); font-weight: 900; font-size: 20px; }
.pod .pod-block {
  width: 100%; border-radius: 12px 12px 0 0; margin-top: 8px;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 8px; font-size: 34px; font-weight: 900; color: #fff;
  box-shadow: var(--shadow); animation: rise .6s cubic-bezier(.2,.9,.25,1.2) both;
}
.pod.p1 .pod-block { height: 130px; background: linear-gradient(180deg,#f3cf6a,#d9a637); animation-delay: .5s; }
.pod.p2 .pod-block { height: 100px; background: linear-gradient(180deg,#e3e7ec,#b7bcc4); animation-delay: .25s; }
.pod.p3 .pod-block { height: 78px;  background: linear-gradient(180deg,#e0a163,#bd7b3c); animation-delay: 0s; }
.pod.p1 { order: 2; } .pod.p2 { order: 1; } .pod.p3 { order: 3; }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.final-list { margin-top: 8px; }
.final-row {
  display: flex; align-items: center; gap: 10px; color: var(--cream);
  padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,.12);
}
.final-row .fr-rank { font-weight: 900; width: 26px; color: var(--gold); }
.final-row .fr-name { flex: 1; font-weight: 700; }
.final-row .fr-total { font-weight: 900; }

#confetti { position: fixed; inset: 0; z-index: 66; pointer-events: none; }

/* ---------- Emoji-Auswahl ---------- */
.emoji-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  max-height: 148px; overflow-y: auto; padding: 8px; margin-top: 4px;
  background: #fff; border: 2px solid var(--wood-2); border-radius: 12px;
}
.emoji-opt {
  aspect-ratio: 1/1; font-size: 22px; border-radius: 10px;
  background: var(--cream-2); display: flex; align-items: center; justify-content: center;
  transition: transform .06s ease;
}
.emoji-opt:active { transform: scale(.9); }
.emoji-opt.sel { background: var(--red); box-shadow: 0 0 0 3px var(--gold); }
.emoji-opt.taken { opacity: .25; filter: grayscale(1); pointer-events: none; }

/* Emoji als Avatar (statt Foto) */
.avatar-big { font-size: 54px; }
.lb-avatar { font-size: 27px; }
.who-chip .av { font-size: 25px; }
.pod .pod-av { font-size: 32px; }

/* ---------- Warten (fremder Zug) ---------- */
.wait {
  text-align: center; font-weight: 800; color: var(--ink-soft);
  background: rgba(0,0,0,.05); border-radius: 12px; padding: 12px; margin: 8px 0;
}
.myscore.small .val { font-size: 34px; }

/* Leaderboard-Bereich (zum Ausblenden bei eigenem Zug) */
#lbWrap.hidden { display: none; }

/* ---------- Löschen ---------- */
.trash {
  background: transparent; font-size: 20px; padding: 8px; border-radius: 10px; line-height: 1;
  flex: 0 0 auto; opacity: .7;
}
.trash:active { transform: scale(.9); background: rgba(192,57,43,.12); }
.modal .card.danger { border-color: var(--red); }
.modal .warn { color: var(--red-2); font-weight: 800; margin: 8px 0; }

/* ---------- Room: Vollbild-Layout ohne Seiten-Scroll ---------- */
#app.room-mode {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding-top: calc(var(--safe-top) + 8px);
  padding-bottom: calc(var(--safe-bot) + 8px);
  overflow: hidden;
}
#app.room-mode .topbar { margin-bottom: 6px; }
#app.room-mode #cfgChip { flex: 0 0 auto; }
#app.room-mode #turnBanner { flex: 0 0 auto; margin-bottom: 8px; }
#app.room-mode #mainArea { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#app.room-mode #myPanel { flex: 0 0 auto; }
#app.room-mode .sec-title { margin-top: 0; }
#app.room-mode .mypanel { padding: 12px; margin-bottom: 0; }
#app.room-mode .who { padding: 2px 2px 8px; }
#app.room-mode .myscore { margin: 4px 0 8px; }
#app.room-mode .myscore .val { font-size: clamp(32px, 6.2vh, 52px); }
#app.room-mode .key { aspect-ratio: auto; height: clamp(46px, 8.4vh, 82px); font-size: clamp(22px, 4.2vh, 32px); }
#app.room-mode .key.zero, #app.room-mode .key.undo { aspect-ratio: auto; height: clamp(46px, 8.4vh, 82px); }
#app.room-mode .next-btn { margin-top: 8px; padding: 12px; }
#app.room-mode .hist { margin-top: 8px; }

/* ---------- Segmented Controls (Home-Konfig) ---------- */
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; padding: 12px 8px; border-radius: 12px; font-weight: 800; font-size: 15px;
  background: #fff; color: var(--ink); border: 2px solid var(--wood-2); box-shadow: 0 3px 0 var(--wood-2);
}
.seg-btn.active { background: linear-gradient(180deg, var(--red), var(--red-2)); color: #fff; border-color: var(--red-2); box-shadow: 0 3px 0 var(--red-2); }
.seg-btn:active { transform: translateY(2px); box-shadow: none; }

/* ---------- Konfig-Chip / Fortschritt ---------- */
.cfg-chip { text-align: center; color: var(--cream); font-size: 12px; font-weight: 800; margin-bottom: 6px; opacity: .9; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.progress-line { text-align: center; font-weight: 800; color: var(--ink-soft); font-size: 13px; margin: 2px 0 8px; }
.done-msg { text-align: center; font-weight: 900; font-size: 18px; color: var(--green); padding: 14px 4px; }

/* ---------- Team-Badges ---------- */
.team-dot { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; font-size: 10px; font-weight: 900; color: #fff; margin-left: 4px; vertical-align: middle; }
.team-dot.tA { background: var(--red); }
.team-dot.tB { background: var(--green); }

/* ---------- Tannenbaum ---------- */
.trees { display: flex; gap: 10px; justify-content: center; align-items: flex-start; }
.tree-card {
  flex: 1 1 0; min-width: 0; background: var(--cream); border: 3px solid var(--wood-2); border-radius: 14px;
  padding: 10px 6px 8px; box-shadow: var(--shadow); text-align: center;
}
.tree-card.tA { border-color: var(--red); }
.tree-card.tB { border-color: var(--green); }
.tree-card.current { box-shadow: 0 0 0 3px var(--gold), var(--shadow); }
.tree-card.won { background: #eafbe6; }
.tree-head { font-weight: 900; font-size: 14px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.trow { display: flex; gap: 4px; justify-content: center; }
.trow.trunk { gap: 22px; }
.tnode {
  width: clamp(18px, 5.6vw, 26px); height: clamp(18px, 5.6vw, 26px); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: clamp(11px, 3.4vw, 15px);
}
.tnode.on { background: linear-gradient(180deg, #3f7d3a, #2f5f2b); color: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.tnode.off { background: transparent; color: var(--ink-soft); opacity: .28; text-decoration: line-through; border: 1px dashed var(--wood-2); }
.tmembers { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin-top: 8px; }
.tmini { width: 24px; height: 24px; border-radius: 50%; overflow: hidden; background: var(--cream-2); border: 2px solid var(--wood-2); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.tmini.now { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.tmini img { width: 100%; height: 100%; object-fit: cover; }
.tann-hint { text-align: center; font-weight: 700; color: var(--ink); background: rgba(0,0,0,.05); border-radius: 12px; padding: 10px; margin: 6px 0 10px; font-size: 14px; }
.need { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 7px; background: var(--gold); color: var(--ink); font-weight: 900; margin: 0 2px; }
.key.zero3 { grid-column: span 3; aspect-ratio: auto; padding: 14px; font-size: 20px; }

/* ---------- Regeln ---------- */
.rules { color: var(--ink); }
.rules-title { font-weight: 900; font-size: 18px; margin-bottom: 6px; }
.rules p { margin: 4px 0; font-size: 14px; }
.rules ul { margin: 6px 0 0; padding-left: 18px; }
.rules li { font-size: 13px; margin: 4px 0; line-height: 1.35; }

/* ---------- Stagen + Bestätigen ---------- */
.key.bust { background: linear-gradient(180deg, #e07a70, #b53023); color: #fff; box-shadow: 0 4px 0 #8f251b, var(--shadow); }
.key.exact { background: linear-gradient(180deg, #63bd63, #2f7d33); color: #fff; box-shadow: 0 4px 0 #245c27, var(--shadow); }
.key.sel { background: linear-gradient(180deg, var(--gold), #e0a92f); color: var(--ink); box-shadow: 0 4px 0 #b9871f, var(--shadow); }
.key.confirm { color: #fff; background: linear-gradient(180deg, #43a047, #2f7d33); box-shadow: 0 4px 0 #245c27, var(--shadow); }
.key.confirm:active { box-shadow: 0 1px 0 #245c27, var(--shadow); }
.key.confirm.disabled, .key.disabled { opacity: .35; pointer-events: none; }
.pending-line { text-align: center; font-weight: 800; color: var(--ink); font-size: 14px; margin: 2px 0 8px; }
.pending-line .pv { display: inline-block; min-width: 26px; padding: 0 6px; border-radius: 7px; background: var(--gold); color: var(--ink); }

/* ---------- Lobby ---------- */
.lobby-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid rgba(0,0,0,.08); }
.lobby-row:last-of-type { border-bottom: none; }
.ready-badge { font-size: 12px; font-weight: 900; padding: 4px 10px; border-radius: 999px; background: var(--wood-2); color: var(--cream); white-space: nowrap; }
.ready-badge.on { background: var(--green); color: #fff; }
.tag.lobby { background: var(--gold); color: var(--ink); }

/* ---------- Team-Punktestand (Punkte-Modus) ---------- */
.team-score { display: flex; align-items: stretch; gap: 8px; margin-bottom: 10px; }
.team-score .ts { flex: 1; background: var(--cream); border: 3px solid var(--wood-2); border-radius: 12px; padding: 8px; text-align: center; box-shadow: var(--shadow); }
.team-score .ts.tA { border-color: var(--red); }
.team-score .ts.tB { border-color: var(--green); }
.team-score .ts.lead { box-shadow: 0 0 0 3px var(--gold), var(--shadow); }
.team-score .ts-name { font-weight: 800; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-score .ts-total { font-weight: 900; font-size: 26px; color: var(--red); }
.team-score .ts.tB .ts-total { color: var(--green); }
.team-score .ts-vs { align-self: center; font-weight: 900; color: var(--cream); }

/* ---------- Lobby Team-Spalten ---------- */
.tcols { display: flex; gap: 10px; }
.tcol { flex: 1; min-width: 0; background: #fff; border: 2px solid var(--wood-2); border-radius: 12px; padding: 8px; }
.tcol.tA { border-color: var(--red); }
.tcol.tB { border-color: var(--green); }
.tcol-head { font-weight: 900; font-size: 13px; text-align: center; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-member { display: flex; align-items: center; gap: 6px; padding: 4px 2px; }
.team-member .tm-name { flex: 1; font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--wood-2); color: var(--cream); font-size: 11px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.rb-dot.on { background: var(--green); color: #fff; }

/* ---------- Sparkline ---------- */
.spark { vertical-align: middle; color: var(--red); opacity: .8; margin-left: 4px; }

/* ---------- Statistik ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { text-align: center; }
.stat .sv { font-size: 24px; font-weight: 900; color: var(--red); }
.stat .sl { font-size: 11px; color: var(--ink-soft); font-weight: 700; }

/* ---------- Strafe ---------- */
.podium-overlay .penalty { background: rgba(192,57,43,.16); border-color: var(--red); text-align: center; }
.pen-title { font-weight: 900; color: var(--cream); font-size: 15px; }
.pen-task { font-weight: 800; color: var(--gold); font-size: 18px; margin-top: 4px; }

/* ---------- Modus-Auswahl (Grid) ---------- */
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.mode-btn {
  display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 12px; font-weight: 800; font-size: 14px;
  background: #fff; color: var(--ink); border: 2px solid var(--wood-2); box-shadow: 0 3px 0 var(--wood-2); text-align: left;
}
.mode-btn .mi { font-size: 22px; }
.mode-btn.active { background: linear-gradient(180deg, var(--red), var(--red-2)); color: #fff; border-color: var(--red-2); box-shadow: 0 3px 0 var(--red-2); }
.mode-btn:active { transform: translateY(2px); box-shadow: none; }

/* ---------- Einfache Modi ---------- */
.sm-big { font-size: 30px; font-weight: 900; color: var(--red); min-width: 52px; text-align: right; }
.sm-nine { min-width: 74px; text-align: right; font-weight: 900; color: var(--green); }
.sm-nine .nbar { height: 6px; background: var(--cream-2); border-radius: 4px; margin-top: 3px; overflow: hidden; }
.sm-nine .nbar span { display: block; height: 100%; background: var(--green); border-radius: 4px; transition: width .4s ease; }
.sau-letters { display: flex; gap: 4px; }
.sau-letters span { width: 26px; height: 26px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-weight: 900; background: var(--cream-2); color: var(--ink-soft); opacity: .4; }
.sau-letters span.on { background: var(--red); color: #fff; opacity: 1; }

/* ---------- Kegelbild (Pin-Positionen im Tannenbaum) ---------- */
.kegelbild { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 6px 0 8px; }
.kb-title { font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.kb-legend { font-size: 10px; color: var(--ink-soft); margin-top: 2px; }
.krow { display: flex; gap: 8px; justify-content: center; }
.kpin {
  width: clamp(24px, 5.4vh, 32px); aspect-ratio: 3 / 4; position: relative;
  border-radius: 45% 45% 42% 42% / 58% 58% 42% 42%;
  background: linear-gradient(180deg, #fff, var(--cream-2)); border: 2px solid var(--wood-2);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 3px;
  font-weight: 900; font-size: 12px; color: var(--ink-soft);
}
.kpin::before { content: ''; position: absolute; top: 24%; left: 15%; right: 15%; height: 3px; background: var(--red); border-radius: 2px; opacity: .5; }
.kpin.need { border-color: var(--green); color: var(--ink); background: linear-gradient(180deg, #fff, #e3f6de); box-shadow: 0 0 0 3px rgba(59,122,59,.4); animation: softpulse 1.3s ease-in-out infinite; }
.kpin.gone { opacity: .3; }
.kpin.gone::before { opacity: .15; }
.kpin.koenig::after { content: '♛'; position: absolute; top: -9px; font-size: 11px; color: var(--gold); }

/* kleine Helfer */
.stack > * + * { margin-top: 10px; }
.label { font-size: 13px; font-weight: 800; color: var(--ink-soft); margin: 2px 2px 4px; text-transform: uppercase; letter-spacing: 1px; }
.err { color: var(--red-2); font-weight: 800; margin-top: 8px; }
