:root {
  --pink: #ff5974;
  --red: #FF556D;
  --dark-pink: #7f2c3a;
  --text-gray: #96969b;
  --nav-h: 60px;
  --header-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --header-total: calc(var(--header-h) + var(--safe-top));
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #1a1a1a;
  color: #fff;
  min-height: 100vh;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
}

/* ─── HEADER ─── */
.header {
  position: fixed;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 600px;
  height: var(--header-total);
  padding-top: var(--safe-top);
  background: #111;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  border-bottom: 1px solid #2a2a2a;
}
.header h1 {
  font-size: 18px; font-weight: 700; letter-spacing: 2px;
  color: #fff; text-transform: uppercase;
}
.header-btn {
  position: absolute; right: 8px;
  background: none; border: none; color: #aaa; cursor: pointer;
  padding: 11px; min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.header-btn svg { width: 22px; height: 22px; }
.header-left svg { width: 22px; height: 22px; }
.header-left {
  position: absolute; left: 8px;
  background: none; border: none; color: #aaa; cursor: pointer;
  padding: 11px; min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}

/* ─── CONTENT AREA ─── */
.content {
  padding-top: var(--header-total);
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 50px);
  min-height: 100vh;
}
.content-no-nav {
  padding-top: var(--header-total);
  padding-bottom: calc(50px + var(--safe-bottom));
  min-height: 100vh;
}

/* ─── BOTTOM NAV ─── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 600px;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #111;
  border-top: 1px solid #2a2a2a;
  display: flex; align-items: center;
  z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 8px 4px;
  cursor: pointer; color: #666; transition: color .2s;
  text-decoration: none;
  -webkit-user-select: none; user-select: none;
}
.nav-item.active { color: var(--pink); }
.nav-item svg { width: 24px; height: 24px; margin-bottom: 3px; }
.nav-item span { font-size: 11px; font-weight: 500; }

/* ─── GROUPS SCREEN ─── */
.screen-groups { background: #f0f0f0; }
.group-block { margin-bottom: 2px; }
.group-header-row {
  background: #222; color: #fff;
  padding: 10px 12px;
  display: flex; align-items: center;
}
.group-header-row h2 { font-size: 15px; font-weight: 700; flex: 1; }
.group-cols { display: flex; }
.gcol { width: 28px; text-align: center; font-size: 12px; color: #aaa; font-weight: 600; }
.gcol.pts { width: 34px; color: #ffd700; }
.group-table { background: #fff; }
.team-row {
  display: flex; align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  text-decoration: none;
}
.team-row:last-child { border-bottom: none; }
.team-row:active { background: #f5f5f5; }
.team-rank { width: 20px; font-size: 13px; color: #888; }
.team-flag { width: 28px; height: 20px; object-fit: contain; margin-right: 8px; }
.team-name { flex: 1; font-size: 14px; color: #222; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.team-stat { width: 28px; text-align: center; font-size: 13px; color: #c00; }
.team-gd { width: 40px; text-align: center; font-size: 12px; color: #888; }
.team-pts { width: 34px; text-align: center; font-size: 14px; font-weight: 700; color: #ffd700; background: #222; border-radius: 4px; padding: 2px 0; }

/* ─── SCORERS ─── */
.screen-scorers { background: #1a1a2e; min-height: 100vh; }
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(100vh - var(--header-h) - var(--nav-h));
  color: rgba(255,255,255,.35);
  text-align: center; padding: 24px;
}
.empty-state h2 { font-size: 28px; margin-bottom: 8px; }
.empty-state p { font-size: 15px; }
.scorer-row {
  display: flex; align-items: center;
  background: #fff;
  border-bottom: 1px solid #ececec;
  padding: 14px 16px;
  gap: 10px;
}
.scorer-rank {
  width: 28px; flex-shrink: 0;
  font-size: 14px; font-weight: 600; color: #555;
  text-align: center;
}
.scorer-info { flex: 1; min-width: 0; }
.scorer-name {
  font-size: 15px; font-weight: 600; color: #e05a2b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scorer-club {
  font-size: 13px; color: #888; margin-top: 1px;
}
.scorer-goals {
  font-size: 22px; font-weight: 800;
  color: #9acd32; min-width: 32px; text-align: right;
}

/* ─── MATCHES ─── */
.screen-matches { background: #1a1a1a; }
.countdown-bar {
  background: #111;
  display: flex; align-items: center; justify-content: center;
  padding: 14px 0; gap: 24px;
  border-bottom: 1px solid #2a2a2a;
}
.countdown-unit { text-align: center; }
.countdown-value { font-size: 32px; font-weight: 800; line-height: 1; }
.countdown-value.red   { color: var(--pink); }
.countdown-value.orange{ color: #ff9500; }
.countdown-value.yellow{ color: #ffd700; }
.countdown-label { font-size: 11px; color: #888; letter-spacing: 1px; margin-top: 2px; }
.countdown-sep { color: #444; font-size: 24px; margin-top: -8px; }
.date-header {
  padding: 10px 14px 6px;
  font-size: 12px; letter-spacing: 1px; font-weight: 600;
  color: #888; text-transform: uppercase;
}
.match-card {
  background: #fff; margin: 0 10px 8px; border-radius: 10px;
  overflow: hidden; cursor: pointer; display: block; text-decoration: none;
}
.match-card:active { opacity: .85; }
.match-flag-row { display: flex; align-items: center; padding: 12px 14px 4px; }
.match-name-row { display: flex; align-items: center; padding: 0 14px 10px; }
.match-team { flex: 1; display: flex; align-items: center; }
.match-team.right { flex-direction: row-reverse; }
.match-flag { width: 30px; height: 22px; object-fit: contain; }
.match-team-name { font-size: 14px; font-weight: 600; color: #222; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.match-team-name.right { text-align: right; }
.match-center { text-align: center; min-width: 70px; }
.match-name-center { min-width: 70px; display: flex; justify-content: center; }
.match-time  { font-size: 16px; font-weight: 700; color: #222; }
.match-score { font-size: 20px; font-weight: 800; color: #222; }
.match-venue { font-size: 11px; color: var(--pink); font-weight: 600; padding: 0 14px 10px; }
/* ── Trận đang đá (LIVE) ── */
.match-card-live {
  border-left: 3px solid #22c55e;
}
.live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #22c55e; color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .8px;
  padding: 3px 8px; border-radius: 20px;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #fff;
  animation: livePulse 1s ease-in-out infinite; flex-shrink: 0;
}
@keyframes livePulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(.65); }
}
.live-score  { font-size: 20px; font-weight: 900; color: #111; letter-spacing: 2px; margin: 3px 0; }
.live-minute { font-size: 11px; color: #22c55e; font-weight: 700; }

/* ── Trận đã xong (FT) ── */
.match-card-done { background: #f7f7f7; border-left: 3px solid #bbb; }
.ft-badge {
  display: inline-block; background: #e0e0e0; color: #888;
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 2px 7px; border-radius: 20px; margin-bottom: 2px;
}
.ft-score { font-size: 20px; font-weight: 900; color: #333; letter-spacing: 2px; }
.match-team-name-done { color: #888; }

.round-pill {
  display: inline-block; background: #eee; color: #888;
  font-size: 11px; padding: 2px 8px; border-radius: 20px; margin: 6px 14px;
  font-weight: 600; letter-spacing: .5px;
}

/* ─── FAVORITES ─── */
.screen-favorites { background: #1a1a1a; }
.fav-header-bar { display: flex; align-items: center; padding: 12px 16px; }
.fav-add-btn { background: none; border: none; color: #fff; cursor: pointer; margin-right: 8px; }

/* ─── MORE ─── */
.screen-more { background: #1a1a1a; }
.more-list { padding: 12px; }
.more-item {
  display: flex; align-items: center;
  background: rgba(255,255,255,.07); border-radius: 12px;
  margin-bottom: 10px; padding: 16px; cursor: pointer;
  transition: background .15s;
}
.more-item:active { background: rgba(255,255,255,.12); }
.more-item-icon { width: 40px; height: 40px; background: var(--pink); border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-right: 14px; flex-shrink: 0; }
.more-item-icon svg { width: 22px; height: 22px; color: #fff; }
.more-item-text h3 { font-size: 15px; font-weight: 600; }
.more-item-text p  { font-size: 12px; color: #888; margin-top: 2px; }
.more-item-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
.more-chevron { margin-left: auto; color: #555; font-size: 20px; }

/* ─── TEAM SELECT MODAL ─── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 200; align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: #1c1c1e; border-radius: 16px 16px 0 0;
  width: 100%; max-width: 600px; margin: 0 auto;
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; padding: 16px;
  border-bottom: 1px solid #2a2a2a;
}
.modal-header h2 { flex: 1; text-align: center; font-size: 16px; font-weight: 700; letter-spacing: 1px; color: var(--pink); text-transform: uppercase; }
.modal-cancel, .modal-save { background: none; border: none; font-size: 15px; cursor: pointer; padding: 4px 8px; }
.modal-cancel { color: #aaa; }
.modal-save   { color: var(--pink); font-weight: 600; }
.modal-list { overflow-y: auto; flex: 1; }
.modal-team-item {
  display: flex; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid #2a2a2a; cursor: pointer;
}
.modal-team-item:active { background: rgba(255,255,255,.05); }
.modal-checkbox {
  width: 22px; height: 22px; border-radius: 5px; border: 2px solid #555;
  margin-right: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.modal-checkbox svg { display: none; }
.modal-checkbox.checked { background: var(--pink); border-color: var(--pink); }
.modal-checkbox.checked svg { display: block; }
.modal-flag { width: 28px; height: 20px; object-fit: contain; margin-right: 10px; }
.modal-team-name { font-size: 15px; color: #fff; }

/* ─── MATCH DETAIL PAGE ─── */
.md-bg {
  min-height: calc(100vh - var(--header-h));
  background: radial-gradient(ellipse at top left, #1a0a2e 0%, #0d0d1a 40%, #1a0a0d 100%);
  position: relative; overflow: hidden;
}
.md-bg::before {
  content:''; position: absolute; inset: 0;
  background: radial-gradient(circle at 70% 30%, rgba(180,30,60,.25) 0%, transparent 60%),
              radial-gradient(circle at 20% 70%, rgba(30,30,120,.2) 0%, transparent 50%);
  pointer-events: none;
}
.md-date {
  text-align: center; color: #4dff88; font-size: 15px;
  font-weight: 700; letter-spacing: 1px; padding: 20px 16px 12px;
  text-transform: uppercase;
}
.md-teams { padding: 8px 24px 20px; }
.md-flags-row {
  display: flex; align-items: center; justify-content: space-between;
}
.md-names-row {
  display: flex; justify-content: space-between; margin-top: 10px;
}
.md-team-col { flex: 1; text-align: center; }
.md-center-gap { min-width: 100px; flex-shrink: 0; display: flex; justify-content: center; }
.md-flag { width: 90px; height: 64px; object-fit: contain; display: inline-block; filter: drop-shadow(0 4px 12px rgba(0,0,0,.5)); }
.md-team-name { color: #4dff88; font-size: 15px; font-weight: 700; text-align: center; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding: 0 4px; }
.md-center {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; min-width: 100px; flex-shrink: 0;
}
.md-time-badge {
  background: #e8d44d; color: #111; border-radius: 20px;
  padding: 6px 16px; font-size: 18px; font-weight: 800;
  display: inline-block; margin: 0 8px;
  box-shadow: 0 0 0 6px rgba(232,212,77,.15);
}
.md-score-badge {
  background: #ff5974; color: #fff; border-radius: 20px;
  padding: 6px 16px; font-size: 22px; font-weight: 900;
  display: inline-block; letter-spacing: 4px;
}
.md-dash { color: #444; font-size: 24px; }
.md-stadium-name { color: #fff; font-size: 20px; font-weight: 700; padding: 8px 20px 12px; }
.md-stadium-img { width: 100%; max-height: 260px; object-fit: cover; display: block; }
.md-goals { display: flex; justify-content: space-between; padding: 12px 16px; gap: 12px; }
.md-goals-team { flex: 1; font-size: 13px; color: #ccc; line-height: 1.8; }
.md-goals-team.right { text-align: right; }
.md-info { padding: 16px 20px; }
.md-info-row { display: flex; margin-bottom: 8px; }
.md-info-label { width: 80px; font-size: 13px; color: #555; }
.md-info-val   { flex: 1; font-size: 13px; color: #ccc; font-weight: 500; }

/* ─── TEAM MATCH LIST PAGE ─── */
.tl-team-header {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
}
.tl-team-flag { width: 50px; height: 36px; object-fit: contain; }
.tl-team-name  { font-size: 18px; font-weight: 700; color: #fff; }
.tl-team-group { font-size: 12px; color: #888; margin-top: 2px; }
.ml-date-header {
  padding: 8px 14px 4px; font-size: 12px; letter-spacing: .8px;
  font-weight: 700; color: #555; text-transform: uppercase;
  background: #e8e8e8;
}
.ml-match-row {
  display: flex; align-items: center;
  background: #fff; border-bottom: 1px solid #eee;
  padding: 10px 14px; cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.ml-match-row:active { background: #f5f5f5; }
.ml-team-left  { display: flex; align-items: center; gap: 8px; flex: 1; }
.ml-team-right { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }
.ml-flag   { width: 26px; height: 19px; object-fit: contain; }
.ml-name   { font-size: 14px; font-weight: 600; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 110px; }
.ml-center { min-width: 72px; text-align: center; font-size: 15px; font-weight: 700; color: #222; }
.ml-venue  { font-size: 12px; color: #d0222a; font-weight: 600; padding: 2px 14px 8px; background: #fff; }
.ml-dashes { color: #999; font-size: 18px; }

/* ─── SMALL SCREEN (≤ 375px) ─── */
@media (max-width: 375px) {
  .md-flag { width: 68px; height: 48px; }
  .md-center { min-width: 80px; }
  .md-center-gap { min-width: 80px; }
  .md-score-badge { font-size: 18px; padding: 5px 12px; }
  .md-team-name { font-size: 13px; }
  .countdown-value { font-size: 26px; }
  .countdown-bar { gap: 16px; }
  .gcol { width: 24px; font-size: 11px; }
  .team-stat { width: 24px; font-size: 12px; }
  .team-gd { width: 36px; font-size: 11px; }
  .gcol.pts { width: 30px; }
  .team-pts { width: 30px; font-size: 13px; }
}

/* ─── AD BANNER ─── */
.ad-banner-wrap {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  width: 320px;
  height: 50px;
  z-index: 99;
  overflow: hidden;
}
.ad-banner-wrap.ad-bottom {
  bottom: var(--safe-bottom);
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* ─── RESPONSIVE ─── */

@media (min-width: 900px) {
  .screen-groups { padding-top: var(--header-total); padding-left: 8px; padding-right: 8px; }
  .group-block { border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
  .match-card { max-width: none; }
}
