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

:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #252525;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --green: #2ecc71;
  --light-green: #58d68d;
  --yellow: #f1c40f;
  --orange: #e67e22;
  --red: #e74c3c;
  --border: #333;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.4;
  min-height: 100vh;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0.5rem;
}

/* Character Select */
.character-select {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  position: relative;
}

.select-group {
  flex: 1;
  min-width: 0;
}

.select-group label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.select-wrapper {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.375rem;
  min-width: 0;
  height: 44px;
}

.char-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 4px;
  object-fit: contain;
  display: none;
}

.char-icon.visible {
  display: block;
}

input[type="text"],
input[list] {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  width: 100%;
}

input::placeholder {
  color: var(--text-muted);
}

.clear-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0 0.25rem;
  cursor: pointer;
  line-height: 1;
}

.clear-btn.visible {
  display: block;
}

/* Swap Button - small, center aligned with bottom of selects */
.swap-btn {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 0.625rem;
  width: 20px;
  height: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* States */
.empty-state,
.loading-state,
.no-data-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

/* Matchup Display */
.matchup-display {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.matchup-header {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.matchup-rating {
  padding: 0.1875rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.matchup-rating.big-advantage { background: var(--green); color: #000; }
.matchup-rating.slight-advantage { background: var(--light-green); color: #000; }
.matchup-rating.even { background: var(--yellow); color: #000; }
.matchup-rating.slight-disadvantage { background: var(--orange); color: #000; }
.matchup-rating.big-disadvantage { background: var(--red); color: #fff; }

.matchup-summary {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* Tip Box */
.tip-box {
  margin: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  display: flex;
  gap: 0.375rem;
  font-size: 0.8125rem;
}

.tip-box.tip {
  background: rgba(52, 152, 219, 0.15);
  border: 1px solid rgba(52, 152, 219, 0.3);
}

.tip-box.warning {
  background: rgba(230, 126, 34, 0.15);
  border: 1px solid rgba(230, 126, 34, 0.3);
}

/* Sections */
.matchup-section {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}

.matchup-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

/* Card List (Punish & Respect) */
.card-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.data-card {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
}

.card-main {
  font-weight: 600;
  color: var(--text-primary);
}

.card-detail {
  color: var(--text-secondary);
}

.card-frames {
  background: var(--bg-primary);
  color: var(--text-muted);
  font-family: monospace;
  font-size: 0.625rem;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  margin-left: auto;
}

.punish-card .card-detail::before {
  content: "→ ";
  color: var(--text-muted);
}

.respect-card {
  border-color: rgba(230, 126, 34, 0.3);
  background: rgba(230, 126, 34, 0.1);
}

/* Kill Percents */
.kills-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.kills-column h4 {
  font-size: 0.625rem;
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.kills-column ul {
  list-style: none;
  font-size: 0.75rem;
}

.kills-column.yours h4 { color: var(--green); }
.kills-column.theirs h4 { color: var(--red); }

/* Resources Section */
.resources-section {
  padding: 0.5rem;
  border-top: 1px solid var(--border);
}

.resources-section .section-title {
  margin-bottom: 0.5rem;
}

.resource-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.75rem;
}

.resource-btn:hover {
  background: var(--bg-primary);
  border-color: var(--text-muted);
}

.resource-btn-full {
  display: flex;
  width: 100%;
  margin-bottom: 0.5rem;
}

.resource-icon-stage {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
}

.resources-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.resources-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
}

.resource-char-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: contain;
}

.resource-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  width: 100%;
}

.resource-charts-label {
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.resource-charts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
}

/* Matchup Charts (for empty state) */
.mu-charts-section {
  margin-top: 1rem;
}

.mu-charts-title {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.mu-charts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  justify-content: center;
}

.mu-chart-link {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.75rem;
}

.mu-chart-link:hover {
  background: var(--bg-primary);
  border-color: var(--text-muted);
}

/* Play Buttons */
.play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.play-btn:hover {
  background: var(--bg-primary);
  transform: scale(1.1);
}

.play-btn:active {
  transform: scale(0.95);
}

.play-btn .play-icon {
  line-height: 1;
}

.play-all {
  background: var(--green);
  border-color: var(--green);
  color: #000;
}

.play-all:hover {
  background: var(--light-green);
}

/* Character Select Button */
.char-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.625rem;
  min-width: 0;
  height: 44px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.char-select:hover {
  border-color: var(--text-muted);
  background: var(--bg-tertiary);
}

.char-select:active {
  background: var(--bg-primary);
}

.char-select-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 4px;
  object-fit: contain;
  display: none;
}

.char-select-icon.visible {
  display: block;
}

.char-select-text {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.char-select-text.selected {
  color: var(--text-primary);
}

/* Progress Circle */
.progress-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  background: conic-gradient(
    var(--green) calc(var(--progress) * 3.6deg),
    var(--bg-tertiary) calc(var(--progress) * 3.6deg)
  );
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-circle::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-secondary);
}

.progress-circle::after {
  content: attr(data-progress) '%';
  position: relative;
  font-size: 0.5rem;
  font-weight: 600;
  color: var(--text-muted);
  z-index: 1;
}

.progress-circle[data-progress="0"] {
  background: var(--bg-tertiary);
}

.progress-circle[data-progress="0"]::after {
  content: '▾';
  font-size: 0.75rem;
}

.progress-circle[data-progress="100"] {
  background: var(--green);
}

.progress-circle[data-progress="100"]::after {
  content: '✓';
  color: var(--green);
}

/* Small progress circle for character picker */
.progress-circle-sm {
  width: 20px;
  height: 20px;
  margin-left: auto;
}

.progress-circle-sm::before {
  width: 12px;
  height: 12px;
  background: var(--bg-tertiary);
}

.progress-circle-sm::after {
  font-size: 0.4rem;
}

.progress-circle-sm[data-progress="0"]::after {
  font-size: 0.5rem;
}

.char-option .progress-circle-sm::before {
  background: var(--bg-tertiary);
}

.char-option:hover .progress-circle-sm::before {
  background: var(--bg-primary);
}

.char-option.selected .progress-circle-sm::before {
  background: rgba(46, 204, 113, 0.1);
}

/* Character Picker (Modal/Dropdown) */
.char-picker {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.char-picker.hidden {
  display: none;
}

.char-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.char-picker-content {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Full screen modal on all devices */
.char-picker-content {
  inset: 0;
  border: none;
  border-radius: 0;
}

.char-picker-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.char-search {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.625rem 0.75rem;
  color: var(--text-primary);
  font-size: 16px; /* Must be 16px+ to prevent iOS zoom on focus */
  outline: none;
}

.char-search:focus {
  border-color: var(--text-muted);
}

.char-picker-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
}

.char-picker-close:hover {
  background: var(--bg-primary);
}

.char-picker-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  align-content: start;
}

.char-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.char-option:hover {
  background: var(--bg-primary);
  border-color: var(--text-muted);
}

.char-option.selected {
  border-color: var(--green);
  background: rgba(46, 204, 113, 0.1);
}

.char-option-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.char-option-name {
  font-size: 0.8125rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive Typography - Tablet */
@media (min-width: 600px) {
  .select-group label {
    font-size: 0.75rem;
  }

  input[type="text"],
  input[list] {
    font-size: 1rem;
  }

  .matchup-rating {
    font-size: 0.875rem;
    padding: 0.25rem 0.625rem;
  }

  .matchup-summary {
    font-size: 0.875rem;
  }

  .tip-box {
    font-size: 0.9375rem;
  }

  .matchup-section {
    font-size: 0.9375rem;
  }

  .section-title {
    font-size: 0.625rem;
  }

  .data-card {
    font-size: 0.875rem;
  }

  .card-frames {
    font-size: 0.6875rem;
  }

  .kills-column h4 {
    font-size: 0.6875rem;
  }

  .kills-column ul {
    font-size: 0.875rem;
  }

  .resource-btn {
    font-size: 0.875rem;
  }

  .mu-chart-link {
    font-size: 0.875rem;
  }

  .char-select-text {
    font-size: 1rem;
  }

  .char-option-name {
    font-size: 0.9375rem;
  }
}

/* Responsive Typography - Desktop */
@media (min-width: 900px) {
  .container {
    max-width: 700px;
  }

  .select-group label {
    font-size: 0.8125rem;
  }

  input[type="text"],
  input[list] {
    font-size: 1.0625rem;
  }

  .matchup-rating {
    font-size: 0.9375rem;
  }

  .matchup-summary {
    font-size: 0.9375rem;
  }

  .tip-box {
    font-size: 1rem;
    padding: 0.625rem;
  }

  .matchup-section {
    font-size: 1rem;
    padding: 0.625rem;
  }

  .section-title {
    font-size: 0.6875rem;
  }

  .data-card {
    font-size: 0.9375rem;
    padding: 0.5rem 0.625rem;
  }

  .card-frames {
    font-size: 0.75rem;
  }

  .kills-column h4 {
    font-size: 0.75rem;
  }

  .kills-column ul {
    font-size: 0.9375rem;
  }

  .resource-btn {
    font-size: 0.9375rem;
  }

  .mu-chart-link {
    font-size: 0.9375rem;
  }

  .resource-char-icon {
    width: 42px;
    height: 42px;
  }

  .char-select-text {
    font-size: 1.0625rem;
  }

  .char-option-name {
    font-size: 1rem;
  }
}
