/* =====================================================================
   AgentSoccer H5 全局样式。
   设计稿：竖屏 1080x1920（与 Unity 端 CanvasScaler referenceResolution 一致）。
   适配策略：#stage 固定 1080x1920，由 https://d1u4k7xc6u3yed.cloudfront.net/agent-soccer/js/app.js 计算 scale 居中缩放；
   横屏浏览器下两侧自然留黑（body 背景为黑），等同 Unity OrientationAdapter。
   ===================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #e8ecf4;
  -webkit-font-smoothing: antialiased;
}

#stage-wrap { width: 100%; height: 100%; position: relative; }

/* 舞台：1080x1920 设计尺寸，transform 由 JS 设置 */
#stage {
  position: absolute;
  width: 1080px; height: 1920px;
  left: 50%; top: 50%;
  transform-origin: center center;
  background: #0b0e16;
  overflow: hidden;
}

.hidden { display: none !important; }
.dim { color: #8b93a7; }
.grow { flex: 1 1 auto; min-height: 0; }

/* ---------------- 屏幕容器 ---------------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

/* ---------------- 启动加载页（boot splash，index.html #screen-boot） ----------------
   默认可见，遮住启动期异步流程（探测后端 + Hub 自动绑定），避免闪登录/注册页。 */
.boot-center {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 56px;
}
.boot-wordmark { font-size: 96px; }
.boot-spinner {
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 8px solid rgba(255, 255, 255, 0.12);
  border-top-color: #15e371;
  box-shadow: 0 0 36px rgba(21, 227, 113, 0.35);
  animation: boot-spin 0.9s linear infinite;
}
.boot-text {
  font-family: 'Saira', 'Noto Sans SC', sans-serif;
  font-size: 34px; font-weight: 600; letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.66);
}
@keyframes boot-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .boot-spinner { animation: none; } }

.panel {
  display: flex; flex-direction: column;
  gap: 24px;
  width: 100%; height: 100%;
  padding: 48px;
  background: linear-gradient(180deg, #11141f 0%, #0b0e16 100%);
}

h1 { font-size: 64px; text-align: center; margin: 40px 0; }
h2 { font-size: 44px; }
h3 { font-size: 30px; color: #aeb8cf; margin-top: 8px; }

label { display: flex; flex-direction: column; gap: 10px; font-size: 30px; color: #aeb8cf; }

input, textarea, select {
  font-size: 34px;
  padding: 20px 24px;
  border: 2px solid #2a3146;
  border-radius: 12px;
  background: #161b29;
  color: #fff;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: #3f6fff; }
textarea { resize: none; }
/* 未配置模型等禁用项灰显 */
select option:disabled { color: #5b6379; }

/* ---------------- 按钮 ---------------- */
.btn {
  font-size: 32px;
  padding: 20px 30px;
  border: none; border-radius: 14px;
  background: #273050;
  color: #e8ecf4;
  cursor: pointer;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: #2f63e8; }
.btn.danger { background: #93312f; }
.btn.big { font-size: 38px; padding: 26px; }
.btn.small { font-size: 26px; padding: 12px 20px; }
.btn.tiny { font-size: 22px; padding: 6px 14px; }
.btn.link { background: transparent; color: #6f9bff; text-decoration: underline; }
.btn.menu { font-size: 40px; padding: 34px; border-radius: 18px; }
.btn.tab { border-radius: 12px 12px 0 0; opacity: .55; }
.btn.tab.active { opacity: 1; background: #2f63e8; }

.status { min-height: 36px; font-size: 26px; color: #ffd27d; }
.tag { font-size: 26px; padding: 8px 16px; border-radius: 10px; background: #1d2438; color: #9fb4e8; }

/* ---------------- 登录页 ---------------- */
.auth-panel { justify-content: center; max-width: 1080px; padding: 48px 96px; }
.nation-picker { display: flex; align-items: center; gap: 24px; }
.nation-picker span { font-size: 36px; color: #fff; min-width: 180px; text-align: center; }

/* ---------------- 主页 ---------------- */
.home-panel { justify-content: center; padding: 48px 96px; }
.player-card {
  background: linear-gradient(135deg, #1a2336 0%, #141a2a 100%);
  border: 2px solid #2a3858;
  border-radius: 22px;
  padding: 36px;
  display: flex; flex-direction: column; gap: 18px;
}
.player-card-head { display: flex; align-items: center; justify-content: space-between; }
.big-name { font-size: 52px; font-weight: bold; }
.player-card-stats { display: flex; gap: 28px; font-size: 30px; color: #cdd6ea; flex-wrap: wrap; }
.home-menu { display: flex; flex-direction: column; gap: 22px; margin-top: 16px; }

/* ---------------- 通用列表 ---------------- */
.bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.list {
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto;
  background: #10131e;
  border-radius: 12px;
  padding: 10px;
}
.row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px;
  border-radius: 10px;
  background: #181d2c;
  font-size: 26px;
  cursor: pointer;
}
.row:hover { background: #222a40; }
.row.header { background: #0d101a; color: #7f8aa6; cursor: default; }
.row.me { background: #20371f; }
.row.fielded { background: #1c3023; }
.row .right { margin-left: auto; }
.row .del { background: #6b2424; border-radius: 8px; padding: 4px 14px; font-size: 22px; }

/* ---------------- 阵容编辑 ---------------- */
.team-panel { padding: 24px; gap: 14px; }
.team-name-input { width: 280px; font-size: 28px; padding: 12px 16px; }
.cycler { display: flex; align-items: center; gap: 10px; }
.cycler span { font-size: 28px; min-width: 90px; text-align: center; }
.team-body { display: flex; gap: 16px; flex: 1 1 auto; min-height: 0; }
.team-pitch {
  position: relative;
  width: 560px; height: 1100px;
  flex: 0 0 auto;
  background:
    linear-gradient(0deg, rgba(255,255,255,.06) 1px, transparent 1px) 0 50%/100% 50%,
    linear-gradient(180deg, #156a22 0%, #0f4f1a 100%);
  border: 3px solid #2c7a3a;
  border-radius: 16px;
}
.team-pitch::after { /* 中圈 */
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 140px; height: 140px;
  border: 2px solid rgba(255,255,255,.25); border-radius: 50%;
  transform: translate(-50%, -50%);
}
.slot-card {
  position: absolute;
  width: 108px; height: 124px;
  transform: translate(-50%, -50%);
  background: #565f73e6;
  border-radius: 12px;
  border: 3px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; cursor: pointer;
  font-size: 20px; text-align: center;
}
.slot-card .role { color: #ffe9a8; font-size: 20px; }
.slot-card .pname { font-size: 24px; color: #fff; }
.slot-card .agent { font-size: 18px; color: #b3d2ff; }
.slot-card.filled { background: #2c3f63e6; }
.slot-card.selected { border-color: #ffd24d; background: #4a4322e6; }
.team-side { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-width: 0; }
.side-block { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.side-block .list { flex: 1 1 auto; }
.detail { background: #141927; border-radius: 12px; padding: 16px; font-size: 24px; line-height: 1.6; white-space: pre-wrap; min-height: 220px; }

/* ---------------- 球员自定义 ---------------- */
.customize-panel { padding: 28px; gap: 14px; }
.cz-body { display: flex; gap: 16px; flex: 1 1 auto; min-height: 0; }
.cz-players { width: 360px; flex: 0 0 auto; }
.cz-attrs-wrap { flex: 1 1 auto; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cz-attrs { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.attr-row {
  display: flex; align-items: center; gap: 14px;
  background: #181d2c; border-radius: 10px; padding: 10px 16px; font-size: 28px;
}
.attr-row .aname { width: 110px; color: #aeb8cf; }
.attr-row .abase { width: 90px; color: #7f8aa6; font-size: 24px; }
.attr-row .abar { flex: 1 1 auto; height: 16px; background: #0d101a; border-radius: 8px; overflow: hidden; display: flex; }
.attr-row .abar i { display: block; height: 100%; background: #2f63e8; }
.attr-row .abar i.extra { background: #43c463; }
.attr-row .aval { width: 120px; text-align: right; }
/* 每 +1 的积分消耗（档位成本，实时跟随当前值） */
.attr-row .acost { width: 160px; text-align: right; font-size: 22px; color: #e8b66a; }
.attr-row .btn.small { padding: 6px 18px; }

/* ---------------- AI 编程 ---------------- */
.coding-panel { padding: 48px 72px; }
/* 模板/模型选择、上传/下载按钮的横排容器 */
.coding-row { display: flex; gap: 24px; align-items: flex-end; }
.coding-row .grow { flex: 1 1 0; min-width: 0; }
.coding-row .btn { flex: 1 1 0; }
.coding-row select { width: 100%; }
/* prompt 框上方的引导文案 */
.coding-intro { font-size: 26px; line-height: 1.6; color: #8fa0c4; }
.code-result {
  flex: 1 1 auto; overflow: auto;
  background: #0d111c; border-radius: 12px;
  padding: 20px; font-size: 22px; line-height: 1.5;
  color: #9fe8a8; white-space: pre-wrap; word-break: break-all;
}

/* ---------------- 排行榜 ---------------- */
.leaderboard-panel { padding: 36px; gap: 16px; }
.tabs { display: flex; gap: 8px; }
.lb-header { font-size: 24px; color: #7f8aa6; padding: 0 18px; }

/* ---------------- 比赛回放 ---------------- */
#screen-match { background: #0a3d12; }
#match-canvas { position: absolute; inset: 0; width: 1080px; height: 1920px; }
.match-hud { position: absolute; inset: 0; pointer-events: none; }
.score-bar {
  position: absolute; left: 0; right: 0; top: 48px; height: 62px;
  background: url("https://d1u4k7xc6u3yed.cloudfront.net/agent-soccer/assets/score_bar.png") center/100% 100% no-repeat, #23263af0;
  display: flex; align-items: center;
}
.score-home, .score-away { flex: 0 0 37%; text-align: center; font-size: 32px; font-weight: bold; color: #fff; overflow: hidden; white-space: nowrap; }
.score-mid { flex: 1 1 auto; text-align: center; font-size: 42px; font-weight: bold; color: #2b2e3c; }
.timer-plate {
  position: absolute; left: 50%; top: 110px; transform: translateX(-50%);
  width: 233px; height: 62px;
  background: url("https://d1u4k7xc6u3yed.cloudfront.net/agent-soccer/assets/timer_plate.png") center/100% 100% no-repeat, #000000a0;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: bold;
}
.match-banner {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  font-size: 96px; font-weight: bold; color: #ffe082;
  text-shadow: 0 6px 24px #000;
  letter-spacing: .2em;
}
.caption-bar {
  position: absolute; left: 50%; bottom: 36px; transform: translateX(-50%);
  width: 1040px; min-height: 80px;
  background: url("https://d1u4k7xc6u3yed.cloudfront.net/agent-soccer/assets/caption_bar.png") center/100% 100% no-repeat, #000000a0;
  display: flex; align-items: center; justify-content: center;
  padding: 14px 48px;
  font-size: 32px; text-align: center;
  transition: opacity .4s;
}
.match-controls {
  position: absolute; right: 20px; top: 190px;
  display: flex; flex-direction: column; gap: 12px;
  pointer-events: auto;
}

/* ---- 比赛回放横版（body.landscape，1920x1080；竖版规则零改动） ----
   画布由 https://d1u4k7xc6u3yed.cloudfront.net/agent-soccer/js/replay.js 同步为 1920x1080，球场长轴水平（主队在左攻向右）。
   记分条 left/right:0 自动横贯顶部、计时牌居中、横幅居中，无需覆盖；
   控制按钮列沿用右上（球场右边线 x≈1644 以外，不挡场地）。 */
body.landscape #match-canvas { width: 1920px; height: 1080px; }
/* 解说条：底部横贯（球场宽度外两侧仍留黑边给静音钮） */
body.landscape .caption-bar { width: 1600px; bottom: 24px; }
/* 视频特写覆盖层 inset:0 + flex 居中，横版下自适应居中，无需覆盖 */
/* 横版：静音钮沉到右下角（theme.css），与「点击跳过」提示同处右下会重叠 →
   横版把跳过提示左移，让出静音钮宽度（72）+间距，竖版静音钮在提示上方不冲突，零改动。 */
body.landscape .video-skip-hint { right: 116px; }

/* ---------------- 结算 ---------------- */
.settlement-panel { padding: 40px 64px; gap: 14px; }
.st-score-row { display: flex; align-items: center; justify-content: space-between; }
.st-team { font-size: 36px; font-weight: bold; max-width: 36%; overflow: hidden; white-space: nowrap; }
.st-score { font-size: 72px; font-weight: bold; }
.st-result-row { display: flex; align-items: center; gap: 24px; }
.st-result { font-size: 44px; font-weight: bold; }
.st-result.win { color: #66e683; }
.st-result.lose { color: #f2807a; }
.st-result.draw { color: #e6da80; }
.stat-table { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; background: #10131e; border-radius: 12px; padding: 10px; }
.stat-row { display: flex; padding: 10px 16px; border-radius: 8px; background: #181d2c; font-size: 24px; }
.stat-row.header { background: #0d101a; color: #7f8aa6; }
.stat-row .c1 { flex: 1 1 40%; }
.stat-row .c2, .stat-row .c3 { flex: 1 1 30%; text-align: center; }

/* ---------------- 关键时刻视频特写覆盖层 ---------------- */
.video-cutaway {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 12, 0.92);
  cursor: pointer;
}
.video-cutaway video {
  width: 100%; max-height: 62%;
  object-fit: contain;
  pointer-events: none; /* 点击落到容器=跳过 */
}
.video-skip-hint {
  position: absolute; right: 28px; bottom: 28px;
  font-size: 22px; color: rgba(255, 255, 255, 0.65);
  background: rgba(0, 0, 0, 0.45); padding: 8px 18px; border-radius: 999px;
}

/* ---------------- 切屏过渡动画（https://d1u4k7xc6u3yed.cloudfront.net/agent-soccer/js/app.js show() 驱动） ----------------
   旧屏 .screen-leave 压在上层淡出（轻微下沉 + 缩到 0.985），
   新屏 .screen-enter 在下层淡入上浮 12px，两者并行 crossfade。
   时长须与 https://d1u4k7xc6u3yed.cloudfront.net/agent-soccer/js/app.js 的 LEAVE_MS(180) / ENTER_MS(280) 保持一致。
   只动 opacity/transform：transform 作用在 .screen 自身，不影响父级
   #stage 的缩放定位，也不打扰 match 屏 canvas 的 RAF 绘制与布局。 */
@keyframes screen-leave {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(10px) scale(0.985); }
}
@keyframes screen-enter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen-leave {
  animation: screen-leave 180ms cubic-bezier(0.4, 0, 1, 1) both;
  z-index: 5;           /* 退场屏在上层盖住新屏做 crossfade */
  pointer-events: none; /* 不拦截落在新屏上的点击 */
}
.screen-enter {
  animation: screen-enter 280ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
/* 系统级减少动态偏好：全部瞬切（JS 侧 motionEnabled() 同步禁用，此处兜底） */
@media (prefers-reduced-motion: reduce) {
  .screen-leave, .screen-enter { animation: none; }
}
