* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at top, #1b2a3a, #0b1119 70%);
  color: #e8eef4;
  min-height: 100vh;
}
header { text-align: center; padding: 18px 0 6px; }
h1 { margin: 0; font-size: 28px; letter-spacing: .5px; }
h2 { font-size: 16px; margin: 0 0 10px; color: #9fb3c8; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; }
main { max-width: 980px; margin: 0 auto; padding: 10px 12px 30px; }
.hidden { display: none !important; }

.panel { background: #142130; border: 1px solid #22364b; border-radius: 14px; padding: 22px; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 640px) { .setup-grid { grid-template-columns: 1fr; } }
.team-list { display: grid; gap: 6px; max-height: 360px; overflow-y: auto; padding-right: 6px; }
.team-list::-webkit-scrollbar { width: 8px; }
.team-list::-webkit-scrollbar-thumb { background: #2b4a68; border-radius: 4px; }
.league-head { font-size: 12px; font-weight: 700; color: #4fc3f7; text-transform: uppercase; letter-spacing: 1px; margin: 8px 0 2px 4px; }
.team-list.tall { max-height: 420px; margin: 14px 0 0; }
.league { margin-left: auto; font-size: 11px; color: #7f95ab; background: #101b27; padding: 2px 7px; border-radius: 6px; }
.team-btn {
  display: flex; align-items: center; gap: 10px;
  background: #1a2a3c; border: 2px solid transparent; color: inherit;
  padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 15px; text-align: left;
}
.team-btn:hover { background: #20344a; }
.team-btn.active { border-color: #4fc3f7; background: #1f3850; }
.team-btn:disabled { opacity: .35; cursor: not-allowed; }
.badge {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 3px solid; box-shadow: 0 0 0 1px #0006;
}
.setup-row { margin-top: 22px; }
.fk-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.fk-side .howto { margin-top: 16px; }
.fk-side .primary { margin-top: 16px; }
.fk-best { margin-top: 14px; color: #ffd54f; font-weight: 600; }
@media (max-width: 720px) { .fk-top { grid-template-columns: 1fr; } }
.seg { display: inline-flex; background: #1a2a3c; border-radius: 10px; padding: 4px; gap: 4px; }
.seg button { background: none; border: 0; color: #9fb3c8; padding: 8px 16px; border-radius: 7px; cursor: pointer; font-size: 15px; }
.seg button.active { background: #2b4a68; color: #fff; }
.howto { margin-top: 20px; font-size: 14px; color: #b8c7d6; line-height: 1.5; background: #101b27; border-radius: 10px; padding: 6px 16px; }
kbd { background: #2b3d52; border-radius: 4px; padding: 1px 6px; margin: 0 1px; font-family: inherit; font-size: 12px; border-bottom: 2px solid #1a2736; }
button.primary {
  margin-top: 20px; width: 100%;
  background: linear-gradient(#43a047, #2e7d32); color: #fff; border: 0;
  padding: 14px; font-size: 18px; font-weight: 600; border-radius: 10px; cursor: pointer;
}
button.primary:hover { filter: brightness(1.1); }

.board { display: grid; gap: 6px; margin-bottom: 10px; }
.board-row {
  display: flex; align-items: center; gap: 12px;
  background: #142130; border: 1px solid #22364b; border-radius: 10px; padding: 8px 14px;
}
.board-row.turn { border-color: #4fc3f7; }
.board-name { flex: 1; font-weight: 600; display: flex; align-items: center; gap: 10px; min-width: 0; }
.board-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dot { width: 18px; height: 18px; border-radius: 50%; background: #2a3b4e; border: 2px solid #3a4f66; }
.dot.goal { background: #43a047; border-color: #81c784; }
.dot.miss { background: #e53935; border-color: #ef9a9a; }
.board-score { font-size: 24px; font-weight: 700; width: 34px; text-align: right; }

.canvas-wrap { position: relative; border-radius: 14px; overflow: hidden; box-shadow: 0 10px 40px #0008; }
canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; background: #0d1a10; }
.status { text-align: center; color: #b8c7d6; min-height: 22px; margin: 10px 0 0; }

/* Окно итога — внизу, чтобы не закрывать празднование команды */
.over {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(transparent 60%, #000b);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 14px;
  animation: fadeIn .5s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.over-card {
  pointer-events: auto;
  background: #142130ee; border: 1px solid #2b4a68; border-radius: 14px; padding: 12px 18px;
  display: flex; align-items: center; gap: 18px; text-align: left;
}
.over-card h2 { font-size: 22px; color: #fff; text-transform: none; letter-spacing: 0; margin: 0; }
.over-card p { font-size: 15px; color: #b8c7d6; margin: 2px 0 0; }
.over-btns { display: flex; gap: 8px; }
.over-btns button { padding: 10px 16px !important; font-size: 15px !important; width: auto !important; }
@media (max-width: 640px) { .over-card { flex-direction: column; text-align: center; } }
.over-btns button { margin-top: 0; }
#back { background: #22364b; color: #fff; border: 0; padding: 12px; border-radius: 10px; font-size: 16px; cursor: pointer; }

/* ---------- Навигация ---------- */
#nav { display: inline-flex; gap: 4px; margin-top: 12px; background: #142130; border: 1px solid #22364b; border-radius: 12px; padding: 4px; }
#nav button { background: none; border: 0; color: #9fb3c8; padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 15px; }
#nav button.active { background: #2b4a68; color: #fff; }

/* ---------- Сезон ---------- */
.muted { color: #8aa0b6; }
.small { font-size: 13px; }
.badge.sm { width: 16px; height: 16px; border-width: 2px; display: inline-block; vertical-align: -3px; margin: 0 6px; }
button.primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
button.ghost { background: #22364b; color: #fff; border: 0; padding: 14px; font-size: 16px; border-radius: 10px; cursor: pointer; margin-top: 20px; }
button.link { background: none; border: 0; color: #6f88a3; cursor: pointer; margin: 14px auto 0; display: block; text-decoration: underline; font-size: 13px; }

.season-head { margin-bottom: 12px; }
.sh-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.sh-club { display: flex; align-items: center; gap: 4px; font-size: 18px; }
.sh-club .badge.sm { width: 30px; height: 30px; border-width: 3px; }
.sh-progress { min-width: 220px; text-align: right; font-size: 13px; }
.bar { height: 8px; background: #1a2a3c; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar div { height: 100%; background: linear-gradient(90deg, #43a047, #4fc3f7); }
.next h3 { margin: 18px 0 8px; font-size: 18px; }
.my-match { font-size: 18px; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; background: #101b27; padding: 12px 14px; border-radius: 10px; }
.my-match .vs { margin: 0 8px; color: #6f88a3; }
.my-match .comp { margin-left: auto; font-size: 12px; color: #4fc3f7; background: #142130; padding: 3px 8px; border-radius: 6px; }
.btn-row { display: flex; gap: 10px; }
.btn-row button { flex: 1; margin-top: 12px; }
.last { margin-top: 12px; font-size: 14px; color: #b8c7d6; }
.win { font-weight: 700; color: #fff; }
.sc { margin: 0 8px; color: #ffd54f; }
.champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; margin: 10px 0; }
.champ { background: #101b27; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.champ.cl { grid-column: 1 / -1; font-size: 16px; background: linear-gradient(90deg, #1f3850, #101b27); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs button { background: #142130; border: 1px solid #22364b; color: #9fb3c8; padding: 8px 12px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.tabs button.active { background: #2b4a68; color: #fff; border-color: #4fc3f7; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { color: #7f95ab; font-weight: 600; font-size: 12px; text-align: center; padding: 6px 4px; border-bottom: 1px solid #22364b; }
.tbl td { text-align: center; padding: 8px 4px; border-bottom: 1px solid #1a2a3c; }
.tbl .club { text-align: left; white-space: nowrap; }
.tbl .pos { width: 28px; color: #8aa0b6; }
.tbl .pts { font-weight: 700; color: #fff; font-size: 15px; }
.tbl tr.ucl td.pos { box-shadow: inset 3px 0 #4fc3f7; }
.tbl tr.ucl4 td.pos { box-shadow: inset 3px 0 #4fc3f766; }
.tbl tr.me td { background: #1f3850; color: #fff; }
.tbl.hist { font-size: 13px; }
.tbl.hist td { text-align: left; }
.legend { font-size: 12px; color: #8aa0b6; margin: 8px 0 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.lg.ucl { background: #4fc3f7; }
.lg.ucl4 { background: #4fc3f766; margin-left: 10px; }
h4 { margin: 16px 0 8px; color: #9fb3c8; font-size: 14px; }
.results { display: grid; gap: 4px; }
.res { background: #101b27; padding: 7px 10px; border-radius: 8px; font-size: 14px; }
.res.me { outline: 1px solid #4fc3f7; }

.bracket { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; }
.col { display: flex; flex-direction: column; }
.col h4 { margin: 0 0 8px; text-align: center; }
.col-ties { display: flex; flex-direction: column; justify-content: space-around; flex: 1; gap: 8px; }
.tie { background: #101b27; border: 1px solid #22364b; border-radius: 8px; font-size: 13px; overflow: hidden; }
.tie > div { display: flex; align-items: center; padding: 5px 6px; gap: 2px; }
.tie > div span:not(.badge) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tie .badge.sm { flex: 0 0 auto; margin: 0 6px 0 0; }
.tie > div + div { border-top: 1px solid #1a2a3c; }
.tie .win { background: #1b3a2a; }
.tie .lose { color: #6f88a3; }
.tie .me span { color: #4fc3f7; font-weight: 700; }
.tie.empty > div { color: #3a4f66; justify-content: center; }
.cl-winner { font-size: 18px; margin-bottom: 12px; background: linear-gradient(90deg, #3d3010, #142130); padding: 10px 14px; border-radius: 10px; }

/* ---------- Лига Европы и кубки после чемпионата ---------- */
.tbl tr.uel td.pos { box-shadow: inset 3px 0 #ff9800; }
.lg.uel { background: #ff9800; margin-left: 10px; }
.champ.el { grid-column: 1 / -1; font-size: 16px; background: linear-gradient(90deg, #4a2c0a, #101b27); }
.bracket.cup { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
.byes { background: #101b27; border: 1px dashed #2b4a68; border-radius: 8px; padding: 8px; line-height: 1.9; }
.me-name { color: #4fc3f7; font-weight: 700; }

/* Статус чемпионата «до 20 очков» */
.lg-status { background: #101b27; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.lg-status .bar { margin-top: 8px; }
.lg-status.done { background: linear-gradient(90deg, #1b3a2a, #101b27); }

/* Регулятор закрутки под полем */
.curl-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: #142130; border: 1px solid #22364b; border-radius: 12px; padding: 10px 14px; margin-top: 10px;
  transition: opacity .2s;
}
.curl-bar.off { opacity: .35; pointer-events: none; }
.curl-label { font-weight: 600; color: #9fb3c8; }
.curl-bar button { background: #22364b; color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; font-size: 18px; cursor: pointer; }
.curl-bar button:hover { background: #2b4a68; }
#curl-reset { font-size: 14px; padding: 8px 12px; }
#curl { width: 260px; accent-color: #4fc3f7; cursor: pointer; }
.curl-val { min-width: 130px; text-align: center; color: #4fc3f7; font-weight: 600; }

/* ---------- iPad и сенсорные экраны ---------- */
body { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
button, input[type=range] { touch-action: manipulation; } /* без зума по двойному тапу */
canvas { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (pointer: coarse) {
  .curl-bar button { padding: 10px 16px; font-size: 20px; }
  #curl { width: 300px; height: 32px; }
  .tabs button, #nav button { padding: 11px 14px; }
}

/* ---------- Значок и режим «на весь экран» ---------- */
.fs-btn {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid #ffffff40;
  background: #0b1119b0; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; transition: background .15s, transform .15s;
}
.fs-btn:hover { background: #2b4a68e0; transform: scale(1.06); }
.fs-btn .fs-close { display: none; }
body.fs .fs-btn .fs-open { display: none; }
body.fs .fs-btn .fs-close { display: block; }

/* Полноэкранная раскладка: табло сверху, поле по центру (пропорции сохраняются), закрутка снизу */
body.fs { overflow: hidden; }
body.fs header { display: none; }
body.fs main { max-width: none; padding: 0; }
body.fs #game-view {
  position: fixed; inset: 0; z-index: 50; background: #0b1119;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
}
body.fs .board { grid-template-columns: 1fr 1fr; width: min(100%, 1600px); margin: 0; gap: 6px; }
body.fs .board-row { padding: 4px 10px; }
body.fs .board-score { font-size: 20px; }
body.fs .canvas-wrap {
  width: min(calc(100vw - 12px), calc((100vh - 130px) * 1.6));
  width: min(calc(100vw - 12px), calc((100dvh - 130px) * 1.6));
  border-radius: 10px;
}
body.fs .curl-bar { margin: 0; padding: 5px 10px; }
body.fs .status { display: none; }
@media (max-height: 500px) { /* телефон горизонтально — экономим высоту */
  body.fs .board-row { padding: 2px 8px; font-size: 13px; }
  body.fs .dot { width: 12px; height: 12px; }
  body.fs .canvas-wrap { width: min(calc(100vw - 12px), calc((100vh - 96px) * 1.6)); width: min(calc(100vw - 12px), calc((100dvh - 96px) * 1.6)); }
  body.fs .curl-bar { padding: 2px 8px; gap: 6px; }
  body.fs .curl-label { display: none; }
}
