:root {
  --bg: #030814;
  --bg-2: #061225;
  --panel: rgba(17, 37, 72, 0.62);
  --panel-2: rgba(8, 20, 40, 0.88);
  --line: rgba(125, 166, 255, 0.16);
  --line-strong: rgba(147, 197, 253, 0.45);
  --text: #eef5ff;
  --muted: #91a7cb;
  --blue: #2f6bff;
  --blue-2: #5b9bff;
  --cyan: #7dd3fc;
  --white: #ffffff;
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 50% -12%, rgba(37, 99, 235, 0.32), transparent 62%),
    radial-gradient(900px 540px at 100% 108%, rgba(96, 165, 250, 0.13), transparent 60%),
    radial-gradient(760px 520px at -10% 100%, rgba(30, 64, 175, 0.18), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  right: -120px;
  bottom: -135px;
  width: 500px;
  height: 500px;
  background: url("assets/fcdb_white.svg") no-repeat center / contain;
  opacity: 0.022;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1020px;
  padding: 14px 16px 28px;
}

.hidden { display: none !important; }

/* ---------- Верхняя панель ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-crest {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.38), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(147, 197, 253, 0.35);
  box-shadow: 0 12px 30px rgba(29, 78, 216, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.brand-crest img { width: 38px; height: 38px; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35)); }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 800; font-size: 17px; letter-spacing: 0.2px; color: #f5f9ff; }
.brand-sub { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.1px; }

.topbar-tag {
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  text-decoration: none;
  color: #cfe3ff;
  border: 1px solid rgba(147, 197, 253, 0.3);
  background: rgba(59, 130, 246, 0.1);
  border-radius: 999px;
  padding: 5px 12px;
  transition: background 0.15s, border-color 0.15s;
}

/* ---------- Панели, кнопки ---------- */
.panel {
  background: linear-gradient(180deg, rgba(23, 47, 90, 0.7), rgba(7, 18, 36, 0.66));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.screen { display: none; }
.screen.active { display: block; animation: screenIn 0.28s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

h1 { font-size: 30px; letter-spacing: -0.4px; }
h2 { font-size: 20px; letter-spacing: -0.2px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 12px 0 8px; }
h3:first-child { margin-top: 0; }
p { line-height: 1.55; }
.muted { color: var(--muted); font-size: 13px; }

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #417fef, #2053c8);
  box-shadow: 0 8px 20px rgba(29, 78, 216, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, opacity 0.12s;
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(29, 78, 216, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22); }
button:active:not(:disabled) { transform: translateY(0) scale(0.985); }
button:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

button.primary {
  background: linear-gradient(180deg, #ffffff, #d7e6ff);
  color: #071a36;
  box-shadow: 0 10px 26px rgba(96, 165, 250, 0.3), inset 0 1px 0 #ffffff;
}
button.primary:hover:not(:disabled) { background: #ffffff; box-shadow: 0 14px 32px rgba(96, 165, 250, 0.42), inset 0 1px 0 #ffffff; }

button.secondary {
  background: rgba(125, 166, 255, 0.1);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: none;
}
button.secondary:hover:not(:disabled) { background: rgba(125, 166, 255, 0.18); box-shadow: none; }

button.ghost { background: transparent; border: 1px solid transparent; color: var(--muted); box-shadow: none; }
button.ghost:hover:not(:disabled) { color: #fff; background: rgba(125, 166, 255, 0.08); box-shadow: none; }

button.big { padding: 14px 26px; font-size: 15px; border-radius: 14px; }

/* ---------- Меню ---------- */
.menu-box {
  padding: 34px 26px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.menu-box::before {
  content: "";
  position: absolute;
  inset: -45% -10% auto;
  height: 320px;
  background: radial-gradient(closest-side, rgba(59, 130, 246, 0.35), transparent);
  pointer-events: none;
}

.hero-crest {
  position: relative;
  width: 132px;
  height: 132px;
  margin: 0 auto 18px;
  padding: 15px;
  border-radius: 36px;
  background: linear-gradient(180deg, #ffffff, #e6f0ff);
  box-shadow: 0 28px 70px rgba(37, 99, 235, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.75), inset 0 2px 0 #ffffff;
  animation: crestFloat 4.2s ease-in-out infinite;
}
.hero-crest img { width: 100%; height: 100%; display: block; }
@keyframes crestFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.menu-box h1 { margin-top: 6px; }
.hero-sub {
  margin-top: 6px;
  color: #9fc0f5;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2.2px;
}
.menu-box .lead { max-width: 640px; margin: 14px auto 0; color: var(--muted); font-size: 14.5px; }
.menu-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 24px 0 30px; position: relative; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: left; }
.feature {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(4, 12, 26, 0.5);
  border: 1px solid rgba(125, 166, 255, 0.12);
}
.feature strong { font-size: 13px; }
.feature span:last-child { font-size: 12px; color: var(--muted); line-height: 1.45; }
.feature-icon { color: var(--cyan); }
.feature-icon svg { width: 24px; height: 24px; display: block; filter: drop-shadow(0 4px 10px rgba(59, 130, 246, 0.4)); }

/* ---------- Состав ---------- */
.squad-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.squad-title { min-width: 0; }
.squad-actions { display: flex; gap: 8px; padding-top: 2px; }
.squad-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.column { padding: 16px; }
.column h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.source-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(125, 166, 255, 0.08);
  color: #cfe3ff;
  white-space: nowrap;
}
.source-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px rgba(125, 211, 252, 0.8); }
.source-chip.loading .source-dot { animation: pulse 1s ease-in-out infinite; }
.source-chip.offline { color: #fcd34d; border-color: rgba(251, 191, 36, 0.25); }
.source-chip.offline .source-dot { background: #fbbf24; box-shadow: 0 0 8px rgba(251, 191, 36, 0.7); }
.refresh-btn {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 9px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: none;
}
.refresh-btn:hover:not(:disabled) { background: rgba(125, 166, 255, 0.1); color: #fff; box-shadow: none; }

.counter {
  font-size: 11px;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(125, 166, 255, 0.12);
  color: var(--text);
}
.counter.full { background: rgba(96, 165, 250, 0.28); color: #dbeafe; }

.player-list { max-height: min(420px, 36vh); overflow-y: auto; padding-right: 3px; scrollbar-width: thin; }
.player-list::-webkit-scrollbar { width: 7px; }
.player-list::-webkit-scrollbar-thumb { background: rgba(147, 197, 253, 0.18); border-radius: 99px; }

.player-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 11px;
  margin-bottom: 6px;
  background: rgba(125, 166, 255, 0.045);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.player-item:hover { background: rgba(125, 166, 255, 0.09); }
.player-item.selected {
  background: linear-gradient(90deg, rgba(47, 107, 255, 0.3), rgba(47, 107, 255, 0.08));
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: inset 3px 0 0 var(--blue-2);
}
.player-item.selected .player-name::after { content: " ✓"; color: #93c5fd; }

.player-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #21457f, #0b1c36);
  border: 1px solid rgba(147, 197, 253, 0.18);
}
.player-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback { font-size: 12px; font-weight: 800; color: #cfe3ff; letter-spacing: 0.5px; }

.player-info { flex: 1; min-width: 0; }
.player-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.player-meta b { color: #dbeafe; font-weight: 700; }
.captain {
  display: inline-block;
  margin-left: 2px;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  color: #07224a;
  background: #93c5fd;
  vertical-align: 2px;
}

.player-number {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-weight: 800;
  font-size: 12.5px;
  color: #dbeafe;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(125, 166, 255, 0.18);
}

.player-item button { padding: 5px 10px; font-size: 11.5px; border-radius: 9px; box-shadow: none; }

.selected-panel { margin-top: 14px; padding: 16px; }
.selected-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.selected-list { list-style: none; display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; min-height: 34px; }
.selected-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  background: rgba(125, 166, 255, 0.07);
  border: 1px solid var(--line);
}
.selected-list .pnum {
  font-size: 10.5px;
  font-weight: 800;
  color: #dbeafe;
  background: rgba(96, 165, 250, 0.18);
  border-radius: 6px;
  padding: 1px 5px;
}
.selected-list .pempty { opacity: 0.5; border-style: dashed; }

.squad-footer { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- Матч ---------- */
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(22, 47, 92, 0.82), rgba(7, 18, 36, 0.82));
  border: 1px solid rgba(125, 166, 255, 0.18);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.hud-team { display: flex; align-items: center; gap: 9px; min-width: 0; }
.hud-team.away { justify-content: flex-end; text-align: right; }
.hud-crest {
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(125, 166, 255, 0.12);
  border: 1px solid var(--line);
}
.hud-crest img { width: 21px; height: 21px; }
.team-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.hud-team.away .team-dot { background: #e5edff; box-shadow: 0 0 12px rgba(229, 237, 255, 0.65); }
.team-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.team-name { font-weight: 800; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-note { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }

.hud-center { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0 10px; }
.hud-score {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.hud-score > span { display: inline-block; }
.hud-score > span.pop { animation: scorePop 0.55s cubic-bezier(.2, 1.4, .5, 1); color: #dff3ff; text-shadow: 0 0 20px rgba(125, 211, 252, 0.8); }
@keyframes scorePop { 0% { transform: scale(1); } 35% { transform: scale(1.55); } 100% { transform: scale(1); } }
.score-sep { color: var(--muted); font-weight: 700; }
.hud-timer { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.hud-timer.waiting { color: var(--cyan); animation: pulse 1.4s ease-in-out infinite; }
.hud-timer.waiting::after { content: " · старт"; font-size: 9px; letter-spacing: 0.4px; color: var(--cyan); opacity: 0.9; }
.hud-timer.low { color: #fca5a5; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-size: 12px;
  letter-spacing: 1px;
  background: rgba(125, 166, 255, 0.1);
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--text);
}
.icon-btn:hover:not(:disabled) { background: rgba(125, 166, 255, 0.2); box-shadow: none; }

#game-wrap {
  position: relative;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(147, 197, 253, 0.12);
  background: #061626;
}
canvas { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }

.game-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translate(-50%, -8px);
  max-width: calc(100% - 32px);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  color: #eaf4ff;
  background: rgba(3, 12, 26, 0.78);
  border: 1px solid rgba(147, 197, 253, 0.22);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 3;
}
.game-hint.show { opacity: 1; transform: translate(-50%, 0); }

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
}
.controls-hint b { color: rgba(238, 245, 255, 0.9); font-weight: 700; }

/* Пауза */
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(2, 8, 20, 0.68);
  backdrop-filter: blur(6px);
}
.pause-card { padding: 26px 30px; text-align: center; min-width: 250px; }
.pause-card h2 { margin-bottom: 4px; }
.pause-actions { display: flex; gap: 9px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* Мобильное управление */
.mobile-controls { display: none; position: absolute; inset: 0; pointer-events: none; z-index: 4; }

.joystick {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(191, 219, 254, 0.18), rgba(59, 130, 246, 0.08) 62%, rgba(3, 12, 26, 0.2));
  border: 1px solid rgba(191, 219, 254, 0.3);
  pointer-events: auto;
  touch-action: none;
  box-shadow: inset 0 8px 24px rgba(0, 0, 0, 0.3);
}
.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffffff, #c7dcff 70%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.05s linear;
}

.action-btn,
.switch-btn {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.4px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.action-btn:active,
.switch-btn:active { transform: scale(0.94); filter: brightness(1.12); }

.action-btn.shoot {
  right: 16px;
  bottom: 22px;
  width: 76px;
  height: 76px;
  font-size: 13px;
  color: #071a36;
  background: linear-gradient(180deg, #ffffff, #cfe0ff);
}
.action-btn.pass {
  right: 104px;
  bottom: 18px;
  width: 62px;
  height: 62px;
  background: linear-gradient(180deg, #6ea8ff, #2f6bff);
}
.action-btn.loft {
  right: 106px;
  bottom: 92px;
  width: 54px;
  height: 54px;
  font-size: 10.5px;
  background: linear-gradient(180deg, #a5f3fc, #0891b2);
  color: #062a33;
}
.switch-btn {
  right: 18px;
  bottom: 112px;
  width: 58px;
  height: 58px;
  font-size: 10.5px;
  background: linear-gradient(180deg, rgba(147, 197, 253, 0.4), rgba(37, 74, 140, 0.5));
}

/* ---------- Результат ---------- */
.result-box { max-width: 520px; margin: 30px auto 0; padding: 30px 24px; text-align: center; }
.result-hero { position: relative; width: 104px; height: 104px; margin: 0 auto 14px; }
.result-crest {
  width: 104px;
  height: 104px;
  padding: 12px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffffff, #e6f0ff);
  box-shadow: 0 24px 60px rgba(37, 99, 235, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.75);
}
.result-crest img { width: 100%; height: 100%; }
.result-badge {
  position: absolute;
  right: -10px;
  bottom: -8px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 21px;
  background: linear-gradient(180deg, #17356a, #0a1c38);
  border: 1px solid rgba(147, 197, 253, 0.35);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
}
.result-score {
  font-size: 58px;
  font-weight: 900;
  letter-spacing: 2px;
  margin: 14px 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-variant-numeric: tabular-nums;
}
#res-text { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.result-stats { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.result-details { display: flex; flex-direction: column; gap: 11px; margin-bottom: 20px; text-align: left; }

.goal-log {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(4, 12, 26, 0.5);
  border: 1px solid var(--line);
}
.detail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.detail-head h3 { margin: 0; }
.detail-head .muted { font-size: 11px; }
#res-goals {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  max-height: 168px;
  overflow-y: auto;
  scrollbar-width: thin;
}
#res-goals::-webkit-scrollbar { width: 6px; }
#res-goals::-webkit-scrollbar-thumb { background: rgba(147, 197, 253, 0.18); border-radius: 99px; }
.goal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 12.5px;
  border-bottom: 1px solid rgba(125, 166, 255, 0.08);
}
.goal-row:last-child { border-bottom: 0; }
.goal-min {
  flex: 0 0 34px;
  font-weight: 800;
  color: #dbeafe;
  font-variant-numeric: tabular-nums;
}
.goal-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.goal-row.home .goal-dot { background: var(--blue-2); box-shadow: 0 0 8px rgba(91, 155, 255, 0.8); }
.goal-row.away .goal-dot { background: #e5edff; box-shadow: 0 0 8px rgba(229, 237, 255, 0.6); }
.goal-scorer { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-num { color: var(--muted); font-size: 10.5px; margin-left: 3px; }
.goal-score { font-weight: 800; color: #dbeafe; font-variant-numeric: tabular-nums; }
.goal-empty { color: var(--muted); font-size: 12.5px; padding: 5px 0; }

.best-player {
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(47, 107, 255, 0.22), rgba(4, 12, 26, 0.5));
  border: 1px solid rgba(96, 165, 250, 0.3);
}
.best-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #9fc0f5;
  margin-bottom: 8px;
}
.best-card { display: flex; align-items: center; gap: 11px; }
.best-avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #21457f, #0b1c36);
  border: 2px solid rgba(147, 197, 253, 0.5);
  position: relative;
}
.best-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.best-avatar .avatar-fallback { font-size: 14px; }
.best-name { font-weight: 800; font-size: 14px; }
.best-team { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin-left: 6px; }
.best-stats { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.result-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.player-stats {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(4, 12, 26, 0.5);
  border: 1px solid var(--line);
  text-align: left;
}
.player-stats .detail-head h3 { font-size: 11px; }
.stats-scroll { margin-top: 8px; overflow-x: auto; scrollbar-width: thin; }
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.stats-table th {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 700;
  padding: 4px 3px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
.stats-table th.st-player,
.stats-table td.st-player { text-align: left; }
.stats-table td {
  padding: 4px 3px;
  border-bottom: 1px solid rgba(125, 166, 255, 0.08);
  text-align: right;
}
.stats-table tr:last-child td { border-bottom: 0; }
.stats-table td.st-player {
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.st-num { display: inline-block; min-width: 20px; color: var(--muted); font-size: 9px; }
.stats-table tr.best td { background: rgba(96, 165, 250, 0.1); }
.stats-table tr.best td.st-player { color: #ffffff; font-weight: 700; }
.stats-table tr.best td.st-player::before { content: "★ "; color: var(--cyan); }
.stats-legend { margin-top: 6px; font-size: 9.5px; color: var(--muted); line-height: 1.5; }

/* ---------- Адаптивность ---------- */
@media (max-width: 820px) {
  .feature-grid { grid-template-columns: 1fr; }
  .player-list { max-height: 230px; }
}

@media (max-width: 820px), (pointer: coarse) {
  .mobile-controls { display: block; }
  .controls-hint { display: none; }
}

@media (max-width: 700px) {
  #app { padding: 10px 10px 22px; }
  body.in-game .topbar { display: none; }
  .topbar { padding-bottom: 12px; }
  .topbar-tag { display: none; }
  .squad-layout { grid-template-columns: 1fr; }
  .squad-head { margin-bottom: 10px; }
  .squad-actions { width: 100%; }
  .squad-actions button { flex: 1; }
  .menu-box { padding: 26px 16px 20px; }
  .menu-actions button { flex: 1 1 150px; }
  h1 { font-size: 25px; }
  .hero-crest { width: 108px; height: 108px; padding: 13px; border-radius: 30px; }
  .hud { grid-template-columns: 1fr auto 1fr auto; padding: 8px 10px; gap: 6px; }
  .hud-crest { width: 24px; height: 24px; }
  .hud-crest img { width: 18px; height: 18px; }
  .team-name { font-size: 13px; }
  .hud-score { font-size: 21px; }
  .icon-btn { width: 34px; height: 34px; }
  .game-hint { font-size: 11.5px; padding: 6px 11px; }
  .result-score { font-size: 46px; }
  .result-hero, .result-crest { width: 92px; height: 92px; }
}

@media (max-width: 820px) and (orientation: portrait) {
  .mobile-controls {
    position: relative;
    inset: auto;
    height: 152px;
    background: linear-gradient(180deg, rgba(3, 12, 26, 0.5), rgba(3, 12, 26, 0.85));
    border-top: 1px solid rgba(147, 197, 253, 0.12);
  }
}

@media (max-width: 420px) {
  .brand-sub { display: none; }
  .brand-title { font-size: 15px; }
  .brand-crest { width: 42px; height: 42px; border-radius: 12px; }
  .brand-crest img { width: 34px; height: 34px; }
  .team-note { display: none; }
  .hud-score { font-size: 19px; }
  .player-number { display: none; }
  .joystick { width: 100px; height: 100px; left: 10px; bottom: 10px; }
  .joystick-knob { width: 42px; height: 42px; }
  .action-btn.shoot { width: 68px; height: 68px; right: 12px; bottom: 18px; }
  .action-btn.pass { width: 56px; height: 56px; right: 88px; bottom: 14px; }
  .action-btn.loft { width: 46px; height: 46px; right: 92px; bottom: 76px; font-size: 9px; }
  .switch-btn { width: 52px; height: 52px; right: 14px; bottom: 96px; }
}

/* ---------- Только альбомная ориентация на телефоне ---------- */
.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(760px 440px at 50% -10%, rgba(37, 99, 235, 0.38), transparent 62%),
    #030814;
}

@media (pointer: coarse) and (orientation: portrait) {
  html, body { overflow: hidden; }
  .rotate-overlay { display: flex; }
}

.rotate-card { max-width: 330px; }
.rotate-crest {
  width: 96px;
  height: 96px;
  margin: 0 auto 18px;
  padding: 12px;
  border-radius: 26px;
  background: linear-gradient(180deg, #ffffff, #e6f0ff);
  box-shadow: 0 24px 60px rgba(37, 99, 235, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.75);
}
.rotate-crest img { width: 100%; height: 100%; }
.rotate-card h2 { font-size: 21px; margin-bottom: 8px; }
.rotate-card p { color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* Мобильный ландшафт: всё в один экран, без прокрутки страницы */
@media (pointer: coarse) and (orientation: landscape) {
  html, body { height: 100%; overflow: hidden; }
  #app {
    height: 100vh;
    height: 100dvh;
    max-width: none;
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
  }
  .topbar { display: none; }
  .screen.active {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    animation: none;
  }

  /* Меню */
  .menu-box {
    margin: auto;
    width: 100%;
    max-width: 780px;
    max-height: 100%;
    overflow-y: auto;
    padding: 14px 20px 16px;
  }
  .hero-crest { width: 72px; height: 72px; padding: 9px; border-radius: 20px; margin-bottom: 8px; animation: none; }
  .menu-box h1 { font-size: 23px; margin-top: 2px; }
  .hero-sub { font-size: 9.5px; letter-spacing: 1.8px; }
  .menu-box .lead { font-size: 12px; margin-top: 6px; }
  .menu-actions { margin: 12px 0 0; }
  .feature-grid { display: none; }

  /* Матч */
  #screen-game .hud { flex: 0 0 auto; padding: 4px 10px; margin-bottom: 4px; border-radius: 12px; }
  #screen-game .hud-crest { width: 22px; height: 22px; }
  #screen-game .hud-crest img { width: 17px; height: 17px; }
  #screen-game .team-name { font-size: 12px; }
  #screen-game .team-note { display: none; }
  #screen-game .hud-score { font-size: 20px; }
  #screen-game .hud-timer { font-size: 10px; }
  #screen-game .icon-btn { width: 30px; height: 30px; }
  #screen-game #game-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
  }
  #screen-game canvas { width: auto; height: auto; max-width: 100%; max-height: 100%; }
  #screen-game .controls-hint { display: none; }
  #screen-game .game-hint { top: 6px; font-size: 10.5px; padding: 5px 10px; }

  /* Состав */
  #screen-squad .squad-head { flex: 0 0 auto; margin-bottom: 6px; gap: 8px; }
  #screen-squad .squad-title h2 { font-size: 16px; }
  #screen-squad .squad-title .muted { display: none; }
  #screen-squad .source-row { margin-top: 4px; }
  #screen-squad .source-chip { font-size: 10px; padding: 3px 8px; }
  #screen-squad .refresh-btn { font-size: 10px; padding: 3px 8px; }
  #screen-squad .squad-actions { padding-top: 0; gap: 6px; width: auto; }
  #screen-squad .squad-actions button { padding: 6px 12px; font-size: 12px; flex: 0 0 auto; }
  #screen-squad .squad-layout { flex: 1 1 auto; min-height: 0; gap: 8px; }
  #screen-squad .column { min-height: 0; display: flex; flex-direction: column; padding: 8px 10px; }
  #screen-squad .column h3 { font-size: 10px; letter-spacing: 0.8px; margin: 3px 0 4px; }
  #screen-squad .column h3:first-child { margin-top: 0; }
  #screen-squad .player-list { flex: 1 1 0; min-height: 0; max-height: none; }
  #screen-squad .player-item { padding: 3px 5px; margin-bottom: 4px; gap: 6px; }
  #screen-squad .player-avatar { width: 28px; height: 28px; border-radius: 7px; }
  #screen-squad .player-name { font-size: 11.5px; }
  #screen-squad .player-meta { font-size: 9px; margin-top: 1px; }
  #screen-squad .player-number { width: 24px; height: 24px; font-size: 10px; border-radius: 7px; }
  #screen-squad .player-item button { padding: 3px 7px; font-size: 9.5px; }
  #screen-squad .selected-panel { display: none; }
  #screen-squad .squad-footer { flex: 0 0 auto; margin-top: 5px; }
  #screen-squad .squad-footer button { padding: 7px 14px; font-size: 12px; }

  /* Результат */
  #screen-result .result-box {
    margin: auto;
    width: 100%;
    max-width: 900px;
    max-height: 100%;
    overflow-y: auto;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    grid-template-areas: "summary details" "actions details" "stats stats";
    gap: 8px 16px;
    align-items: start;
    text-align: center;
  }
  #screen-result .result-summary { grid-area: summary; }
  #screen-result .result-details { grid-area: details; margin-bottom: 0; text-align: left; gap: 7px; }
  #screen-result .result-actions { grid-area: actions; }
  #screen-result .player-stats { grid-area: stats; margin-top: 0; padding: 7px 9px; }
  #screen-result .stats-scroll { max-height: 126px; overflow-y: auto; }
  #screen-result .stats-table { font-size: 9px; }
  #screen-result .stats-table th { font-size: 8px; padding: 2px; }
  #screen-result .stats-table td { padding: 2px; }
  #screen-result .stats-table td.st-player { max-width: 120px; }
  #screen-result .stats-legend { font-size: 8px; margin-top: 3px; }
  #screen-result .result-hero, #screen-result .result-crest { width: 68px; height: 68px; }
  #screen-result .result-crest { border-radius: 18px; padding: 8px; }
  #screen-result .result-badge { width: 30px; height: 30px; font-size: 15px; right: -6px; bottom: -5px; }
  #screen-result h2 { font-size: 14px; }
  #screen-result .result-score { font-size: 38px; margin: 4px 0 2px; gap: 8px; }
  #screen-result #res-text { font-size: 12px; margin-bottom: 3px; }
  #screen-result .result-stats { font-size: 10.5px; margin-bottom: 4px; }
  #screen-result .result-actions button { padding: 7px 12px; font-size: 11.5px; }
  #screen-result .goal-log { padding: 7px 9px; }
  #screen-result .detail-head h3 { font-size: 10px; }
  #screen-result .detail-head .muted { font-size: 9px; }
  #screen-result #res-goals { max-height: 110px; margin-top: 4px; }
  #screen-result .goal-row { padding: 2px 0; font-size: 10.5px; gap: 6px; }
  #screen-result .goal-min { flex-basis: 28px; }
  #screen-result .best-player { padding: 7px 9px; }
  #screen-result .best-label { font-size: 8.5px; margin-bottom: 4px; }
  #screen-result .best-avatar { width: 32px; height: 32px; }
  #screen-result .best-name { font-size: 11.5px; }
  #screen-result .best-stats { font-size: 9.5px; margin-top: 2px; }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  .joystick { width: 92px; height: 92px; left: 10px; bottom: 10px; }
  .joystick-knob { width: 38px; height: 38px; }
  .action-btn.shoot { width: 64px; height: 64px; right: 12px; bottom: 16px; font-size: 12px; }
  .action-btn.pass { width: 52px; height: 52px; right: 82px; bottom: 12px; }
  .action-btn.loft { width: 42px; height: 42px; right: 84px; bottom: 68px; font-size: 8px; }
  .switch-btn { width: 48px; height: 48px; right: 14px; bottom: 86px; font-size: 9.5px; }
}
