:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #142033;
  --muted: #667085;
  --line: #d9e1ea;
  --accent: #0f7c6c;
  --accent-dark: #075f54;
  --warning: #b54708;
  --danger: #b42318;
  --ok: #067647;
  --focus: #fff7dc;
  --shadow: 0 16px 40px rgba(20, 32, 51, 0.10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand, nav { display: flex; align-items: center; gap: 14px; }
.brand { text-decoration: none; font-weight: 800; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
}
nav { flex-wrap: wrap; justify-content: flex-end; font-size: 14px; }
nav a { text-decoration: none; color: var(--muted); font-weight: 650; }
nav a:hover { color: var(--ink); }
.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.page { width: min(1180px, calc(100vw - 28px)); margin: 28px auto 56px; }
.hero, .page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.hero {
  min-height: 260px;
  padding: clamp(28px, 5vw, 54px);
  color: white;
  background:
    linear-gradient(90deg, rgba(8, 43, 52, .90), rgba(8, 43, 52, .58)),
    url("https://images.unsplash.com/photo-1508098682722-e99c43a406b2?auto=format&fit=crop&w=1800&q=80");
  background-size: cover;
  background-position: center;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.eyebrow {
  margin: 0 0 8px;
  color: #13a28e;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.hero .eyebrow { color: #8ee7d8; }
h1 { margin: 0; font-size: clamp(30px, 5vw, 58px); line-height: 1.02; letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 22px; letter-spacing: 0; }
.lead { max-width: 650px; margin: 14px 0 0; color: rgba(255, 255, 255, .86); font-size: 18px; line-height: 1.5; }
.hero-actions, .admin-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  cursor: pointer;
}
.button.primary { border-color: var(--accent); background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-dark); }
.button.compact { min-height: 34px; padding: 0 10px; }
.match-list, .admin-match-list, .log-list { display: grid; gap: 12px; }
.section-block {
  margin: 0 0 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.urgent-block {
  border-color: #f2c94c;
  background: #fffdf4;
}
.empty-state {
  padding: 18px;
  border: 1px dashed #d6dbe4;
  border-radius: 8px;
  color: var(--muted);
  background: #ffffff;
}
.match-card, .auth-panel, .table-wrap, .admin-match, .log-entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20, 32, 51, .05);
}
.match-card {
  position: relative;
  padding: 16px;
  transition: border-color .2s ease, background .2s ease, transform .2s ease, box-shadow .2s ease;
}
.match-card.needs-prediction {
  border-color: #f2b84b;
  background: var(--focus);
  box-shadow: 0 10px 26px rgba(181, 71, 8, .10);
}
.match-card.has-prediction {
  border-color: #a6d8c5;
}
.match-card.just-saved {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(6, 118, 71, .18);
}
.match-card.saving {
  opacity: .76;
}
.match-card.save-error {
  border-color: var(--danger);
}
.match-live {
  border-color: #f97066;
  background: #fff8f7;
}
.match-finished {
  background: #f9fafb;
}
.match-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: #475467;
  font-size: 12px;
  font-weight: 850;
}
.status-live {
  background: #fee4e2;
  color: var(--danger);
}
.status-finished, .saved-badge {
  background: #dcfae6;
  color: var(--ok);
}
.action-needed {
  background: #fef0c7;
  color: var(--warning);
}
.protected {
  background: #e0e7ff;
  color: #3538cd;
}
.teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin: 16px 0;
}
.team { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 20px; }
.team strong { overflow-wrap: anywhere; }
.flag {
  width: 34px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(20, 32, 51, .12);
}
.placeholder-flag { font-size: 28px; }
.team.away { justify-content: flex-end; text-align: right; }
.score {
  display: grid;
  place-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 26px;
  font-weight: 850;
}
.live-dot {
  color: var(--danger);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .08em;
}
.match-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.venue, .muted { color: var(--muted); }
.match-extra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  min-height: 24px;
}
.points-result {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #c7eed8;
  border-radius: 8px;
  background: #edfcf2;
  color: var(--ok);
}
.points-result strong {
  font-size: 18px;
}
.points-result span {
  color: #087443;
  font-size: 13px;
  font-weight: 800;
}
.points-result.perfect {
  border-color: #f5c542;
  background: linear-gradient(90deg, #fff7d6, #e9fff1);
  color: #8a5a00;
  box-shadow: 0 8px 24px rgba(245, 197, 66, .20);
}
.points-result.empty-points {
  border-color: #e4e7ec;
  background: #f9fafb;
  color: var(--muted);
}
.points-result.empty-points span {
  color: var(--muted);
}
.score-issue-link {
  color: #98a2b3;
  font-size: 12px;
  text-decoration: none;
}
.score-issue-link:hover {
  color: var(--ink);
  text-decoration: underline;
}
.finished-block {
  margin-top: 18px;
}
.finished-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
  cursor: pointer;
}
.finished-block summary span {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 28px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 14px;
}
.finished-block[open] summary {
  margin-bottom: 12px;
}
.prediction-form, .score-inputs { display: flex; align-items: center; gap: 8px; }
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
}
.prediction-form input, .score-inputs input { width: 58px; text-align: center; padding: 0 6px; }
.prediction-form input::placeholder { color: #98a2b3; }
.save-state {
  min-width: 96px;
  color: var(--ok);
  font-size: 13px;
  font-weight: 800;
}
.save-error .save-state { color: var(--danger); }
.button:disabled, input:read-only {
  opacity: .58;
  cursor: not-allowed;
}
.locked { color: var(--warning); font-weight: 700; }
.auth-panel { max-width: 460px; margin: 40px auto; padding: 28px; }
.lead-auth { color: var(--muted); font-size: 18px; line-height: 1.55; }
.stack { display: grid; gap: 14px; margin: 20px 0; }
.stack label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; }
.alert { padding: 12px; border-radius: 8px; background: #fff3ea; color: #9a3412; border: 1px solid #fed7aa; }
.score-pill {
  padding: 14px 18px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 22px;
  font-weight: 850;
}
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 14px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.admin-note {
  margin: -12px 0 22px;
  color: var(--muted);
  font-weight: 650;
}
.admin-match { display: flex; justify-content: space-between; gap: 12px; padding: 12px; }
.admin-match form:first-child {
  flex: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.admin-match div:first-child, .log-entry { display: grid; gap: 5px; }
.admin-match span, .log-entry span { color: var(--muted); font-size: 13px; }
.admin-match.is-protected {
  background: #f5f7ff;
}
.protect-button {
  border-color: #c7d7fe;
  color: #3538cd;
}
.log-entry { padding: 12px; }
code { white-space: pre-wrap; word-break: break-word; color: var(--muted); font-size: 12px; }

@media (max-width: 820px) {
  .topbar, .hero, .page-head, .match-bottom, .admin-match { align-items: stretch; flex-direction: column; }
  .hero { min-height: 340px; justify-content: flex-end; }
  .teams { grid-template-columns: 1fr; }
  .team.away { justify-content: flex-start; text-align: left; flex-direction: row-reverse; }
  .score { min-height: 44px; }
  .admin-grid { grid-template-columns: 1fr; }
  .prediction-form { width: 100%; justify-content: flex-start; }
  .admin-match form:first-child { flex-direction: column; }
  .match-extra { align-items: flex-start; flex-direction: column; }
}
