@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --cream:         #F5F0E8;
  --paper:         #EDE7D9;
  --espresso:      #1E0F0A;
  --espresso-mid:  #3D2518;
  --amber:         #C8860A;
  --gold:          #D4A017;
  --coral:         #E8744A;
  --ink:           #2C2018;
  --muted:         #8B7355;
  --border:        #C4A87A;
  --success:       #2E7D4F;
  --error:         #B83232;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Lora', Georgia, serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Masthead ───────────────────────────────────────────────────────────────── */
.masthead {
  background: var(--espresso);
  color: var(--cream);
  padding: 1rem 1.5rem 0;
  border-bottom: 3px solid var(--amber);
  position: relative;
}

/* Sunrise gradient line across the very top */
.masthead::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--coral) 0%, var(--amber) 40%, var(--gold) 60%, var(--amber) 80%, var(--coral) 100%);
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-top: 0.25rem;
}

.masthead-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--cream);
}

.masthead-tagline {
  font-style: italic;
  font-size: 0.78rem;
  color: var(--amber);
  margin-top: 0.2rem;
}

.masthead-date {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

.strike-counter {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.strike-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--amber);
  transition: background 0.3s, border 0.3s;
}

.strike-dot.used {
  background: transparent;
  border: 2px solid var(--error);
}

.masthead-nav {
  display: flex;
  gap: 1.5rem;
  padding: 0.65rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 0.75rem;
}

.masthead-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: color 0.15s;
}

.masthead-nav a:hover,
.masthead-nav a.active { color: var(--amber); }

/* ── Main layout ────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  width: 100%;
}

/* ── Round progress ─────────────────────────────────────────────────────────── */
.rounds-progress {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.round-pip {
  height: 5px;
  flex: 1;
  max-width: 60px;
  border-radius: 3px;
  background: var(--border);
  opacity: 0.5;
  transition: background 0.3s, opacity 0.3s;
}

.round-pip.complete { background: var(--success); opacity: 1; }
.round-pip.active   { background: var(--amber);   opacity: 1; }

.round-indicator {
  text-align: center;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 1.1rem;
}

/* ── Post card ──────────────────────────────────────────────────────────────── */
.post-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1.75rem 1.75rem 1.25rem;
  margin-bottom: 1.4rem;
  position: relative;
  box-shadow: 2px 3px 10px rgba(44, 24, 16, 0.07);
}

/* "HOT POST" tag in the top-left corner */
.post-card::before {
  content: 'HOT POST';
  position: absolute;
  top: -1px;
  left: 1.5rem;
  background: var(--amber);
  color: var(--espresso);
  font-family: 'Lora', serif;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 0.15rem 0.5rem;
}

.post-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.post-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.05rem, 2.8vw, 1.45rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

.post-source-link {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.68rem;
  color: var(--amber);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  transition: color 0.15s;
}

.post-source-link:hover { color: var(--gold); }

/* ── Guess prompt ───────────────────────────────────────────────────────────── */
.guess-prompt {
  text-align: center;
  font-style: italic;
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 0.9rem;
}

/* ── Options grid ───────────────────────────────────────────────────────────── */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.option-btn {
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: 2px;
  padding: 0.75rem 1rem;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s, border-color 0.12s, color 0.12s;
  line-height: 1.3;
}

.option-btn strong {
  color: var(--muted);
  font-weight: 600;
}

.option-btn:hover:not(:disabled) {
  background: var(--paper);
  border-color: var(--amber);
  color: var(--espresso);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(200, 134, 10, 0.15);
}

.option-btn:hover:not(:disabled) strong {
  color: var(--amber);
}

.option-btn.correct {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  font-weight: 600;
}

.option-btn.correct strong { color: rgba(255,255,255,0.75); }

.option-btn.wrong {
  background: #fdf0f0;
  border-color: var(--error);
  color: var(--error);
  animation: shake 0.42s ease;
}

.option-btn.eliminated {
  background: var(--paper);
  border-color: transparent;
  color: var(--muted);
  text-decoration: line-through;
  cursor: not-allowed;
  opacity: 0.5;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ── End modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 15, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--cream);
  border: 2px solid var(--border);
  border-radius: 2px;
  padding: 2rem;
  max-width: 440px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(30, 15, 10, 0.3);
  animation: slide-up 0.25s ease;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 0.3rem;
}

.modal-subtitle {
  color: var(--muted);
  font-style: italic;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
}

.share-box {
  background: var(--espresso);
  color: var(--cream);
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  padding: 1rem 1.1rem;
  border-radius: 2px;
  white-space: pre;
  margin-bottom: 0.75rem;
  line-height: 1.65;
  overflow-x: auto;
}

.copy-btn {
  width: 100%;
  background: var(--amber);
  border: none;
  color: var(--espresso);
  padding: 0.75rem;
  font-family: 'Lora', serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.2s;
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}

.copy-btn:hover { background: var(--gold); }

/* Answers reveal */
.answers-reveal h3 {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 0.6rem;
}

.answer-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(196, 168, 122, 0.25);
  font-size: 0.85rem;
}

.answer-row .round-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--muted);
}

.answer-row a {
  flex: 1;
  color: var(--amber);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
}

.answer-row a:hover { text-decoration: underline; }

/* ── Post image / gallery ───────────────────────────────────────────────────── */
.post-gallery {
  margin-top: 0.875rem;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.post-gallery:empty { display: none; }

/* Single image: full width, natural aspect ratio — no crop, no letterbox */
.post-gallery img {
  display: block;
  width: 100%;
  height: auto;
}

/* Multi-image gallery: horizontal scroll strip */
.post-gallery.multi {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border: none;
}

.post-gallery.multi::-webkit-scrollbar { display: none; }

.post-gallery.multi img {
  flex-shrink: 0;
  width: 88%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  background: var(--paper);
  scroll-snap-align: start;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.gallery-hint {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  margin: 0.3rem 0 0;
  font-style: italic;
}

.answer-row .result-icon { font-size: 0.95rem; flex-shrink: 0; }
.answer-row.correct  .result-icon { color: var(--success); }
.answer-row.incorrect .result-icon { color: var(--error); }

.chain-connector {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0 0.15rem 1.75rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
}

.chain-connector .chain-arrow { opacity: 0.5; }

.chain-keyword {
  font-style: italic;
  color: var(--amber);
  font-family: 'Lora', serif;
}

.play-again-btn {
  display: none;
  width: 100%;
  margin-top: 1rem;
  padding: 0.55rem 1rem;
  background: transparent;
  border: 1px dashed var(--error);
  color: var(--error);
  border-radius: 3px;
  font-family: 'Lora', serif;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}

.play-again-btn:hover { background: rgba(184, 50, 50, 0.07); }

/* ── Loading / error ────────────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-style: italic;
}

.error-card {
  background: #fdf0f0;
  border: 1px solid var(--error);
  border-radius: 2px;
  padding: 1.5rem;
  text-align: center;
  color: var(--error);
}

.error-card small { display: block; margin-top: 0.4rem; color: var(--muted); font-size: 0.8rem; }

/* ── Stats (history page) ───────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1rem;
  text-align: center;
}

.stat-value {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--espresso);
  display: block;
  line-height: 1;
  margin-bottom: 0.3rem;
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ── History list ───────────────────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 0.45rem; }

.history-item {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.85rem;
}

.h-date    { color: var(--ink); min-width: 100px; }
.h-result  { font-size: 0.7rem; font-weight: 700; padding: 0.18rem 0.5rem; border-radius: 2px; }
.h-result.won  { background: var(--success); color: #fff; }
.h-result.lost { background: var(--error);   color: #fff; }
.h-strikes { color: var(--muted); font-size: 0.8rem; }

/* ── Leaderboard ────────────────────────────────────────────────────────────── */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.leaderboard-table th {
  background: var(--espresso);
  color: var(--amber);
  padding: 0.6rem 0.8rem;
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.leaderboard-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}

.leaderboard-table tr:nth-child(even) td { background: var(--paper); }

.leaderboard-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}

/* ── Page headings (non-game pages) ─────────────────────────────────────────── */
.page-header {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.page-subheader {
  font-style: italic;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .masthead { padding: 0.8rem 1rem 0; }
  .masthead-title { font-size: 1.75rem; }
  .post-card { padding: 1.25rem 1.1rem 1rem; }
  .options-grid { grid-template-columns: 1fr; }
  main { padding: 1rem 0.75rem 2rem; }
}
