:root {
  --blue: #0a4bd6;
  --orange: #e8670c;
  --ink: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  color: var(--ink);
  font-family: -apple-system, system-ui, "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* Anzeige */
#board {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#sets {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 4vw;
  padding: 1.5vh 2vw;
  font-size: 7vh;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-height: 11vh;
}
#sets .set sup { font-size: 0.45em; opacity: 0.7; margin-left: 0.15em; }
#sets .won { font-size: 0.5em; font-weight: 500; opacity: 0.7; }

.team {
  display: grid;
  grid-template-rows: auto auto 1fr;
  justify-items: center;
  padding: 1vh 1vw 0;
}
.team[data-team="0"] { background: var(--blue); }
.team[data-team="1"] { background: var(--orange); }

.name {
  font-size: 5.5vh;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4em;
  max-width: 100%;
}
.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.serve { font-size: 0.8em; min-width: 0.8em; }
.games {
  font-size: 15vh;
  font-weight: 700;
  line-height: 1;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}
.points {
  align-self: center;
  font-size: 40vh;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

footer {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 1vh 2vw;
  font-size: 4vh;
  background: #000;
}
#clock { opacity: 0.7; font-variant-numeric: tabular-nums; }
#status { font-weight: 700; text-align: center; }
#conn { justify-self: end; width: 2.4vh; height: 2.4vh; border-radius: 50%; background: #d33; }
#conn.ok { background: #2c5; }

/* Formulare */
.panel {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 3vh 4vw;
  overflow: auto;
}
form { width: min(520px, 100%); display: grid; gap: 14px; }
h1 { margin: 0 0 4px; font-size: 28px; }
label { display: grid; gap: 6px; font-size: 16px; opacity: 0.9; }
label.check { grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
input[type="text"], input:not([type]), input[type="password"], select {
  font: inherit;
  font-size: 20px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #444;
  background: #1a1a1a;
  color: var(--ink);
}
input[type="checkbox"] { width: 24px; height: 24px; }
button {
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  padding: 16px;
  border-radius: 12px;
  border: 0;
  background: #fff;
  color: #000;
}
button.danger { background: #b3261e; color: #fff; }
.error { margin: 0; min-height: 1.2em; color: #ff8a80; }

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10;
}
#tap { background: rgba(0, 0, 0, 0.92); z-index: 20; font-size: 6vh; text-align: center; }
#tap small { font-size: 0.5em; opacity: 0.7; }
.sheet {
  width: min(560px, 92vw);
  max-height: 94vh;
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: 18px;
  background: #1c1c1e;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row button:first-child { background: var(--blue); color: #fff; }
.row button:last-child { background: var(--orange); color: #fff; }
fieldset { border: 1px solid #444; border-radius: 12px; display: grid; gap: 12px; padding: 14px; margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 14vh;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 999px;
  background: #b3261e;
  font-size: 20px;
  z-index: 30;
}
