:root {
  --bg: #0f1220;
  --panel: #171a2b;
  --panel-2: #1d2140;
  --text: #e7eaf6;
  --muted: #a7adcf;
  --accent: #00bcd4;
  --accent-2: #4dd0e1;
  --border: #2a3159;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.search {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: min(360px, 50vw);
  outline: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  font-size: 0.95rem;
}

.button:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
}

.button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.button.secondary {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid var(--border);
}

.card {
  background: linear-gradient(0deg, var(--panel), var(--panel));
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 700px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  font-size: 0.9rem;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  z-index: 1;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}

thead th.sortable:hover {
  background: #23284a;
}

thead th .sort-icon {
  margin-left: 6px;
  color: var(--muted);
  opacity: 0.65;
  font-size: 0.85em;
}

thead th[data-sort="asc"] .sort-icon::after {
  content: "▲";
}

thead th[data-sort="desc"] .sort-icon::after {
  content: "▼";
}

thead th[data-sort="none"] .sort-icon::after {
  content: "⇅";
}

tbody td {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  vertical-align: top;
  font-size: 0.95rem;
}

tbody tr:nth-child(odd) td {
  background: #161a31;
}

tbody tr:nth-child(even) td {
  background: #141833;
}

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

a.title-link:hover {
  text-decoration: underline;
}

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

.fact a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #23305a;
  color: var(--accent-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.loading,
.error,
.empty {
  padding: 16px;
  color: var(--muted);
}

.footer {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.count {
  color: var(--accent-2);
}

.nowrap {
  white-space: nowrap;
}

.fact {
  white-space: pre-wrap;
  word-break: break-word;
}

.hero-image {
  text-align: center;
  margin-bottom: 24px;
}

.hero-image img {
  max-width: 200px;
  height: auto;
  border-radius: 8px;
}

.random-fact-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 32px;
}

.random-fact-card .fact-title {
  font-size: 1.4rem;
  font-weight: 600;
}

.random-fact-card .fact-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
}

.random-fact-card .fact-body {
  font-size: 1.15rem;
  line-height: 1.75;
}

.random-fact-card .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 640px) {
  .container {
    padding: 0 12px;
  }

  table {
    min-width: 0;
  }

  .random-fact-card {
    padding: 22px;
  }

  .random-fact-card .fact-title {
    font-size: 1.25rem;
  }

  .random-fact-card .fact-body {
    font-size: 1.05rem;
  }
}
