:root {
  --primary: #ffd700;
  --primary-soft: #fff7bf;
  --bg: #f8f9fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --success: #e8f8ee;
  --success-text: #087c36;
  --danger: #dc2626;
  --shadow: 0 10px 26px rgba(17, 24, 39, 0.07);
  --radius: 8px;
  --font-main: "Segoe UI", "Roboto", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

[v-cloak] {
  display: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  line-height: 1.45;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.header-content {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.12rem;
  line-height: 1.22;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.08rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
  letter-spacing: 0;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 10px 10px 92px;
  display: grid;
  gap: 10px;
}

.quick-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  max-width: none;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.96);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 26px rgba(17, 24, 39, 0.08);
  backdrop-filter: blur(10px);
}

.tab-button {
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 0 8px;
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
}

.tab-button.active {
  background: var(--primary);
  color: var(--text);
}

.tab-panel {
  scroll-margin-top: 72px;
}

.tab-panel.active {
  display: block;
}

.panel,
.champion-section {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel {
  padding: 10px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading p,
.finals-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.save-status {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.date-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.date-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.danger-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

.matches-list {
  display: grid;
  gap: 6px;
}

.match-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.match-row.invalid {
  border-color: #fecaca;
  background: #fff7f7;
}

.match-status {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}

.team-name {
  min-width: 0;
  text-align: center;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.18;
}

.match-vs {
  text-align: center;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
}

.score-line {
  display: grid;
  grid-template-columns: minmax(54px, 72px) auto minmax(54px, 72px);
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.score-line span {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 900;
}

.score-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: center;
  font-size: 1.02rem;
  font-weight: 900;
}

.score-input:focus {
  border-color: #d3ad00;
  outline: 3px solid rgba(255, 215, 0, 0.35);
}

.score-input.error {
  border-color: var(--danger);
}

.match-error,
.set-error {
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.ranking-cards {
  display: grid;
  gap: 10px;
}

.ranking-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  grid-template-areas:
    "rank team diff"
    "rank team points";
  gap: 4px 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.ranking-card.rank-top-two {
  background: var(--success);
  border-color: #cbeed7;
}

.mobile-rank {
  grid-area: rank;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary-soft);
  font-size: 1.2rem;
  font-weight: 900;
}

.ranking-card h3 {
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.ranking-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

.mobile-stat {
  grid-area: diff;
  text-align: right;
  font-size: 1.1rem;
  font-weight: 900;
}

.mobile-points {
  grid-area: points;
  text-align: right;
  color: var(--text);
  font-weight: 900;
}

.positive {
  color: var(--success-text);
}

.negative {
  color: var(--danger);
}

.table-wrap {
  display: none;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
}

.ranking-table th,
.ranking-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.ranking-table th:nth-child(2),
.ranking-table td:nth-child(2) {
  text-align: left;
}

.ranking-table thead th {
  position: sticky;
  top: 0;
  background: var(--text);
  color: #fff;
}

.rank-badge {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary-soft);
  font-weight: 900;
}

.rank-1 .rank-badge {
  background: var(--primary);
}

.rank-2 .rank-badge {
  background: #e5e7eb;
}

.rank-3 .rank-badge {
  background: #f0c08a;
}

.final-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.final-teams {
  display: grid;
  gap: 8px;
  padding: 18px 14px;
  background: var(--primary-soft);
  text-align: center;
}

.final-team {
  overflow-wrap: anywhere;
  font-size: 1.18rem;
  font-weight: 900;
}

.vs {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.sets-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.set-row {
  display: grid;
  gap: 8px;
  justify-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.set-label {
  font-weight: 900;
}

.set-row .score-input {
  max-width: 112px;
}

.set-score-line {
  display: grid;
  grid-template-columns: minmax(74px, 112px) auto minmax(74px, 112px);
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.set-score-line span {
  color: var(--muted);
  font-size: 1.4rem;
  font-weight: 900;
}

.set-winner {
  color: var(--success-text);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: center;
}

.champion-section {
  padding: 14px;
  background: var(--primary);
  color: var(--text);
}

.champion-section h2 {
  margin-bottom: 12px;
}

.champion-grid {
  display: grid;
  gap: 12px;
}

.result-card {
  min-height: 116px;
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 8px;
  background: #fff8cf;
  padding: 16px;
  display: grid;
  align-content: center;
  gap: 6px;
  text-align: center;
}

.result-card.runner {
  background: #fff;
}

.result-label {
  font-size: 1rem;
  font-weight: 900;
}

.result-team {
  overflow-wrap: anywhere;
  font-size: 1.55rem;
  line-height: 1.15;
  font-weight: 900;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

@media (min-width: 480px) {
  .header-content {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .match-row {
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
      "status status status"
      "teamA vs teamB"
      "score score score"
      "error error error";
    align-items: center;
  }

  .match-status {
    grid-area: status;
  }

  .team-a {
    grid-area: teamA;
  }

  .team-b {
    grid-area: teamB;
  }

  .match-vs {
    grid-area: vs;
  }

  .score-line {
    grid-area: score;
  }

  .match-error {
    grid-area: error;
  }

  .champion-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .app-shell {
    padding-top: 14px;
    gap: 14px;
  }

  .panel,
  .champion-section {
    padding: 16px;
  }

  .matches-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .final-teams {
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
  }

  .set-row {
    grid-template-columns: 86px minmax(250px, 300px) 1fr;
    justify-items: stretch;
    align-items: center;
  }

  .set-error {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  .header-content {
    padding: 14px 18px;
  }

  h1 {
    font-size: 1.35rem;
  }

  .ranking-cards {
    display: none;
  }

  .table-wrap {
    display: block;
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
  }

  .quick-tabs {
    left: 50%;
    right: auto;
    bottom: 16px;
    width: min(560px, calc(100% - 32px));
    transform: translateX(-50%);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    box-shadow: var(--shadow);
  }

  .matches-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
