:root {
  --field: #203731;
  --field-2: #2d4f47;
  --chalk: #f4f1e8;
  --ink: #14251f;
  --muted: #5d7068;
  --line: rgba(32, 55, 49, 0.14);
  --accent: #ffb612;
  --accent-2: #ffd35a;
  --good: #203731;
  --bad: #b33a2b;
  --panel: rgba(244, 241, 232, 0.94);
  --shadow: 0 18px 50px rgba(20, 37, 31, 0.16);
  --radius: 18px;
  --font-display: "Archivo Black", Impact, sans-serif;
  --font-body: "Figtree", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: #e6eee8;
  line-height: 1.5;
}

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(255, 182, 18, 0.28), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(32, 55, 49, 0.28), transparent 50%),
    linear-gradient(180deg, #cfdcd4 0%, #e8efe9 42%, #e3ebe6 100%);
}
.bg-mesh::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image: repeating-linear-gradient(
    -12deg,
    transparent 0 10px,
    rgba(32, 55, 49, 0.38) 10px 11px
  );
  pointer-events: none;
}

a { color: var(--field-2); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  backdrop-filter: blur(14px);
  background: rgba(243, 239, 228, 0.82);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand-logo {
  display: block;
  height: 2.6rem;
  width: auto;
  max-width: min(220px, 46vw);
  object-fit: contain;
}

.nav-toggle {
  margin-left: auto;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: rgba(255,255,255,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  padding: 0;
  line-height: 0;
}
.nav-toggle span {
  display: block;
  width: 1.05rem;
  height: 2px;
  margin: 2px 0;
  background: var(--ink);
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
  transform-origin: center;
  flex: 0 0 auto;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.nav {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.85rem;
}
.nav a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.35rem 0.15rem;
  border-bottom: 2px solid transparent;
}
.nav a.btn {
  color: #f7f4ea;
  border-bottom: none;
}
.nav a.btn:hover,
.nav a.btn:focus {
  color: #ffffff;
}
.nav a.is-active { border-bottom-color: var(--accent); }
.nav a.nav-muted { color: var(--muted); font-weight: 500; }
.nav a.nav-account {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.main {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.4rem 0 3rem;
}

.footer {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}
.footer-note { margin: 0.2rem 0 0; font-size: 0.8rem; }

.flash {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(255, 182, 18, 0.22);
  border: 1px solid rgba(32, 55, 49, 0.22);
  animation: rise 0.45s ease both;
}

.hero {
  display: grid;
  gap: 1.25rem;
  padding: 1.6rem 0 0.5rem;
  animation: rise 0.55s ease both;
}
.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--field);
}
.hero-lead {
  margin: 0;
  max-width: 34rem;
  font-size: 1.08rem;
  color: var(--muted);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem;
  animation: rise 0.5s ease both;
}
.panel + .panel { margin-top: 1rem; }
.panel h2, .panel h3 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
  font-weight: 400;
}

.grid-2 {
  display: grid;
  gap: 1rem;
}
@media (min-width: 800px) {
  .grid-2 { grid-template-columns: 1.2fr 0.8fr; }
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}
@media (min-width: 640px) {
  .stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.stat {
  padding: 0.85rem 0.9rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--line);
}
.stat-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  background: linear-gradient(135deg, var(--field-2), var(--field));
  color: #f7f4ea;
  box-shadow: 0 10px 22px rgba(32, 55, 49, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); color: #ffffff; }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.9rem; }
.btn-ghost {
  background: transparent;
  color: var(--field);
  border: 1px solid rgba(32, 55, 49, 0.25);
  box-shadow: none;
}
.btn-ghost:hover { color: var(--field); background: rgba(255,255,255,0.45); }
.btn-accent {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #203731;
}

.form { display: grid; gap: 0.85rem; }
.form label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.92rem; }
.form input, .form select, .form textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(32, 55, 49, 0.2);
  background: rgba(255,255,255,0.75);
  font: inherit;
  color: var(--ink);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid rgba(255, 182, 18, 0.55);
  border-color: transparent;
}
.form .hint { font-weight: 500; color: var(--muted); font-size: 0.85rem; }

/* Week filters / selects outside .form (player pages) */
.inline-actions label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
}
select {
  appearance: auto;
  -webkit-appearance: menulist;
  font: inherit;
  color: var(--ink);
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(32, 55, 49, 0.2);
  background-color: rgba(255, 255, 255, 0.9);
  background-image: none;
  line-height: 1.3;
  max-width: 100%;
  cursor: pointer;
}
select:focus {
  outline: 2px solid rgba(255, 182, 18, 0.55);
  border-color: transparent;
}
select option {
  color: var(--ink);
  background: #fff;
}
.error {
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: rgba(179, 58, 43, 0.12);
  color: var(--bad);
  border: 1px solid rgba(179, 58, 43, 0.25);
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
table.data th, table.data td {
  padding: 0.7rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
table.data tr.is-me { background: rgba(255, 182, 18, 0.18); }
.points-pos { color: var(--good); font-weight: 700; }
.points-neg { color: var(--bad); font-weight: 700; }

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.5rem;
}
.team-option {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.55);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  min-height: 3.1rem;
}
.form label.team-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  grid-template-columns: none;
  font-weight: 600;
}
.team-option:hover { transform: translateY(-1px); border-color: rgba(20,53,42,0.35); }
.team-option.is-used {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}
.team-option.is-selected {
  border-color: var(--accent);
  background: rgba(255, 182, 18, 0.2);
  box-shadow: inset 0 0 0 1px rgba(32, 55, 49, 0.28);
}
.team-option input { position: absolute; opacity: 0; pointer-events: none; }
.team-option img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex: 0 0 auto;
}
.team-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  line-height: 1.15;
}
.team-abbr {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1;
}
.team-vs {
  font-size: 10pt;
  font-weight: 500;
  color: #8a9790;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-name {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mult-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.mult-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.6);
  cursor: pointer;
  font-weight: 700;
}
.form label.mult-chip {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  grid-template-columns: none;
  font-weight: 700;
}
.mult-chip.is-selected {
  background: var(--field);
  color: var(--chalk);
  border-color: transparent;
}
.mult-chip.is-disabled { opacity: 0.4; cursor: not-allowed; }
.mult-chip input {
  accent-color: var(--accent);
  margin: 0;
  width: auto;
  flex: 0 0 auto;
}

.game-list { display: grid; gap: 0.65rem; }
.game {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.85rem 0.9rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--line);
}
.game-side { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.game-side.away { justify-content: flex-start; }
.game-side.home { justify-content: flex-end; text-align: right; }
.game-side img { width: 28px; height: 28px; }
.game-score {
  font-family: var(--font-display);
  font-size: 1.2rem;
  text-align: center;
  min-width: 4.5rem;
}
.game-meta {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(20,53,42,0.1);
}
.badge-live { background: rgba(255, 182, 18, 0.22); color: #203731; }
.badge-final { background: rgba(31,122,76,0.15); color: var(--good); }

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.admin-tabs a, .admin-tabs button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.55);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.admin-tabs .is-active {
  background: var(--field);
  color: var(--chalk);
  border-color: transparent;
}

.muted { color: var(--muted); }
.stack { display: grid; gap: 0.85rem; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.week-links {
  max-width: 100%;
}
.week-links .btn {
  min-width: 2.4rem;
  padding: 0.4rem 0.55rem;
}

.hero-with-avatar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.hero-with-avatar .avatar {
  flex-shrink: 0;
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(32, 55, 49, 0.14);
  flex-shrink: 0;
}
.avatar-sm { width: 1.65rem; height: 1.65rem; }
.avatar-lg { width: 4.5rem; height: 4.5rem; }
.avatar-fallback {
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85em;
  color: var(--field);
}
.avatar-lg.avatar-fallback { font-size: 1.4rem; }

.player-link,
.player-link-static {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
  color: inherit;
  font-weight: 600;
  min-width: 0;
}
.player-link:hover { color: var(--accent); }
.player-link-static { font-weight: inherit; }

.player-identity {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.chirp-list {
  display: grid;
  gap: 0.85rem;
}
.chirp {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.45);
}
.chirp-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.45rem;
}
.chirp-author {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
}
.chirp-author:hover { color: var(--accent); }
.chirp-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  background: rgba(255,255,255,0.72);
  resize: vertical;
  min-height: 5rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  .nav {
    display: none;
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    top: calc(100% + 0.4rem);
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    border-radius: 16px;
    background: rgba(243, 239, 228, 0.97);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 0.65rem 0.4rem; border-bottom: none; }
  .topbar { position: sticky; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
