* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #fff; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  background: radial-gradient(ellipse at 50% 40%, #1d7a4c 0%, #12623b 45%, #0b4229 100%);
}
button { font-family: inherit; touch-action: manipulation; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }

/* ---------- Start ---------- */
#start { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.start-inner {
  max-width: 480px; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) 20px 40px;
  text-align: center;
}
.logo { font-size: 64px; line-height: 1; animation: bounce 2.4s ease-in-out infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-10px) rotate(180deg); } }
h1 { font-size: 44px; margin: 6px 0 0; letter-spacing: 1px; text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.sub { margin: 2px 0 18px; font-size: 20px; opacity: .85; }
h2 { font-size: 22px; margin: 22px 0 4px; }
.hint-small { margin: 0 0 10px; opacity: .8; font-size: 17px; }
.bot-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.bot-tile {
  background: rgba(255,255,255,.1); border: 3px solid transparent;
  border-radius: 18px; padding: 12px 6px; color: #fff; font-size: 18px; cursor: pointer;
  transition: transform .15s, background .15s, border-color .15s;
}
.bot-tile .av { width: 58px; height: 58px; margin: 0 auto 6px; font-size: 28px; }
.bot-tile .bn { font-weight: 700; font-size: 20px; }
.bot-tile .bd { font-size: 14px; opacity: .85; margin-top: 2px; min-height: 34px; }
.bot-tile.sel { background: rgba(255,255,255,.22); border-color: #ffd54a; transform: scale(1.04); }
.bot-tile.sel::after { content: "✓"; display: block; color: #ffd54a; font-size: 22px; font-weight: 800; }
.av {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.25), inset 0 -3px 0 rgba(0,0,0,.15);
}
.tempo { display: flex; gap: 10px; justify-content: center; }
.tempo-btn {
  flex: 1; max-width: 200px; padding: 14px 8px; font-size: 19px; border-radius: 14px; border: 3px solid transparent;
  background: rgba(255,255,255,.1); color: #fff;
}
.tempo-btn.sel { border-color: #ffd54a; background: rgba(255,255,255,.22); }
.big-btn {
  display: block; width: 100%; max-width: 360px; margin: 14px auto 0; padding: 18px; font-size: 24px; font-weight: 800;
  border: none; border-radius: 18px; color: #fff; cursor: pointer;
}
.big-btn.primary { background: linear-gradient(#ffcf3f, #f0a500); color: #3a2600; box-shadow: 0 5px 0 #a87300; margin-top: 26px; }
.big-btn.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #a87300; }
.big-btn.primary:disabled { opacity: .45; }
.big-btn.ghost { background: rgba(255,255,255,.12); font-size: 20px; font-weight: 600; }
.stats { margin-top: 22px; font-size: 17px; line-height: 1.6; opacity: .9; }

/* ---------- Spieltisch ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; height: calc(46px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0; display: flex; align-items: center; justify-content: space-between;
  font-size: 19px; font-weight: 700; background: rgba(0,0,0,.18); z-index: 900;
}
.icon-btn { background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 24px; width: 46px; height: 38px; border-radius: 10px; }
#table { position: absolute; inset: 0; }
#labels { position: absolute; inset: 0; pointer-events: none; }

.plabel {
  position: absolute; display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700;
  transition: opacity .3s; white-space: nowrap; z-index: 50;
}
.plabel .av { width: 30px; height: 30px; font-size: 16px; }
.plabel .pts { font-weight: 500; opacity: .85; font-size: 16px; }
.plabel.active .nm { color: #ffd54a; }
.plabel.active .av { box-shadow: 0 0 0 3px #ffd54a, 0 0 14px #ffd54a; }
.plabel .lock { font-size: 18px; }
.zone-label { position: absolute; font-size: 14px; opacity: .75; text-align: center; z-index: 40; white-space: nowrap; transform: translateX(-50%); }

.bubble {
  position: absolute; background: #fff; color: #222; font-size: 16px; font-weight: 700; padding: 7px 11px;
  border-radius: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.3); z-index: 950; max-width: 70vw;
  animation: pop .25s ease-out; pointer-events: none;
}
.bubble::before {
  content: ""; position: absolute; left: -8px; top: 50%; margin-top: -8px; border: 8px solid transparent; border-left: 0; border-right-color: #fff;
}
.bubble.out { animation: fade .3s ease-in forwards; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { to { opacity: 0; transform: translateY(-6px); } }

/* Karten */
.card {
  position: absolute; left: 0; top: 0; width: 100px; height: 140px; transform-origin: 0 0;
  transition: transform var(--move, .45s) cubic-bezier(.3,.8,.3,1); perspective: 600px; z-index: 1;
}
.card.moving { z-index: 800 !important; }
.card .inner {
  position: absolute; inset: 0; transform-style: preserve-3d; transition: transform var(--flip, .4s) ease;
}
.card.up .inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; border-radius: 10px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.95) 0 15px, transparent 16px),
    repeating-linear-gradient(45deg, #b3261e 0 6px, #8e1a14 6px 12px);
  border: 5px solid #fff;
}
.back::after { content: "⚽"; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-52%); font-size: 24px; }
.front { background: #fff; transform: rotateY(180deg); color: #1b1b1b; overflow: hidden; border: 1px solid #ddd; }
.front.red { color: #d0161b; }
.front .idx { position: absolute; left: 7px; top: 4px; font-size: 30px; font-weight: 800; line-height: .95; text-align: center; }
.front .idx .s { display: block; font-size: 26px; }
.front .idx.br { left: auto; top: auto; right: 7px; bottom: 4px; transform: rotate(180deg); }
.front .pip { position: absolute; left: 50%; top: 56%; text-align: center; transform: translate(-50%,-50%); font-size: 54px; line-height: 1; }
.front .face-letter {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 58px; height: 78px; border: 3px solid currentColor;
  border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800;
}
.front .face-letter b { font-size: 36px; line-height: 1; }
.front .face-letter i { font-style: normal; font-size: 22px; }
.front .power { position: absolute; left: 0; right: 0; bottom: 5px; text-align: center; font-size: 13px; font-weight: 700; opacity: .8; }
.front.joker { background: linear-gradient(160deg, #fff 0%, #fff6d6 100%); color: #6a2bb5; }
.front.joker .jk { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); text-align: center; font-weight: 900; }
.front.joker .jk .star { font-size: 46px; display: block; line-height: 1; }
.front.joker .jk .t { font-size: 20px; letter-spacing: 1px; }
.front.joker .idx { color: #6a2bb5; font-size: 24px; }

.card.tap { cursor: pointer; }
.card.tap .face { box-shadow: 0 0 0 4px #ffd54a, 0 4px 10px rgba(0,0,0,.4); }
.card.pick .face { box-shadow: 0 0 0 6px #42e07b, 0 6px 16px rgba(0,0,0,.45); }
.card.glow .face { box-shadow: 0 0 0 5px #ffd54a, 0 0 22px #ffd54a; }
.card.bad .face { box-shadow: 0 0 0 6px #ff4b4b, 0 0 22px #ff4b4b; }
.card.dim { opacity: .55; }
.card.pulse .face { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px #ffd54a, 0 2px 4px rgba(0,0,0,.35); } 50% { box-shadow: 0 0 0 7px #ffd54a, 0 0 18px #ffd54a; } }

.slot-gap { position: absolute; border: 2px dashed rgba(255,255,255,.25); border-radius: 10px; pointer-events: none; }

.status {
  position: absolute; left: 10px; right: 10px; text-align: center; font-size: 21px; font-weight: 700; z-index: 60;
  text-shadow: 0 2px 4px rgba(0,0,0,.35); line-height: 1.25; pointer-events: none;
}
.timer { position: absolute; height: 12px; border-radius: 6px; background: rgba(0,0,0,.3); overflow: hidden; z-index: 60; }
.timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ffd54a, #ff8a3d); transform-origin: 0 50%; }
.timer.run .timer-fill { animation: drain var(--dur, 4s) linear forwards; }
.timer.paused .timer-fill { animation-play-state: paused; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.actions {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; justify-content: center; z-index: 700; min-height: 90px; align-items: flex-end;
}
.act {
  flex: 1; max-width: 260px; min-height: 64px; font-size: 21px; font-weight: 800; border: none; border-radius: 16px;
  color: #fff; background: rgba(255,255,255,.18); box-shadow: 0 4px 0 rgba(0,0,0,.25); padding: 8px 10px;
}
.act:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.act.gold { white-space: nowrap; font-size: 20px; }
.act.gold { background: linear-gradient(#ffcf3f, #f0a500); color: #3a2600; box-shadow: 0 4px 0 #a87300; }
.act.red { background: linear-gradient(#ff6b5b, #d8342a); box-shadow: 0 4px 0 #8d1e17; }
.act.blue { background: linear-gradient(#4aa3ff, #1e6fd0); box-shadow: 0 4px 0 #134a8c; }
.act.wiggle { animation: wiggle 1s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-2deg) scale(1.03); } 75% { transform: rotate(2deg) scale(1.03); } }

.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%,-50%); z-index: 960; text-align: center;
  background: rgba(10,30,20,.92); border: 3px solid #ffd54a; border-radius: 22px; padding: 18px 22px; width: min(88vw, 420px);
  font-size: 24px; font-weight: 800; line-height: 1.3; box-shadow: 0 10px 40px rgba(0,0,0,.5); animation: pop .3s ease-out;
  pointer-events: none;
}
.banner.huge { font-size: 34px; }
.banner small { display: block; font-size: 18px; font-weight: 600; margin-top: 6px; opacity: .9; }

/* Overlays */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 990; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.panel {
  background: #fdfaf2; color: #222; border-radius: 22px; padding: 20px; width: min(94vw, 460px); max-height: 88vh; overflow-y: auto;
  box-shadow: 0 12px 50px rgba(0,0,0,.5); animation: pop .25s ease-out;
}
.panel h2 { margin: 0 0 12px; text-align: center; font-size: 28px; }
.panel p { font-size: 18px; line-height: 1.45; }
.panel .big-btn { margin-top: 14px; }
.panel .big-btn.ghost { background: #e8e2d2; color: #333; }
.score-table { width: 100%; border-collapse: collapse; font-size: 20px; }
.score-table th { font-size: 15px; text-align: right; color: #666; font-weight: 600; padding: 4px 6px; }
.score-table th:first-child { text-align: left; }
.score-table td { padding: 10px 6px; border-top: 1px solid #e6e0cf; text-align: right; }
.score-table td:first-child { text-align: left; font-weight: 700; }
.score-table tr.best td { background: #fff3c4; }
.note { background: #ffe9e6; color: #9b1c12; border-radius: 12px; padding: 10px 12px; font-size: 17px; margin: 12px 0 0; font-weight: 600; }
.note.ok { background: #e3f7e9; color: #146b33; }
.rules h3 { margin: 16px 0 4px; font-size: 20px; }
.rules ul { margin: 0; padding-left: 20px; font-size: 17px; line-height: 1.45; }
.winner { text-align: center; font-size: 26px; font-weight: 800; margin: 4px 0 12px; }
.trophy { text-align: center; font-size: 64px; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 995; width: 100%; height: 100%; }
