:root {
  --ink: #14210f;
  --muted: #64705f;
  --line: #dfe8d6;
  --paper: #eff3ea;
  --card: #fff;
  --forest: #204707;
  --field: #143206;
  --lime: #d4f052;
  --gold: #f0c419;
  --red: #bf3b2f;
  --green: #3da975;
  --blue: #2f6fdd;
  --shadow: 0 10px 30px rgba(22, 31, 16, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px) 0 0 / 96px 96px,
    linear-gradient(0deg, rgba(255,255,255,.04) 1px, transparent 1px) 0 0 / 96px 96px,
    radial-gradient(circle at 50% 30%, rgba(212,240,82,.12), transparent 32%),
    var(--field);
}

button, input, select { font: inherit; }

.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  overflow-x: clip;
  background: var(--forest);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 900;
  line-height: 1.15;
  text-transform: uppercase;
}

.brand-logo {
  width: 64px;
  height: 46px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.18);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--lime);
  color: var(--forest);
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav button {
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  background: transparent;
  color: rgba(255,255,255,.78);
  cursor: pointer;
  font-weight: 750;
  white-space: nowrap;
}

.nav button.active {
  background: rgba(240,196,25,.18);
  color: var(--gold);
}

.nav-user {
  margin-left: 8px;
  color: rgba(255,255,255,.72);
  font-size: .78rem;
  font-weight: 750;
  white-space: nowrap;
}

.nav-role {
  color: rgba(255,255,255,.48);
  font-size: .72rem;
  white-space: nowrap;
}

.logout-button {
  border: 1px solid rgba(255,255,255,.42) !important;
  padding-inline: 13px !important;
}

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 18px 60px;
  background: var(--paper);
  min-height: calc(100vh - 74px);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.96), rgba(244,249,238,.92));
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: .95;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  text-transform: none;
}

.subtitle {
  margin: 10px 0 0;
  color: #475348;
}

.hero .subtitle {
  margin-top: 8px;
  font-size: .98rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 520px;
  margin: 34px auto;
}

.auth-card > .subtitle:first-child {
  margin-top: 0;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: #fbfcf8;
  color: var(--ink);
}

select,
.maintenance-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fbfcf8;
  color: var(--ink);
}

.button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--forest);
  color: #fff;
  cursor: pointer;
  font-weight: 850;
}

.button.secondary {
  background: #edf4e6;
  color: var(--forest);
  border: 1px solid #cbdabd;
}

.button.danger {
  background: var(--red);
}

.button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.action-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 6px;
}

.score-item {
  min-height: 66px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--forest);
  color: #fff;
}

.score-item strong {
  color: var(--lime);
  font-size: 1.45rem;
  white-space: nowrap;
}

.score-item span {
  display: block;
  margin-top: 2px;
  color: rgba(255,255,255,.72);
  font-size: .8rem;
}

.management-view .hero,
.management-view .score-strip,
.management-view .score-note {
  display: none;
}

#appView:not(.score-context-view) .score-strip,
#appView:not(.score-context-view) .score-note {
  display: none;
}

#appView:not(.live-context-view) .live-section {
  display: none !important;
}

.management-view .view.active {
  padding-top: 26px;
}

.admin-prediction-lock {
  max-width: 560px;
}

.admin-prediction-lock p {
  margin: 8px 0 0;
  color: #475348;
}

.status-view,
.admin-readonly-note {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eef3e7;
  color: var(--green);
  font-weight: 800;
}

.admin-readonly-note {
  opacity: .78;
}

.score-note {
  margin: 0 0 26px;
  color: #475348;
  font-size: .9rem;
}

.summary-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 13px 14px;
  border: 1px solid #cbdabd;
  border-radius: 8px;
  background: #f8fbf2;
  box-shadow: 0 3px 0 rgba(41,72,10,.04);
}

.summary-panel strong {
  display: block;
  margin-bottom: 3px;
}

.summary-panel span {
  color: #475348;
  font-size: .9rem;
  line-height: 1.35;
}

.info-panel {
  margin: -2px 0 14px;
  padding: 12px 14px;
  border: 1px solid #cbdabd;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: #f8fbf2;
  color: #475348;
  line-height: 1.45;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.panel h3 + .subtitle {
  margin-top: -6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eaf2df;
  color: var(--forest);
  font-weight: 850;
  font-size: .72rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag.red {
  color: var(--red);
  background: #fae9e6;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 16px;
}

.filter-tabs button {
  min-height: 36px;
  border: 1px solid #cbdabd;
  border-radius: 999px;
  padding: 7px 12px;
  background: #f5f8ef;
  color: var(--forest);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
}

.filter-tabs button.active {
  border-color: var(--forest);
  background: var(--forest);
  color: #fff;
}

.admin-game-filters {
  margin: 12px 0 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.live-section {
  margin-bottom: 24px;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.live-card {
  background: #fbfcf8;
  border: 1px solid #b9cd9d;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 3px 0 rgba(41,72,10,.05);
}

.live-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  background: #edf4e6;
  color: #4e5b4a;
  font-size: .78rem;
  font-weight: 750;
}

.live-score-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 18px 14px 12px;
}

.live-score-line span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
  font-weight: 800;
}

.live-score-line strong {
  min-width: 74px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--forest);
  color: var(--lime);
  font-size: 1.25rem;
}

.live-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 0 14px 14px;
  color: var(--muted);
  font-size: .86rem;
}

.live-details strong {
  color: var(--ink);
}

.match-card {
  background: var(--card);
  border: 1px solid #b9cd9d;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 3px 0 rgba(41,72,10,.05);
}

.match-card-focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgba(211,255,64,.38), 0 3px 0 rgba(41,72,10,.05);
}

.match-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: #edf4e6;
  padding: 9px 14px;
  color: #4e5b4a;
  font-size: .78rem;
  font-weight: 750;
}

.match-deadline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px 0;
  color: var(--forest);
  font-weight: 850;
}

.countdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #edf4e6;
  color: var(--forest);
  font-size: .78rem;
  font-weight: 950;
}

.countdown::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(240, 196, 25, .22);
}

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 126px;
  padding: 20px 14px;
}

.team {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-width: 0;
  text-align: center;
}

.flag {
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 30px;
  padding: 0 8px;
  border-radius: 5px;
  background: #eef3e9;
  color: var(--forest);
  font-weight: 950;
  font-size: .8rem;
  overflow: hidden;
}

.flag-img {
  display: block;
  width: 32px;
  height: 22px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(20, 33, 15, .12);
}

.inline-flag {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 4px;
}

.inline-flag .flag-img {
  width: 24px;
  height: 16px;
}

.team-name {
  width: 100%;
  color: #26351f;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.score-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-inputs input {
  width: 48px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  font-size: 1.35rem;
  color: var(--ink);
  background: #fbfcf8;
}

.match-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid #eef1e8;
  color: var(--muted);
  font-size: .78rem;
}

.prediction-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 900;
}

.prediction-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.status-saved {
  background: #e5f4e9;
  color: #1f6c38;
}

.status-saved::before {
  background: #3da975;
  box-shadow: 0 0 0 3px rgba(61, 169, 117, .2);
}

.status-open {
  background: #fff1cf;
  color: #815b00;
}

.status-open::before {
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(240, 196, 25, .22);
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #edf0e8;
  background: var(--card);
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
}

.table th, .table td {
  padding: 13px 16px;
  border-bottom: 1px solid #edf0e8;
  text-align: left;
}

.table th {
  background: #edf4e6;
  color: #52604e;
  font-size: .72rem;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.ranking-note {
  margin: 12px 0 0;
  color: #475348;
  font-size: .9rem;
  line-height: 1.4;
}

.calc-text {
  display: inline-block;
  color: #475348;
  font-size: .9rem;
  line-height: 1.35;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-game {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.audit-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  padding: 14px 16px;
  background: #edf4e6;
  color: #26351f;
}

.audit-summary::marker {
  color: var(--forest);
}

.audit-game-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 850;
}

.audit-game-title .flag-img {
  width: 24px;
  height: 16px;
}

.audit-meta {
  color: #52604e;
  font-size: .86rem;
  font-weight: 750;
}

.audit-table-wrap {
  border-radius: 0;
}

.audit-table {
  box-shadow: none;
}

.my-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.my-result-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 3px 0 rgba(41,72,10,.05);
}

.my-result-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: #edf4e6;
  color: #52604e;
  font-size: .8rem;
}

.my-result-game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 16px 14px;
  text-align: center;
  font-weight: 850;
}

.my-result-game span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.my-result-game .flag-img {
  width: 28px;
  height: 18px;
}

.my-result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid #eef1e8;
  border-bottom: 1px solid #eef1e8;
}

.my-result-stats div {
  padding: 11px 10px;
  text-align: center;
}

.my-result-stats div + div {
  border-left: 1px solid #eef1e8;
}

.my-result-stats span {
  display: block;
  margin-bottom: 3px;
  color: #64705f;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.my-result-stats strong {
  color: var(--forest);
  font-size: 1.05rem;
}

.my-result-calc {
  padding: 11px 14px;
  color: #475348;
  font-size: .88rem;
  line-height: 1.35;
}

.games-list {
  display: grid;
  gap: 10px;
}

.game-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 3px 0 rgba(41,72,10,.05);
  scroll-margin-top: 96px;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.game-main {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
}

.game-date {
  color: #3e4b38;
  font-weight: 750;
  font-size: .9rem;
}

.game-teams {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  text-align: center;
  flex-wrap: wrap;
}

.game-score {
  color: var(--forest);
  font-size: 1.2rem;
  font-weight: 900;
  min-width: 52px;
  text-align: center;
}

.game-sub {
  display: flex;
  justify-content: center;
  gap: 28px;
  padding: 9px 14px;
  border-top: 1px solid #eef1e8;
  color: var(--muted);
  font-size: .82rem;
}

.position {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--forest);
  color: #fff;
  font-weight: 950;
}

.position-1 {
  background: #d8a514;
  color: #1b240f;
  box-shadow: inset 0 0 0 1px rgba(86, 58, 0, .18);
}

.position-2 {
  background: #c5ccd1;
  color: #1f2a2c;
  box-shadow: inset 0 0 0 1px rgba(35, 48, 54, .16);
}

.position-3 {
  background: #b97835;
  color: #fffaf3;
  box-shadow: inset 0 0 0 1px rgba(75, 38, 11, .2);
}

.rules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.examples-panel {
  grid-column: 1 / -1;
}

.score-example-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.score-example {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcf8;
}

.example-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.example-head span {
  min-width: 42px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--forest);
  color: #fff;
  font-weight: 900;
  text-align: center;
}

.score-example p {
  margin: 8px 0 4px;
}

.score-example small + p {
  margin-top: 12px;
}

.score-example small {
  color: #475348;
}

.rule-note {
  color: #475348;
  line-height: 1.45;
}

.phase-grid + .rule-note {
  margin-top: 12px;
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.phase {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-radius: 7px;
  background: #f5f8ef;
  color: #3c4938;
  font-weight: 700;
}

.admin-section-head {
  margin: 30px 0 10px;
  padding: 0 0 0 13px;
  border-left: 4px solid var(--forest);
}

.admin-section-head h3 {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.admin-section-head p {
  max-width: 760px;
  margin: 4px 0 0;
  color: #475348;
  font-size: .92rem;
  line-height: 1.4;
}

#admin .panel > .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

#admin .panel > .form-grid .button,
#admin .panel > .form-grid .action-row,
#admin .panel > .form-grid .full-row {
  grid-column: 1 / -1;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.status-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.status-item strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--ink);
}

.status-item span {
  color: #475348;
  font-size: .9rem;
  line-height: 1.35;
}

.status-item em {
  font-style: normal;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: .72rem;
  text-transform: uppercase;
}

.status-item em.ok {
  background: #e5f4e9;
  color: #1f6c38;
}

.status-item em.warn {
  background: #fff1cf;
  color: #815b00;
}

.danger-panel {
  border-color: #efd3cf;
  background: linear-gradient(180deg, #fff, #fffafa);
}

.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.maintenance-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px;
  border: 1px solid #ead1cc;
  border-radius: 8px;
  background: #fffdfb;
}

.maintenance-card strong {
  color: var(--ink);
}

.maintenance-card span {
  color: #475348;
  font-size: .9rem;
  line-height: 1.35;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcf8;
}

.history-item span {
  color: #475348;
  font-size: .9rem;
}

.view { display: none; }
.view.active { display: block; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--ink);
  color: #fff;
  padding: 11px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  font-weight: 750;
}

.toast.show { opacity: 1; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 16, 8, .58);
}

.modal-card {
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f5f8ef;
  color: var(--forest);
  cursor: pointer;
  font-weight: 900;
}

.diagnostics-output {
  margin: 0;
  padding: 18px 20px;
  overflow: auto;
  background: #10170d;
  color: #f6fbef;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

@media (max-width: 820px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
  }

  .brand {
    max-width: 100%;
  }

  .brand div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav {
    width: 100%;
    padding-bottom: 2px;
  }

  .nav button {
    padding: 8px 10px;
    font-size: .92rem;
  }

  .nav-user {
    margin-left: 2px;
  }

  .wrap {
    padding-top: 22px;
  }

  .hero,
  .score-strip,
  .grid,
  .live-grid,
  .rules,
  .admin-grid,
  .status-grid,
  .maintenance-grid,
  .my-results-grid,
  .score-example-grid,
  #admin .panel > .form-grid {
    grid-template-columns: 1fr;
  }

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

  .score-inputs input { width: 40px; }

  .summary-panel {
    align-items: stretch;
    flex-direction: column;
  }

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

  .my-result-stats div + div {
    border-left: 0;
    border-top: 1px solid #eef1e8;
  }

  .table { font-size: .88rem; }
  .table th, .table td { padding: 11px 10px; }

  .modal-backdrop { padding: 10px; }
  .modal-card { max-height: calc(100vh - 20px); }
  .modal-header,
  .modal-actions {
    padding: 14px;
  }
  .modal-actions {
    flex-direction: column;
  }

  .game-main {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .game-sub {
    flex-direction: column;
    gap: 4px;
    align-items: center;
  }

  .audit-summary {
    grid-template-columns: 1fr;
  }
}
