/* Paper Soccer – only what's specific to this game.
   Header, difficulty, score and status come from /css/style.css. */

.ps-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: -10px;
  text-align: center;
}

/* The holder sits in a centred column, so it needs its own width */
.ps-holder {
  /* As big as fits: never taller than the window (the pitch is about 2:3) */
  width: min(100%, 400px, max(260px, calc((100svh - 330px) * 0.66)));
}

.ps-pitch {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  touch-action: manipulation;
}

/* ---------- The pitch ---------- */

.ps-grass {
  fill: var(--inset);
}

.ps-goal {
  fill: var(--accent-soft);
}

.ps-markings line,
.ps-markings circle {
  stroke: var(--border-strong);
  stroke-width: 1.5;
  stroke-dasharray: 4 5;
}

.ps-border line {
  stroke: var(--text-muted);
  stroke-width: 3;
  stroke-linecap: round;
}

.ps-dots circle {
  fill: var(--text-faint);
}

.ps-labels text {
  fill: var(--text-muted);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Passes ---------- */

.ps-line {
  stroke-width: 3;
  stroke-linecap: round;
}

.ps-line.is-mine {
  stroke: var(--accent);
}

.ps-line.is-theirs {
  stroke: var(--text);
}

/* The other player's last turn stands out until you move */
.ps-line.is-fresh {
  stroke-width: 4.5;
  filter: drop-shadow(0 0 3px var(--text-muted));
}

.ps-line.is-mine.is-fresh {
  filter: drop-shadow(0 0 3px var(--accent));
}

/* A pass that's just been made draws itself along */
.ps-line.is-new {
  stroke-dasharray: 1;
  animation: ps-draw 170ms ease-out both;
}

@keyframes ps-draw {
  from { stroke-dashoffset: 1; }
  to   { stroke-dashoffset: 0; }
}

/* ---------- Ball ---------- */

.ps-ball {
  fill: var(--text);
  stroke: var(--bg);
  stroke-width: 2.5;
  transition: cx 160ms ease, cy 160ms ease;
}

/* ---------- Where you can go ---------- */

.ps-target {
  cursor: pointer;
  outline: none;
}

.ps-hit {
  fill: transparent;
}

.ps-ring {
  fill: var(--surface-2);
  stroke: var(--accent);
  stroke-width: 2.5;
}

/* Bouncing dots (you'll go again) are filled in */
.ps-target.is-bounce .ps-ring {
  fill: var(--accent);
}

.ps-guide {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 3 4;
  opacity: 0;
}

.ps-target:hover .ps-guide,
.ps-target:focus-visible .ps-guide {
  opacity: 0.8;
}

.ps-target:hover .ps-ring,
.ps-target:focus-visible .ps-ring {
  r: 9;
}

.ps-target:focus-visible .ps-hit {
  stroke: var(--accent);
  stroke-width: 2;
}

/* ---------- Legend + rules ---------- */

.ps-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.ps-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ps-legend i {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--accent);
}

.ps-legend i.is-bounce {
  background: var(--accent);
}

.ps-dot {
  display: inline-block;
  width: 14px;
  height: 3px;
  margin-left: 2px;
  border-radius: 2px;
  vertical-align: 3px;
}

.ps-dot.is-mine {
  background: var(--accent);
}

.ps-dot.is-theirs {
  background: var(--text);
}

.ps-rules {
  max-width: 420px;
  color: var(--text-muted);
}

.ps-rules summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.ps-rules p {
  margin-top: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .ps-ball {
    transition: none;
  }
  .ps-line.is-new {
    animation: none;
  }
}

/* Phone held sideways: fit the screen height (see css/style.css) */
@media (orientation: landscape) and (max-height: 540px) {
  .ps-holder { width: min(400px, var(--play-w), calc(var(--play-h) * 0.7)); }
}
