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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0a0a0a;
  color: #e8e6df;
  min-height: 100vh;
}

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 0.5px solid rgba(255,255,255,0.1);
  flex-wrap: wrap;
  gap: 10px;
}

#header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: #fff;
}

.sub {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
}

#view-toggle {
  display: flex;
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  overflow: hidden;
}

.vtab {
  font-size: 12px;
  padding: 7px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.45);
  transition: all 0.15s;
  font-family: inherit;
}

.vtab.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-weight: 500;
}

#prediction-count {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
}

#header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

#map-wrap {
  position: relative;
  background: #111;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

#map {
  width: 100%;
  position: relative;
}

#legend {
  display: none;
}

#map svg {
  display: block;
  width: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#tooltip {
  display: none;
  position: absolute;
  background: #1a1a1a;
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
  min-width: 180px;
  max-width: 220px;
}

.tt-country {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 0.5px solid rgba(255,255,255,0.1);
  color: #fff;
}

.tt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.tt-label { color: rgba(255,255,255,0.45); }
.tt-val { font-weight: 500; color: #fff; }

.tt-bar-wrap {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.tt-bar-fill { height: 100%; border-radius: 2px; }

#pick-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(55, 138, 221, 0.12);
  border-top: 0.5px solid rgba(55, 138, 221, 0.3);
  border-bottom: 0.5px solid rgba(55, 138, 221, 0.3);
  gap: 12px;
  flex-wrap: wrap;
}

#pick-prompt-text {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
}

#pick-prompt-btn {
  background: #378ADD;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

#pick-prompt-btn:hover {
  background: #2d6ab5;
}

#personal-stats {
  display: flex;
  gap: 24px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-value {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

#panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

#panel-left {
  padding: 14px 16px;
  border-right: 0.5px solid rgba(255,255,255,0.08);
}

#panel-right { padding: 14px 16px; }

.panel-title {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.06);
  font-size: 12px;
}

.lb-row:last-child { border-bottom: none; }
.lb-rank { font-size: 10px; color: rgba(255,255,255,0.25); width: 14px; flex-shrink: 0; }
.lb-flag { font-size: 14px; width: 20px; text-align: center; flex-shrink: 0; }
.lb-name { color: #e8e6df; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-val { font-weight: 500; color: #fff; font-size: 11px; white-space: nowrap; }

.lb-show-more {
  background: none;
  border: 0.5px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.4);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 6px;
  font-family: inherit;
  width: 100%;
}
.lb-show-more:hover {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.3);
}

.bar-wrap {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill { height: 100%; border-radius: 2px; }

#predict-panel {
  padding: 14px 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

.match-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.06);
  font-size: 13px;
}

.match-row:last-child { border-bottom: none; }
.match-time { font-size: 11px; color: rgba(255,255,255,0.35); width: 48px; flex-shrink: 0; }
.match-teams { flex: 1; color: #e8e6df; }

.match-pick { display: flex; gap: 4px; }

.pick-btn {
  font-size: 11px;
  padding: 4px 8px;
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.pick-btn:hover { background: rgba(255,255,255,0.07); color: #fff; }
.pick-btn.active { background: #378ADD; color: #fff; border-color: #378ADD; }

#submit-wrap {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

#country-select {
  flex: 1;
  font-size: 13px;
  padding: 7px 10px;
  background: #1a1a1a;
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: #e8e6df;
  font-family: inherit;
}

#submit-btn {
  font-size: 13px;
  padding: 7px 18px;
  background: #378ADD;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  transition: opacity 0.15s;
}

#submit-btn:hover { opacity: 0.85; }
#submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#about-section {
  margin: 0 16px 20px;
  border: 0.5px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: #111;
  overflow: hidden;
}

#about-section summary {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #e8e6df;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

#about-section summary::-webkit-details-marker { display: none; }

#about-section summary::after {
  content: '+';
  float: right;
  color: rgba(255,255,255,0.35);
  font-weight: 400;
}

#about-section[open] summary::after { content: '−'; }

#about-section .about-body {
  padding: 0 14px 14px;
  border-top: 0.5px solid rgba(255,255,255,0.08);
}

#about-section .about-item {
  padding-top: 12px;
}

#about-section .about-item strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

#about-section .about-item p {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255,255,255,0.45);
  margin: 0;
}

.loading { color: rgba(255,255,255,0.3); font-size: 12px; }
.no-data { color: rgba(255,255,255,0.3); font-size: 12px; margin-top: 4px; }

.match-stage {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 0 4px;
}
#zoom-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}

#zoom-controls button {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.08);
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: background 0.15s;
}

#zoom-controls button:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.tt-uk-nation {
  margin-top: 4px;
  padding-top: 4px;
}

.tt-uk-label {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  margin-bottom: 3px;
}
#tournament-pick-panel {
  padding: 14px 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

#tournament-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.team-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.team-btn:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}

.team-btn.active {
  background: #378ADD;
  color: #fff;
  border-color: #378ADD;
}

#tournament-selected {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

#tournament-selected span {
  color: #fff;
  font-weight: 500;
}

#match-predict-panel {
  padding: 14px 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

.hidden { display: none; }

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  #pick-prompt {
    flex-direction: column;
    align-items: flex-start;
  }

  #header {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    gap: 12px;
  }

  #header-left {
    min-width: 0;
  }

  #header h1 {
    font-size: 18px;
  }

  .sub {
    font-size: 11px;
    line-height: 1.4;
    max-width: 100%;
  }

  #header-controls {
    justify-content: space-between;
    width: 100%;
    gap: 10px;
    margin-left: 0;
  }

  #view-toggle {
    flex: 1 1 auto;
    min-width: 0;
  }

  .vtab {
    flex: 1;
    padding: 10px 8px;
    font-size: 11px;
    min-height: 44px;
  }

  #prediction-count {
    flex: 1 1 100%;
    font-size: 11px;
    line-height: 1.4;
  }

  #map-wrap {
    overflow: hidden;
  }

  #zoom-controls {
    bottom: 10px;
    right: 10px;
    gap: 6px;
  }

  #zoom-controls button {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  #panels {
    grid-template-columns: 1fr;
  }

  #panel-left {
    border-right: none;
    border-bottom: 0.5px solid rgba(255,255,255,0.08);
    padding: 12px 14px;
  }

  #panel-right {
    padding: 12px 14px;
  }

  #predict-panel {
    padding: 0;
  }

  #tournament-pick-panel,
  #match-predict-panel {
    padding: 12px 14px;
  }

  #tournament-teams {
    gap: 8px;
  }

  .team-btn {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 12px;
    -webkit-tap-highlight-color: transparent;
  }

  .match-row {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
  }

  .match-time {
    width: auto;
    flex: 0 0 auto;
  }

  .match-teams {
    flex: 1 1 calc(100% - 56px);
    min-width: 0;
    font-size: 12px;
    line-height: 1.35;
  }

  .match-pick {
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }

  .pick-btn {
    min-height: 44px;
    padding: 8px 6px;
    font-size: 11px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
  }

  #submit-wrap {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    gap: 10px;
  }

  #country-select {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  #submit-btn {
    width: 100%;
    min-height: 44px;
    padding: 12px 18px;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
  }

  #about-section {
    margin: 0 14px 16px;
  }

  #about-section summary {
    padding: 14px;
    font-size: 13px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  #about-section summary::after {
    float: none;
  }

  #about-section .about-item p {
    font-size: 13px;
  }
}