:root {
  --bg: #0f1419;
  --bg-elevated: #1a2332;
  --bg-card: #1e2a3a;
  --border: #2d3a4f;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #5eb8ff;
  --accent-soft: rgba(94, 184, 255, 0.12);
  --tag-week: #7c6cff;
  --tag-topic: #3ecf8e;
  --tag-note: #f0a04b;
  --tag-source: #5eb8ff;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(94, 184, 255, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(124, 108, 255, 0.06), transparent);
}

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

a:hover {
  text-decoration: underline;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  max-width: 1400px;
  margin: 0 auto;
  gap: 0;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: rgba(15, 20, 29, 0.85);
  backdrop-filter: blur(8px);
}

.main {
  padding: 1.5rem 2rem 3rem;
  min-width: 0;
}

.brand h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.search-box {
  position: relative;
  margin-bottom: 1rem;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--accent);
}

.filter-mode {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.filter-mode button {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-mode button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.tag-section {
  margin-bottom: 1.25rem;
}

.tag-section h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-chip:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.tag-chip.active {
  color: var(--text);
  border-color: transparent;
}

.tag-chip.source.active {
  background: rgba(94, 184, 255, 0.25);
}

.tag-chip.week.active {
  background: rgba(124, 108, 255, 0.25);
}

.tag-chip.topic.active {
  background: rgba(62, 207, 142, 0.2);
}

.tag-chip.note.active {
  background: rgba(240, 160, 75, 0.2);
}

.clear-filters {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.clear-filters:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.stats-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.stats-bar .count {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.stats-bar .count strong {
  color: var(--text);
  font-weight: 600;
}

.sort-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.8rem;
}

.paper-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.paper-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.paper-card:hover {
  border-color: rgba(94, 184, 255, 0.35);
  box-shadow: var(--shadow);
}

.paper-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
  margin: 0 0 0.35rem;
}

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

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

.paper-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.4rem;
}

.paper-tag {
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.paper-tag.source {
  color: var(--tag-source);
  background: rgba(94, 184, 255, 0.1);
}

.paper-tag.week {
  color: var(--tag-week);
  background: rgba(124, 108, 255, 0.1);
}

.paper-tag.topic {
  color: var(--tag-topic);
  background: rgba(62, 207, 142, 0.1);
}

.paper-tag.note {
  color: var(--tag-note);
  background: rgba(240, 160, 75, 0.1);
}

.paper-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  font-style: italic;
}

.paper-url {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  word-break: break-all;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.loading {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main {
    padding: 1rem;
  }
}

/* —— Home —— */
.home {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1.5rem;
}

.home-inner {
  text-align: center;
  max-width: 520px;
}

.home-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 600;
  margin: 0 0 0.5rem;
  letter-spacing: -0.03em;
}

.home-subtitle {
  color: var(--text-muted);
  margin: 0 0 2.5rem;
  font-size: 1rem;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.home-btn {
  display: block;
  padding: 1.1rem 1.5rem;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  border: 1px solid var(--border);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.home-btn:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.home-btn-primary {
  background: linear-gradient(135deg, rgba(94, 184, 255, 0.22), rgba(124, 108, 255, 0.18));
  border-color: rgba(94, 184, 255, 0.45);
  color: var(--text);
}

.home-btn-secondary {
  background: var(--bg-card);
  color: var(--text);
}

.home-btn-secondary:hover {
  border-color: var(--accent);
}

/* —— Nav —— */
.back-home {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}

.back-home:hover {
  color: var(--accent);
  text-decoration: none;
}

/* —— Game —— */
.game-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  min-height: 100vh;
}

.game-container {
  margin-top: 0.5rem;
}

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
}

.game-intro h1,
.game-results h1 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  margin: 0 0 1rem;
}

.game-intro p {
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.game-hint {
  margin-bottom: 1.5rem !important;
}

.game-progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.game-progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.game-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--tag-week));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.game-question {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin: 0 0 1.25rem;
  line-height: 1.35;
}

.game-options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.game-option {
  text-align: left;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.game-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.game-option:disabled {
  cursor: default;
}

.game-option.correct {
  border-color: var(--tag-topic);
  background: rgba(62, 207, 142, 0.15);
}

.game-option.wrong {
  border-color: #e85d5d;
  background: rgba(232, 93, 93, 0.12);
}

.game-feedback {
  margin: 1rem 0 0;
  font-size: 0.9rem;
}

.game-feedback.success {
  color: var(--tag-topic);
}

.game-feedback.fail {
  color: #f08080;
}

.game-btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.game-btn-primary {
  background: linear-gradient(135deg, rgba(94, 184, 255, 0.25), rgba(124, 108, 255, 0.2));
  border-color: rgba(94, 184, 255, 0.45);
}

.game-btn-secondary {
  background: var(--bg-elevated);
}

.game-btn:hover {
  border-color: var(--accent);
}

.game-score {
  font-size: 1.15rem;
  margin: 0 0 1.25rem;
}

.game-meme {
  display: block;
  max-width: 100%;
  width: min(100%, 420px);
  margin: 0 auto 1.25rem;
  border-radius: var(--radius);
}

.game-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.game-result-actions .game-btn {
  margin-top: 0;
}

@media (max-width: 600px) {
  .game-card {
    padding: 1.25rem 1rem;
  }

  .game-option {
    font-size: 0.85rem;
  }
}
