*, *::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;
}

.privacy-note {
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  margin-top: 4px;
  letter-spacing: 0.2px;
}

#view-toggle {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  border: 0.5px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  overflow: hidden;
  z-index: 10;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(10px);
}

.vtab {
  font-size: 13px;
  font-weight: 500;
  padding: 9px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

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

.vtab:not(.active):hover {
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.05);
}

#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 {
  position: absolute;
  bottom: 16%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.82);
  border: 0.5px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 14px 24px;
  backdrop-filter: blur(10px);
  white-space: nowrap;
  z-index: 10;
  pointer-events: auto;
}

#pick-prompt-text {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

#pick-prompt-btn {
  background: #378ADD;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

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

#personal-stats {
  padding: 16px 20px;
  background: rgba(255,255,255,0.02);
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

#personal-stats-top {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
}

#personal-history {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.history-round-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.06);
}

.history-round-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.history-round-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}

.history-round-header:hover .history-round-label {
  color: rgba(255,255,255,0.7);
}

.history-round-chevron {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  margin-left: auto;
}

.history-round-body {
  padding-top: 8px;
}

.history-empty {
  font-size: 11px;
  color: rgba(255,255,255,0.2);
  font-style: italic;
}

.history-round-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-round-accuracy {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
}

.history-champion-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 10px;
}

.history-champion-label {
  color: rgba(255,255,255,0.35);
}

.history-champion-team {
  font-weight: 700;
  font-size: 13px;
}

.history-match-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.perfect-round {
  border: 0.5px solid rgba(255,215,0,0.3);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255,215,0,0.04);
}

.perfect-badge {
  font-size: 11px;
  font-weight: 700;
  color: #FFD700;
  background: rgba(255,215,0,0.12);
  padding: 2px 8px;
  border-radius: 10px;
  border: 0.5px solid rgba(255,215,0,0.3);
}

.round-percentiles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  margin-top: 2px;
}

.round-percentile-item {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}

.round-percentile-sep {
  color: rgba(255,255,255,0.2);
  font-size: 11px;
}

.streak-peak {
  outline: 1px solid rgba(255,165,0,0.5);
}

.streak-badge {
  font-size: 11px;
  font-weight: 600;
  color: #FF9800;
  padding: 3px 10px;
  background: rgba(255,152,0,0.1);
  border-radius: 10px;
  border: 0.5px solid rgba(255,152,0,0.3);
  align-self: center;
}

.match-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  border: 0.5px solid rgba(255,255,255,0.08);
}

.chip-correct {
  background: rgba(76,175,80,0.15);
  border-color: rgba(76,175,80,0.3);
}

.chip-wrong {
  background: rgba(239,83,80,0.15);
  border-color: rgba(239,83,80,0.3);
}

.chip-team {
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
}

.chip-team-picked {
  color: #fff;
  font-weight: 700;
}

.chip-vs {
  color: rgba(255,255,255,0.2);
  font-size: 10px;
}

.chip-draw-picked {
  color: #fff;
  font-weight: 700;
  font-size: 11px;
}

.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-predict-panel {
  padding: 20px 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
  max-width: 560px;
  margin: 0 auto;
}

.match-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 16px 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.06);
}

.match-row:last-child { border-bottom: none; }

.match-time {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  width: auto;
}

.match-teams {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.2px;
}

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

.pick-btn {
  font-size: 13px;
  font-weight: 500;
  padding: 9px 20px;
  border: 0.5px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
  min-width: 100px;
}

.pick-btn:hover { background: rgba(255,255,255,0.07); color: #fff; }
.pick-btn.active { background: #378ADD; color: #fff; border-color: #378ADD; }
.pick-btn.locked { opacity: 0.3; cursor: not-allowed; }

#submit-wrap {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

#country-select {
  width: 100%;
  font-size: 15px;
  font-weight: 500;
  padding: 11px 14px;
  background: #1a1a1a;
  border: 1px solid rgba(212, 175, 55, 0.6);
  border-radius: 10px;
  color: #e8e6df;
  font-family: inherit;
  cursor: pointer;
}

#country-select:focus {
  outline: none;
  border-color: rgba(212, 175, 55, 0.9);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.15);
}

#submit-btn {
  width: 100%;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  background: #378ADD;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  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: 28px 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  text-align: center;
}

#tournament-pick-panel .panel-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  text-transform: none;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

#tournament-pick-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 18px;
}

#tournament-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  justify-content: center;
}

.team-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 0.5px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  background: transparent;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  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.35);
}

.team-btn.active {
  background: #378ADD;
  color: #fff;
  border-color: #378ADD;
  box-shadow: 0 0 10px rgba(55, 138, 221, 0.4);
}

.team-flag {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 4px;
  display: inline-block;
}

.country-flag {
  width: 24px;
  height: 18px;
  vertical-align: middle;
  margin-right: 6px;
  display: inline-block;
  border-radius: 2px;
  object-fit: cover;
}

#tournament-selected {
  margin-top: 16px;
  font-size: 15px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
}

#tournament-selected span {
  color: #fff;
  font-weight: 700;
  font-size: 17px;
}

.hidden { display: none; }

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

  #pick-prompt {
    bottom: 12%;
    padding: 10px 14px;
    gap: 10px;
  }

  #pick-prompt-text {
    font-size: 13px;
  }

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

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

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

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

  #view-toggle {
    top: 8px;
    white-space: nowrap;
  }

  .vtab {
    font-size: 11px;
    padding: 8px 14px;
    min-height: 0;
  }

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

  #map-wrap {
    overflow: hidden;
    height: 65vh;
    min-height: 420px;
  }

  #map {
    width: 100%;
  }

  .sub {
    display: none;
  }

  .privacy-note {
    font-size: 10px;
    opacity: 0.55;
    margin-top: 2px;
  }

  #tooltip {
    pointer-events: auto;
    max-height: 180px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #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-teams {
    font-size: 15px;
  }

  .match-pick {
    width: 100%;
    justify-content: center;
  }

  .pick-btn {
    min-height: 44px;
    flex: 1;
    min-width: 0;
    font-size: 12px;
    padding: 8px 6px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  #submit-wrap {
    padding: 16px 14px;
  }

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

  #submit-btn {
    min-height: 44px;
  }

  #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;
  }

  #personal-stats {
    padding: 14px;
  }

  #personal-stats-top {
    gap: 14px;
  }

  .match-chip {
    font-size: 10px;
    padding: 4px 8px;
  }
}

#round-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(90deg, #378ADD22, #378ADD11);
  border-bottom: 1px solid #378ADD55;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  flex-wrap: wrap;
}

#round-banner button {
  background: #378ADD;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

#round-banner button:hover { opacity: 0.85; }

#share-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#share-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
}

#share-modal-content {
  position: relative;
  z-index: 101;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 20px;
  background: #141414;
  border: 0.5px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}

#share-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.5);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

#share-modal-close:hover { color: #fff; background: rgba(255,255,255,0.15); }

#share-modal-header {
  text-align: center;
  padding-top: 8px;
}

#share-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

#share-modal-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
}

#share-preview {
  width: 100%;
  max-width: 240px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

#share-buttons {
  display: flex;
  gap: 10px;
  width: 100%;
}

#share-btn {
  flex: 1;
  background: linear-gradient(135deg, #833AB4 0%, #E1306C 100%);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-height: 44px;
}

#share-btn:hover {
  background: linear-gradient(135deg, #6f2f9a 0%, #c7285e 100%);
}

#download-btn {
  flex: 1;
  background: #25D366;
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-height: 44px;
}

#download-btn:hover { background: #1fb855; }

#share-modal-skip {
  font-size: 12px;
  color: rgba(255,255,255,0.25);
  cursor: pointer;
  padding: 4px;
}

#share-modal-skip:hover { color: rgba(255,255,255,0.5); }

@media (max-width: 640px) {
  #share-modal-content {
    width: 95%;
    padding: 20px 16px;
  }
  #share-buttons { flex-direction: column; }
}

.tap-hint {
  display: none;
}

@media (max-width: 640px) {
  .tap-hint {
    display: block;
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    padding: 10px 14px;
    background: #0a0a0a;
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.06);
    letter-spacing: 0.02em;
  }
}