:root {
  --ice: #eaf6ff;
  --ice-line: #ffffff;
  --rink-blue: #1c6dd0;
  --rink-red: #d0311c;
  --rink-border: #0b3d91;
  --dark: #0b1d33;
  --accent: #ffb703;
  --accent-dark: #e08e00;
  --danger: #e63946;
  --card-bg: #ffffff;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--dark);
  touch-action: manipulation;
  user-select: none;
}

/* ---------- Screens ---------- */

.screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 12px) 12px env(safe-area-inset-bottom, 12px);
}

.screen.active {
  display: flex;
}

/* ---------- Cards (name/resume/summary) ---------- */

.card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.title {
  font-size: 2rem;
  margin: 0 0 8px;
  color: var(--rink-border);
}

.subtitle {
  font-size: 1.1rem;
  margin: 0 0 20px;
  color: #444;
}

.name-input {
  width: 100%;
  font-size: 1.3rem;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--rink-blue);
  margin-bottom: 16px;
  text-align: center;
}

.button-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.link-btn {
  background: none;
  border: none;
  color: var(--rink-blue);
  font-size: 1rem;
  margin-top: 14px;
  padding: 10px;
  cursor: pointer;
  text-decoration: underline;
}

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

.btn {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 16px 22px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  min-height: 56px;
  min-width: 56px;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: 0.55; }

.btn-primary { background: var(--accent); color: var(--dark); }
.btn-primary:active { background: var(--accent-dark); }

.btn-secondary { background: #ddd; color: var(--dark); }

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

.hud {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
}

/* ---------- Rink area ---------- */

.rink-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: var(--ice);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.rink-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The shootout background is a real photo (public/assets/arena.jpg, 667x1000 = 2:3) — the
   container matches that exact ratio so the image is never stretched or cropped, per the net's
   true position in the photo (see shootout.js ZONE_POS/LEAN_POS, measured from the source image:
   net posts at x=28.6%/70%, crossbar at y=30%, net base at y=46.5%). */
#screen-shootout .rink-wrap {
  aspect-ratio: 2 / 3;
  background-image: url("../assets/arena.jpg");
  background-size: 100% 100%;
}

/* No fixed aspect-ratio here on purpose: the source art isn't uniform (a standing pose is
   taller than wide, a diving pose is wider than tall), so each sprite's height comes from its
   own image's natural proportions at the given width — forcing one box ratio for all of them
   just caused object-fit:contain to letterbox most poses, making them render smaller than
   intended and throwing off bottom-anchored positioning. */
.sprite {
  position: absolute;
  width: 22%;
  transition: left 0.15s ease-out, top 0.15s ease-out;
  pointer-events: none;
}

.sprite img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.shooter-sprite {
  width: 46%; /* bigger — foreground/closer to camera than the goalie */
  left: 27%;
  bottom: 4%;
  z-index: 3;
}

.goalie-sprite {
  width: 28%; /* JS sets this per-shot too (shootout.js GOALIE_WIDTH) — kept in sync here as the
  default before JS first runs */
  z-index: 2;
  opacity: 0;
  transition: left 0.2s ease-out, top 0.2s ease-out, opacity 0.15s;
}

.goalie-sprite.no-transition {
  transition: none;
}

.defender-sprite {
  position: absolute;
  width: 20%;
  pointer-events: none;
}

.defender-sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.popup {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--danger);
  text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
  pointer-events: none;
  animation: pop-fade 0.7s ease-out forwards;
}

@keyframes pop-fade {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  30% { opacity: 1; transform: translate(-50%, -60%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(1); }
}

.outcome-banner {
  position: absolute;
  /* Clear of the net entirely (goalie occupies roughly 29%-50% across all zones/poses) — sits
     in the open ice below instead, rather than relying on z-index to sit over the goalie. */
  top: 57%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 900;
  padding: 10px 22px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  color: var(--rink-border);
  z-index: 5; /* above both sprites (goalie=2, shooter=3) so it's never covered/unreadable */
  white-space: nowrap;
}

.outcome-banner.goal { color: #2a9d3f; }
.outcome-banner.save { color: var(--danger); }

/* ---------- Dodge lane controls ---------- */

.lane-controls {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}

.btn-lane {
  flex: 1;
  font-size: 2.2rem;
  padding: 20px 0;
  background: var(--rink-blue);
  color: #fff;
  border-radius: 16px;
}

.btn-lane:active { background: var(--rink-border); }

/* ---------- Shootout aim grid ---------- */

.aim-grid {
  width: 100%;
  max-width: 320px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.btn-aim {
  font-size: 1.6rem;
  padding: 18px 0;
  background: var(--rink-blue);
  color: #fff;
  border-radius: 14px;
}

.btn-aim:active { background: var(--rink-border); }

.btn-aim[data-zone="topLeft"] { grid-column: 1; grid-row: 1; }
.btn-aim[data-zone="topRight"] { grid-column: 3; grid-row: 1; }
.btn-aim[data-zone="center"] { grid-column: 2; grid-row: 1 / span 2; background: var(--accent); color: var(--dark); }
.btn-aim[data-zone="bottomLeft"] { grid-column: 1; grid-row: 2; }
.btn-aim[data-zone="bottomRight"] { grid-column: 3; grid-row: 2; }

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

.summary-score {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 4px 0;
}

.summary-best {
  font-size: 1.05rem;
  color: #2a9d3f;
  font-weight: 700;
  margin: 0 0 14px;
}

.leaderboard {
  background: var(--ice);
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0 20px;
  text-align: left;
}

.leaderboard-title {
  font-weight: 800;
  margin-bottom: 8px;
  text-align: center;
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  font-size: 0.95rem;
}

.leaderboard-loading, .leaderboard-empty {
  display: block;
  text-align: center;
  color: #777;
  font-style: italic;
}

/* ---------- Small screens ---------- */

@media (max-height: 600px) {
  .title { font-size: 1.5rem; }
  .btn-lane, .btn-aim { padding: 12px 0; }
}
