/* ============================================================
   RACEDLE — dark, racing-flavored theme (Loldle-style layout)
   ============================================================ */

:root {
  --bg: #0d1117;
  --bg-raised: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #e10600;        /* racing red */
  --green: #2ea043;
  --yellow: #d9750b;
  --gray: #3a4048;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 50% -20%, #1c2430 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 3px solid var(--accent);
  background: var(--bg-raised);
}
.logo {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 3px;
  margin: 0;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s ease;
}
.logo:hover { opacity: 0.8; }
.logo:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
.logo .flag { font-size: 1.3rem; }
.header-btns { display: flex; gap: 8px; }
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.1rem;
  padding: 6px 12px;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- Layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.tagline { text-align: center; color: var(--text-dim); margin: 8px 0 4px; }
.puzzle-label { text-align: center; font-weight: 700; margin: 0 0 16px; }
.puzzle-label span { color: var(--accent); }

/* ---------- Genre tabs ---------- */
.genre-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 14px;
}
.genre-tab {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.genre-tab:hover { color: var(--text); border-color: var(--text-dim); }
.genre-tab.active {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(180deg, #2a1214, #1a0d0e);
}
.genre-tab.ultimate.active {
  border-color: #d4a017;
  background: linear-gradient(180deg, #2a2214, #1a150e);
}

/* ---------- Mode tabs ---------- */
.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}
.tab {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  padding: 8px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.tab.active {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(180deg, #2a1214, #1a0d0e);
}
#free-new {
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: none;
  color: var(--text-dim);
  padding: 8px 16px;
  cursor: pointer;
}
#free-new:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Guess input ---------- */
.guess-box {
  position: relative;
  max-width: 440px;
  margin: 0 auto 6px;
}
#guess-input {
  width: 100%;
  padding: 13px 16px;
  font-size: 1.05rem;
  background: var(--bg-raised);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}
#guess-input:focus { border-color: var(--accent); }
#guess-input:disabled { opacity: 0.6; }

#suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.suggestion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
}
.suggestion:last-child { border-bottom: none; }
.suggestion:hover, .suggestion.highlighted { background: #21262d; }

.guess-count { text-align: center; color: var(--text-dim); font-size: 0.85rem; min-height: 1.2em; }

/* Free play "New driver" feedback */
.guess-count.notice { color: var(--accent); font-weight: 700; animation: noticeFade 2.6s ease forwards; }
@keyframes noticeFade {
  0%   { opacity: 0; transform: translateY(-4px); }
  12%  { opacity: 1; transform: none; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
#guess-input.pulse { animation: inputPulse 0.9s ease; }
@keyframes inputPulse {
  0%   { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(225, 6, 0, 0.6); }
  100% { box-shadow: 0 0 0 12px rgba(225, 6, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .guess-count.notice, #guess-input.pulse { animation: none; }
}

/* ---------- Board ---------- */
.board-scroll { overflow-x: auto; margin-top: 18px; }
#board { min-width: 560px; }
.board-header, .board-row {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 0.7fr 0.8fr 0.9fr 0.8fr;
  gap: 6px;
  margin-bottom: 6px;
}
/* Decade modes: no Debut column. */
#board.no-debut .board-header, #board.no-debut .board-row { grid-template-columns: 1.5fr 1.5fr 0.7fr 0.8fr 0.9fr; }
#board.no-debut .col-debut { display: none; }
.board-header div {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--border);
}
.tile {
  position: relative;
  min-height: 62px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  word-break: break-word;
}
.name-tile { background: var(--bg-raised); border: 1px solid var(--border); }
.tile.green { background: var(--green); color: #fff; }
.tile.yellow { background: var(--yellow); color: #fff; }
.tile.gray { background: var(--gray); color: var(--text); }
.arrow { font-size: 0.7rem; opacity: 0.9; margin-top: 2px; }

.flip { animation: flipIn 0.5s ease both; }
@keyframes flipIn {
  from { transform: rotateX(90deg); opacity: 0; }
  to { transform: rotateX(0); opacity: 1; }
}

/* ---------- Legend ---------- */
.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.legend .chip {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: -1px;
}
.chip.green { background: var(--green); }
.chip.yellow { background: var(--yellow); }
.chip.gray { background: var(--gray); }

/* ---------- Win panel ---------- */
#win-panel {
  margin: 22px auto 0;
  max-width: 440px;
  background: var(--bg-raised);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
#win-panel.pop { animation: pop 0.4s ease; }
@keyframes pop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
#win-panel h2 { margin: 0 0 4px; font-size: 1rem; color: var(--green); text-transform: uppercase; letter-spacing: 2px; }
#win-driver { font-size: 1.4rem; font-weight: 800; margin: 4px 0; }
#win-guesses { color: var(--text-dim); margin: 0 0 14px; }
.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px 22px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.15); }
#countdown-wrap { margin-top: 14px; color: var(--text-dim); font-size: 0.9rem; }
#countdown { font-weight: 700; color: var(--text); }

.yesterday { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin-top: 26px; }

/* ---------- Ads ---------- */
.ad-slot {
  max-width: 728px;
  margin: 14px auto;
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  letter-spacing: 1px;
}

/* ---------- Modals ---------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.modal-card h2 { margin-top: 0; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
}
.modal-card table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.modal-card td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  text-align: center;
  margin-top: 12px;
}
.stat-num { font-size: 1.6rem; font-weight: 800; }
.stat-label { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  line-height: 1.7;
}
footer a { color: var(--text-dim); }

.hidden { display: none !important; }

/* ---------- Site nav (content pages) ---------- */
a.logo { text-decoration: none; color: inherit; }
.site-nav { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Prose (content pages) ---------- */
.prose { max-width: 760px; line-height: 1.7; }
.prose h1 { font-size: 1.8rem; margin: 0 0 6px; }
.prose h2 { font-size: 1.25rem; margin: 32px 0 8px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.prose h3 { font-size: 1.05rem; margin: 22px 0 6px; }
.prose p, .prose li { color: var(--text); }
.prose a { color: #f2685f; }
.prose ul { padding-left: 20px; }
.prose li { margin: 5px 0; }
.prose .lead { color: var(--text-dim); font-size: 1.08rem; }
.prose table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.9rem; }
.prose th, .prose td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose th { color: var(--text-dim); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; }
.prose .chip {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px;
  margin-right: 5px; vertical-align: -1px;
}
.back-link { margin-top: 34px; }
.back-link a { color: var(--accent); text-decoration: none; font-weight: 700; }

/* ---------- Footer nav ---------- */
.footer-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; }
.footer-nav a { color: var(--text); font-weight: 600; text-decoration: none; }
.footer-nav a:hover { color: var(--accent); }

@media (max-width: 600px) {
  .logo { font-size: 1.2rem; letter-spacing: 2px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  header { flex-wrap: wrap; gap: 8px; }
  .site-nav { gap: 12px; }
}
