:root {
  --bg: #0b1320; --card: #141f31; --card2: #1c2a41; --line: #2a3b57;
  --text: #f1f5fb; --dim: #9db0cc; --ball: #d8f24a; --ink: #111a06;
  --a: #1c55c4; --b: #ad4826; --a-soft: #8fb4ff; --b-soft: #ffab8c;
  --top: env(safe-area-inset-top, 0px); --bot: env(safe-area-inset-bottom, 0px);
  --left: env(safe-area-inset-left, 0px); --right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font: 17px/1.4 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--ball); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Seiten */
.page { max-width: 620px; margin: 0 auto; padding: calc(var(--top) + 20px) calc(var(--right) + 16px) calc(var(--bot) + 32px) calc(var(--left) + 16px); }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; min-height: 44px; }
.head h1 { flex: 1; min-width: 0; margin: 0; font-size: 1.7rem; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 28px 0 10px; font-weight: 700; color: var(--dim); }
.icon { width: 44px; height: 44px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; flex: none; }
.icon svg { width: 22px; height: 22px; }
.big { display: block; width: 100%; min-height: 56px; padding: 14px 18px; border-radius: 18px; background: var(--ball); color: var(--ink); font-weight: 800; font-size: 1.1rem; text-align: center; }
.big.alt { background: var(--card2); color: var(--text); }
.big:disabled { opacity: .4; }
.stack { display: grid; gap: 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode { text-align: left; padding: 16px; border-radius: 18px; background: var(--card); min-height: 104px; display: flex; flex-direction: column; gap: 4px; justify-content: flex-end; }
.mode b { font-size: 1.12rem; line-height: 1.2; }
.mode span { color: var(--dim); font-size: .88rem; line-height: 1.3; }
.mode.hero { grid-column: 1 / -1; background: linear-gradient(var(--a) 0 0); min-height: 120px; }
.mode.hero span { color: #d3e1ff; }
.resume { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 16px; border-radius: 18px; background: var(--ball); color: var(--ink); margin-bottom: 10px; }
.resume div { flex: 1; min-width: 0; }
.resume b, .resume span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--card); border-radius: 14px; width: 100%; text-align: left; }
.row > div { flex: 1; min-width: 0; }
.row small { display: block; color: var(--dim); }
.row strong { font-variant-numeric: tabular-nums; white-space: pre; }
.hint { color: var(--dim); font-size: .92rem; margin: 8px 0; }
.del { color: var(--dim); min-width: 44px; min-height: 44px; font-size: 1.3rem; }

/* Formular */
.field { margin: 0 0 18px; }
.field > label, .field > .lbl { display: block; color: var(--dim); font-size: .95rem; margin-bottom: 6px; }
input[type=text] { width: 100%; min-height: 50px; padding: 0 14px; border-radius: 14px; border: 2px solid transparent; background: var(--card); }
input[type=text].a { border-color: var(--a); } input[type=text].b { border-color: var(--b); }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { flex: 1 1 auto; min-height: 46px; padding: 8px 14px; border-radius: 14px; background: var(--card); font-weight: 600; }
.seg button[aria-pressed=true] { background: var(--text); color: var(--bg); }
.num { display: flex; align-items: center; justify-content: center; gap: 12px; }
.num output { font-size: 2.4rem; font-weight: 800; min-width: 2.2ch; text-align: center; font-variant-numeric: tabular-nums; }

/* Court */
.court { position: fixed; inset: 0; display: grid; grid-template-rows: 1fr auto 1fr; background: var(--bg); overflow: hidden; }
.half { position: relative; overflow: hidden; display: block; width: 100%; min-width: 0; min-height: 0; text-align: center; color: #fff; }
.half.a { background: var(--a); } .half.b { background: var(--b); }
.half.a:active { background: #2a65d8; } .half.b:active { background: #c25530; }
.half i { position: absolute; display: block; background: rgba(255,255,255,.34); pointer-events: none; }
.half .srv { left: 0; right: 0; height: 3px; } .half.b .srv { top: 30%; } .half.a .srv { bottom: 30%; }
.half .mid { width: 3px; left: calc(50% - 1.5px); } .half.b .mid { top: 30%; bottom: 0; } .half.a .mid { bottom: 30%; top: 0; }
.half .box { background: rgba(216,242,74,.24); width: 50%; } .half.b .box { top: 30%; bottom: 0; } .half.a .box { bottom: 30%; top: 0; }
.half .box.lo { left: 0; } .half .box.hi { right: 0; }
.half .ball { width: 34px; height: 34px; border-radius: 50%; background: var(--ball); box-shadow: 0 0 0 5px rgba(216,242,74,.28); overflow: hidden; }
.half .ball::after { content: ""; position: absolute; inset: -12px 12px 12px -12px; border: 2.5px solid #fff; border-radius: 50%; }
.half.b .ball { top: calc(var(--top) + 60px); } .half.a .ball { bottom: calc(var(--bot) + 20px); }
.half .ball.lo { left: 10%; } .half .ball.hi { right: 10%; }
.half .txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 60px; pointer-events: none; }
.half.b .txt { padding-top: calc(var(--top) + 48px); } .half.a .txt { padding-bottom: calc(var(--bot) + 8px); flex-direction: column-reverse; }
.half .name { font-weight: 700; font-size: 1.15rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.half .pts { font-size: min(27vh, 46vw); line-height: .95; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.half .pts.long { font-size: min(22vh, 36vw); }
.half.hit .pts { animation: hit .32s cubic-bezier(.2,.9,.3,1.3); }
@keyframes hit { from { transform: scale(1.18); } to { transform: none; } }
.net { position: relative; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 8px calc(var(--right) + 10px) 8px calc(var(--left) + 10px); background: var(--bg); border-block: 3px solid #fff; }
.board { flex: 1; min-width: 0; display: flex; gap: 6px; justify-content: center; }
.board .set { display: grid; grid-template-rows: 1fr 1fr; min-width: 36px; padding: 2px 6px; border-radius: 10px; background: var(--card); text-align: center; font-weight: 800; font-size: 1.22rem; line-height: 1.3; font-variant-numeric: tabular-nums; }
.board .set.now { background: var(--card2); box-shadow: inset 0 0 0 2px var(--dim); }
.board .set .lose { color: var(--dim); font-weight: 600; }
.board .info { align-self: center; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.board .info small { display: block; color: var(--dim); font-weight: 500; }
.bar { position: absolute; z-index: 3; top: calc(var(--top) + 8px); left: calc(var(--left) + 10px); right: calc(var(--right) + 10px); display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.bar > * { pointer-events: auto; }
.bar .icon { background: rgba(11,19,32,.55); }
.bar .clock { padding: 6px 14px; border-radius: 99px; background: rgba(11,19,32,.55); font-weight: 700; font-variant-numeric: tabular-nums; }
.bar .clock.out { background: var(--ball); color: var(--ink); }
.toast { position: absolute; z-index: 4; left: 50%; top: calc(var(--top) + 62px); transform: translateX(-50%); padding: 12px 24px; border-radius: 99px; background: var(--ball); color: var(--ink); font-weight: 800; font-size: 1.25rem; white-space: nowrap; pointer-events: none; animation: toast 2.4s forwards; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
@keyframes toast { 0% { opacity: 0; scale: .8; } 8%, 80% { opacity: 1; scale: 1; } 100% { opacity: 0; } }
.stake { position: absolute; z-index: 2; left: 50%; transform: translateX(-50%); padding: 3px 14px; border-radius: 99px; background: var(--ball); color: var(--ink); font-weight: 800; font-size: .95rem; white-space: nowrap; pointer-events: none; }
.half.b .stake { bottom: 10px; } .half.a .stake { top: 10px; }

@media (orientation: portrait) {
  .half .name { position: absolute; left: 22%; right: 22%; max-width: none; }
  .half.b .name { top: calc(30% - 1.9em); } .half.a .name { bottom: calc(30% - 1.9em); }
  .half.a .txt, .half.b .txt { padding: 0 8px; }
  .half.b .pts { margin-top: 24%; } .half.a .pts { margin-bottom: 24%; }
}
@media (orientation: landscape) {
  .court { grid-template-rows: none; grid-template-columns: 1fr auto 1fr; }
  .half.a { order: 0; } .net { order: 1; } .half.b { order: 2; }
  .half .srv { top: 0; bottom: 0; height: auto; width: 3px; }
  .half.a .srv { left: 30%; right: auto; bottom: 0; } .half.b .srv { left: auto; right: 30%; top: 0; }
  .half .mid { height: 3px; width: auto; top: calc(50% - 1.5px); }
  .half.a .mid { left: 30%; right: 0; top: calc(50% - 1.5px); bottom: auto; } .half.b .mid { left: 0; right: 30%; top: calc(50% - 1.5px); bottom: auto; }
  .half .box { width: auto; height: 50%; }
  .half.a .box { left: 30%; right: 0; } .half.b .box { left: 0; right: 30%; }
  .half .box.lo { top: 0; bottom: auto; } .half .box.hi { top: auto; bottom: 0; }
  .half.a .ball { left: calc(var(--left) + 24px); right: auto; } .half.b .ball { right: calc(var(--right) + 24px); left: auto; }
  .half .ball.lo { top: calc(var(--top) + 70px); bottom: auto; } .half .ball.hi { bottom: calc(var(--bot) + 24px); top: auto; }
  .half.a .txt, .half.b .txt { flex-direction: column; padding: 16px 60px; }
  .half .pts { font-size: min(56vh, 24vw); } .half .pts.long { font-size: min(50vh, 19vw); }
  .net { flex-direction: column; justify-content: center; border-block: 0; border-inline: 3px solid #fff; padding: calc(var(--top) + 8px) 8px calc(var(--bot) + 8px); }
  .board { flex: none; flex-direction: column; }
  .board .set { grid-template-rows: none; grid-template-columns: 1fr 1fr; min-width: 64px; gap: 6px; }
  .half.a .stake, .half.b .stake { top: auto; bottom: 14px; }
}

/* Ergebnis, Tabelle, Dialog */
.final { text-align: center; padding: 22px 12px; border-radius: 22px; background: var(--card); margin-bottom: 16px; }
.final.a { background: var(--a); } .final.b { background: var(--b); }
.final b { display: block; font-size: 1.5rem; font-weight: 800; overflow-wrap: anywhere; }
.final .score { font-size: 2.3rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: pre-wrap; line-height: 1.2; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 14px; overflow: hidden; }
th, td { padding: 10px 12px; text-align: right; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th { color: var(--dim); font-weight: 600; font-size: .9rem; }
th:first-child, td:first-child { text-align: left; overflow-wrap: anywhere; }
.stats td:nth-child(1) { text-align: right; font-weight: 800; color: var(--a-soft); } .stats td:nth-child(2) { text-align: center; color: var(--dim); } .stats td:nth-child(3) { text-align: left; font-weight: 800; color: var(--b-soft); }
.duel { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; padding: 14px; border-radius: 16px; background: var(--card); width: 100%; }
.duel span { min-width: 0; overflow-wrap: anywhere; font-weight: 600; } .duel span:first-child { text-align: right; } .duel span:last-child { text-align: left; }
.duel strong { min-width: 74px; padding: 8px 10px; border-radius: 12px; background: var(--card2); font-variant-numeric: tabular-nums; text-align: center; }
dialog { border: 0; border-radius: 24px; background: var(--card); color: var(--text); padding: 20px; width: min(92vw, 420px); max-height: 88vh; overflow: auto; }
dialog::backdrop { background: rgba(4,8,15,.72); }
dialog h3 { margin: 0 0 14px; font-size: 1.2rem; }
dialog .row { background: var(--card2); min-height: 52px; }
.sw { width: 52px; height: 32px; border-radius: 99px; background: var(--line); position: relative; flex: none; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; }
[aria-checked=true] .sw { background: #8fae1c; } [aria-checked=true] .sw::after { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) { .half.hit .pts { animation: none; } .toast { animation-timing-function: step-end; } .sw::after { transition: none; } }
