:root {
  --bg: #f0f5f1;
  --card: #ffffff;
  --line: #e2eae4;
  --line2: #cfe2d5;
  --text: #14271c;
  --muted: #6e8377;
  --accent: #00a857;
  --accent-dark: #007a3f;
  --accent-soft: #e6f7ed;
  --gold: #d9920b;
  --gold-soft: #fdf3df;
  --red: #d94855;
  --red-soft: #fdecee;
  --shadow: 0 2px 12px rgba(20, 39, 28, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(110% 45% at 50% -8%, #ddf0e3 0%, transparent 65%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.2px;
}
.title-logo { width: 28px; height: 28px; object-fit: contain; }

.whoami {
  border: 1px solid var(--line2);
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 800;
}

main { padding: 16px 14px 24px; max-width: 560px; margin: 0 auto; }

/* ---------- crests ---------- */
.crest {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(20, 39, 28, 0.18));
}
.crest-sm { width: 22px; height: 22px; object-fit: contain; flex-shrink: 0; }
.crest-xs { width: 15px; height: 15px; object-fit: contain; vertical-align: -3px; }
.flag { font-size: 28px; line-height: 1; }

/* ---------- name screen ---------- */
.hero { text-align: center; padding: 26px 8px 14px; }
.hero-logo {
  width: 130px;
  height: 130px;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 168, 87, 0.25));
}
.hero h1 { font-size: 27px; margin-top: 14px; line-height: 1.2; letter-spacing: -0.3px; }
.hero p { color: var(--muted); margin-top: 8px; font-size: 15px; line-height: 1.45; }

.namebox { margin-top: 24px; }
.namebox label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.name-input {
  width: 100%;
  font-size: 18px;
  padding: 15px 16px;
  border-radius: 16px;
  border: 1.5px solid var(--line2);
  background: var(--card);
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow);
}
.name-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 168, 87, 0.12); }

.big-btn {
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  font-size: 17px;
  font-weight: 800;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 168, 87, 0.3);
}
.big-btn:active { transform: scale(0.98); opacity: 0.92; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--line2);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 11px 17px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.chip:active { background: var(--accent-soft); border-color: var(--accent); }

.didyoumean {
  margin-top: 14px;
  background: var(--gold-soft);
  border: 1px solid #f0d9a8;
  border-radius: 16px;
  padding: 15px;
  font-size: 15px;
  line-height: 1.45;
}
.didyoumean .row { display: flex; gap: 10px; margin-top: 12px; }
.didyoumean button {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line2);
  font-size: 15px;
  font-weight: 800;
  background: var(--card);
  color: var(--text);
}
.didyoumean button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- predict ---------- */
.progress-wrap {
  margin-bottom: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 15px;
  box-shadow: var(--shadow);
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 800;
}
.progress-label span:last-child { color: var(--accent-dark); }
.progress-bar { height: 9px; border-radius: 99px; background: #e8efe9; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6fd39b);
  border-radius: 99px;
  transition: width 0.3s;
}

.toggle-all {
  width: 100%;
  margin-bottom: 16px;
  padding: 14px;
  font-size: 15px;
  font-weight: 800;
  border: 1.5px solid var(--line2);
  border-radius: 16px;
  background: var(--card);
  color: var(--accent-dark);
  box-shadow: var(--shadow);
}
.toggle-all:active { background: var(--accent-soft); }

.lock-hint {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin: -6px 4px 14px;
  line-height: 1.4;
}
.lock-hint b { color: var(--text); }

.banner {
  background: linear-gradient(135deg, #e9f8ef, #d9f3e3);
  border: 1px solid #b9e6ca;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 15px;
  line-height: 1.5;
}
.banner.gold { background: linear-gradient(135deg, #fdf6e4, #fbeecb); border-color: #f0d9a8; }

.section-label {
  font-size: 13px;
  font-weight: 900;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 4px 10px;
}

.date-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 14px 4px 9px;
}
.date-head::after { content: ""; flex: 1; height: 1px; background: var(--line2); }
.date-head .today-tag {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 99px;
  letter-spacing: 0.5px;
}
.date-head .tmrw-tag {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--line2);
  font-size: 10px;
  padding: 2.5px 9px;
  border-radius: 99px;
}

.match {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.match.done { background: #fbfdfb; }

.match-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.kick { margin-left: 8px; font-size: 12px; font-weight: 800; color: var(--text); }
.tz-row {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.group-badge {
  font-size: 11px;
  font-weight: 900;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 4px 11px;
  border-radius: 99px;
  letter-spacing: 0.6px;
}
.match-status { font-size: 12px; color: var(--muted); font-weight: 700; }
.match-status.saved { color: var(--accent-dark); }

.match-row { display: grid; grid-template-columns: 1fr 92px; gap: 8px; align-items: center; }
.match-row + .match-row { margin-top: 9px; }

.team { display: flex; align-items: center; gap: 11px; min-width: 0; }
.team .tname { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.score-cell { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.score-input {
  width: 54px;
  height: 46px;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
  background: #f2f6f3;
  border: 1.5px solid var(--line2);
  border-radius: 13px;
  outline: none;
  caret-color: var(--accent);
}
.score-input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px rgba(0, 168, 87, 0.1); }
.score-input:disabled { opacity: 0.55; }
.real-score { font-size: 18px; font-weight: 900; width: 30px; text-align: center; color: var(--gold); }

.points-pill {
  display: inline-block;
  margin-top: 11px;
  font-size: 13px;
  font-weight: 900;
  padding: 5px 13px;
  border-radius: 99px;
}
.pts-3 { background: var(--gold-soft); color: var(--gold); }
.pts-1 { background: var(--accent-soft); color: var(--accent-dark); }
.pts-0 { background: var(--red-soft); color: var(--red); }

/* played-matches accordion */
.played-box {
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.played-box summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 16px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.played-box summary::-webkit-details-marker { display: none; }
.played-box summary .arrow { color: var(--muted); transition: transform 0.2s; }
.played-box[open] summary .arrow { transform: rotate(90deg); }
.played-box .inner { padding: 0 12px 12px; }
.played-box .inner .match { box-shadow: none; }
.played-pts { color: var(--gold); }

.locked-note {
  text-align: center;
  background: var(--card);
  border: 1.5px dashed var(--line2);
  border-radius: 18px;
  padding: 18px 16px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
}
.locked-note b { color: var(--text); }

/* ---------- leaderboard ---------- */
.board-title { font-size: 20px; font-weight: 900; margin: 4px 4px 14px; letter-spacing: -0.2px; }

.board-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px 14px;
  margin-bottom: 10px;
  width: 100%;
  color: var(--text);
  font-size: 16px;
  text-align: left;
  box-shadow: var(--shadow);
}
.board-row:active { background: var(--accent-soft); }
.board-row.top1 { border-color: #ecc94b; background: linear-gradient(135deg, #fffdf4, #fdf6e0); }
.board-rank { font-size: 19px; font-weight: 900; width: 34px; text-align: center; }
.board-name { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.board-pts { font-weight: 900; color: var(--gold); white-space: nowrap; }
.board-sub { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 3px; }

.score-rules {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-top: 16px;
  line-height: 1.6;
}

.back-btn {
  border: 1px solid var(--line2);
  background: var(--card);
  color: var(--accent-dark);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.pick-teams { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 800; }
.pick-teams .sep { color: var(--muted); font-weight: 500; }
.pick-val { font-weight: 900; white-space: nowrap; }
.pick-val .res { color: var(--gold); font-weight: 700; font-size: 12px; }
.locked { color: var(--muted); font-size: 13px; }

.empty { text-align: center; color: var(--muted); padding: 44px 16px; font-size: 15px; line-height: 1.55; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 11px 0 9px;
  background: none;
  border: none;
  color: #9aab9f;
  font-size: 11px;
  font-weight: 800;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent-dark); }

/* ---------- account sheet ---------- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 20, 0.4);
  z-index: 60;
  display: flex;
  align-items: flex-end;
}
.sheet {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-up 0.22s ease-out;
  box-shadow: 0 -8px 40px rgba(15, 30, 20, 0.18);
}
@keyframes sheet-up {
  from { transform: translateY(40%); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-title { text-align: center; font-size: 16px; font-weight: 900; margin-bottom: 8px; }
.sheet-btn {
  display: block;
  width: 100%;
  padding: 15px;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid var(--line2);
  background: #f6faf7;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}
.sheet-btn small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.sheet-btn:active { opacity: 0.8; }
.sheet-btn.danger { color: var(--red); border-color: #f3c2c8; background: var(--red-soft); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #122a1b;
  color: #fff;
  padding: 12px 19px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 700;
  z-index: 50;
  white-space: nowrap;
  box-shadow: 0 8px 28px rgba(15, 30, 20, 0.35);
}
