/* Kneipen-Tipprunde – Spieler-Tablet-PWA.
   Kioskmaessig: dunkles, ruhiges Layout, sehr grosse Touch-Ziele (>= 56px),
   hoher Kontrast, keine winzigen Texte. Optimiert fuer Tablet quer (1280x800)
   und hoch (800x1280); auf dem Smartphone (390x844) bleibt alles bedienbar. */

:root {
  --bg: #0e1626;
  --bg-2: #11203a;
  --surface: #182a48;
  --surface-2: #1f3358;
  --surface-3: #27406b;
  --border: #2c4368;
  --border-strong: #3a557f;
  --text: #f3f6fc;
  --muted: #9fb2d4;
  --primary: #3d7be0;
  --primary-hover: #4f8bef;
  --primary-soft: #1c2f50;
  --accent: #f4b740;
  --danger: #ff6b5e;
  --danger-soft: #3a1f22;
  --success: #46c98b;
  --success-soft: #163a2c;
  --ring: #6ea8ff;
  --radius: 16px;
  --radius-lg: 22px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  font-size: 18px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
}

h1 {
  font-size: 1.8rem;
  margin: 0;
  font-weight: 700;
  line-height: 1.15;
}
h2 {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 650;
}
p {
  margin: 0;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.9rem;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* --- Screen scaffold ------------------------------------------------------ */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .title {
  flex: 1;
  min-width: 0;
}
.topbar .title b {
  display: block;
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .title span {
  color: var(--muted);
  font-size: 0.9rem;
}
.topbar .who {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  flex: 1;
  padding: clamp(16px, 4vw, 40px);
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  min-height: 56px;
  padding: 0 22px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, transform 0.05s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--surface);
}
.btn-lg {
  min-height: 64px;
  font-size: 1.15rem;
  padding: 0 28px;
}
.btn-block {
  width: 100%;
}

/* --- Avatars -------------------------------------------------------------- */

.avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  flex: none;
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
}
.avatar-xl {
  width: 96px;
  height: 96px;
  font-size: 2.2rem;
}

/* --- Centered card layout (pairing / pin) --------------------------------- */

.center {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(120% 120% at 50% 0%, #1a2c4d 0%, var(--bg) 70%);
}
.panel {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 28px 32px;
  box-shadow: 0 24px 60px rgba(3, 9, 20, 0.5);
  text-align: center;
}
.panel .brand {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 18px;
}
.panel h1 {
  margin-bottom: 6px;
}
.panel .lead {
  color: var(--muted);
  margin-bottom: 22px;
}

/* --- Code / PIN input ----------------------------------------------------- */

.code-input {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  text-align: center;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  min-height: 72px;
  padding: 0 12px 0 22px;
  margin-bottom: 18px;
}
.code-input:focus-visible {
  outline: none;
  border-color: var(--primary);
}

.dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 8px 0 26px;
  min-height: 26px;
}
.dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

/* --- Keypad --------------------------------------------------------------- */

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 360px;
  margin: 0 auto;
}
.key {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1.9rem;
  font-weight: 650;
  height: 78px;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.key:active {
  background: var(--surface-3);
  transform: translateY(1px);
}
.key:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}
.key-action {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
}
.key-confirm {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.inline-msg {
  min-height: 24px;
  margin: 4px 0 14px;
  font-weight: 600;
}
.inline-msg.err {
  color: var(--danger);
}
.inline-msg.ok {
  color: var(--success);
}

/* --- Player grid ---------------------------------------------------------- */

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.player-tile {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 22px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  min-height: 168px;
  justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.player-tile:hover {
  background: var(--surface-2);
  border-color: var(--primary);
}
.player-tile:active {
  transform: translateY(1px);
}
.player-tile:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}
.player-tile .name {
  font-size: 1.2rem;
  font-weight: 650;
  line-height: 1.2;
}

/* --- Round chooser -------------------------------------------------------- */

.round-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.round-card {
  appearance: none;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 20px 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
}
.round-card:hover {
  background: var(--surface-2);
  border-color: var(--primary);
}
.round-card .grow {
  flex: 1;
}
.round-card .rname {
  font-size: 1.2rem;
  font-weight: 650;
}
.round-card .chev {
  font-size: 1.6rem;
  color: var(--muted);
}

/* --- Match cards (tippen) ------------------------------------------------- */

.match {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.match.locked {
  opacity: 0.72;
}
.match-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.match-head .kickoff {
  color: var(--muted);
  font-size: 0.9rem;
}
.match-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.team {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.team.away {
  flex-direction: row-reverse;
  text-align: right;
}
.team .tname {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crest {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 6px;
  background: #fff2;
  object-fit: contain;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stepper button {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper button:active {
  background: var(--surface-3);
}
.stepper .val {
  min-width: 44px;
  text-align: center;
  font-size: 1.7rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.score-sep {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0 2px;
}

.match-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.joker {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  min-height: 48px;
  padding: 0 18px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.joker[aria-pressed="true"] {
  background: #3a2f12;
  border-color: var(--accent);
  color: var(--accent);
}
.joker .star {
  font-size: 1.2rem;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
}
.save-state.saved {
  color: var(--success);
}
.save-state.dirty {
  color: var(--accent);
}

.lock-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
}

/* --- Leaderboard ---------------------------------------------------------- */

.lb {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.lb-row:last-child {
  border-bottom: none;
}
.lb-row.me {
  background: var(--surface-3);
}
.lb-rank {
  font-size: 1.2rem;
  font-weight: 750;
  width: 34px;
  text-align: center;
  color: var(--muted);
  flex: none;
}
.lb-row .grow {
  flex: 1;
  min-width: 0;
}
.lb-name {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-pts {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.lb-pts span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

/* --- States --------------------------------------------------------------- */

.state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.state h2 {
  color: var(--text);
  margin-bottom: 8px;
}
.state .actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Toasts --------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 80;
  width: min(92vw, 460px);
  pointer-events: none;
}
.toast {
  background: #07223f;
  border: 1px solid var(--border);
  color: #fff;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-weight: 600;
  text-align: center;
  animation: toast-in 0.18s ease;
}
.toast.success {
  background: var(--success-soft);
  border-color: var(--success);
}
.toast.error {
  background: var(--danger-soft);
  border-color: var(--danger);
}
@keyframes toast-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}

/* --- Responsive: tablet hoch / phone -------------------------------------- */

@media (max-width: 560px) {
  body {
    font-size: 17px;
  }
  .player-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .player-tile {
    min-height: 140px;
    padding: 16px 10px;
  }
  .team .tname {
    font-size: 0.95rem;
  }
  .stepper button {
    width: 44px;
    height: 44px;
  }
}
