:root {
  color-scheme: light dark;
  --foreground: #1d1d1f;
  --background: #f7f7f8;
  --accent: #0070f3;
  --surface: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: rgba(15, 23, 42, 0.08);
  --text-muted: #505050;
  --table-header-bg: #eef2ff;
  --table-row-alt: rgba(37, 99, 235, 0.06);
  --table-row-hover: rgba(59, 130, 246, 0.12);
  --table-border-strong: rgba(15, 23, 42, 0.16);
}

@media (prefers-color-scheme: dark) {
  :root {
    --foreground: #e9ecf1;
    --background: #0f172a;
    --surface: #1e293b;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: rgba(15, 23, 42, 0.3);
    --text-muted: #a0aec0;
    --table-header-bg: rgba(0, 112, 243, 0.2);
    --table-row-alt: rgba(148, 163, 184, 0.18);
    --table-row-hover: rgba(59, 130, 246, 0.32);
    --table-border-strong: rgba(148, 163, 184, 0.4);
  }
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--foreground);
  background: radial-gradient(circle at top, #eef3ff 0%, var(--background) 55%);
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

.page-header,
.page-footer {
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  text-align: center;
  background-color: transparent;
}

.page-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.page-header p {
  margin: 0;
  color: var(--text-muted);
}

.page-content {
  padding: 0 clamp(1rem, 4vw, 3rem) 3rem;
  flex: 1;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  margin-bottom: 1rem;
  background-color: var(--surface);
  border-radius: 1rem;
  box-shadow: 0 12px 24px var(--shadow);
  border: 1px solid var(--border);
}

.controls-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 200px;
}

.controls label {
  font-weight: 600;
}

.controls select {
  min-width: min(360px, 80vw);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.controls select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 112, 243, 0.2);
}

.reset-button {
  padding: 0.7rem 1.5rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 112, 243, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.reset-button:focus,
.reset-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 112, 243, 0.35);
}

.cards-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.table-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.status-message {
  text-align: center;
  color: var(--text-muted);
  margin: 0;
  font-size: 1rem;
}

.cards-container {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.set-block {
  background: var(--surface);
  border-radius: 1.25rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 14px 28px var(--shadow);
}

.set-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.set-header h2 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 1.8rem);
}

.set-header span {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.25rem;
}

.card-tile {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.65));
  border-radius: 1rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 18px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-tile:hover,
.card-tile:focus-within {
  transform: translateY(-3px);
  box-shadow: 0 18px 28px rgba(15, 23, 42, 0.12);
}

.card-image {
  width: 100%;
  aspect-ratio: 7 / 10;
  border-radius: 0.75rem;
  object-fit: cover;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.card-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.card-number {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.card-pricing {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--text-muted);
}

.card-pricing span {
  display: block;
}

.error-message {
  color: #dc2626;
  text-align: center;
  font-weight: 600;
}

.table-wrapper {
  overflow-x: auto;
  background: var(--surface);
  border-radius: 1rem;
  border: 1px solid var(--border);
  box-shadow: 0 14px 28px var(--shadow);
  padding: 1rem;
}

#cards-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
  font-size: 0.95rem;
}

#cards-table thead th {
  position: sticky;
  top: 0;
  background: var(--table-header-bg);
  color: var(--foreground);
  backdrop-filter: blur(6px);
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--table-border-strong);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#cards-table tbody tr:nth-child(even) {
  background: var(--table-row-alt);
}

#cards-table tbody tr:hover {
  background: var(--table-row-hover);
}

#cards-table td {
  padding: 0.75rem;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
}

#cards-table td pre {
  margin: 0;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 600px) {
  .controls {
    align-items: stretch;
  }

  .controls select {
    min-width: 100%;
  }

  .table-wrapper {
    padding: 0.5rem;
  }
}
