/* Schnick-Schnack-Schnuck-Turnier – Besitzer: RPS-Agent. Alle Klassen mit Präfix .mg-rps- */
.mg-rps {
  --mg-rps-ink: var(--c-outline, #1b1b2f);
  --mg-rps-hand: 92px;
  --mg-rps-btn: 72px;
  position: absolute; inset: 0;
  display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr);
  padding: var(--safe-top, 0px) var(--safe-right, 0px) var(--safe-bottom, 0px) var(--safe-left, 0px);
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 18px, transparent 18px 36px),
    radial-gradient(ellipse at 50% 40%, #6a3fd0 0%, #43239a 55%, #2a1666 100%);
  color: #fff; font-family: system-ui, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none;
  overflow: hidden;
}
.mg-rps.mg-rps-tablet { --mg-rps-hand: 150px; --mg-rps-btn: 104px; }
:where(.mg-rps) button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; cursor: pointer; }

/* ---------- Kopfzeile ---------- */
.mg-rps-top { display: flex; align-items: center; gap: 8px; padding: 6px 10px 2px; min-height: 40px; min-width: 0; }
.mg-rps-title {
  font-family: "Press Start 2P", system-ui, sans-serif; font-size: 13px; white-space: nowrap;
  padding: 6px 10px; border-radius: 10px; background: var(--c-gold, #ffd23f); color: var(--mg-rps-ink);
  border: 3px solid var(--mg-rps-ink); box-shadow: 3px 3px 0 var(--mg-rps-ink);
}
.mg-rps-tablet .mg-rps-title { font-size: 16px; }
.mg-rps-others { flex: 1; display: flex; gap: 6px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
.mg-rps-chip {
  flex: none; min-height: 48px; padding: 4px 10px; border-radius: 12px; font-size: 12px; white-space: nowrap;
  background: rgba(0,0,0,.3); border: 3px solid var(--mg-rps-ink);
}
.mg-rps-chip.sel { background: var(--c-accent, #3a86ff); }
.mg-rps-chip.done { opacity: .6; }
.mg-rps-pot {
  margin-left: auto; padding: 6px 12px; border-radius: 12px; font-weight: 800; white-space: nowrap;
  background: #2b2b44; border: 3px solid var(--c-gold, #ffd23f); color: var(--c-gold, #ffd23f);
}
.mg-rps-main { position: relative; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Timer ---------- */
.mg-rps-timer {
  position: relative; height: 22px; width: min(420px, 70%); margin: 4px auto; border-radius: 11px; overflow: hidden;
  background: rgba(0,0,0,.4); border: 3px solid var(--mg-rps-ink);
}
.mg-rps-timer.slim { height: 16px; }
.mg-rps-timer-bar { position: absolute; inset: 0; background: var(--c-good, #0ead69); transform-origin: left center; }
.mg-rps-timer.low .mg-rps-timer-bar { background: var(--c-bad, #ff4d4d); }
.mg-rps-timer-sec { position: relative; display: block; text-align: center; font-weight: 900; font-size: 13px; line-height: 16px; text-shadow: 1px 1px 0 #000; }
.mg-rps-timer.slim .mg-rps-timer-sec { font-size: 10px; line-height: 10px; }

/* ---------- Turnierbaum ---------- */
.mg-rps-bview { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 4px 8px 8px; }
.mg-rps-cap { text-align: center; font-weight: 900; font-size: 18px; text-shadow: 2px 2px 0 var(--mg-rps-ink); }
.mg-rps-cap-sub { text-align: center; font-size: 14px; opacity: .9; margin-top: 2px; text-shadow: none; font-weight: 600; }
.mg-rps-bracket {
  flex: 1; display: flex; gap: 14px; align-items: stretch; justify-content: center; overflow: auto; padding: 6px 4px;
  min-height: 0; touch-action: pan-x pan-y;
}
.mg-rps-bk-col { display: flex; flex-direction: column; justify-content: space-around; gap: 8px; min-width: 120px; max-width: 190px; flex: 1; }
.mg-rps-bk-col.cur .mg-rps-bk-title { background: var(--c-gold, #ffd23f); color: var(--mg-rps-ink); }
.mg-rps-bk-title {
  align-self: center; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 8px; background: rgba(0,0,0,.35);
}
.mg-rps-bk-m {
  background: var(--c-panel, #fff7e6); color: var(--mg-rps-ink); border: 3px solid var(--mg-rps-ink); border-radius: 10px;
  box-shadow: 3px 3px 0 var(--mg-rps-ink); overflow: hidden; flex: none;
}
.mg-rps-bk-m.live { border-color: var(--c-gold, #ffd23f); box-shadow: 0 0 0 3px var(--mg-rps-ink), 0 0 14px var(--c-gold, #ffd23f); }
.mg-rps-bk-m.tbd { opacity: .45; }
.mg-rps-bk-m.bye { background: #e3dcff; }
.mg-rps-bk-p { display: flex; justify-content: space-between; gap: 6px; padding: 3px 8px; font-size: 13px; min-height: 22px; align-items: center; }
.mg-rps-bk-p + .mg-rps-bk-p { border-top: 2px dashed rgba(27,27,47,.3); }
.mg-rps-bk-p span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-rps-bk-p.win { font-weight: 900; background: #c9f5dd; }
.mg-rps-bk-p.lose span { text-decoration: line-through; opacity: .55; }
.mg-rps-bk-p.me span::after { content: ' ★'; color: var(--c-accent-2, #8338ec); }
.mg-rps-tablet .mg-rps-bk-p { font-size: 16px; min-height: 30px; }

/* ---------- Duell ---------- */
.mg-rps-duel { flex: 1; display: grid; grid-template-rows: 1fr auto auto; min-height: 0; padding: 0 8px 8px; }
.mg-rps-arena { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; min-height: 0; gap: 6px; }
.mg-rps-side { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; transition: transform .3s, opacity .3s; }
.mg-rps-side.win { transform: scale(1.08); }
.mg-rps-side.lose { opacity: .5; filter: grayscale(.7); }
.mg-rps-fig { position: relative; line-height: 0; }
.mg-rps-fig svg { display: block; }
.mg-rps-crown { position: absolute; top: -18px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: 28px; line-height: 1; animation: mg-rps-bob 1s ease-in-out infinite; }
.mg-rps-crown.big { font-size: 56px; top: -44px; }
.mg-rps-name { font-weight: 900; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 2px 2px 0 var(--mg-rps-ink); }
.mg-rps-side.me .mg-rps-name { color: var(--c-gold, #ffd23f); }
.mg-rps-off { font-size: 10px; background: var(--c-bad, #ff4d4d); padding: 1px 4px; border-radius: 4px; text-shadow: none; }
.mg-rps-pips { display: flex; gap: 5px; }
.mg-rps-pips span { width: 16px; height: 16px; border-radius: 50%; background: rgba(0,0,0,.35); border: 3px solid var(--mg-rps-ink); }
.mg-rps-pips span.on { background: var(--c-gold, #ffd23f); }
.mg-rps-tablet .mg-rps-pips span { width: 22px; height: 22px; }

.mg-rps-center { display: flex; align-items: center; justify-content: center; gap: 10px; }
.mg-rps-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.mg-rps-slot small { font-size: 12px; font-weight: 800; opacity: .9; }
.mg-rps-slot.ready small { color: var(--c-good, #0ead69); text-shadow: 1px 1px 0 #000; }
.mg-rps-slot.chosen small { color: var(--c-gold, #ffd23f); }
.mg-rps-slot.won .mg-rps-hand { background: #c9f5dd; box-shadow: 0 0 0 4px var(--c-good, #0ead69), 0 0 18px var(--c-good, #0ead69); }
.mg-rps-slot.lost .mg-rps-hand { background: #ffd6d6; opacity: .75; }
.mg-rps-slot.draw .mg-rps-hand { background: #fff1b8; }
.mg-rps-auto { position: absolute; bottom: -4px; padding: 1px 5px; border-radius: 6px; background: var(--c-orange, #ff9f1c); color: var(--mg-rps-ink); font-size: 10px !important; }
.mg-rps-hand {
  width: var(--mg-rps-hand); height: var(--mg-rps-hand); display: grid; place-items: center; border-radius: 50%;
  background: var(--c-panel, #fff7e6); border: 4px solid var(--mg-rps-ink); box-shadow: 4px 4px 0 var(--mg-rps-ink);
  font-size: calc(var(--mg-rps-hand) * .58); line-height: 1;
}
.mg-rps-hand span { display: block; transform-origin: 50% 80%; }
.mg-rps-hand.flip span { transform: scaleX(-1); }
.mg-rps-hand.idle span { opacity: .35; }
.mg-rps-hand.shake span { animation: mg-rps-shake .45s ease-in-out 3; }
.mg-rps-hand.flip.shake span { animation-name: mg-rps-shake-flip; }
.mg-rps-hand.pop { animation: mg-rps-pop .35s cubic-bezier(.2,1.6,.4,1); }
.mg-rps-vs { font-family: "Press Start 2P", system-ui, sans-serif; font-size: 18px; color: var(--c-gold, #ffd23f); text-shadow: 3px 3px 0 var(--mg-rps-ink); }
.mg-rps-vs.big { font-size: 34px; }
.mg-rps-chant { position: relative; width: 96px; height: 30px; }
.mg-rps-chant span {
  position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 18px; color: var(--c-gold, #ffd23f);
  text-shadow: 2px 2px 0 var(--mg-rps-ink); opacity: 0; animation: mg-rps-chant .45s ease-out both;
}
.mg-rps-chant span:nth-child(2) { animation-delay: .45s; }
.mg-rps-chant span:nth-child(3) { animation-delay: .9s; }

.mg-rps-status { display: flex; flex-direction: column; align-items: center; min-height: 34px; }
.mg-rps-gameno { font-size: 13px; font-weight: 800; opacity: .9; }
.mg-rps-result {
  margin: 2px auto; padding: 6px 14px; border-radius: 12px; font-weight: 900; font-size: 16px;
  background: rgba(0,0,0,.4); border: 3px solid var(--mg-rps-ink); animation: mg-rps-pop .35s cubic-bezier(.2,1.6,.4,1);
}
.mg-rps-result.big { font-size: 20px; }
.mg-rps-result.good { background: var(--c-good, #0ead69); }
.mg-rps-result.bad { background: var(--c-bad, #ff4d4d); }
.mg-rps-result.draw { background: var(--c-orange, #ff9f1c); color: var(--mg-rps-ink); }

.mg-rps-bottom { display: flex; justify-content: center; }
.mg-rps-picks { display: flex; gap: 12px; justify-content: center; }
.mg-rps-pick {
  min-width: calc(var(--mg-rps-btn) * 1.3); min-height: var(--mg-rps-btn); padding: 4px 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  border-radius: 16px; background: var(--c-panel, #fff7e6); color: var(--mg-rps-ink) !important;
  border: 4px solid var(--mg-rps-ink); box-shadow: 4px 4px 0 var(--mg-rps-ink);
  animation: mg-rps-bob 1.2s ease-in-out infinite;
}
.mg-rps-pick:nth-child(2) { animation-delay: .15s; }
.mg-rps-pick:nth-child(3) { animation-delay: .3s; }
.mg-rps-pick span { font-size: calc(var(--mg-rps-btn) * .5); line-height: 1.05; }
.mg-rps-pick b { font-size: 13px; }
.mg-rps-pick:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--mg-rps-ink); }
.mg-rps-wait { padding: 10px 16px; border-radius: 12px; background: rgba(0,0,0,.3); font-weight: 700; text-align: center; }

/* ---------- Wetten ---------- */
.mg-rps-betpanel, .mg-rps-betwait {
  margin: 4px auto 8px; width: min(860px, calc(100% - 16px)); max-height: calc(100% - 12px); overflow-y: auto;
  padding: 10px 14px; box-sizing: border-box; border-radius: 16px;
  background: var(--c-panel, #fff7e6); color: var(--mg-rps-ink); border: 4px solid var(--mg-rps-ink); box-shadow: 5px 5px 0 var(--mg-rps-ink);
  touch-action: pan-y;
}
.mg-rps-betwait .mg-rps-cap { color: var(--mg-rps-ink); text-shadow: none; }
.mg-rps-bethead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mg-rps-bethead h2 { margin: 0; font-size: 18px; }
.mg-rps-bethead .mg-rps-timer { flex: 1; width: auto; min-width: 120px; color: #fff; }
.mg-rps-betwait .mg-rps-timer { color: #fff; }
.mg-rps-betrows { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 6px 14px; margin: 8px 0; }
.mg-rps-betctl { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px; }
.mg-rps-betrow, .mg-rps-vsrow { display: flex; align-items: center; justify-content: center; gap: 10px; }
.mg-rps-betrow > b, .mg-rps-vsrow > b { font-family: "Press Start 2P", system-ui, sans-serif; font-size: 12px; }
.mg-rps-betside {
  flex: 1; max-width: 220px; min-height: 56px; display: flex; align-items: center; gap: 8px; padding: 4px 10px;
  border-radius: 12px; background: #fff; border: 3px solid var(--mg-rps-ink); box-shadow: 3px 3px 0 var(--mg-rps-ink);
  color: var(--mg-rps-ink) !important; font-weight: 800; text-align: left;
}
.mg-rps-betside span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-rps-betside.sel { background: var(--c-gold, #ffd23f); transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--mg-rps-ink); }
.mg-rps-vsp { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.mg-rps-stepper { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.mg-rps-amt { min-width: 70px; text-align: center; font-size: 22px; font-weight: 900; }
.mg-rps-btn {
  min-width: 48px; min-height: 48px; padding: 4px 14px; border-radius: 12px; font-weight: 900;
  background: #fff; color: var(--mg-rps-ink) !important; border: 3px solid var(--mg-rps-ink); box-shadow: 3px 3px 0 var(--mg-rps-ink);
}
.mg-rps-btn:disabled { opacity: .4; cursor: default; }
.mg-rps-btn.round { border-radius: 24px; }
.mg-rps-btn.good { background: var(--c-good, #0ead69); color: #fff !important; min-width: 130px; }
.mg-rps-btn.ghost { background: transparent; }
.mg-rps-btn:not(:disabled):active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--mg-rps-ink); }
.mg-rps-betinfo { text-align: center; font-size: 13px; margin: 6px 0; opacity: .85; }
.mg-rps-betactions { display: flex; justify-content: center; gap: 10px; }
.mg-rps-betlist { margin: 6px 0; padding-left: 20px; font-size: 13px; }

/* ---------- Gewinner ---------- */
.mg-rps-champ { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px; min-height: 0; overflow: auto; }
.mg-rps-champfig { position: relative; line-height: 0; margin-top: 30px; animation: mg-rps-bob 1.4s ease-in-out infinite; }
.mg-rps-champtxt { font-family: "Press Start 2P", system-ui, sans-serif; font-size: 16px; text-align: center; color: var(--c-gold, #ffd23f); text-shadow: 3px 3px 0 var(--mg-rps-ink); line-height: 1.4; }
.mg-rps-tablet .mg-rps-champtxt { font-size: 24px; }
.mg-rps-champpot { font-weight: 900; }
.mg-rps-champdelta { padding: 4px 12px; border-radius: 10px; font-weight: 900; border: 3px solid var(--mg-rps-ink); }
.mg-rps-champdelta.good { background: var(--c-good, #0ead69); }
.mg-rps-champdelta.bad { background: var(--c-bad, #ff4d4d); }
.mg-rps-ranking { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; }
.mg-rps-ranking li.me { color: var(--c-gold, #ffd23f); font-weight: 900; }

/* ---------- Banner ---------- */
.mg-rps-banner { position: absolute; left: 0; right: 0; top: calc(var(--safe-top, 0px) + 52px); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 5; }
.mg-rps-bannermsg {
  padding: 6px 14px; border-radius: 12px; font-weight: 900; background: rgba(27,27,47,.85); border: 3px solid var(--mg-rps-ink);
  animation: mg-rps-banner 2.2s ease-out both;
}
.mg-rps-bannermsg.good { background: var(--c-good, #0ead69); }
.mg-rps-bannermsg.bad { background: var(--c-bad, #ff4d4d); }
.mg-rps-bannermsg.me { background: var(--c-accent, #3a86ff); }
.mg-rps-avatar-fb { display: grid; place-items: center; border-radius: 50%; background: var(--c-accent, #3a86ff); border: 3px solid var(--mg-rps-ink); font-weight: 900; box-sizing: border-box; color: #fff; line-height: 1; }

/* ---------- Tablet: größere Schrift ---------- */
.mg-rps-tablet .mg-rps-name { font-size: 20px; }
.mg-rps-tablet .mg-rps-slot small, .mg-rps-tablet .mg-rps-gameno { font-size: 16px; }
.mg-rps-tablet .mg-rps-result { font-size: 20px; }
.mg-rps-tablet .mg-rps-result.big { font-size: 26px; }
.mg-rps-tablet .mg-rps-pick b { font-size: 16px; }
.mg-rps-tablet .mg-rps-timer { height: 28px; }
.mg-rps-tablet .mg-rps-timer-sec { font-size: 16px; line-height: 22px; }
.mg-rps-tablet .mg-rps-vs { font-size: 26px; }

/* ---------- Handy: kompakter ---------- */
@media (max-height: 420px) {
  .mg-rps { --mg-rps-hand: 78px; --mg-rps-btn: 64px; }
  .mg-rps-top { min-height: 34px; padding-top: 4px; }
  .mg-rps-name { font-size: 13px; }
  .mg-rps-result { font-size: 14px; padding: 4px 10px; }
  .mg-rps-pick b { font-size: 11px; }
  .mg-rps-betpanel, .mg-rps-betwait { padding: 6px 10px; }
  .mg-rps-bethead h2 { font-size: 15px; }
  .mg-rps-betrows { margin: 4px 0; }
  .mg-rps-betside { min-height: 48px; padding: 2px 8px; }
  .mg-rps-betinfo { margin: 2px 0; font-size: 12px; }
  .mg-rps-cap { font-size: 15px; }
  .mg-rps-bracket { padding: 2px 4px; gap: 10px; }
  .mg-rps-bk-col { gap: 5px; }
  .mg-rps-bk-p { min-height: 17px; padding: 1px 6px; font-size: 12px; }
  .mg-rps-bk-m { border-width: 2px; box-shadow: 2px 2px 0 var(--mg-rps-ink); }
}

@keyframes mg-rps-shake { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-26%) rotate(-18deg); } }
@keyframes mg-rps-shake-flip { 0%, 100% { transform: scaleX(-1) translateY(0) rotate(0); } 50% { transform: scaleX(-1) translateY(-26%) rotate(-18deg); } }
@keyframes mg-rps-chant { 0% { opacity: 0; transform: scale(.4); } 40% { opacity: 1; transform: scale(1.15); } 100% { opacity: 0; transform: scale(1); } }
@keyframes mg-rps-pop { 0% { transform: scale(.3); } 100% { transform: scale(1); } }
@keyframes mg-rps-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.mg-rps-crown { animation-name: mg-rps-crownbob; }
@keyframes mg-rps-crownbob { 0%, 100% { transform: translateX(-50%) rotate(-8deg) translateY(0); } 50% { transform: translateX(-50%) rotate(-8deg) translateY(-4px); } }
@keyframes mg-rps-banner { 0% { opacity: 0; transform: translateY(-10px) scale(.8); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .mg-rps-pick, .mg-rps-champfig, .mg-rps-crown { animation: none; }
}
