/* Match Day (reading): the coach's call along the top, then Goal Kick's striped pitch (soccer.css)
   seen from behind the ball. The field scrolls as the ball goes up it (data-line 0-3 on the pitch);
   the net slides in once it's close enough to shoot. --s is a player's size, set from the pitch's size. */
.matchday { --us: #3f7fe0; --them: #ef4655; }
.matchday .game-top h2 span { white-space: nowrap; }

/* ---------- the score and the clock ---------- */
.matchday .md-score { display: inline-flex; align-items: center; gap: 6px; }
.matchday .md-score em { font-style: normal; color: var(--ink-soft); }
.matchday .md-score b { display: inline-block; min-width: .6em; text-align: center; }
.matchday .md-score b.pop { animation: md-pop .5s cubic-bezier(.2, 1.6, .4, 1); color: var(--coral-dark); }
.matchday .md-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.matchday .md-time.low { color: var(--coral-dark); }
.matchday .hud span { white-space: nowrap; }

/* ---------- the coach's call ---------- */
.matchday .md-call {
  display: flex; align-items: center; gap: 10px; position: relative; z-index: 4;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  background: #fffaf0; border-bottom: 4px solid var(--ink);
}
.matchday .md-coach { flex: none; position: relative; width: 70px; height: 70px; font-size: 66px; line-height: 1; }
.matchday .md-coach .critter-svg { display: block; }
.matchday .md-coach > span { position: absolute; right: -12px; bottom: -2px; font-size: 30px; transform: rotate(-14deg); }
.matchday .md-bubble {
  flex: 1; min-width: 0; min-height: 70px; display: flex; align-items: center; position: relative;
  background: #fff; border: 4px solid var(--ink); border-radius: 20px; padding: 4px 16px; box-shadow: 0 4px 0 rgba(58, 42, 74, .18);
}
.matchday .md-bubble::before { content: ''; position: absolute; left: -15px; top: 50%; margin-top: -10px; border: 10px solid transparent; border-right: 14px solid var(--ink); border-left: 0; }
.matchday .md-text { margin: 0; font-size: clamp(26px, 2.4vw + 12px, 46px); font-weight: 700; line-height: 1.24; color: var(--ink); overflow-wrap: anywhere; }
.matchday .md-text.in { animation: md-in .22s ease-out; }
.matchday .md-text .w { border-radius: 8px; transition: background .15s, opacity .2s; }
.matchday .md-text .w.say { background: #ffe27a; box-shadow: 0 0 0 3px #ffe27a; }
.matchday .md-text .did { opacity: .38; }
.matchday .md-call.done .md-text .w:not(.key), .matchday .md-call.done .md-text .pn { opacity: .55; }
.matchday .md-text .w.key { background: #ffe27a; box-shadow: 0 0 0 3px #ffe27a; }
.matchday .md-hear {
  flex: none; width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--ink); background: #fff; font-size: 30px; line-height: 1;
  box-shadow: var(--shadow); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.matchday .md-hear:active { transform: translateY(2px) scale(.96); }

/* ---------- the pitch ---------- */
.matchday .md-pitch { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; transition: background-position .6s ease; }
.matchday .md-pitch[data-line="1"] { background-position: 0 144px; }
.matchday .md-pitch[data-line="2"] { background-position: 0 288px; }
.matchday .md-pitch[data-line="3"] { background-position: 0 432px; }
/* the halfway line and the center circle: there at kickoff, then left behind */
.matchday .md-mid { position: absolute; left: 0; right: 0; top: 62%; height: 0; z-index: 1; pointer-events: none; transition: transform .6s ease; }
.matchday .md-half { position: absolute; left: 0; right: 0; top: -2px; border-top: 4px solid rgba(255, 255, 255, .7); }
.matchday .md-circle { position: absolute; left: 50%; top: 0; width: min(40vw, 230px); aspect-ratio: 1; border: 4px solid rgba(255, 255, 255, .7); border-radius: 50%; transform: translate(-50%, -50%); }
.matchday .md-pitch[data-line="1"] .md-mid { transform: translateY(48vh); }
.matchday .md-pitch[data-line="2"] .md-mid, .matchday .md-pitch[data-line="3"] .md-mid { transform: translateY(110vh); }

/* the net: up out of sight until the ball's close (line 2), then a big target to tap */
.matchday .md-goal {
  position: absolute; top: 18px; left: 50%; width: min(520px, 62%); height: clamp(66px, 19%, 140px); z-index: 2;
  padding: 0; border: 0; background: none; font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transform: translate(-50%, calc(-300% - 90px)); transition: transform .6s ease;
}
.matchday .md-pitch[data-line="2"] .md-goal, .matchday .md-pitch[data-line="3"] .md-goal { transform: translate(-50%, 0); }
.matchday .md-goal.ripple .net { animation: soc-net .7s ease-out; }
.matchday .md-box { position: absolute; left: -20%; right: -20%; top: -30px; height: calc(100% + 30px + 70%); border: 4px solid rgba(255, 255, 255, .7); border-top: 0; pointer-events: none; }
.matchday .md-keeper { position: absolute; left: 50%; bottom: -2px; height: 96%; aspect-ratio: 170 / 185; transform: translateX(-50%); z-index: 3; pointer-events: none; transition: left .3s ease-out; }
.matchday .md-keeper.dive.left { left: 28%; }
.matchday .md-keeper.dive.right { left: 72%; }
.matchday .md-keeper .goalie-svg { display: block; width: 100%; height: 100%; }
.matchday .md-keeper.dive .goalie-svg { animation: none; }
.matchday .md-keeper.dive.left .goalie-svg { transform: rotate(-38deg) translateY(-10px); }
.matchday .md-keeper.dive.right .goalie-svg { transform: rotate(38deg) translateY(-10px); }
.matchday .md-keeper.catch .goalie-svg { animation: soc-catch .5s ease-out; }

/* ---------- the players ---------- */
.matchday .md-players { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.matchday .md-pl {
  position: absolute; left: 0; top: 0; width: var(--s); height: var(--s); margin: calc(var(--s) * -1) 0 0 calc(var(--s) / -2);
  padding: 0; border: 0; background: none; font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; pointer-events: auto;
  transition: transform .55s cubic-bezier(.3, .7, .4, 1), opacity .3s, filter .3s; will-change: transform;
}
.matchday .md-pl:focus { outline: none; }
.matchday .md-pl:focus-visible .md-ring { opacity: .9; }
.matchday .md-pl.chase { transition: opacity .3s, filter .3s; }
.matchday .md-pl.leaving { pointer-events: none; opacity: 0; transition: transform .6s ease-in, opacity .6s; }
.matchday .md-pl.me { width: calc(var(--s) * .8); height: calc(var(--s) * 1.3); margin: calc(var(--s) * -1.3) 0 0 calc(var(--s) * -.4); }
.matchday .md-pl.me .avatar-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.matchday .md-pl .md-pl-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
/* fliers hover just a little, so they stay over the spot you tap */
.matchday .md-pl .mv-fly .cr-motion, .matchday .md-pl .mv-flutter .cr-motion { animation: md-hover 1.4s ease-in-out infinite alternate; }
.matchday .md-ring { position: absolute; left: 8%; right: 8%; bottom: -5%; height: 20%; border-radius: 50%; background: var(--ring, #fff); opacity: .7; border: 3px solid #fff; }
.matchday .md-pl.us { --ring: var(--us); }
/* the team he can tap is in front: his own when we have the ball, theirs when we're getting it back */
.matchday .md-pitch[data-phase="attack"] .md-pl.us, .matchday .md-pitch[data-phase="defense"] .md-pl.them { z-index: 2; }
.matchday .md-pl.them { --ring: var(--them); }
@media (hover: hover) { .matchday .md-pl:hover .md-ring { opacity: .85; } }
.matchday .md-pl.dim { filter: saturate(.45) brightness(.95); opacity: .7; }
.matchday .md-pl.got .md-pl-svg { animation: md-hop .4s ease-out; }
.matchday .md-pl.near .md-ring { animation: md-near .45s ease-in-out infinite alternate; }
.matchday .md-pl.nudge .md-pl-svg, .matchday .md-pl.nudge .avatar-svg { animation: md-shake .35s; }
.matchday .md-pl.fumble .md-pl-svg { animation: md-spin .9s ease-in-out; }
.matchday .md-pl.trip .md-pl-svg { transform: rotate(-70deg) translate(-10%, 30%); transition: transform .3s ease-out; }
.matchday .md-pl.fumble::after, .matchday .md-pl.trip::after { content: '💫'; position: absolute; left: 50%; top: -12%; font-size: calc(var(--s) * .34); transform: translateX(-50%); animation: md-dizzy .6s linear infinite; }
.matchday .md-ball { position: absolute; left: 0; top: 0; z-index: 6; width: 1em; height: 1em; margin: -.5em 0 0 -.5em; font-size: calc(var(--s) * .34); line-height: 1; pointer-events: none; will-change: transform; }

/* a name, after a miss: green for the one the coach meant, red for the one tapped */
.matchday .md-tags { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.matchday .md-tag {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap; display: flex; align-items: center; gap: 6px;
  padding: 0 12px; font-size: clamp(24px, 1.6vw + 14px, 38px); font-weight: 700; line-height: 1.3; color: var(--ink);
  background: #fff; border: 4px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 rgba(0, 0, 0, .2); animation: md-tag .3s cubic-bezier(.2, 1.6, .4, 1);
}
.matchday .md-tag b { font-family: var(--font); font-size: .7em; }
.matchday .md-tag.below { transform: translate(-50%, 0); animation: none; }
.matchday .md-tag.ok { background: #dcf8e3; }
.matchday .md-tag.ok b { color: var(--good); }
.matchday .md-tag.bad { background: #ffe1e3; color: #a33; }
.matchday .md-tag.bad b { color: var(--bad); }

.matchday .banner { font-size: clamp(44px, 11vw, 96px); }
.matchday .md-pitch.cheer .md-pl.us .md-pl-svg { animation: md-hop .45s ease-out 2; }
.matchday .md-toast {
  position: absolute; left: 50%; top: 10px; z-index: 9; transform: translate(-50%, -16px); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  background: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: 2px 14px; font-weight: 800; font-size: 22px; white-space: nowrap; color: var(--ink);
}
.matchday .md-toast.show { opacity: 1; transform: translate(-50%, 0); }
.matchday .md-toast .rd-word { font-size: 1.2em; }

/* ---------- before kickoff ---------- */
.matchday .md-start { position: absolute; inset: 0; z-index: 12; display: none; place-items: center; background: rgba(40, 20, 70, .35); padding: 16px; overflow: auto; }
.matchday .md-start.show { display: grid; }
.matchday .md-card { background: #fff; border: 4px solid var(--ink); border-radius: 26px; padding: 14px 22px 16px; box-shadow: var(--shadow); text-align: center; max-width: 560px; }
.matchday .md-vs { display: flex; align-items: center; justify-content: center; gap: 12px; }
.matchday .md-side { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 160px; font-weight: 800; font-size: 18px; color: var(--ink); line-height: 1.15; }
.matchday .md-badge { width: 92px; height: 103px; }
.matchday .md-vsword { font-size: 34px; color: var(--coral-dark); }
.matchday .md-go { font-size: 30px; padding: 8px 36px; margin-top: 12px; touch-action: manipulation; }
.matchday .rk-now { margin: 12px 0 0; font-weight: 700; color: var(--ink-soft); }
.matchday .rk-now .rd-word { font-size: 20px; color: var(--ink); }

/* ---------- smaller screens ---------- */
@media (max-width: 760px) {
  .matchday .md-coach { width: 56px; height: 56px; font-size: 52px; }
  .matchday .md-coach > span { font-size: 24px; right: -8px; }
}
@media (max-width: 560px) {
  .matchday .game-top { gap: 6px; }
  .matchday .game-top h2 { font-size: 20px; }
  .matchday .game-top h2 span { display: none; }
  .matchday .hud { gap: 6px; font-size: 18px; }
  .matchday .hud span { padding: 0 8px; }
  .matchday .md-call { gap: 8px; padding-top: 6px; padding-bottom: 6px; }
  .matchday .md-coach { display: none; }
  .matchday .md-bubble { padding: 4px 10px; min-height: 64px; border-radius: 16px; }
  .matchday .md-bubble::before { display: none; }
  .matchday .md-hear { width: 60px; height: 60px; font-size: 26px; }
  .matchday .md-side { width: 120px; font-size: 15px; }
  .matchday .md-badge { width: 72px; height: 81px; }
  .matchday .md-vsword { font-size: 26px; }
  .matchday .md-goal { width: 70%; }
}
/* phones: the title makes room for the score and the clock */
@media (max-width: 440px) {
  .matchday .game-top { grid-template-columns: auto 1fr; }
  .matchday .game-top h2 { display: none; }
  .matchday .hud { font-size: 17px; }
}
@media (max-height: 700px) {
  .matchday .md-goal { top: 14px; height: clamp(60px, 18%, 110px); }
}

@keyframes md-hover { to { transform: translateY(-7%); } }
@keyframes md-pop { 0% { transform: scale(.4); } 60% { transform: scale(1.5); } 100% { transform: none; } }
@keyframes md-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes md-hop { 0%, 100% { transform: none; } 40% { transform: translateY(-14%); } }
@keyframes md-shake { 25% { transform: translateX(-8%); } 75% { transform: translateX(8%); } }
@keyframes md-spin { 0% { transform: none; } 50% { transform: rotate(200deg) scale(.9); } 100% { transform: rotate(360deg); } }
@keyframes md-dizzy { to { transform: translateX(-50%) rotate(360deg); } }
@keyframes md-near { to { opacity: .95; transform: scale(1.12); } }
@keyframes md-tag { from { transform: translate(-50%, -60%) scale(.4); opacity: 0; } to { transform: translate(-50%, -100%); opacity: 1; } }
