:root {
  --page: #f6f8f6;
  --surface: #ffffff;
  --surface-soft: #f1f5f2;
  --text: #101820;
  --muted: #66746d;
  --line: #dce5df;
  --green: #087642;
  --green-strong: #056236;
  --green-soft: #e7f5ed;
  --gold: #c99a22;
  --gold-soft: #fff4d5;
  --red: #b42318;
  --red-soft: #fee4e2;
  --radius: 8px;
  --shadow: 0 14px 40px rgba(17, 36, 26, 0.08);
  --shadow-soft: 0 8px 24px rgba(17, 36, 26, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(650px 280px at 82% -80px, rgba(201, 154, 34, 0.12), transparent 70%),
    radial-gradient(700px 300px at 8% -90px, rgba(8, 118, 66, 0.09), transparent 68%),
    var(--page);
  color: var(--text);
  font-family: Tahoma, Arial, sans-serif;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.shell {
  width: min(100% - 24px, 980px);
  margin: 0 auto;
}

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

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-weight: 900;
}

.brand-mark {
  color: var(--gold);
  filter: drop-shadow(0 3px 8px rgba(201, 154, 34, 0.2));
}

.nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.nav a {
  padding: 7px 9px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.nav a[aria-current="page"] {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
}

.main {
  padding: 14px 0 34px;
}

.intro-badge {
  width: max-content;
  max-width: 100%;
  padding: 5px 10px;
  border: 1px solid rgba(8, 118, 66, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.intro-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(220, 229, 223, 0.92);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(250, 253, 251, 0.94)),
    radial-gradient(260px 120px at 12% 0%, rgba(8, 118, 66, 0.08), transparent 70%);
  box-shadow: var(--shadow);
}

.intro-card::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.intro-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.contest-emblem {
  display: none;
  place-items: center;
  width: 82px;
  height: 82px;
  border: 1px solid rgba(201, 154, 34, 0.32);
  border-radius: 999px;
  background: linear-gradient(180deg, #fffaf0, #ffffff);
  color: var(--text);
  box-shadow: 0 12px 26px rgba(201, 154, 34, 0.12);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.contest-emblem span {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.contest-emblem strong {
  margin-top: 4px;
}

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

h1 {
  font-size: 25px;
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.prize {
  grid-column: 1 / -1;
  display: inline-grid;
  place-items: center;
  justify-self: start;
  min-width: 92px;
  padding: 8px 11px;
  border: 1px solid #ead399;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff8df, var(--gold-soft));
  color: #805d0f;
  line-height: 1.25;
  box-shadow: var(--shadow-soft);
}

.prize strong {
  color: var(--text);
  font-size: 19px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.join-panel {
  padding: 15px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.96);
}

.join-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.field {
  display: grid;
  gap: 5px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.input,
.score-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: 0;
}

.input {
  min-height: 48px;
  padding: 9px 12px;
}

.input:focus,
.score-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(10, 123, 67, 0.12);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 9px 14px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 900;
}

.button-primary {
  background: linear-gradient(180deg, var(--green), var(--green-strong));
  color: #fff;
  box-shadow: 0 8px 18px rgba(8, 118, 66, 0.2);
}

.button-soft {
  background: var(--green-soft);
  color: var(--green);
}

.button-danger {
  width: 100%;
  background: var(--red-soft);
  color: var(--red);
}

.participant-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(8, 118, 66, 0.12);
  background: linear-gradient(180deg, #f0fbf5, var(--green-soft));
  color: var(--green);
  font-weight: 900;
}

.participant-card button {
  min-height: 34px;
  padding: 5px 9px;
}

.form-message {
  min-height: 22px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.form-message.error {
  color: var(--red);
  font-weight: 800;
}

.padded {
  padding-inline: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.count-chip,
.state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.count-chip {
  background: var(--surface-soft);
  color: var(--muted);
}

.state-open {
  background: var(--green-soft);
  color: var(--green);
}

.state-saved {
  background: var(--green);
  color: #fff;
}

.state-locked {
  background: var(--surface-soft);
  color: var(--muted);
}

.state-scored {
  background: var(--gold-soft);
  color: #805d0f;
}

.match-list,
.leaderboard-list,
.page-grid,
.top-three,
.rules-list,
.admin-match-list,
.participant-list {
  display: grid;
}

.match-list {
  gap: 10px;
  padding: 10px;
}

.match-row {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
  box-shadow: 0 8px 22px rgba(17, 36, 26, 0.04);
}

.table-row:last-child,
.schedule-row:last-child,
.rule:last-child,
.admin-match:last-child,
.participant-row:last-child {
  border-bottom: 0;
}

.match-time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.match-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px 32px 112px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.team {
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 0;
  text-align: center;
  font-weight: 900;
  font-size: 13px;
}

.team span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flag-img {
  display: inline-block;
  width: 32px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface-soft);
  box-shadow: 0 0 0 1px rgba(20, 32, 24, 0.08);
}

.flag-fallback {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 24px;
  border-radius: 4px;
  background: var(--surface-soft);
  font-size: 17px;
}

.score-input {
  height: 40px;
  padding: 6px;
  text-align: center;
  font-size: 17px;
  font-weight: 900;
  border-radius: 7px;
  font-variant-numeric: tabular-nums;
}

.score-stepper {
  display: grid;
  grid-template-columns: 30px minmax(0, 42px) 30px;
  justify-content: center;
  align-items: center;
  gap: 4px;
}

.step-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--green);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.step-button:active {
  transform: translateY(1px);
}

.versus {
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.save-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid rgba(220, 229, 223, 0.72);
  padding-top: 8px;
}

.save-ok {
  color: var(--green);
  font-weight: 900;
}

.save-error {
  color: var(--red);
  font-weight: 900;
}

.save-locked {
  color: var(--muted);
  font-weight: 900;
}

.save-scored {
  color: #805d0f;
  font-weight: 900;
}

.empty {
  padding: 18px 12px;
  color: var(--muted);
}

.top-three {
  gap: 8px;
  margin-bottom: 12px;
}

.winner-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.winner-card:first-child {
  border-color: #ead399;
  background: linear-gradient(180deg, #fffaf0, #ffffff);
}

.top-three .winner-card:nth-child(2) {
  border-color: #d9dedc;
  background: linear-gradient(180deg, #f7f9f8, #ffffff);
}

.top-three .winner-card:nth-child(3) {
  border-color: #ebd6c5;
  background: linear-gradient(180deg, #fff5ed, #ffffff);
}

.rank-badge {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #805d0f;
  font-weight: 900;
}

.top-three .winner-card:nth-child(2) .rank-badge {
  background: #eef1f0;
  color: #53605a;
}

.top-three .winner-card:nth-child(3) .rank-badge {
  background: #f7eadf;
  color: #8b5429;
}

.winner-card strong,
.table-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 58px 58px 58px;
  gap: 6px;
  align-items: center;
  padding: 11px 12px;
}

.table-head {
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 900;
}

.table-row {
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.schedule-day {
  overflow: hidden;
  margin-bottom: 12px;
}

.day-title {
  padding: 11px 12px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  font-weight: 900;
}

.schedule-row {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.schedule-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.result-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  direction: ltr;
}

.schedule-teams,
.admin-teams {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-weight: 900;
}

.schedule-teams .flag-img,
.schedule-teams .flag-fallback,
.admin-teams .flag-img,
.admin-teams .flag-fallback {
  width: 26px;
  height: 20px;
}

.rules-list {
  overflow: hidden;
}

.rule {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
}

.rule-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}

.admin-login {
  max-width: 560px;
  padding: 16px;
}

.admin-layout {
  display: grid;
  gap: 12px;
}

.admin-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}

.admin-match {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.admin-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px 54px auto;
  gap: 7px;
  align-items: center;
}

.participant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.danger-zone {
  display: grid;
  gap: 8px;
  padding: 12px;
}

@media (min-width: 640px) {
  .main {
    padding-top: 20px;
  }

  h1 {
    font-size: 30px;
  }

  .contest-emblem {
    display: grid;
  }

  .prize {
    grid-column: auto;
    justify-self: end;
  }

  .join-form {
    grid-template-columns: minmax(0, 1fr) 140px auto;
    align-items: end;
  }

  .admin-login-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .match-row {
    grid-template-columns: 112px minmax(0, 1fr) 154px;
    align-items: center;
  }

  .match-time,
  .save-line {
    display: grid;
    justify-content: stretch;
  }

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

  .admin-layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.7fr);
    align-items: start;
  }
}

@media (max-width: 390px) {
  .shell {
    width: calc(100% - 18px);
  }

  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 9px 0;
  }

  .nav {
    width: 100%;
  }

  .match-main {
    grid-template-columns: minmax(0, 1fr) 90px 26px 90px minmax(0, 1fr);
    gap: 5px;
  }

  .score-stepper {
    grid-template-columns: 25px minmax(0, 34px) 25px;
    gap: 3px;
  }

  .step-button {
    width: 25px;
    height: 34px;
    font-size: 16px;
  }

  .score-input {
    height: 38px;
    font-size: 16px;
  }

  .table-head,
  .table-row {
    grid-template-columns: 34px minmax(0, 1fr) 46px 46px 46px;
    padding-inline: 9px;
  }

  .admin-result {
    grid-template-columns: minmax(0, 1fr) 48px 48px;
  }

  .admin-result button {
    grid-column: 1 / -1;
  }
}
