/* Shared responsive layout — phones, tablets, small screens */

/* ── Global: prevent horizontal page scroll ── */
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
}

.header {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.main,
main {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.section,
.card,
.stat-card,
.match-card,
.ticker,
.grid-2,
.grid-3,
.grid-4,
.grid-auto,
.stat-cards {
  max-width: 100%;
  min-width: 0;
}

/* ── Tablet ── */
@media (max-width: 1024px) {
  .main { padding: 20px; }
  .card { padding: 20px; }
}

/* ── Mobile / small tablet ── */
@media (max-width: 768px) {
  .main { padding: 16px; }
  .card { padding: 16px; border-radius: 14px; }
  .section-title { font-size: clamp(1.2rem, 4.5vw, 1.5rem); line-height: 1.25; }
  .section-subtitle { font-size: 13px; margin-bottom: 16px; line-height: 1.5; }

  /* Stats grid — always fit viewport */
  .stat-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  /* Match cards — 3-column grid keeps VS/score on one row */
  .match-card { padding: 14px 12px; }
  .match-meta { flex-wrap: wrap; gap: 6px; }
  .match-teams {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 6px 8px;
  }
  .team { min-width: 0; }
  .team-name {
    font-size: 11px;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
    max-width: none;
    word-break: break-word;
  }
  .team-flag { width: 28px; height: 28px; flex-shrink: 0; }
  .team-flag .flag-img { width: 24px; }
  .match-score { min-width: 0; padding: 0 2px; }
  .score-display { font-size: 18px; letter-spacing: 2px; }
  .score-vs { font-size: 11px; }
  .match-venue { font-size: 10px; flex-wrap: wrap; line-height: 1.4; }

  /* Scrollable tables */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px 4px;
  }
  .table-scroll::-webkit-scrollbar { height: 4px; }
  .table-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 2px; }
  .standings-table { min-width: 520px; }
  .table-scroll table { min-width: 480px; }

  /* Grids */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  .grid-auto { grid-template-columns: 1fr; }
  .stat-card { padding: 14px 10px; }
  .stat-card .stat-value { font-size: 24px; }
  .stat-card .stat-icon { font-size: 22px; }

  /* Bracket — scroll inside container only */
  .bracket-container {
    margin: 0;
    padding: 12px 0 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .bracket { gap: 20px; }
  .bracket-round { min-width: 188px; }
  .bracket-team { padding: 8px 10px; font-size: 11px; }
  .bracket-team .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
    display: inline-block;
    vertical-align: bottom;
  }

  /* Predictions & news */
  .prediction-team .name { font-size: 11px; }
  .prediction-bar .bar-value { font-size: 14px; }
  .prediction-bars { gap: 6px; }
  .news-title { font-size: 15px; }
  .news-card { padding: 16px; }

  /* Ticker */
  .ticker {
    padding: 8px 10px;
    margin-bottom: 14px;
    width: 100%;
    box-sizing: border-box;
  }
  .ticker-item { font-size: 12px; gap: 6px; }

  /* Modals — bottom sheet on mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-height: 94vh;
    border-radius: 16px 16px 0 0;
    max-width: 100%;
  }
  .modal-head { padding: 14px 16px; }
  .modal-head h2 { font-size: 16px; }
  .modal-body { padding: 16px; font-size: 14px; }

  /* Tabs & filters */
  .tab-bar { margin-bottom: 14px; max-width: 100%; }
  .tab-btn { padding: 8px 12px; font-size: 11px; min-height: 36px; }
  .filter-pills { gap: 6px; margin-bottom: 14px; }
  .pill { padding: 6px 12px; font-size: 11px; min-height: 34px; }
  .card-header { flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .card-title { font-size: 14px; }

  /* Match detail page */
  .hero { padding: 22px 14px 20px; border-radius: 16px; }
  .hero-teams { gap: 6px 8px; }
  .hero-team .name { font-size: clamp(10px, 2.8vw, 14px); }
  .hero-score { font-size: clamp(26px, 8.5vw, 40px); letter-spacing: 2px; }
  .hero-meta { font-size: 10px; margin-bottom: 14px; }
  .hero-status { font-size: 11px; padding: 5px 12px; }
  .hero-venue { font-size: 10px; }

  /* Qualified page */
  .group-grid { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: clamp(1.35rem, 5vw, 1.75rem); }
  .stat-card .val { font-size: 24px; }
  .team-card { gap: 10px; flex-wrap: wrap; }

  /* Full-bleed heroes on subpages (not match scoreboard) */
  .main .hero:not(.match-hero) {
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .match-hero {
    margin-left: 0;
    margin-right: 0;
    padding-left: 16px;
    padding-right: 16px;
    align-items: center;
  }

  .match-hero .hero-teams {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    justify-content: space-between;
    padding: 0;
  }

  .match-hero .hero-team {
    flex: 1 1 0;
    min-width: 0;
  }

  .match-hero .hero-score {
    flex: 0 0 auto;
    margin: 0 clamp(2px, 1vw, 8px);
  }

  /* Egypt hub */
  .hero-qual { margin-left: 0; width: 100%; }
  .stat-cards.egypt-stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .hero-qual .pct { font-size: 36px; }
  .match-row { flex-wrap: wrap; gap: 8px; }
  .match-meta { min-width: auto; text-align: left; width: 100%; }
  .news-grid { grid-template-columns: 1fr; }
  .video-grid { grid-template-columns: 1fr; }
  .outlook-block { padding: 16px; }
  .outlook-block h3 { font-size: 15px; }
}

/* ── Small phones ── */
@media (max-width: 480px) {
  .main { padding: 12px; }
  .logo-text h1 { font-size: 15px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-label { font-size: 10px; }
  .team-name { font-size: 10px; }
  .score-display { font-size: 16px; letter-spacing: 1px; }
  .score-vs { font-size: 10px; }
  .scorer-goals { font-size: 16px; }
  .search-box input { font-size: 16px; padding: 11px 14px 11px 40px; }
  .match-hero { padding-left: 12px; padding-right: 12px; }
  .match-hero .hero-teams { gap: 4px; }
  .hero-teams { gap: 4px 6px; }
  .hero-score { font-size: clamp(24px, 7.5vw, 32px); min-width: 0; }
  .flag-img.flag-lg { width: clamp(36px, 11vw, 48px); }
  .stat-bar-wrap .val { width: 28px; font-size: 11px; }
  .stat-row-head { font-size: 12px; }
  .card { padding: 14px; }
  .page-toolbar { padding: 8px 12px; }
  .back-btn { font-size: 13px; padding: 8px 12px; min-height: 44px; }
  .site-footer { padding: 20px 12px 28px; font-size: 11px; }
  .visitor-counter { font-size: 10px; }
  .stat-card .val { font-size: 20px; }
  .team-card .qual-wrap {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
  }
}

@media (max-width: 360px) {
  .stat-cards { grid-template-columns: 1fr !important; }
}

/* Touch-friendly: reduce hover-only hints on touch devices */
@media (hover: none) {
  .match-hint { opacity: 1; font-size: 9px; }
  .match-card:hover { transform: none; }
}
