:root {
  --pitch: #2f9e44;
  --pitch-line: #ffffff;
  --dark: #0b1d0f;
  --accent: #ffd400;
  --accent-dark: #e0b800;
  --danger: #d23c3c;
  --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: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--dark);
  touch-action: manipulation;
  user-select: none;
}

/* ---------- Screens ---------- */
/* Each phase is a fixed fullscreen flex container that centers its content — no JS-computed
   sizing anywhere; the rink-wrap card below is purely CSS (max-width + aspect-ratio), mirroring
   hockey's proven pattern (which doesn't fight browser viewport/chrome quirks). */

.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);
  gap: 10px;
}

.screen.active {
  display: flex;
}

/* ---------- Cards (intro/result/trophy) ---------- */

.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: 1.8rem;
  margin: 0 0 8px;
  color: var(--dark);
}

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

.standings-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 18px;
  font-size: 0.95rem;
}

.standings-table th,
.standings-table td {
  padding: 7px 6px;
  text-align: center;
  border-bottom: 1px solid #eee;
}

.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  text-align: left;
}

.standings-table thead th {
  font-weight: 700;
  color: #888;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid #ddd;
}

.standings-table tbody tr:last-child td {
  border-bottom: none;
}

.standings-table tbody tr.you {
  background: #fff6c9;
  font-weight: 700;
  color: var(--dark);
}

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

/* ---------- 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); }

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

.hud {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 14px;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* ---------- Rink (pitch/goal) area ---------- */

.rink-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: var(--pitch);
  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 (assets/arena.jpg) — the container matches its exact
   ratio so the image is never stretched or cropped, per the goal's true position in the photo
   (see shootout.js ZONE_POS, measured from the source image). */
#shootout-card {
  aspect-ratio: 700 / 1052;
  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. */
.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));
}

.player-sprite {
  width: 20%;
  z-index: 3;
}

.shooter-sprite {
  width: 30%;
  left: 35%;
  bottom: 4%;
  z-index: 3;
}

.goalie-sprite {
  width: 15%; /* JS sets this per-zone too (shootout.js ZONE_WIDTH) — kept in sync 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;
}

.puck {
  position: absolute;
  width: 5%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #333333;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 4; /* above the goalie (2) and shooter (3), below the outcome banner (5) */
  opacity: 0;
  pointer-events: none;
  transition: left 0.3s ease-in, top 0.3s ease-in, opacity 0.1s;
}

.puck.no-transition {
  transition: none;
}

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

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


.outcome-banner {
  position: absolute;
  top: 62%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.6rem;
  font-weight: 900;
  padding: 10px 22px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  color: var(--dark);
  z-index: 5; /* above both sprites (goalie=2, shooter=3) so it's never covered/unreadable */
  white-space: nowrap;
}

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

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

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

.btn-lane {
  flex: 1;
  font-size: 2.2rem;
  padding: 20px 0;
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 16px;
}

.btn-lane:active { background: rgba(255, 255, 255, 0.5); }

/* ---------- 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;
}

.btn-aim {
  font-size: 1.6rem;
  padding: 18px 0;
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 14px;
}

.btn-aim:active { background: rgba(255, 255, 255, 0.5); }
.btn-aim:disabled { opacity: 0.5; }

.btn-aim[data-zone="topLeft"] { grid-column: 1; grid-row: 1; }
.btn-aim[data-zone="topRight"] { grid-column: 3; grid-row: 1; }
.btn-aim-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; }

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

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