:root {
  color-scheme: light;
  font-family: Arial, sans-serif;
  --page-background: #f5f7fb;
  --text-color: #1f2937;
  --muted-text-color: #4b5563;
  --surface-background: #ffffff;
  --border-color: #9ca3af;
  --button-hover-background: #e5e7eb;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-background: #111827;
  --text-color: #f3f4f6;
  --muted-text-color: #d1d5db;
  --surface-background: #1f2937;
  --border-color: #6b7280;
  --button-hover-background: #374151;
}

body {
  margin: 0;
  padding: 1rem;
  background: var(--page-background);
  color: var(--text-color);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app {
  max-width: 800px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-header h1 {
  margin-top: 0;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.total-progress-block {
  flex: 1;
  min-width: 180px;
  max-width: 300px;
}

.total-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted-text-color);
}

.total-progress-label {
  white-space: nowrap;
}

#total-progress-bar {
  width: 100%;
  height: 0.75rem;
  accent-color: #2563eb;
}

#total-progress-count {
  min-width: 3.5em;
  text-align: right;
  white-space: nowrap;
}

.legend {
  width: fit-content;
  margin: 1rem auto 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--surface-background);
  font-size: 0.75rem;
  color: var(--muted-text-color);
}

.legend-title {
  font-weight: 700;
}

.legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.25rem;
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

.legend-item {
  white-space: nowrap;
  font-weight: 600;
}

.legend-item-green {
  color: #15803d;
}

.legend-item-red {
  color: #dc2626;
}

.controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

#import-input {
  display: none;
}

.import-label,
#export-button,
.tab-button,
.subtype-tab-button,
.theme-toggle,
.update-log-button,
.report-bug-button {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--surface-background);
  color: var(--text-color);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

#export-button,
.import-label {
  min-width: 9rem;
  box-sizing: border-box;
  text-align: center;
}

.import-label:hover,
#export-button:hover,
.tab-button:hover,
.subtype-tab-button:hover,
.theme-toggle:hover,
.update-log-button:hover,
.report-bug-button:hover {
  background: var(--button-hover-background);
}

.report-bug-button {
  text-align: center;
  text-decoration: none;
}

.update-log-dialog {
  width: min(90vw, 34rem);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--surface-background);
  color: var(--text-color);
  padding: 1.25rem;
}

.update-log-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.update-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.update-log-header h2 {
  margin: 0;
}

.app-version {
  margin: 0.25rem 0 0;
  color: var(--muted-text-color);
  font-size: 0.85rem;
}

.dialog-close {
  border: 0;
  background: transparent;
  color: var(--text-color);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.update-log-list {
  margin: 1rem 0 0;
  padding-left: 1.25rem;
}

.update-log-list li + li {
  margin-top: 0.75rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab-button.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.tab-panel {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  background: var(--surface-background);
}

.subtype-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.subtype-tab-button {
  flex: 0 0 auto;
}

.subtype-tab-button.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

ul {
  padding-left: 1.25rem;
}

.collectible-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
}

.collectible-row details {
  flex: 1;
}

.collectible-row summary {
  cursor: pointer;
}

.collectible-row p {
  margin: 0.35rem 0 0;
  color: var(--muted-text-color);
}

.countdown {
  font-weight: 700;
  color: #15803d;
}

:root[data-theme="dark"] .countdown {
  color: #86efac;
}

.collectible-row details img {
  display: block;
  width: min(100%, 320px);
  height: auto;
  margin-top: 0.5rem;
}

li.unobtainable .collectible-row {
  background: rgba(255, 120, 120, 0.25);
}

li.becoming-unobtainable .collectible-row {
  background: rgba(74, 222, 128, 0.28);
  outline: 1px solid rgba(22, 163, 74, 0.55);
}

@media (max-width: 520px) {
  .app-header {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .app-header h1 {
    flex: 1 1 100%;
    font-size: 1.5rem;
  }

  .total-progress-block {
    max-width: none;
  }

  .header-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
