:root {
  --bg: #143f30;
  --bg2: #1d5a43;
  --card: #0f2c22;
  --card-edge: rgba(255, 255, 255, 0.09);
  --text: #f2f7f4;
  --muted: rgba(242, 247, 244, 0.68);
  --accent: #ff7849;
  --accent-ink: #1b0f08;
  --court: #2f63a6;
  --ball: #e6f14a;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.screen, .overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  z-index: 10;
}
.screen { background: radial-gradient(120% 90% at 50% 0%, var(--bg2), var(--bg)); }
.overlay { background: rgba(6, 18, 13, 0.72); backdrop-filter: blur(3px); z-index: 20; }
.screen.active, .overlay.active { display: flex; }

.card {
  width: 100%;
  max-width: 380px;
  margin: auto;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  padding: 24px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.wide { max-width: 560px; }

.hero { text-align: center; align-items: stretch; }
.logo { width: 84px; height: 84px; margin: 0 auto 2px; }
.logo svg { width: 100%; height: 100%; }
h1 { margin: 0; font-size: 34px; letter-spacing: -0.5px; }
h2 { margin: 0 0 4px; font-size: 24px; }
.tag { margin: 0 0 8px; color: var(--muted); line-height: 1.45; }
.fine { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.hint { color: var(--muted); font-weight: 400; font-size: 13px; }
.hint.small { margin: -4px 0 0; font-size: 13px; line-height: 1.4; }

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  font-size: 16px;
  padding: 13px 18px;
  border-radius: 12px;
  cursor: pointer;
  min-height: 48px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn:focus-visible, .seg button:focus-visible, input:focus-visible { outline: 3px solid var(--ball); outline-offset: 2px; }

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .players { grid-template-columns: 1fr; } }
.pcfg { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.pcfg label { font-weight: 700; }
.pname {
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  width: 100%;
}
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
  cursor: pointer; padding: 0;
}
.swatch.sel { border-color: #fff; }
.swatch:disabled { opacity: 0.25; cursor: not-allowed; }

.row { display: flex; flex-direction: column; gap: 8px; }
.lbl { font-weight: 650; display: flex; justify-content: space-between; }
.seg { display: flex; background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 650; padding: 10px 6px; border-radius: 9px; cursor: pointer; min-height: 42px;
}
.seg button.sel { background: rgba(255, 255, 255, 0.14); color: var(--text); }
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }

.toggles { display: flex; flex-direction: column; gap: 4px; }
.tg { display: flex; align-items: center; gap: 12px; padding: 8px 2px; cursor: pointer; }
.tg input { width: 22px; height: 22px; accent-color: var(--accent); }

.actions { display: flex; gap: 10px; margin-top: 6px; }
.actions .btn { flex: 1; }

/* tutorial */
.tut .slides { position: relative; min-height: 340px; }
.slide { display: none; flex-direction: column; gap: 10px; }
.slide.active { display: flex; }
.slide svg { width: 100%; max-height: 220px; background: #1d5a43; border-radius: 12px; }
.slide h3 { margin: 4px 0 0; font-size: 21px; }
.slide p { margin: 0; color: var(--muted); line-height: 1.5; }
.slide ul { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.55; }
.slide b { color: var(--text); }
.dots { display: flex; justify-content: center; gap: 8px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }
.dots span.on { background: var(--accent); }

/* match over */
.big { font-size: 22px; font-weight: 800; margin: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 12px; }
.stat h4 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.stat h4 i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.stat p { margin: 2px 0; color: var(--muted); font-size: 14px; }
.stat p b { color: var(--text); }
