/* Paper Soccer: game CSS. Tokens from /design/garden.css; the app bar and card patterns follow our Pizzanality sprout.
   The page is a column: the app bar, then the match: the far player's bar, the pitch, the near player's bar. On a
   sideways phone the pitch lies across the screen (goals left and right) with the two bars at its ends. Nothing on
   the page scrolls. */
html, body { height: 100%; }
body { display: flex; flex-direction: column; height: 100svh; overflow: hidden; overscroll-behavior: none; background: var(--gg-cream); }
.ps-appbar { position: relative; z-index: 5; flex: none; }
.ps-appbar .gg-wordmark { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
.ps-namechip { min-height: 30px; }
.ps-ggchip:empty { display: none; }
@media (max-width: 560px) { .ps-namechip, .ps-ggchip { display: none; } }
@media (max-width: 420px) { .ps-appbar .gg-wordmark span { display: none; } }   /* four round buttons since the Leaderboard trophy (11-12) */
@media (orientation: landscape) and (max-height: 560px) {
  .ps-appbar .gg-appbar__in { min-height: 48px; }
  .ps-appbar .gg-wordmark { font-size: 19px; }
  .ps-appbar .gg-wordmark svg { width: 30px; height: 30px; }
}
:root {
  --ps-sab: env(safe-area-inset-bottom, 0px); --ps-sal: env(safe-area-inset-left, 0px); --ps-sar: env(safe-area-inset-right, 0px);
  --ps-ink-0: #1F7A3D; --ps-ink-1: #C81D63; --ps-soft-0: #CFEFC0; --ps-soft-1: #FFD3E4; --ps-glow-0: #9CFF1E; --ps-glow-1: #FF7AB0;
}
.ps-main *, .ps-appbar, .ps-appbar * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }

/* ---------- the match ---------- */
.ps-main {
  position: relative; flex: 1 1 auto; min-height: 0; width: 100%; max-width: 600px; margin: 0 auto;
  display: grid; grid-template-rows: auto auto auto; grid-template-columns: var(--ps-fw, 100%); grid-template-areas: "far" "field" "near"; gap: 6px;
  align-content: center; justify-content: center;
  padding: 8px max(10px, var(--ps-sal)) calc(8px + var(--ps-sab)) max(10px, var(--ps-sar));
}
.ps-main.is-idle { visibility: hidden; }
.ps-bar--far { grid-area: far; }
.ps-bar--near { grid-area: near; }
.ps-field { grid-area: field; position: relative; min-height: 0; min-width: 0; display: grid; justify-self: center; }
.ps-pitch { width: 100%; height: 100%; display: block; touch-action: none; overflow: visible; }
.ps-pitch.is-live { cursor: pointer; }

body.ps-rot .ps-main {
  max-width: none; grid-template-rows: minmax(0, 1fr); grid-template-columns: 136px auto 136px; align-content: stretch;
  grid-template-areas: "near field far"; padding-top: 6px; padding-bottom: calc(6px + var(--ps-sab));
}

/* the two bars: whose turn it is, in that side's colour */
.ps-bar {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 12px;
  background: var(--gg-paper); border: 2.5px solid var(--gg-ink); border-radius: var(--gg-r-md); box-shadow: 0 3px 0 var(--gg-ink);
  transition: background-color var(--gg-dur-md), transform var(--gg-dur-md) var(--gg-ease-spring);
}
.ps-bar.is-active[data-side="0"] { background: var(--ps-soft-0); }
.ps-bar.is-active[data-side="1"] { background: var(--ps-soft-1); }
.ps-bar.is-active { transform: translateY(-1px); }
.ps-who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.ps-who b { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-swatch { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--gg-ink); }
.ps-swatch--0 { background: var(--ps-ink-0); }
.ps-swatch--1 { background: var(--ps-ink-1); }
.ps-score { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-lg); padding: 0 8px; border-radius: 999px; background: var(--gg-paper); border: 2px solid var(--gg-ink); }
.ps-status { margin-left: auto; font-weight: 800; font-size: var(--gg-text-sm); color: var(--gg-ink); text-align: right; white-space: nowrap; }
.ps-bar:not(.is-active) .ps-status { color: var(--gg-ink-3); font-weight: 700; }
.ps-showres { margin-left: 8px; min-height: 44px; }
body.ps-rot .ps-bar { flex-direction: column; justify-content: center; align-items: stretch; text-align: center; gap: 8px; padding: 10px 8px; }
body.ps-rot .ps-who { flex-direction: column; gap: 6px; }
body.ps-rot .ps-who b { white-space: normal; font-size: var(--gg-text-sm); line-height: 1.15; }
body.ps-rot .ps-status { margin: 0; text-align: center; white-space: normal; line-height: 1.2; }
body.ps-rot .ps-score { align-self: center; }
body.ps-rot .ps-showres { margin: 0; }

/* ---------- the pitch (SVG, in pitch units) ---------- */
.ps-grass { fill: #E6F4D4; }
.ps-band { fill: #DAEEC6; }
.ps-mark { stroke: #fff; stroke-opacity: .7; stroke-width: .07; fill: none; }
.ps-border { fill: none; stroke: var(--gg-ink); stroke-width: .1; stroke-linejoin: round; }
.ps-dots circle { fill: #5E584C; fill-opacity: .6; }
.ps-post { fill: var(--gg-ink); }
.ps-line { fill: none; stroke-width: .12; stroke-linecap: round; }
.ps-line--0 { stroke: var(--ps-ink-0); }
.ps-line--1 { stroke: var(--ps-ink-1); }
.ps-line.is-new { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ps-draw calc(190ms * var(--gg-time, 1)) var(--gg-ease-out) forwards; }
@keyframes ps-draw { to { stroke-dashoffset: 0; } }
.ps-halo { fill: none; stroke-linecap: round; stroke-width: .44; opacity: .32; }
.ps-halo--0 { stroke: var(--ps-glow-0); }
.ps-halo--1 { stroke: var(--ps-glow-1); }
#g-halo.is-fresh .ps-halo { animation: ps-glow 2.4s var(--gg-ease-out) forwards; }
@keyframes ps-glow { 0% { opacity: .95; stroke-width: .62; } 30% { opacity: .85; stroke-width: .56; } 100% { opacity: .32; stroke-width: .44; } }
.ps-target__ring { stroke-width: .045; transition: transform var(--gg-dur-sm) var(--gg-ease-spring); }
.ps-target--0 .ps-target__ring { fill: var(--ps-soft-0); stroke: var(--ps-ink-0); }
.ps-target--1 .ps-target__ring { fill: var(--ps-soft-1); stroke: var(--ps-ink-1); }
.ps-target__dot { fill: var(--gg-ink); }
.ps-target { animation: ps-pop calc(220ms * var(--gg-time, 1)) var(--gg-ease-spring); }
.ps-target.is-cand .ps-target__ring { transform: scale(1.5); stroke-width: .06; }
@keyframes ps-pop { from { transform-box: fill-box; opacity: 0; } }
.ps-ball { pointer-events: none; }
.ps-ball.is-moving { transition: transform calc(200ms * var(--gg-time, 1)) var(--gg-ease-out); }
.ps-ballring { fill: none; stroke-width: .07; stroke-dasharray: .16 .12; animation: ps-spin 6s linear infinite; transform-origin: 0 0; }
.ps-ball[data-turn="0"] .ps-ballring { stroke: var(--ps-ink-0); }
.ps-ball[data-turn="1"] .ps-ballring { stroke: var(--ps-ink-1); }
@keyframes ps-spin { to { transform: rotate(360deg); } }
.ps-sunturn { transition: transform 1.2s var(--gg-ease-out); }

/* a short banner over the pitch: whose turn it is in pass and play */
.ps-flash {
  position: absolute; left: 50%; top: 50%; z-index: 3; margin: 0; transform: translate(-50%, -50%); pointer-events: none;
  font-family: var(--gg-font-display); font-weight: 800; font-size: clamp(22px, 6vw, 30px); white-space: nowrap;
  padding: 10px 20px; border: 3px solid var(--gg-ink); border-radius: 999px; box-shadow: 3px 3px 0 var(--gg-ink); background: var(--gg-paper);
}
.ps-flash[data-side="0"] { background: var(--ps-soft-0); }
.ps-flash[data-side="1"] { background: var(--ps-soft-1); }
.ps-flash.is-on { animation: ps-flash calc(900ms * var(--gg-time, 1)) var(--gg-ease-out) forwards; }
@keyframes ps-flash { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); } 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.96); } }

/* ---------- pop-ups ---------- */
.ps-card { max-width: 520px; text-align: center; max-height: calc(100svh - 32px); overflow: auto; }
.ps-title { margin: 2px 0 6px; font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-3xl); letter-spacing: -.02em; line-height: 1; }
.ps-titleart { display: flex; justify-content: center; margin: 4px 0 8px; }
.ps-titleart svg { width: 150px; height: auto; display: block; }
.ps-lede { margin: 0 auto 14px; font-size: var(--gg-text-md); line-height: 1.45; color: var(--gg-ink-2); max-width: 40ch; }
.ps-modes { display: grid; gap: 10px; margin-bottom: 10px; }
.ps-modes [hidden] { display: none; }
.ps-mode { flex-direction: column; gap: 1px; line-height: 1.15; min-height: 56px; }
.ps-mode small { font-family: var(--gg-font-body); font-weight: 700; font-size: 13px; opacity: .8; }
.ps-btns { display: grid; gap: 10px; }
.ps-titlecard .ps-btns { grid-template-columns: 1fr 1fr; }
.ps-h2 { margin: 2px 0 10px; font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-2xl); line-height: 1.05; }
.ps-howlist { text-align: left; margin: 0 0 16px; padding-left: 20px; display: grid; gap: 8px; font-size: var(--gg-text-sm); line-height: 1.45; }
.ps-rline { margin: 0 auto 12px; font-size: var(--gg-text-md); line-height: 1.4; color: var(--gg-ink-2); max-width: 36ch; }
.ps-rnote { margin: 0 auto 14px; padding: 10px 12px; border: 2.5px solid var(--gg-ink); border-radius: var(--gg-r-md); background: var(--gg-lime); box-shadow: 3px 3px 0 var(--gg-ink); font-weight: 800; max-width: 34ch; }
.ps-rnote[hidden] { display: none; }
.ps-gg { margin: 0 auto 12px; max-width: 40ch; }
.ps-gg[hidden] { display: none; }
@media (orientation: landscape) and (max-height: 560px) {
  .ps-titlecard { max-width: 700px; display: grid; grid-template-columns: 170px 1fr; column-gap: 18px; text-align: left; align-items: center; padding: 14px 18px; }
  .ps-titlecard > * { grid-column: 2; }
  .ps-titlecard .ps-titleart { grid-column: 1; grid-row: 1 / span 5; margin: 0; }
  .ps-titlecard .ps-titleart svg { width: 160px; }
  .ps-titlecard .ps-title { font-size: 34px; }
  .ps-titlecard .ps-lede { margin: 0 0 10px; font-size: var(--gg-text-sm); }
  .ps-modes { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .ps-modes #b-resume { grid-column: 1 / -1; }
  .ps-mode { min-height: 52px; padding-left: 8px; padding-right: 8px; font-size: 15px; }
  .ps-mode small:not(#b-bot-level) { display: none; }
  .ps-rbtns { grid-template-columns: 1fr 1fr auto; }
  .ps-rbtns .gg-btn--lg { grid-column: 1 / -1; }
  .ps-card { padding-top: 14px; padding-bottom: 14px; }
  .ps-rline { margin-bottom: 8px; }
  /* the result in landscape: the story on the left, the leaderboard line and the buttons on the right, so the whole
     card fits a 390 px tall screen with the leaderboard moment in it */
  .ps-resultcard { max-width: 780px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-items: center; }
  .ps-resultcard > * { grid-column: 1; }
  .ps-resultcard > .ps-gg, .ps-resultcard > .ps-rbtns { grid-column: 2; }
  .ps-resultcard > .ps-gg { grid-row: 1 / span 3; align-self: end; margin-bottom: 8px; }
  .ps-resultcard > .ps-rbtns { grid-row: 4 / span 2; align-self: start; margin-top: 0; }
  .ps-resultcard .ps-rtitle { font-size: 30px; }
  .ps-rnote { padding: 6px 10px; margin-bottom: 10px; }
  #how .ps-card { max-width: 780px; }
  .ps-howlist { grid-template-columns: 1fr 1fr; column-gap: 22px; gap: 6px 22px; margin-bottom: 10px; font-size: 14px; line-height: 1.35; }
  #how .ps-h2 { font-size: 24px; margin-bottom: 8px; }
  #how .ps-btns { grid-template-columns: 1fr 1fr; max-width: 420px; margin: 0 auto; }
}
@media (max-height: 720px) and (orientation: portrait) {
  .ps-main { gap: 4px; padding-top: 6px; padding-bottom: calc(6px + var(--ps-sab)); }
  .ps-bar { min-height: 40px; padding: 3px 10px; }
  .ps-who b { font-size: var(--gg-text-sm); }
  .ps-showres { min-height: 44px; margin-top: -3px; margin-bottom: -3px; }
}
@media (max-height: 600px) and (orientation: portrait) {
  .ps-howlist { gap: 4px; font-size: 14px; line-height: 1.35; margin-bottom: 10px; }
  #how .ps-h2 { font-size: 24px; margin-bottom: 6px; }
  #how .ps-btns, .ps-rbtns { grid-template-columns: 1fr 1fr; }
  .ps-rbtns .gg-btn--lg { grid-column: 1 / -1; }
  .ps-card { padding-top: 14px; padding-bottom: 14px; }
  .ps-titleart svg { width: 110px; }
  .ps-title { font-size: 34px; }
  .ps-lede { font-size: var(--gg-text-sm); margin-bottom: 10px; }
  .ps-mode small:not(#b-bot-level) { display: none; }
  .ps-mode { min-height: 48px; }
  .ps-titlecard .ps-btns .gg-btn { white-space: nowrap; padding-left: 8px; padding-right: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .ps-line.is-new, .ps-target, .ps-ballring, #g-halo.is-fresh .ps-halo, .ps-flash.is-on { animation: none; }
  .ps-line.is-new { stroke-dashoffset: 0; }
  .ps-ball.is-moving, .ps-bar, .ps-sunturn { transition: none; }
}
