:root {
  --radius: 16px;
  --goal-band: 5.4%;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
}

/* 主题一：白色 */
:root, [data-theme="white"] {
  --ink: #1b2432;
  --ink-dim: #66738a;
  --bg: #f4f6fa;
  --bg-2: #eaeef5;
  --panel: #ffffff;
  --panel-line: #dfe4ec;
  --hover: #f7f9fc;
  --accent: #0f9d58;
  --accent-2: #1d6fd0;
  --accent-soft: rgba(15, 157, 88, .12);
  --accent-line: rgba(15, 157, 88, .28);
  --primary-ink: #04140b;
  --primary-bg: linear-gradient(135deg, #4ef29b, #1fbf6a);
  --primary-shadow: rgba(15, 157, 88, .45);
  --title-grad: linear-gradient(180deg, #1b2432 12%, #14532d 55%, #0f9d58 100%);
  --overlay-bg: rgba(27, 36, 50, .42);
  --dialog-bg: linear-gradient(165deg, #ffffff, #f7f9fc);
  --dialog-shadow: rgba(27, 36, 50, .38);
  --lose: #d93a3a;
  --draw: #b8860b;
  --ball-phase: #d97706;
  --stripe: rgba(27, 36, 50, .018);
}

/* 主题二：黑色 */
[data-theme="dark"] {
  --ink: #e8eefb;
  --ink-dim: #8fa0bb;
  --bg: #070c14;
  --bg-2: #0d1522;
  --panel: rgba(255, 255, 255, .05);
  --panel-line: rgba(255, 255, 255, .11);
  --hover: rgba(255, 255, 255, .085);
  --accent: #35d07f;
  --accent-2: #4aa8ff;
  --accent-soft: rgba(53, 208, 127, .14);
  --accent-line: rgba(53, 208, 127, .28);
  --primary-ink: #04140b;
  --primary-bg: linear-gradient(135deg, #4ef29b, #1fbf6a);
  --primary-shadow: rgba(53, 208, 127, .5);
  --title-grad: linear-gradient(180deg, #ffffff 20%, #7ff0b4 75%, #29b46c);
  --overlay-bg: rgba(3, 8, 14, .8);
  --dialog-bg: linear-gradient(165deg, #14213a, #0a1220);
  --dialog-shadow: rgba(0, 0, 0, .85);
  --lose: #ff6b6b;
  --draw: #ffc857;
  --ball-phase: #fbbf24;
  --stripe: rgba(255, 255, 255, .016);
}

/* 主题三：亮色（清爽青绿） */
[data-theme="green"] {
  --ink: #10312b;
  --ink-dim: #4a7a70;
  --bg: #eef7f3;
  --bg-2: #e2f0ea;
  --panel: #ffffff;
  --panel-line: #cfe5dc;
  --hover: #f4fbf8;
  --accent: #0d9488;
  --accent-2: #0284c7;
  --accent-soft: rgba(13, 148, 136, .12);
  --accent-line: rgba(13, 148, 136, .3);
  --primary-ink: #ffffff;
  --primary-bg: linear-gradient(135deg, #14b8a6, #0d9488);
  --primary-shadow: rgba(13, 148, 136, .45);
  --title-grad: linear-gradient(180deg, #10312b 10%, #0f766e 60%, #14b8a6 100%);
  --overlay-bg: rgba(16, 49, 43, .4);
  --dialog-bg: linear-gradient(165deg, #ffffff, #f0f8f5);
  --dialog-shadow: rgba(16, 49, 43, .3);
  --lose: #d64545;
  --draw: #b45309;
  --ball-phase: #ea580c;
  --stripe: rgba(16, 49, 43, .018);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  transition: background .25s ease, color .25s ease;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
}

#app { height: 100%; position: relative; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: clamp(14px, 2.2vw, 26px);
  gap: 14px;
}
.screen.is-active { display: flex; animation: fade .32s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------------- 通用控件 ---------------- */
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

.btn-primary {
  padding: 13px 30px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--primary-ink);
  background: var(--primary-bg);
  box-shadow: 0 10px 26px -8px var(--primary-shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -10px var(--primary-shadow); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 15px;
  color: var(--ink-dim);
  border: 1px solid var(--panel-line);
  background: var(--bg-2);
  transition: color .15s, border-color .15s, background .15s;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-dim); background: var(--hover); }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  font-size: 19px;
  color: var(--ink-dim);
  border: 1px solid var(--panel-line);
  display: grid; place-items: center;
}
.icon-btn:hover { color: var(--ink); background: var(--hover); }

/* ---------------- 顶部栏 ---------------- */
.topbar { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.topbar-title { font-size: 21px; font-weight: 700; letter-spacing: .05em; }
.topbar-step {
  margin-left: auto;
  font-size: 12px; letter-spacing: .18em;
  color: var(--ink-dim);
  padding: 5px 12px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
}

/* ---------------- 界面一：首页 ---------------- */
#screen-home { align-items: center; justify-content: center; text-align: center; }
.home-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 70% at 50% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(90% 60% at 50% 115%, var(--accent-soft), transparent 62%),
    repeating-linear-gradient(115deg, var(--stripe) 0 40px, transparent 40px 80px);
  pointer-events: none;
}
.home-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 30px; }
.home-title {
  font-size: clamp(72px, 17vw, 168px);
  font-weight: 900;
  letter-spacing: .14em;
  margin-right: -.14em;
  background: var(--title-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 14px 34px var(--primary-shadow));
}
.btn-start {
  font-size: 19px;
  letter-spacing: .3em;
  margin-right: -.3em;
  color: var(--ink-dim);
  padding: 9px 6px 9px 22px;
  position: relative;
  transition: color .2s;
}
.btn-start::after {
  content: ""; position: absolute; left: 0; bottom: 2px;
  width: 0; height: 2px; border-radius: 2px;
  background: var(--accent); transition: width .3s ease;
}
.btn-start:hover { color: var(--ink); }
.btn-start:hover::after { width: 100%; }
.home-tip { font-size: 12px; color: var(--ink-dim); opacity: .75; letter-spacing: .12em; }

/* ---------------- 界面二：选择 ---------------- */
.setup-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel-title { font-size: 14px; letter-spacing: .18em; color: var(--ink-dim); margin-bottom: 12px; }

.team-grid {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  align-content: start;
  padding-right: 4px;
}
.team-grid::-webkit-scrollbar { width: 6px; }
.team-grid::-webkit-scrollbar-thumb { background: var(--panel-line); border-radius: 3px; }

.team-card {
  position: relative;
  padding: 12px 8px 10px;
  border-radius: 13px;
  border: 1.5px solid transparent;
  background: var(--panel);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .15s, border-color .15s, background .15s;
}
.team-card:hover { transform: translateY(-3px); background: var(--hover); }
.team-card.is-on { border-color: var(--accent); background: rgba(53, 208, 127, .12); }
.team-card.is-on::after {
  content: "✓";
  position: absolute; top: 6px; right: 9px;
  font-size: 12px; color: var(--accent);
}
.team-name { font-size: 13px; }

.shirt {
  width: 40px; height: 40px;
  display: inline-block;
  position: relative;
  background: var(--c1, #888);
  border-radius: 10px 10px 14px 14px;
  clip-path: polygon(26% 0, 40% 0, 50% 16%, 60% 0, 74% 0, 100% 18%, 86% 38%, 86% 100%, 14% 100%, 14% 38%, 0 18%);
  box-shadow: inset 0 -10px 16px rgba(0, 0, 0, .28);
  flex: 0 0 auto;
}
.shirt::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(180deg, transparent 0 46%, var(--c2, #fff) 46% 62%, transparent 62% 100%);
}
.shirt.is-sm { width: 30px; height: 30px; }

.formation-list { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.formation-card {
  display: flex; align-items: center; gap: 14px;
  padding: 12px;
  border-radius: 13px;
  border: 1.5px solid transparent;
  background: var(--panel);
  text-align: left;
  transition: transform .15s, border-color .15s, background .15s;
}
.formation-card:hover { transform: translateX(3px); background: var(--hover); }
.formation-card.is-on { border-color: var(--accent-2); background: rgba(47, 157, 255, .14); }
.mini-pitch {
  width: 60px; height: 60px; flex: 0 0 auto;
  border-radius: 8px;
  background: #2c8651;
  border: 1px solid var(--panel-line);
  position: relative;
  overflow: hidden;
}
.mini-pitch i {
  position: absolute;
  width: 8px; height: 8px; margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #eaf4ff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .35);
}
.formation-meta { display: flex; flex-direction: column; gap: 4px; }
.formation-name { font-size: 15px; font-weight: 700; }
.formation-desc { font-size: 12px; color: var(--ink-dim); line-height: 1.5; }

.setup-foot {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
}
.setup-summary { flex: 1 1 auto; font-size: 13px; color: var(--ink-dim); letter-spacing: .04em; }
.setup-summary b { color: var(--ink); }

/* ---------------- 界面三：规则 ---------------- */
.rules-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.rules-body::-webkit-scrollbar { width: 6px; }
.rules-body::-webkit-scrollbar-thumb { background: var(--panel-line); border-radius: 3px; }
.rules-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rules-hero > div {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
.tag { font-size: 11px; letter-spacing: .2em; color: var(--accent); }
.rules-hero p { margin-top: 7px; font-size: 13.5px; line-height: 1.75; color: var(--ink); opacity: .86; }

.rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px; }
.rule-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
}
.rule-badge {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  color: #04140b;
}
.rule-text { display: flex; flex-direction: column; gap: 3px; }
.rule-name { font-size: 14.5px; font-weight: 700; }
.rule-move { font-size: 12px; color: var(--ink-dim); line-height: 1.55; }
.rule-move b { color: var(--ink); font-weight: 700; }

.rules-note {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px dashed var(--panel-line);
  font-size: 13px; line-height: 1.8; color: var(--ink-dim);
}
.rules-note b { color: var(--ink); }

/* ---------------- 界面四：比赛 ---------------- */
#screen-game { padding-bottom: clamp(10px, 1.6vw, 18px); gap: 12px; }

.scorebar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-line);
}
.team-block { display: flex; align-items: center; gap: 10px; flex: 1 1 0; min-width: 0; }
.team-block.is-right { justify-content: flex-end; }
.sb-name { font-size: 15px; font-weight: 700; white-space: nowrap; }
.sb-poss {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1.5px var(--panel-line);
  flex: 0 0 auto;
  transition: background .2s, box-shadow .2s;
}
.sb-poss.is-on {
  background: radial-gradient(circle at 34% 30%, #ffffff 0 38%, #dfe4ec 39% 100%);
  box-shadow: 0 0 0 2px var(--accent);
}
.turn-box { text-align: center; flex: 0 0 auto; padding: 0 6px; }
.turn-label { font-size: 14px; font-weight: 700; letter-spacing: .06em; }
.turn-label.is-ai { color: #ffb454; }
.turn-label.is-me { color: var(--accent); }
.turn-round { font-size: 11px; color: var(--ink-dim); margin-top: 3px; letter-spacing: .1em; }

.board-wrap { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; }

.pitch {
  position: relative;
  width: min(100%, calc((100vh - 210px) * 0.92));
  aspect-ratio: 9 / 11;
  max-height: 100%;
  border-radius: 18px;
  background:
    repeating-linear-gradient(180deg, #2c8651 0 10%, #268048 10% 20%);
  border: 3px solid rgba(255, 255, 255, .95);
  box-shadow: 0 18px 40px -16px var(--dialog-shadow), inset 0 0 60px rgba(0, 0, 0, .2);
  overflow: hidden;
  touch-action: none;
}

/* 球场线与 8×8 网格放在同一容器内，百分比天然对齐 */
.field {
  position: absolute;
  inset: var(--goal-band) 0;
  border-left: 2px solid rgba(255, 255, 255, .82);
  border-right: 2px solid rgba(255, 255, 255, .82);
}
.pitch-lines { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.line { position: absolute; background: rgba(255, 255, 255, .8); }
.line-halfway { left: 0; right: 0; top: 45%; height: 2px; transform: translateY(-1px); }
.circle {
  position: absolute; left: 50%; top: 45%;
  width: 26%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 50%;
}
.spot { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.85); }
.spot-center { left: 50%; top: 45%; transform: translate(-50%, -50%); }
/* 每格 12.5%（8 列 / 8 行）。禁区内伸 2 格、宽 4 格；小禁区 1 格深、2 格宽 */
/* 禁区从球门线起算（每格 10% 高、11.1% 宽） */
.box { position: absolute; left: 50%; transform: translateX(-50%); border: 2px solid rgba(255, 255, 255, .5); }
.box-top { top: 0; width: 55.5%; height: 20%; border-top: 0; }
.box-top-small { top: 0; width: 33.3%; height: 10%; border-top: 0; }
.box-bottom { bottom: 0; width: 55.5%; height: 20%; border-bottom: 0; }
.box-bottom-small { bottom: 0; width: 33.3%; height: 10%; border-bottom: 0; }
.spot-top-pen { top: 14%; left: 50%; transform: translateX(-50%); }
.spot-bottom-pen { bottom: 14%; left: 50%; transform: translateX(-50%); }

.goal { position: absolute; left: 50%; transform: translateX(-50%); width: 33.3%; display: grid; place-items: center; pointer-events: none; }
.goal-top { top: 0; height: 5.4%; }
.goal-bottom { bottom: 0; height: 5.4%; }
.goal-net {
  width: 100%; height: 100%;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.34) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.34) 0 1px, transparent 1px 5px),
    rgba(255, 255, 255, .18);
  border: 2px solid rgba(255, 255, 255, .85);
}
.goal-top .goal-net { border-top: 0; transform: translateY(-2px); }
.goal-bottom .goal-net { border-bottom: 0; transform: translateY(2px); }

.grid {
  position: absolute; inset: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(10, 1fr);
}
.cell {
  position: relative;
  border-right: 1px dashed rgba(255, 255, 255, .14);
  border-bottom: 1px dashed rgba(255, 255, 255, .14);
}
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+82) { border-bottom: 0; }

.cell.is-target::before {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 26%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 0 10px rgba(255, 255, 255, .7);
  animation: pop .18s ease both;
}
/* 球门：底线中路三格 */
.cell.is-goal {
  background: rgba(255, 255, 255, .13);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55);
}
.cell.is-goal::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 60%; height: 3px; border-radius: 2px;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, .85);
}

/* 球 */
.ball {
  position: absolute;
  left: 50%; top: 50%;
  width: 44%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 6;
  background:
    radial-gradient(circle at 34% 30%, #ffffff 0 38%, #e2e6ec 39% 100%);
  box-shadow: 0 3px 9px rgba(0, 0, 0, .5), inset 0 -2px 4px rgba(0, 0, 0, .18);
  cursor: default;
}
.ball::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(27, 36, 50, .85) 0 22%, transparent 23%),
    radial-gradient(circle at 50% 12%, rgba(27, 36, 50, .55) 0 12%, transparent 13%),
    radial-gradient(circle at 88% 50%, rgba(27, 36, 50, .55) 0 12%, transparent 13%),
    radial-gradient(circle at 50% 88%, rgba(27, 36, 50, .55) 0 12%, transparent 13%),
    radial-gradient(circle at 12% 50%, rgba(27, 36, 50, .55) 0 12%, transparent 13%);
}
.ball.is-free { cursor: grab; }
.ball.is-free::after {
  content: "";
  position: absolute; inset: -24%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .95);
  box-shadow: 0 0 14px rgba(255, 255, 255, .6);
}
@keyframes ballPulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.1); } }

/* 推球目标格 */
.cell.is-ball-target::before {
  content: "";
  position: absolute; inset: 12%;
  border-radius: 50%;
  border: 2.5px dashed rgba(255, 255, 255, .95);
  box-shadow: 0 0 12px rgba(255, 255, 255, .55);
  animation: spin 3.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cell.is-hover::before {
  content: "";
  position: absolute; inset: 2%;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, .8);
  background: rgba(255, 255, 255, .1);
}
.cell.is-from { background: rgba(255, 255, 255, .1); }
.cell.is-last { background: rgba(255, 214, 120, .16); }

.piece {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: clamp(9px, 1.5vw, 13px);
  font-weight: 800;
  color: #fff;
  letter-spacing: .02em;
  background: radial-gradient(circle at 32% 26%, rgba(255,255,255,.55), transparent 46%), var(--c1);
  border: 2px solid var(--c2);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .45);
  cursor: grab;
  z-index: 3;
  transition: transform .16s ease;
}
.piece:hover { transform: scale(1.07); }
.piece.is-mine { cursor: grab; }
.piece.is-locked { cursor: default; opacity: .96; }
.piece.is-selected {
  transform: scale(1.14);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .85), 0 6px 16px rgba(0, 0, 0, .5);
  z-index: 4;
}
.piece.is-gk { border-style: dashed; }
.piece.is-hidden { opacity: 0; pointer-events: none; }

.drag-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.drag-layer .piece {
  position: absolute;
  width: auto; height: auto;
  inset: auto;
  cursor: grabbing;
  transform: scale(1.16);
  box-shadow: 0 14px 26px rgba(0, 0, 0, .55);
}
.drag-layer .ball {
  position: absolute;
  inset: auto;
  cursor: grabbing;
  transform: scale(1.18);
  box-shadow: 0 12px 22px rgba(0, 0, 0, .5);
  animation: none;
}
.drag-layer .ball::after { display: none; }

/* 推球阶段：底部提示条高亮 */
.foot-hint.is-ball { color: var(--accent); font-weight: 700; }
.turn-label.is-ball { color: var(--ball-phase); }

.game-foot { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }
.foot-hint { flex: 1 1 auto; text-align: center; font-size: 12px; color: var(--ink-dim); letter-spacing: .05em; }

/* ---------------- 结算弹窗 ---------------- */
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  z-index: 40;
  animation: fade .25s ease both;
}
.overlay[hidden] { display: none; }
.dialog {
  width: min(88vw, 380px);
  padding: 30px 26px 24px;
  border-radius: 22px;
  text-align: center;
  background: var(--dialog-bg);
  border: 1px solid var(--panel-line);
  box-shadow: 0 30px 70px -18px var(--dialog-shadow);
  animation: rise .32s cubic-bezier(.2, 1.2, .4, 1) both;
}
@keyframes rise { from { transform: translateY(26px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-mark { font-size: 46px; line-height: 1; }
.dialog-title { font-size: 28px; font-weight: 900; letter-spacing: .1em; margin: 12px 0 8px; }
.dialog-title.is-win { color: var(--accent); }
.dialog-title.is-lose { color: var(--lose); }
.dialog-title.is-draw { color: var(--draw); }
.dialog-desc { font-size: 14px; line-height: 1.8; color: var(--ink-dim); margin-bottom: 22px; }
.dialog-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------------- 窄屏 ---------------- */
@media (max-width: 860px) {
  .setup-body { grid-template-columns: 1fr; overflow-y: auto; }
  .panel { min-height: auto; }
  .team-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .rules-hero { grid-template-columns: 1fr; }
  .pitch { width: 100%; }
  .sb-name { font-size: 13px; }
}
/* ============================================================
   新增组件：半格门将 / 传球射门 / 提示 / 主题
   ============================================================ */

/* 半格门将层 */
.keeper-layer { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.keeper {
  position: absolute;
  width: calc(100% / 9 * .74);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(8px, 1.2vw, 11px);
  font-weight: 800;
  background: radial-gradient(circle at 32% 26%, rgba(255,255,255,.55), transparent 46%), var(--c1);
  border: 2px solid var(--c2);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .45);
  white-space: nowrap;
}
.keeper.is-mine-active { pointer-events: auto; cursor: ew-resize; }
.keeper.is-mine-active:hover { transform: translate(-50%, -50%) scale(1.08); }
.keeper.is-ai { opacity: .96; }

/* 传球 / 射门 操作栏 */
.action-bar {
  flex: 0 0 auto;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
}
.action-bar.is-on { display: flex; animation: pop .2s ease both; }
.action-label { font-size: 13px; color: var(--accent); font-weight: 700; letter-spacing: .06em; }
.action-btn {
  padding: 8px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-dim);
  border: 1.5px solid var(--panel-line);
  background: var(--bg-2);
  transition: all .15s;
}
.action-btn:hover { color: var(--ink); border-color: var(--ink-dim); }
.action-btn.is-on {
  color: var(--primary-ink);
  background: var(--primary-bg);
  border-color: transparent;
  box-shadow: 0 6px 16px -6px var(--primary-shadow);
}

/* 射门目标：红环强调 */
.cell.is-shoot::before {
  content: "";
  position: absolute; inset: 6%;
  border-radius: 50%;
  border: 3px solid rgba(255, 92, 92, .95);
  box-shadow: 0 0 14px rgba(255, 70, 70, .8), inset 0 0 12px rgba(255, 80, 80, .35);
  animation: pop .18s ease both;
}
.cell.is-shoot { background: rgba(255, 70, 70, .22); }

/* 被门将封堵的球门角：灰色虚线圈 */
.cell.is-blocked::before {
  content: "";
  position: absolute; inset: 8%;
  border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, .45);
  animation: pop .18s ease both;
}

/* 提示浮层 */
.toast {
  position: absolute;
  left: 50%; top: 46%;
  transform: translate(-50%, -50%) scale(.9);
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .1em;
  color: #fff;
  background: rgba(20, 20, 24, .86);
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 30;
}
.toast.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* 主题选择器 */
.theme-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
}
.theme-label { font-size: 12px; color: var(--ink-dim); letter-spacing: .12em; }
.theme-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-dim);
  border: 1.5px solid var(--panel-line);
  background: var(--bg-2);
  transition: all .15s;
}
.theme-dot:hover { color: var(--ink); transform: translateY(-2px); }
.theme-dot.is-on {
  color: var(--primary-ink);
  background: var(--primary-bg);
  border-color: transparent;
}

/* ============================================================
   首页控制区
   ============================================================ */
.home-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ============================================================
   横屏布局：棋盘按高度撑满，场地不再被压扁
   ============================================================ */
:root[data-layout="landscape"] #screen-game { display: none; }
:root[data-layout="landscape"] #screen-game.is-active {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "bar    bar"
    "board  side"
    "foot   side";
  align-items: stretch;
  column-gap: 18px;
  row-gap: 10px;
}
/* 棋盘区必须能拿到高度 */
:root[data-layout="landscape"] #screen-game .board-wrap {
  grid-area: board;
  min-height: 0;
  height: 100%;
}
/* 右侧栏堆叠记分条与操作栏 */
:root[data-layout="landscape"] .side-stack {
  grid-area: side;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 0; overflow: auto;
}
:root[data-layout="landscape"] #screen-game .scorebar { flex-direction: column; gap: 8px; }
:root[data-layout="landscape"] #screen-game .action-bar { flex-direction: column; border-radius: var(--radius); padding: 12px; }
:root[data-layout="landscape"] #screen-game .action-label { display: block; text-align: center; }
:root[data-layout="landscape"] #screen-game .game-foot { grid-area: foot; flex-direction: row; }
:root[data-layout="landscape"] .game-layout-bar { grid-area: bar; display: flex; gap: 12px; justify-content: flex-end; }

/* 记分条在横屏里竖排显示 */
:root[data-layout="landscape"] .scorebar { padding: 14px; }
:root[data-layout="landscape"] .scorebar .team-block,
:root[data-layout="landscape"] .scorebar .team-block.is-right {
  flex-direction: row;
  justify-content: flex-start;
  width: 100%;
}
:root[data-layout="landscape"] .scorebar .sb-name { font-size: 15px; }
:root[data-layout="landscape"] .scorebar .turn-box { width: 100%; padding: 6px 0; border-block: 1px solid var(--panel-line); }
:root[data-layout="landscape"] .scorebar .turn-label { font-size: 15px; }

/* 横屏下棋盘按可用高度计算，不再被宽度挤压 */
:root[data-layout="landscape"] .pitch {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 10.6;
}
:root[data-layout="landscape"] .foot-hint { text-align: left; }

/* 竖屏时维持原样 */
:root[data-layout="portrait"] .pitch {
  width: min(100%, calc((100vh - 240px) * 0.86));
}
