/* 頁面基本設定 */
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 15%, #183039, #0b1920 70%);
  color: #f3f8f6;
  font-family: Arial, "Microsoft JhengHei", sans-serif;
}
.game { width: min(100% - 32px, 960px); margin: 0 auto; padding: 36px 0 20px; }
.game-header { text-align: center; margin-bottom: 26px; }
/* In-game home title only; survives menu text updates without changing cover. */
body[data-mode="menu"] .game-header h1::after {
  content: "⚽";
  display: inline-block;
  margin-inline-start: 0.25em;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-size: 0.72em;
  line-height: 1;
  vertical-align: 0.04em;
  color: #f5f5eb;
  -webkit-text-fill-color: initial;
  text-shadow: none;
}
.eyebrow { color: #97e6a6; font-size: 12px; letter-spacing: 4px; }
h1 { font-size: clamp(28px, 5vw, 46px); margin: 10px 0; letter-spacing: -1px; }
.description, .status { color: #a7bab9; font-size: 14px; }
.status { text-align: center; margin-top: 18px; }
.scoreboard {
  margin-bottom: 16px;
  padding: 16px clamp(12px, 3vw, 28px);
  border: 1px solid #bda15a66;
  border-radius: 16px;
  background: linear-gradient(135deg, #152b45e8, #09192de0);
  color: #fff;
  box-shadow: 0 10px 28px #0003, inset 0 1px 0 #ffe5a51a;
}
.scoreboard-info { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; padding-bottom: 12px; border-bottom: 1px solid #dbbd7130; }
.shot-progress { color: #d9e2ed; letter-spacing: 1px; }
.turn-label { color: #f4d88b; font-size: 12px; }
.scoreboard-match { display: grid; grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr); align-items: center; gap: 8px; padding-top: 16px; }
.score-row { min-width: 0; text-align: center; }
.score-row-heading { display: grid; justify-items: center; gap: 4px; }
.team-name { color: #dce5f1; font-size: 12px; font-weight: bold; letter-spacing: 2px; transition: color 250ms ease; }
.score-row-heading strong { font-size: clamp(32px, 6vw, 48px); line-height: 1.15; font-variant-numeric: tabular-nums; color: #fff; }
.scoreboard-vs { color: #e8c46c; font-size: 14px; letter-spacing: 2px; text-align: center; }
.scoreboard[data-turn="player"] .player-score-row .team-name,
.scoreboard[data-turn="ai"] .ai-score-row .team-name { color: #ffdc86; }
.goal-count { color: #97e6a6; }
.shot-history {
  display: grid;
  grid-template-columns: repeat(5, clamp(18px, 4.7vw, 32px));
  justify-content: center;
  gap: clamp(4px, 1vw, 8px);
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.shot-history li {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid #8290a155;
  border-radius: 50%;
  background: #63708433;
  text-align: center;
  font-size: clamp(10px, 2.5vw, 14px);
  font-weight: bold;
  color: #c6ced8;
  transition: background-color 280ms ease, color 280ms ease, border-color 280ms ease, box-shadow 280ms ease;
}
.shot-history [data-result="GOAL"] { color: #b1ffd1; background: #23754c; border-color: #69d99c; box-shadow: 0 0 9px #53d88822; }
.shot-history [data-result="SAVED"],
.shot-history [data-result="MISS"] { color: #ffcece; background: #7b3546; border-color: #df7b8d; }
.match-summary {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: #071820c9;
}
.match-summary[hidden] { display: none; }
.summary-card { width: min(90%, 340px); padding: 24px; border: 1px solid #58846b; border-radius: 14px; background: #13282c; text-align: center; }
.summary-card h2 { margin: 0 0 20px; }
.summary-card strong { color: #97e6a6; }
.restart-button { margin-top: 12px; padding: 12px 24px; border: 0; border-radius: 8px; background: #97e6a6; color: #10271b; font: inherit; font-weight: bold; cursor: pointer; }
.restart-button:hover { background: #b1f1bd; }
.restart-button:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.match-summary { padding: 14px; overflow: auto; background: #071820a8; }
.summary-card {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  background: #10252aeb;
  box-shadow: 0 16px 50px #0006;
  animation: summary-fade-in 450ms ease-out both;
}
.summary-caption { margin: 0 0 14px; color: #b8c8c5; font-size: 11px; letter-spacing: 2px; }
.final-outcome { font-size: clamp(26px, 6vw, 38px); }
.match-summary[data-outcome="win"] .final-outcome { color: #ffdb73; text-shadow: 0 0 20px #ffd45a55; }
.match-summary[data-outcome="win"] .summary-card { border-color: #d2ae57; }
.match-summary[data-outcome="lose"] .final-outcome { color: #edb2aa; }
.match-summary[data-outcome="draw"] .final-outcome { color: #cde2e8; }
.final-score { font-size: 24px; }
.summary-records { display: grid; gap: 10px; margin-top: 22px; }
.summary-records > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.summary-records ol { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 0; padding: 0; list-style: none; }
.summary-records li { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid #688077; border-radius: 50%; color: #c5b7b4; }
.summary-records [data-result="GOAL"] { color: #9be5ae; background: #284d36; border-color: #76b98b; }
.summary-legend { font-size: 12px; color: #a7bab9; }
.summary-fireworks { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.summary-fireworks span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffe497;
  box-shadow: 0 0 7px #ffce59;
  animation: summary-spark 1000ms var(--delay) ease-out both;
}
@keyframes summary-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes summary-spark {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); }
}
@media (prefers-reduced-motion: reduce) {
  .summary-card { animation: none; }
  .summary-fireworks { display: none; }
}
.shot-result {
  position: absolute;
  z-index: 4;
  top: 9%;
  left: 50%;
  width: max-content;
  max-width: 90%;
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  font-size: clamp(32px, 6vw, 60px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 3px;
  text-shadow: 0 3px 8px #000b;
  pointer-events: none;
}
.shot-result:empty { visibility: hidden; }
.shot-result:not(:empty) { animation: result-appear 240ms ease-out both; }
@keyframes result-appear {
  from { opacity: 0; transform: translateX(-50%) scale(0.75); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}
.shot-result[data-result="GOAL"] { color: #80ee9e; }
.shot-result[data-result="SAVED"] { color: #ffe078; }
.shot-result[data-result="MISS"] { color: #ff8585; }

/* 使用百分比定位，讓整個足球場隨畫面一起縮放。 */
.scene {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid #36544c;
  border-radius: 16px;
  background: #678f9a;
  box-shadow: 0 24px 60px #0005;
}
.stadium {
  position: absolute;
  inset: 0 0 65%;
  background:
    radial-gradient(ellipse at 8% 8%, #efffff75, transparent 28%),
    radial-gradient(ellipse at 92% 8%, #efffff75, transparent 28%),
    linear-gradient(#101f2c, #304451 40%, #182832 41%, #24383c 92%, #a5b6af 93%, #344c43 96%);
}
/* 觀眾與看台都是背景偽元素，不新增會參與碰撞的實體。 */
.stadium::before {
  content: "";
  position: absolute;
  inset: 26% 0 8%;
  background:
    repeating-linear-gradient(to bottom, transparent 0 20%, #0d1b29b0 20% 23%, #71848b55 23% 24%, transparent 24% 25%),
    radial-gradient(ellipse at 25% 30%, #c5b4a5a8 0 1px, transparent 1.8px) 0 0 / 11px 9px,
    radial-gradient(ellipse at 65% 60%, #7c9ca7b3 0 1.2px, transparent 2px) 3px 4px / 13px 11px,
    radial-gradient(ellipse at 40% 40%, #a27f76a6 0 1px, transparent 1.8px) 5px 2px / 17px 13px,
    linear-gradient(#283c49, #162934);
  box-shadow: inset 0 10px 18px #0005, inset 0 -10px 12px #08151c88;
}
.stadium::after {
  content: "";
  position: absolute;
  left: 5%;
  right: 5%;
  top: 12%;
  height: 3%;
  background: linear-gradient(90deg, #dffaff 0 12%, transparent 12% 88%, #dffaff 88%);
  border-top: 1px solid #c8e2e44d;
  filter: drop-shadow(0 0 6px #c5eeffb3);
}
/* Small independent background layers; all remain behind the existing goal. */
.stadium { overflow: hidden; }
.stadium * { pointer-events: none; }
.stadium-lights { position: absolute; inset: 0; z-index: 1; }
.stadium-lights::before, .stadium-lights::after {
  content: ""; position: absolute; top: -25%; width: 62%; height: 140%;
  background: radial-gradient(ellipse at 50% 5%, #cfe9ed33, #d4e6df0d 45%, transparent 70%);
  opacity: 0.65; animation: stadium-light-breathe 9s ease-in-out infinite alternate;
}
.stadium-lights::before { left: -20%; }
.stadium-lights::after { right: -20%; animation-duration: 11s; animation-delay: -4s; }
.crowd-sections { position: absolute; inset: 30% 3% 12%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 3%; }
.crowd-patch { position: relative; --phase: -0.8s; --pace: 4.7s; --cheer-delay: 0ms; }
.crowd-patch:nth-child(2) { --phase: -2.3s; --pace: 5.9s; --cheer-delay: 90ms; }
.crowd-patch:nth-child(3) { --phase: -1.7s; --pace: 4.1s; --cheer-delay: 180ms; }
.crowd-patch:nth-child(4) { --phase: -3.8s; --pace: 6.3s; --cheer-delay: 40ms; }
.crowd-patch:nth-child(5) { --phase: -2.9s; --pace: 5.2s; --cheer-delay: 130ms; }
.crowd-patch:nth-child(6) { --phase: -0.4s; --pace: 5.5s; --cheer-delay: 210ms; }
.crowd-patch::before, .crowd-patch::after { content: ""; position: absolute; inset: 0; opacity: 0.5; }
.crowd-patch::before {
  background: radial-gradient(ellipse, #d6b79a 0 1px, transparent 1.7px) 2px 3px / 17px 14px,
    radial-gradient(ellipse, #8eafba 0 1px, transparent 1.8px) 8px 8px / 21px 19px;
  animation: crowd-idle var(--pace) var(--phase) ease-in-out infinite alternate;
}
.crowd-patch::after {
  inset: 5% 14% 10%; opacity: 0.24;
  background: repeating-linear-gradient(110deg, transparent 0 15px, #e1c7a4 16px 17px, transparent 18px 29px);
  mask-image: repeating-linear-gradient(transparent 0 11px, #000 12px 15px, transparent 16px 28px);
  animation: crowd-hands var(--pace) var(--phase) ease-in-out infinite alternate;
}
.stadium-flag { position: absolute; top: 43%; width: 1px; height: 31%; background: #9caca5; }
.flag-left { left: 12%; }
.flag-right { right: 14%; }
.stadium-flag::after { content: ""; position: absolute; top: 0; left: 1px; width: clamp(10px, 2.4vw, 22px); height: clamp(7px, 1.4vw, 12px); background: linear-gradient(110deg, #d6c078bb 50%, #6b9cacbb 50%); transform-origin: left center; animation: stadium-flag-wave 5.7s ease-in-out infinite alternate; }
.flag-right::after { animation-delay: -2.6s; animation-duration: 6.9s; }
.stadium.is-cheering .crowd-patch { animation: crowd-celebrate 460ms var(--cheer-delay) ease-in-out 3; }
.stadium-cameras { position: absolute; inset: 0; }
.stadium-cameras i { position: absolute; width: 3px; height: 3px; border-radius: 50%; opacity: 0; background: #e2eff5; box-shadow: 0 0 5px 1px #cfe5ed99; }
.stadium.is-cheering .stadium-cameras i { animation: stadium-camera 100ms var(--flash-delay) ease-out both; }
@keyframes stadium-light-breathe { from { opacity: 0.45; } to { opacity: 0.72; } }
@keyframes crowd-idle { from { transform: translateY(0); } to { transform: translateY(-1.5px); } }
@keyframes crowd-hands { from { transform: translateY(1px) skewX(-2deg); } to { transform: translateY(-1px) skewX(3deg); } }
@keyframes stadium-flag-wave { from { transform: skewY(-7deg) scaleX(0.86); } to { transform: skewY(7deg) scaleX(1); } }
@keyframes crowd-celebrate { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-4px); } }
@keyframes stadium-camera { 0%, 100% { opacity: 0; } 35% { opacity: 0.7; } }
@media (max-width: 540px) {
  .crowd-sections { grid-template-columns: repeat(3, 1fr); gap: 6%; }
  .crowd-patch:nth-child(n+4), .flag-right, .stadium-cameras i:nth-child(n+3) { display: none; }
  .stadium-lights::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .stadium-lights::before, .stadium-lights::after,
  .crowd-patch::before, .crowd-patch::after, .stadium-flag::after,
  .stadium.is-cheering .crowd-patch { animation: none; }
  .stadium-cameras { display: none; }
}
.pitch {
  position: absolute;
  inset: 32% 0 0;
  background:
    radial-gradient(ellipse at 50% 12%, #c3e8aa26, transparent 65%),
    repeating-linear-gradient(104deg, #d6efaa0d 0 1px, transparent 1px 4px),
    repeating-linear-gradient(16deg, #082c180d 0 1px, transparent 1px 5px),
    linear-gradient(to bottom, #092e2926, transparent 30%, #071d1633),
    linear-gradient(to bottom,
      #397a43 0% 8%, #32713c 8% 18%,
      #3c8148 18% 30%, #327640 30% 44%,
      #3e854b 44% 61%, #347844 61% 80%, #3b814a 80% 100%);
  box-shadow: inset 36px 0 55px -35px #071e1b80, inset -36px 0 55px -35px #071e1b80;
}
.pitch::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 14% 0%, #ecffdb1c, transparent 55%),
    radial-gradient(ellipse at 86% 0%, #ecffdb1c, transparent 55%);
}
.penalty-area {
  position: absolute;
  left: 14%; top: 39%; width: 72%; height: 38%;
  border: 2px solid #e4f0d9b3;
  transform: perspective(250px) rotateX(40deg);
  transform-origin: center top;
  box-shadow: 0 1px 1px #173f2850, inset 0 1px 1px #173f2826;
}
.goal {
  position: absolute;
  left: 28%; top: 22%; width: 44%; height: 25%;
  border: clamp(3px, .6vw, 6px) solid #f1f4ec;
  border-bottom: 0;
  /* 僅調整顏色與陰影，保留門框 border 寬度及內外緣座標。 */
  border-color: #f4f7f2 #c9d5d0 #c9d5d0 #e8efeb;
  box-shadow: 2px 1px 0 #a0b2ad, 4px 5px 6px #0b252b55, inset 1px 1px 2px #ffffff80;
}
.goal::before {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 2px 2px 3px #071e2833;
}
.goal::after {
  content: "";
  position: absolute;
  left: 2%;
  right: -5%;
  bottom: -9%;
  height: 11%;
  background: #0a271a45;
  transform: skewX(-25deg);
  filter: blur(4px);
}
.net {
  width: 100%; height: 100%;
  position: relative;
  overflow: hidden;
}
/* 碰撞邊界 .net 保持不動，只有內部可見網格變形。 */
.net-visual {
  position: absolute;
  inset: 0;
  background-color: #102b3038;
  background-image:
    linear-gradient(#edf6ed55 1px, transparent 1px),
    linear-gradient(90deg, #edf6ed55 1px, transparent 1px);
  background-size: clamp(7px, 1.4vw, 14px) clamp(7px, 1.4vw, 14px);
  box-shadow: inset 0 6px 15px #071f2840, inset 0 -3px 9px #071f2826;
}
/* 純裝飾背景與球網皆不攔截點擊；足球、瞄準線及結果保持原圖層。 */
.stadium, .stadium::before, .stadium::after,
.pitch, .pitch::before, .penalty-area,
.goal, .goal::before, .goal::after, .net { pointer-events: none; }
.net-visual { pointer-events: none; }

/* 守門員：頭、身體、手臂與雙腿。 */
.keeper { position: absolute; left: 45%; top: 31%; width: 10%; height: 18%; }
.keeper-head { position: absolute; left: 37%; top: 0; width: 26%; height: 25%; border-radius: 45%; background: #d69a70; border-top: 4px solid #252b29; }
.keeper-body { position: absolute; left: 28%; top: 24%; width: 44%; height: 43%; background: #f8c34f; border-radius: 18% 18% 6% 6%; }
.keeper-jersey { position: absolute; inset: 36% 0 0; text-align: center; color: #24313b; font-size: clamp(9px, 1.8vw, 19px); font-weight: 900; line-height: 1.2; pointer-events: none; }
.pk-player-info { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid #dbbd7130; color: #f1d693; font-size: 13px; line-height: 1.7; }
.pk-player-info[hidden] { display: none; }
.keeper-arm { position: absolute; top: 29%; width: 38%; height: 15%; background: #f8c34f; border-radius: 12px; }
.keeper-arm.left { left: 0; transform: rotate(-22deg); border-left: 7px solid #f0f1e7; }
.keeper-arm.right { right: 0; transform: rotate(22deg); border-right: 7px solid #f0f1e7; }
.keeper-arm.left { border-left: 0; }
.keeper-arm.right { border-right: 0; }
.keeper-palm { position: absolute; top: -15%; width: 28%; height: 130%; border-radius: 35%; background: #f0f1e7; border: 1px solid #cbd6d0; }
.keeper-arm.left .keeper-palm { left: -12%; }
.keeper-arm.right .keeper-palm { right: -12%; }
.keeper { will-change: transform; pointer-events: none; }
/* 撲救時身體從中心傾斜，雙手從肩膀向上伸展。 */
.keeper { transform-origin: center center; }
.keeper-arm.left { transform-origin: right center; }
.keeper-arm.right { transform-origin: left center; }
.keeper-leg { position: absolute; top: 63%; width: 19%; height: 37%; background: #23333d; border-bottom: 5px solid #eff3e7; }
.keeper-leg.left { left: 25%; transform: rotate(12deg); }
.keeper-leg.right { right: 25%; transform: rotate(-12deg); }
.keeper-leg { transform-origin: center top; }
.penalty-spot { position: absolute; left: 49%; top: 73%; width: 2%; height: 1%; border-radius: 50%; background: #f0f4dc; }
.ball {
  z-index: 2;
  cursor: grab;
  touch-action: none;
  position: absolute; left: 48%; top: 69%; width: 4%; aspect-ratio: 1;
  border-radius: 50%; border: 1px solid #dbe0da;
  overflow: hidden;
  background: #f5f5eb;
  box-shadow: inset -1px -2px 3px #14312650;
}
/* 只轉動花紋，外層球體的位移、縮放與碰撞尺寸保持原樣。 */
.ball-surface {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%, #233338 0 22%, transparent 24%), radial-gradient(circle at 0 75%, #233338 0 19%, transparent 21%), radial-gradient(circle at 100% 75%, #233338 0 19%, transparent 21%), #f5f5eb;
}
.ball::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #fff8, transparent 45%), linear-gradient(135deg, transparent 50%, #102b3540);
  pointer-events: none;
}
.ball-shadow, .ball-trail {
  position: absolute;
  left: 48%;
  top: 69%;
  width: 4%;
  aspect-ratio: 1;
  pointer-events: none;
  border-radius: 50%;
}
.ball-shadow {
  background: radial-gradient(ellipse, #081d16a6 0%, #081d165c 38%, transparent 72%);
  transform: translateY(50%) scaleY(0.28);
  opacity: 0.45;
}
.ball-trail {
  z-index: 1;
  background: radial-gradient(circle at 40% 35%, #fffdf1c9, #c9d4c975 65%, transparent 75%);
  opacity: 0;
}
.miss-sparkle {
  position: absolute;
  z-index: 2;
  width: 30px;
  height: 30px;
  color: #fff7c9;
  font-size: 24px;
  line-height: 1;
  text-shadow: 0 0 6px #fff9cf99;
  pointer-events: none;
}
.miss-sparkle[hidden] { display: none; }
.miss-sparkle span { position: absolute; left: 3px; top: 3px; }
.miss-sparkle span:nth-child(2) { transform: translate(16px, -7px) scale(0.45); opacity: 0.75; }
.miss-sparkle span:nth-child(3) { transform: translate(-12px, 12px) scale(0.3); opacity: 0.6; }

/* 前景球員背對鏡頭，背號由 PK 陣容身分更新。 */
.player { position: absolute; left: 35%; top: 59%; width: 13%; height: 38%; isolation: isolate; overflow: visible; }
.player-head { position: absolute; left: 35%; top: 0; width: 30%; height: 19%; background: #a97552; border-radius: 40%; border-top: 10px solid #222a2c; z-index: 4; box-shadow: inset -2px -1px 0 #80533255; }
.player-body { position: absolute; left: 20%; top: 18%; width: 60%; height: 41%; background: #eaeef0; border-radius: 20% 20% 5% 5%; border-top: 5px solid #2168a7; text-align: center; z-index: 2; box-shadow: inset -3px 0 0 #c1ced766; }
.player-body span { display: block; margin-top: 12%; color: #235e94; font-size: clamp(12px, 3vw, 30px); font-weight: bold; }
.player-body .player-name, .keeper-name { position: absolute; top: 8%; left: 2%; width: 96%; margin: 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 900; line-height: 1.15; pointer-events: none; }
.player-body .player-name { font-size: calc(clamp(7px, 1.2vw, 12px) * var(--name-scale, 1)); }
.keeper-name { color: #24313b; font-size: calc(clamp(5px, 0.8vw, 8px) * var(--name-scale, 1)); }
.player-body .player-jersey { position: absolute; inset: 32% 0 0; margin: 0; }

/* Isolate scene depth: incoming/rebounding ball is in front of actors;
   after a confirmed goal it sits behind the goalkeeper, inside the net. */
.scene { isolation: isolate; }
.stadium, .pitch { z-index: 0; }
.goal, .ball-shadow { z-index: 1; }
.keeper, .player { z-index: 3; }
.scene[data-ball-depth="field"] .ball,
.scene[data-ball-depth="field"] .ball-trail { z-index: 4; }
.scene[data-ball-depth="goal"] .ball { z-index: 2; }
.scene > .shot-result, .scene > .goal-celebration { z-index: 10; }
.scene > .match-summary { z-index: 20; }
.scene > .start-screen, .scene > .kickoff-countdown { z-index: 21; }
.scene > .arena-screen { z-index: 22; }
.scene > .player > .player-arm { position: absolute; top: 22%; width: 17%; height: 37%; background: linear-gradient(#eaeef0 40%, #a97552 40%); border-radius: 35% 35% 42% 42%; z-index: 3; box-shadow: inset -2px 0 0 #69482e44, 0 0 0 1px #19314933; }
.scene > .player > .player-arm::before { content: ""; position: absolute; left: 0; top: 36%; width: 100%; height: 4%; border-radius: 2px; background: #28659a; }
.scene > .player > .player-arm::after { content: ""; position: absolute; left: 6%; bottom: -1%; width: 88%; height: 18%; border-radius: 45%; background: #bd8965; box-shadow: inset -1px -1px 0 #80533266; }
.player-arm.left { left: 7%; transform: rotate(8deg); }
.player-arm.right { right: 7%; transform: rotate(-8deg); }
.scene > .player > .player-leg { position: absolute; top: 57%; width: 25%; height: 43%; background: linear-gradient(#245f96 32%, #a97552 32% 59%, #eaeef0 59% 90%, #e77948 90%); border-radius: 12% 12% 18% 18%; z-index: 1; box-shadow: inset -2px 0 0 #15395044; }
.scene > .player > .player-leg::before { content: ""; position: absolute; left: 6%; top: 43%; width: 88%; height: 8%; border-radius: 50%; background: #bd896544; }
.scene > .player > .player-leg::after { content: ""; position: absolute; left: -8%; bottom: 0; width: 116%; height: 12%; border-radius: 40% 45% 22% 22%; background: linear-gradient(#ef9057 70%, #26394a 70%); box-shadow: 0 1px 1px #11293666; }
.player-leg.left { left: 21%; transform: rotate(4deg); }
.player-leg.right { right: 21%; transform: rotate(-4deg); }
/* 從髖部與肩膀擺動；實際動畫由 game.js 配合觸球時機控制。 */
.player { transform-origin: center bottom; pointer-events: none; }
.player-leg, .player-arm { transform-origin: center top; }
.scene-label { position: absolute; left: 18px; top: 16px; padding: 7px 10px; border: 1px solid #ffffff35; border-radius: 6px; background: #102d355e; color: #e6efea; font-size: 12px; letter-spacing: 2px; }
.scene { user-select: none; }
.ball.is-dragging { cursor: grabbing; }
.ball.is-flying { pointer-events: none; }
/* 從球心出發的方向線與箭頭。 */
.aim-line {
  position: absolute;
  z-index: 3;
  height: 3px;
  background: #fff3a6;
  transform-origin: left center;
  pointer-events: none;
}
.aim-line::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -5px;
  border-left: 12px solid #fff3a6;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
@media (max-width: 540px) {
  .game { width: calc(100% - 20px); padding-top: 24px; }
  .scene { aspect-ratio: 4 / 5; }
  .goal { left: 16%; width: 68%; height: 20%; top: 27%; }
  .keeper { left: 43%; width: 14%; top: 33%; height: 16%; }
  .player { left: 27%; width: 20%; height: 32%; top: 63%; }
  .ball { width: 6%; left: 49%; top: 73%; }
  .ball-shadow, .ball-trail { width: 6%; left: 49%; top: 73%; }
  .penalty-spot { top: 76%; left: 51%; }
}

/* 雙方比分與攻守回合 */
.scene.ai-turn .scene-label { background: #63432f; border-color: #e6ba7a; }
.scene.ai-turn .player-body { border-top-color: #d25d46; }
.scene.ai-turn .player-body span { color: #c7503b; }
.scene.ai-turn .ball { cursor: default; }
.match-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.match-actions button { display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px; border: 1px solid #d9ba7066; border-radius: 8px; background: #10243ce8; color: #f1d693; font: inherit; font-size: 12px; cursor: pointer; }
.match-actions button span { font-size: 20px; line-height: 1; }
.match-actions button:hover { background: #203a57; border-color: #f1d693; }
.match-actions button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.volume-panel { flex: 0 0 100%; margin-left: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 16px; padding: 14px; border: 1px solid #d9ba7055; border-radius: 10px; background: #10243ce8; color: #f1d693; }
.volume-panel[hidden] { display: none; }
.volume-panel label { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.volume-panel input { grid-column: 1; width: 100%; min-width: 0; accent-color: #e7c879; cursor: pointer; }
.volume-panel .mute-button { grid-column: 2; grid-row: 1 / 3; justify-content: center; }
.volume-value { font-variant-numeric: tabular-nums; }

/* Arena navigation reuses the one existing live stadium beneath its cover. */
body[data-mode="menu"] .scoreboard,
body[data-mode="menu"] .quick-restart-button,
body[data-mode="menu"] .home-button { display: none; }
body[data-mode="menu"] .scene { aspect-ratio: auto; min-height: 650px; }
body[data-mode="menu"] .scene > .ball,
body[data-mode="menu"] .scene > .ball-shadow,
body[data-mode="menu"] .scene > .keeper,
body[data-mode="menu"] .scene > .player,
body[data-mode="menu"] .scene > .penalty-spot,
body[data-mode="menu"] .scene-label { visibility: hidden; }
.arena-screen { position: absolute; inset: 0; z-index: 7; display: grid; align-items: center; padding: clamp(20px, 4vw, 40px); overflow: auto; background: linear-gradient(145deg, #08172ee8, #0b2135b8 55%, #071528dd); }
.arena-screen[hidden], .arena-menu[hidden], .arena-coming[hidden] { display: none; }
.arena-cover { width: min(100%, 720px); margin: auto; }
.arena-kicker { margin: 0 0 10px; color: #d9bb72; font-size: 11px; letter-spacing: 3px; }
.arena-cover h2 { margin: 0; color: #fff5d8; font-family: "Microsoft JhengHei", "PingFang TC", sans-serif; font-weight: 900; font-size: clamp(36px, 6.5vw, 62px); line-height: 1.2; letter-spacing: 2px; text-shadow: 0 0 24px #edbd5033; }
.arena-cover h2 span { color: #e7c474; }
/* The large title inside the five-mode menu, separate from both cover titles. */
.arena-cover #arena-title { display: flex; align-items: center; white-space: nowrap; }
.arena-cover #arena-title > .arena-title-text { color: inherit; }
.arena-cover #arena-title::after {
  content: "⚽";
  flex: 0 0 auto;
  margin-inline-start: 0.22em;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-size: 0.65em;
  line-height: 1;
  color: #f5f5eb;
  -webkit-text-fill-color: initial;
  text-shadow: none;
}
@media (max-width: 540px) {
  .arena-cover #arena-title { font-size: clamp(18px, 5.9vw, 32px); }
}
.arena-tagline { color: #b6c8d7; font-size: 14px; margin: 12px 0 26px; }
.arena-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.arena-mode { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 19px 16px; border: 1px solid #9caec13d; border-radius: 12px; background: linear-gradient(120deg, #17314ce6, #0b1d32eb); color: #eef3f7; font: inherit; text-align: left; cursor: pointer; transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease; }
.arena-mode-featured { grid-column: 1 / -1; padding: 23px 18px; border-color: #d6b66caa; background: linear-gradient(115deg, #4b4228d9, #17314ce6 70%); }
.arena-mode-number { flex-shrink: 0; color: #d6b66c; font-size: 12px; font-variant-numeric: tabular-nums; }
.arena-mode-copy { flex: 1; min-width: 0; }
.arena-mode strong { display: block; font-size: clamp(16px, 2.2vw, 21px); letter-spacing: 1px; }
.arena-mode small { display: block; margin-top: 6px; color: #a9bdce; font-size: 10px; line-height: 1.5; }
.arena-mode-badge { color: #bdc5cb; font-size: 10px; white-space: nowrap; }
.arena-mode-featured .arena-mode-badge { color: #ffe09a; }
@media (hover: hover) { .arena-mode:hover { transform: translateY(-3px); border-color: #dfc078; box-shadow: 0 8px 24px #0004; } }
.arena-mode:active { transform: scale(0.98); }
.arena-mode:focus-visible, .arena-back-button:focus-visible { outline: 2px solid #ffe09a; outline-offset: 4px; }
.arena-footer { margin: 24px 0 0; color: #91a7b6; font-size: 10px; letter-spacing: 2px; }
.arena-coming { min-height: 245px; padding: 28px 0; }
.arena-coming h3 { color: #f5d690; font-size: 30px; margin: 12px 0; }
.arena-coming > p:not(.arena-kicker) { color: #b6c8d7; }
.arena-back-button { margin-top: 20px; padding: 12px 20px; background: #e6c476; color: #11243b; border: 1px solid #ffdfa0; border-radius: 8px; font: inherit; font-weight: bold; cursor: pointer; }
@media (max-width: 540px) {
  body[data-mode="menu"] .scene { min-height: 720px; }
  .arena-menu { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .arena-mode { padding: 15px 12px; }
  .arena-mode-featured { padding: 20px 12px; }
  .arena-mode small { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .arena-mode { transition: none; }
  .arena-mode:hover, .arena-mode:active { transform: none; }
}

.start-screen, .kickoff-countdown {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #071a32c9;
  text-align: center;
}
.start-screen[hidden], .kickoff-countdown[hidden] { display: none; }
.start-screen { overflow: auto; }
.start-card { width: min(100%, 520px); }
.start-eyebrow { color: #dfc27e; font-size: clamp(9px, 1.5vw, 12px); letter-spacing: clamp(1px, 0.35vw, 3px); }
.game-header h1, .start-card h2 {
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  font-weight: 900;
  color: #ffe6a3;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 #85551f, 0 0 12px #f6c55c66, 0 0 30px #eeb03c33, 0 4px 14px #0009;
}
.start-card h2 { margin: 18px 0 24px; font-size: clamp(34px, 7vw, 70px); line-height: 1.2; transform: skewX(-5deg); }
.start-card h2 span { color: #fff5d6; }
.start-button { padding: 14px 30px; border: 1px solid #ffe7a2; border-radius: 8px; background: linear-gradient(#f6de9a, #d6a947); color: #152139; font: inherit; font-weight: 900; letter-spacing: 2px; cursor: pointer; box-shadow: 0 5px 24px #deb55333; }
.start-button:hover { background: #ffe6a4; }
.start-button:focus-visible { outline: 3px solid #fff; outline-offset: 5px; }
.start-button:disabled { cursor: default; }
.difficulty-options { display: flex; justify-content: center; gap: 8px; margin: 0 0 18px; }
.difficulty-options button { min-width: 0; padding: 10px clamp(9px, 2vw, 18px); border: 1px solid #7890aa66; border-radius: 7px; background: #0e213bcc; color: #d6e0ef; font: inherit; font-size: 12px; font-weight: bold; letter-spacing: 1px; cursor: pointer; transition: border-color 180ms, box-shadow 180ms, color 180ms; }
.difficulty-options button[aria-pressed="true"] { border-color: #ffe09a; color: #ffe7a4; box-shadow: 0 0 13px #e9be5c66, inset 0 0 10px #e9be5c15; }
.difficulty-options button:focus-visible, .change-difficulty-button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.change-difficulty-button { display: block; margin: 14px auto 0; padding: 7px 10px; border: 1px solid #9ca9b655; border-radius: 6px; background: transparent; color: #c3d0df; font: inherit; font-size: 11px; letter-spacing: 1px; cursor: pointer; }
.start-controls { margin: 22px 0 0; color: #d4dfeb; font-size: clamp(11px, 1.6vw, 14px); line-height: 2; }
.start-controls span { color: #ffe4a0; font-weight: bold; }
.kickoff-countdown { background: #071a3260; pointer-events: auto; }
.countdown-text { color: #ffdc80; font-size: clamp(40px, 10vw, 100px); line-height: 1.1; text-shadow: 0 0 22px #ffd27244, 0 4px 12px #0008; }


/* Isolated decoration: never transforms the ball, keeper or result label. */
.goal-celebration {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}
.goal-celebration[hidden] { display: none; }
.goal-celebration * { pointer-events: none; }
.goal-cheer {
  position: absolute;
  left: 50%;
  top: 50%;
  color: #ffd34e;
  font-size: clamp(44px, 10vw, 96px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  -webkit-text-stroke: 1.5px #fff9df;
  paint-order: stroke fill;
  text-shadow: 0 0 12px #ffe69999, 0 0 28px #ffc64d66, 0 4px 6px #39270b88;
  animation: goal-cheer-pop 1350ms ease-out both;
}
.goal-burst { position: absolute; width: 0; height: 0; }
.goal-flash {
  position: absolute;
  width: clamp(100px, 28vw, 260px);
  aspect-ratio: 2;
  border-radius: 50%;
  background: radial-gradient(ellipse, #fff8dca6, #ffd35555 35%, transparent 70%);
  animation: goal-flash 450ms ease-out both;
}
.goal-particle {
  position: absolute;
  left: 0;
  top: 0;
  color: #ffe28b;
  font-size: 20px;
  line-height: 1;
  text-shadow: 0 0 7px #ffd85ccc;
  animation: goal-particle-burst 850ms var(--delay) ease-out both;
}
.goal-confetti { position: absolute; inset: 0; }
.goal-ribbon {
  position: absolute;
  top: -14px;
  width: 6px;
  height: 13px;
  border-radius: 1px;
  animation: goal-ribbon-fall 1750ms var(--delay) ease-out both;
}
@keyframes goal-cheer-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.35); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  29% { transform: translate(-50%, -50%) scale(0.96); }
  40%, 65% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(1.04); }
}
@keyframes goal-flash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}
@keyframes goal-particle-burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.5); }
}
@keyframes goal-ribbon-fall {
  0% { opacity: 0; transform: translate(0, 0) rotate(0deg); }
  12%, 65% { opacity: 0.85; }
  100% { opacity: 0; transform: translate(var(--drift), var(--fall)) rotate(var(--spin)); }
}
@media (prefers-reduced-motion: reduce) {
  .goal-cheer { animation-name: goal-cheer-fade; }
  .goal-particle, .goal-ribbon, .goal-flash { display: none; }
}
@keyframes goal-cheer-fade {
  0%, 100% { opacity: 0; transform: translate(-50%, -50%); }
  15%, 65% { opacity: 1; transform: translate(-50%, -50%); }
}
