:root {
  --bg: #f3f6fb;
  --panel: #f8fbff;
  --ink: #1d2433;
  --muted: #5b667a;
  --accent: #0f6d5d;
  --accent-soft: #dff3ee;
  --warn: #c9562a;
  --line: #d9e3f0;
  --shadow: 0 14px 34px rgba(30, 55, 90, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(70, 118, 183, 0.14), transparent 40%),
    radial-gradient(circle at left center, rgba(129, 157, 203, 0.1), transparent 38%),
    var(--bg);
  line-height: 1.45;
}

.hero {
  padding: 0.8rem 0.85rem 0.4rem;
  max-width: 1200px;
  margin: 0 auto;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.2rem, 1.8vw, 1.7rem);
}

.hero p {
  margin: 0.2rem 0 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 0.82rem;
}

.hero-actions {
  margin-top: 0;
}

.top-controls {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.top-right-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

.sync-live-btn {
  border: 1px solid #56759b;
  background: #6a88ac;
  color: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.66rem;
  font-size: 0.75rem;
  line-height: 1.1;
}

.sync-live-btn.is-busy {
  opacity: 0.7;
  cursor: wait;
}

#liveSyncStatus.status-ok {
  color: #2c6f4a;
}

#liveSyncStatus.status-warn {
  color: #8a5a18;
}

#liveSyncStatus.status-error {
  color: #8b3d3d;
}

.view-tabs {
  display: flex;
  gap: 0.28rem;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid #8fb0aa;
  background: #f3fbf8;
  color: #0f5e52;
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.tab-btn.is-active {
  background: #0f6d5d;
  border-color: #0b5d50;
  color: #fff;
}

.compact-toggle {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.kpi-bar {
  margin-top: 0.4rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.35rem;
}

.kpi-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.42rem;
}

.kpi-chip.kpi-exact {
  border-color: #558a6e;
  background: #f1faf4;
  border-width: 2px;
}

.kpi-chip.kpi-tendency {
  border-color: #97cfb2;
  background: #f1faf4;
}

.kpi-chip.kpi-miss {
  border-color: #e1a27f;
  background: #fff2ea;
}

.kpi-label {
  font-size: 0.68rem;
  color: var(--muted);
}

.kpi-chip.kpi-exact .kpi-label,
.kpi-chip.kpi-tendency .kpi-label,
.kpi-chip.kpi-miss .kpi-label {
  color: inherit;
}

.kpi-chip.kpi-exact .kpi-value {
  color: #1c6f41;
}

.kpi-chip.kpi-tendency .kpi-value {
  color: #1f7a46;
}

.kpi-chip.kpi-miss .kpi-value {
  color: #a9471f;
}

.kpi-value {
  margin-top: 0.08rem;
  font-size: 0.94rem;
  font-weight: 800;
}

main {
  max-width: 1200px;
  margin: 0 auto 2rem;
  padding: 0 0.85rem;
  display: grid;
  gap: 0.72rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.68rem;
  box-shadow: var(--shadow);
}

.panel.is-hidden {
  display: none;
}

.panel h2 {
  margin-top: 0;
}

.panel-head,
.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.panel-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ko-sim-btn {
  border: 1px solid #4d6f96;
  background: #5f81a8;
  color: #fff;
  border-radius: 999px;
  padding: 0.22rem 0.5rem;
  font-size: 0.68rem;
  line-height: 1.1;
}

.panel-head h2,
.panel-head h3,
.group-head h3 {
  margin: 0;
}

.collapse-btn {
  border: 1px solid #3a5f86;
  background: #4a6f95;
  color: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.75rem;
  line-height: 1.1;
}

.panel-content.is-collapsed,
.group-content.is-collapsed {
  display: none;
}

.panel-content,
.group-content {
  margin-top: 0.5rem;
}

.panel-subtoggle {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.small-note {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.65rem;
}

.round-placeholders-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.round-placeholder-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  padding: 0.5rem;
}

.round-placeholder-card h4 {
  margin: 0 0 0.32rem;
  font-size: 0.86rem;
}

.round-placeholder-matches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.45rem;
}

.placeholder-match {
  border-color: #d2dbe8;
  background: linear-gradient(180deg, #fbfdff, #f3f7fd);
}

.placeholder-line {
  margin: 0.2rem 0;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.16rem;
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  background: #ffffff;
  padding: 0.35rem;
}

.placeholder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
}

.placeholder-index {
  font-size: 0.68rem;
  color: #6a7488;
}

.placeholder-teams {
  min-width: 0;
  color: #2f3a4d;
}

.placeholder-prog {
  font-size: 0.7rem;
  color: #74829a;
}

.placeholder-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.04rem 0.4rem;
  font-size: 0.64rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-confirmed {
  background: #e7f4ec;
  border: 1px solid #9bc8ad;
  color: #1f6a44;
}

.badge-projected {
  background: #edf1f8;
  border: 1px solid #c6d3e4;
  color: #456185;
}

.group-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
  background: #fbfdff;
}

.group-card h3 {
  margin: 0;
}

.team-list {
  margin: 0.35rem 0 0.55rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.match-list {
  display: grid;
  gap: 0.45rem;
}

.match-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.46rem;
  background: linear-gradient(180deg, #ffffff, #f6f9fe);
}

.match-card.match-active-md {
  background: linear-gradient(180deg, #fffdf3, #fff8dd);
  border-color: #d7b826;
  border-width: 2px;
}

.match-card.match-today-us {
  border-color: transparent;
  border-width: 2px;
  background-clip: padding-box;
  position: relative;
  background: linear-gradient(180deg, #fffdf3, #fff8dd);
  box-shadow: 0 0 0 2px transparent, var(--shadow);
  outline: 2px solid transparent;
}

.match-card.match-today-us::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 12px;
  padding: 3px;
  background: linear-gradient(135deg, #ffffff, #ffe566, #f5a623, #ffffff, #f5d020, #ff8c00);
  background-size: 300% 300%;
  animation: shimmer-border 2.5s ease infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

@keyframes shimmer-border {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.match-card.finished-exact {
  background: linear-gradient(180deg, #f2faf6, #e7f4ee);
  border-color: #4ea176;
  border-width: 2px;
}

.match-card.finished-tendency {
  background: linear-gradient(180deg, #f8fcf9, #eef7f2);
  border-color: #cadfd3;
}

.match-card.finished-miss {
  background: linear-gradient(180deg, #fdf7f7, #f9eded);
  border-color: #d9a0a0;
  border-width: 2px;
}

.match-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.match-title {
  font-weight: 700;
}

.match-status {
  font-size: 0.74rem;
  color: var(--muted);
}

.match-status.status-exact {
  color: #1f7a46;
}

.match-status.status-tendency {
  color: #3f7d5d;
}

.match-status.status-miss {
  color: #a04040;
}

.teams-row,
.prognosis-row,
.result-row {
  margin-top: 0.24rem;
  font-size: 0.84rem;
}

.prognosis-row {
  background: #e9eef5;
  border-radius: 7px;
  border: 1px solid #d6deea;
  padding: 0.28rem;
}

.team-pending {
  color: #b8c4cc;
  font-style: italic;
  font-weight: 400;
}

.pred-changed-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  background: #f59e0b;
  color: #fff;
  border-radius: 4px;
  padding: 1px 7px;
  margin-top: 3px;
  letter-spacing: 0.02em;
}

.result-row {
  color: var(--warn);
  font-weight: 700;
}

.result-form {
  margin-top: 0.32rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.28rem;
}

.result-form.is-collapsed {
  display: none;
}

.manual-wrap {
  margin-top: 0.2rem;
}

.manual-toggle {
  border: 1px solid #aeb6c4;
  background: #f4f6fa;
  color: #4a566b;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.72rem;
  line-height: 1.1;
}

.result-form button {
  padding: 0.24rem 0.42rem;
  font-size: 0.72rem;
  line-height: 1.1;
  opacity: 0.86;
}

.result-form button:hover {
  opacity: 1;
}

.result-form label {
  display: grid;
  font-size: 0.68rem;
  color: var(--muted);
}

input[type="number"] {
  width: 100%;
  margin-top: 0.1rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.22rem;
  font-size: 0.82rem;
}

button {
  border: 1px solid #0b5f52;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  padding: 0.34rem 0.5rem;
  font-size: 0.76rem;
  cursor: pointer;
}

button.clear-result {
  border-color: #8c3d1d;
  background: #b44e24;
}

#resetDataBtn {
  background: #31445b;
  border-color: #253547;
}

.bracket {
  overflow-x: auto;
}

.bracket-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 0.6rem;
  min-width: 900px;
}

.round {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.5rem;
  background: #fbfdff;
}

.round h4 {
  margin: 0 0 0.35rem;
}

.tie {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.32rem;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  background: #f7fafe;
}

.tie-meta {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

body.compact-mode .small-note {
  display: none;
}

body.compact-mode #liveSyncStatus {
  display: inline;
}

body.compact-mode .prognosis-row {
  display: none;
}

body.compact-mode .team-list {
  margin-bottom: 0.45rem;
}

body.compact-mode .match-card {
  padding: 0.45rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.42rem;
  margin-bottom: 0.7rem;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.5rem;
  background: #fbfdff;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--muted);
}

.stat-value {
  margin-top: 0.1rem;
  font-size: 1.02rem;
  font-weight: 700;
}

.outcome-hit {
  color: #1f7a46;
}

.outcome-exact {
  color: #1c6f41;
}

.outcome-miss {
  color: #a9471f;
}

.qualification-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.45rem;
}

.qual-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.5rem;
  background: #fbfdff;
}

.qual-card h4 {
  margin: 0 0 0.35rem;
}

.qual-line {
  margin: 0.16rem 0;
  font-size: 0.82rem;
}

.qual-badge {
  display: inline-block;
  border: 1px solid #9bb9b2;
  background: #ecf7f4;
  color: #144f44;
  border-radius: 999px;
  padding: 0.08rem 0.45rem;
  font-size: 0.74rem;
  margin-right: 0.3rem;
}

.mc-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  align-items: end;
  margin-bottom: 0.55rem;
}

.mc-controls label {
  display: grid;
  font-size: 0.78rem;
  color: var(--muted);
}

.mc-bar-wrap {
  margin-top: 0.2rem;
}

.mc-bar-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.mc-bar {
  width: 100%;
  height: 8px;
  background: #e8eef7;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #d5e0ee;
}

.mc-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0f6d5d, #5aa78f);
}

.mc-table-wrap {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.mc-table-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfdff;
  padding: 0.42rem;
  overflow-x: auto;
}

.mc-table-card h5 {
  margin: 0 0 0.4rem;
}

.mc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.mc-table th,
.mc-table td {
  border-bottom: 1px solid #e6edf7;
  padding: 0.3rem 0.35rem;
  text-align: right;
  white-space: nowrap;
}

.mc-table th:first-child,
.mc-table td:first-child {
  text-align: left;
}

@media (max-width: 700px) {
  .hero-top {
    flex-wrap: wrap;
  }

  .result-form {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 0.85rem;
  }

  .top-controls {
    align-items: flex-start;
  }

  .top-right-tools {
    width: 100%;
    justify-content: flex-start;
  }
}
