:root {
  --bg: #0b2a1a; --panel: #123a25; --text: #f1f5ee; --muted: #b3c7b8;
  --accent: #ffd23f; --line: #2a5a3d; --button: #c2410c; --goal: #4ade80; --miss: #f87171;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Every game: a way back to the others, and who's signed in. */
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.bar .home { color: var(--muted); text-decoration: none; }
.bar .home:hover { color: var(--text); }
.bar .account { color: var(--muted); text-align: right; }
.bar .account strong { color: var(--text); }

button {
  font: inherit; font-weight: 700; border: 0; border-radius: 10px; cursor: pointer;
  padding: 12px 20px; background: var(--button); color: #fff;
}
button.secondary { background: transparent; color: var(--text); border: 2px solid var(--muted); }
button:hover { filter: brightness(1.1); }
input {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--line);
  background: #0a2216; color: var(--text);
}

.lobby { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 32px 16px; text-align: center; }
h1 { font-size: clamp(36px, 8vw, 64px); margin: 0 0 8px; letter-spacing: -0.02em; }
.tagline { color: var(--muted); font-size: 18px; margin: 0 0 32px; }
.tagline strong { color: var(--accent); }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; text-align: left; }
.choice { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.choice h2 { margin: 0 0 6px; font-size: 22px; }
.choice p { color: var(--muted); margin: 0 0 16px; }
.join { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.join label { color: var(--muted); }
.join input { width: 7em; text-transform: uppercase; letter-spacing: 0.15em; }
.error { color: var(--miss); min-height: 1.2em; margin: 12px 0 0 !important; }
.how { text-align: left; margin-top: 32px; color: var(--muted); }
.how h2 { color: var(--text); font-size: 20px; }
.how li { margin-bottom: 8px; }
kbd {
  display: inline-block; min-width: 1.8em; padding: 1px 6px; text-align: center;
  border: 1px solid var(--muted); border-bottom-width: 3px; border-radius: 6px;
  font: 600 14px system-ui, sans-serif; color: var(--text);
}
.code { font-size: 56px; font-weight: 800; letter-spacing: 0.2em; color: var(--accent); margin: 16px 0; }
.share { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.share input { width: min(100%, 420px); }

.game { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 12px 16px 24px; text-align: center; }
.scoreboard { display: grid; gap: 6px; margin-bottom: 10px; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 2.2em; align-items: center; gap: 10px;
  background: var(--panel); border: 2px solid transparent; border-radius: 10px; padding: 6px 12px; text-align: left;
}
.row.up { border-color: var(--accent); }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .name small { color: var(--muted); font-weight: 400; }
.row .dots { display: flex; gap: 5px; }
.row .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.row .dot.goal { background: var(--goal); border-color: var(--goal); }
.row .dot.miss { background: var(--miss); border-color: var(--miss); }
.row .score { font-size: 24px; font-weight: 800; text-align: right; }
.pitch { position: relative; }
canvas { display: block; width: 100%; height: auto; border-radius: 14px; touch-action: none; }
.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-size: clamp(28px, 7vw, 60px); font-weight: 900; text-transform: uppercase; white-space: nowrap;
  color: #fff; text-shadow: 0 3px 0 #000, 0 0 24px rgba(0, 0, 0, 0.6);
  animation: pop 0.35s ease-out;
}
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .banner { animation: none; } }
.message { font-size: 18px; min-height: 2.6em; margin: 12px 0; }
.pad { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.pad button { width: 72px; height: 64px; font-size: 26px; background: var(--panel); border: 2px solid var(--line); user-select: none; -webkit-user-select: none; touch-action: none; }
.pad button.shoot { background: var(--button); border-color: var(--button); }
.pad button.pressed { background: var(--accent); color: #000; }
.pad.shooter .keeper-only, .pad.keeper .shooter-only, .pad.idle { display: none; }
.after { display: flex; gap: 16px; justify-content: center; align-items: center; margin-top: 16px; }
