/* Reset and base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  color: #e0e0e0;
  background: #1a1a1a;
  text-transform: uppercase;
  font-style: italic;
}

.container {
  width: min(100% - 2rem, 64rem);
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

/* Header / Logo */
header {
  margin-bottom: 2rem;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.logo-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 800;
  color: #e0e0e0;
  text-transform: uppercase;
  font-style: italic;
  flex: 1;
}

.logo-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #999;
  text-transform: uppercase;
  font-style: italic;
  padding: 0.2rem 0.6rem;
  border: 1px solid #444;
  border-radius: 0.35rem;
  flex-shrink: 0;
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.controls select {
  flex: 1 1 14rem;
}

select {
  width: 100%;
  padding: 0.85rem 2.5rem 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #e0e0e0;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  text-transform: uppercase;
  font-style: italic;
}

select:focus-visible {
  outline: none;
  border-color: #666;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08), 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Warning */
.warning {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  color: #f0a0a0;
  background: #2a1a1a;
  border: 1px solid #5a2a2a;
  border-radius: 0.5rem;
  font-weight: 600;
}

/* Matchup */
.matchup {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.matchup .ranking-row {
  flex: 1;
}

.matchup-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1rem;
  color: #999;
  padding: 0 0.25rem;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .matchup {
    flex-direction: column;
    gap: 0.5rem;
  }

  .matchup-vs {
    padding: 0.25rem 0;
  }
}

/* Rankings */
.rankings {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, filter 0.15s, opacity 0.15s, box-shadow 0.15s;
  text-transform: uppercase;
  font-weight: 700;
  overflow: hidden;
  position: relative;
}

.flag-bg {
  position: absolute;
  top: 50%;
  left: -100px;
  transform: translateY(-50%) rotate(75deg);
  width: 85%;
  height: auto;
  opacity: 0.10;
  pointer-events: none;
  z-index: 0;
  -webkit-mask-image: linear-gradient(to right, black 30%, transparent 80%);
  mask-image: linear-gradient(to right, black 30%, transparent 80%);
}

.rank {
  font-weight: 900;
  color: rgba(255, 255, 255, 0.15);
  font-size: clamp(3.5rem, 8vw, 5.5rem);
  line-height: 1;
  position: absolute;
  top: 50%;
  left: 0.5rem;
  transform: translateY(-50%);
  pointer-events: none;
  width: clamp(3rem, 10vw, 3.5rem);
  text-align: center;
  font-variant-numeric: tabular-nums;
  z-index: 2;
}

.nation {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  font-weight: 900;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  padding: 0.85rem 50% 0.85rem clamp(3.25rem, 12vw, 4rem);
  position: relative;
  z-index: 2;
}

.flag {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid #ffffff;
}

.power {
  font-weight: 900;
  color: #fff;
  font-size: clamp(2.75rem, 7vw, 5.5rem);
  line-height: 1;
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 clamp(0.65rem, 3vw, 1rem) 0 clamp(1.5rem, 6vw, 4rem);
  width: clamp(5rem, 34%, 50%);
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
  z-index: 2;
  pointer-events: none;
}

/* Row states */
.ranking-row.projected {
  background: #3a3a3a;
  border-color: #555;
}

.ranking-row.projected .power {
  color: #aaa;
}

.ranking-row.scoreless:not(.projected) {
  filter: grayscale(100%);
  opacity: 0.5;
}

.ranking-row.highlight {
  background: #3a3a3a;
  border-color: #666;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.ranking-row.highlight .nation,
.ranking-row.highlight .power {
  font-weight: 800;
}

.ranking-row.dim {
  filter: grayscale(100%);
  opacity: 0.45;
}

/* Desktop */
@media (min-width: 641px) {
  .nation {
    padding-right: 36%;
  }
}

/* Mobile */
@media (max-width: 640px) {
  .container {
    padding: 1.25rem 0 3rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .controls select {
    flex: 1 1 auto;
    width: 100%;
  }

  .ranking-row {
    gap: 0.5rem;
    min-height: 4rem;
  }

  .rank {
    font-size: 4rem;
    width: 3rem;
  }

  .power {
    font-size: 2.5rem;
    width: 32%;
    min-width: 4rem;
  }

  .nation {
    padding: 0.5rem 36% 0.5rem 3.75rem;
  }

  .flag-bg {
    left: -60px;
    width: 75%;
  }
}

/* Very small screens */
@media (max-width: 360px) {
  .logo-row {
    padding: 0.75rem 1rem;
    gap: 0.65rem;
  }

  .rank {
    font-size: 3.5rem;
    width: 2.75rem;
  }

  .power {
    font-size: 2.25rem;
    width: 30%;
  }

  .nation {
    padding: 0.5rem 34% 0.5rem 3.5rem;
  }
}
