:root {
  --bg: #0b0f1a;
  --bg-soft: #111827;
  --card: rgba(23, 31, 48, 0.82);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8edf7;
  --muted: #93a0b8;
  --accent: #41e0a3;
  --accent-2: #5b8cff;
  --danger: #ff6b6b;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(91, 140, 255, 0.20), transparent 60%),
    radial-gradient(760px 460px at 92% 4%, rgba(65, 224, 163, 0.16), transparent 62%),
    linear-gradient(180deg, #0b0f1a 0%, #080b13 100%);
}

/* ---------------------------- Kopfzeile ---------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px clamp(14px, 4vw, 40px) 10px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 22px;
  color: #06121a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(65, 224, 163, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 28px);
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.uptime {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  backdrop-filter: blur(8px);
}

.uptime-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.uptime-value {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(65, 224, 163, 0.6);
}

.dot.online {
  background: var(--accent);
  animation: pulse 2.4s infinite;
}

.dot.offline { background: var(--danger); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(65, 224, 163, 0.55); }
  70% { box-shadow: 0 0 0 12px rgba(65, 224, 163, 0); }
  100% { box-shadow: 0 0 0 0 rgba(65, 224, 163, 0); }
}

/* ----------------------------- Layout ------------------------------ */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 8px clamp(14px, 4vw, 40px) 28px;
  flex: 1;
}

.play { min-width: 0; }

.stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #0e1524 0%, #0a0f19 100%);
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 8 / 5;
}

/* ----------------------------- HUD -------------------------------- */

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.hud-item {
  flex: 1;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(8, 12, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(6px);
}

.hud-item span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-item strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

/* --------------------------- Overlays ------------------------------ */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  background: rgba(6, 10, 18, 0.82);
  backdrop-filter: blur(10px);
  transition: opacity 0.25s ease;
}

.overlay.hidden { display: none; }

.overlay h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 30px);
  letter-spacing: -0.02em;
}

.overlay p {
  margin: 0;
  max-width: 460px;
  color: var(--muted);
  font-size: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(280px, 90%);
  text-align: left;
}

.field span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

input[type="text"] {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 16px; /* verhindert Zoom auf iOS */
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(65, 224, 163, 0.18);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 13px 30px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn.primary {
  color: #04121a;
  background: linear-gradient(135deg, var(--accent), #6ef2c1);
  box-shadow: 0 12px 30px rgba(65, 224, 163, 0.25);
}

.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px) scale(0.995); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.score-big {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 44px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.score-big small {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.result { min-height: 22px; }
.result.ok { color: var(--accent); }
.result.warn { color: #ffd479; }
.result.err { color: var(--danger); }

.hint, .legal {
  color: var(--muted);
  font-size: 12px;
}

.legal {
  margin: 10px 2px 0;
  max-width: 620px;
}

/* --------------------------- Seitenteil ---------------------------- */

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  backdrop-filter: blur(8px);
  padding: 16px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.card-head h3 { margin: 0; }

.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(91, 140, 255, 0.16);
  color: #a9c0ff;
  border: 1px solid rgba(91, 140, 255, 0.3);
  white-space: nowrap;
}

.board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.board li {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 10px;
  font-size: 14px;
}

.board li + li { border-top: 1px solid rgba(255, 255, 255, 0.05); }

.board .rank {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.board .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board .pts {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

.board li.top1 .rank { color: #ffd479; font-weight: 700; }
.board li.top2 .rank { color: #d6deea; font-weight: 700; }
.board li.top3 .rank { color: #e0a878; font-weight: 700; }
.board li.me { background: rgba(65, 224, 163, 0.12); }
.board-empty { color: var(--muted); font-size: 14px; padding: 8px 6px; }

.stats dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stats dl > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.stats dt { color: var(--muted); font-size: 13px; }
.stats dd {
  margin: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ----------------------------- Footer ----------------------------- */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  padding: 0 clamp(14px, 4vw, 40px) 18px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

/* --------------------------- Responsive ---------------------------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .panel { order: 2; }
  .uptime { flex: 1 1 100%; justify-content: center; }
}

@media (max-width: 520px) {
  .tagline { display: none; }
  .hud-item strong { font-size: 15px; }
  .overlay { gap: 10px; padding: 14px; }
  .overlay p { font-size: 13px; }
  .score-big { font-size: 36px; }
  .board li { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .dot.online { animation: none; }
  .btn { transition: none; }
}
