/* Colours come from CSS variables set per dle in each page's <head>. */
*,
*::before,
*::after { box-sizing: border-box; }

html { background-color: var(--background); }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
h1, h2, h3, .site-header .brand { line-height: 1.2; font-family: var(--headingFont, var(--font)); }
.muted { color: var(--muted); }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px;
  background: var(--surface);
}
.site-header .brand { color: var(--text); font-weight: 700; text-decoration: none; }
.mode-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.mode-nav a {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--background);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.mode-nav a[aria-current="page"] { background: var(--primary); }

.layout {
  display: grid;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}
@media (min-width: 1000px) {
  .layout.with-sidebar { grid-template-columns: minmax(0, 1fr) 300px; }
}
main { min-width: 0; }

.page-title { margin: 8px 0 4px; font-size: clamp(24px, 5vw, 34px); }
.intro { margin-top: 0; }

/* Guess form */
.guess-form { position: relative; display: flex; gap: 8px; margin: 16px 0; }
.guess-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 2px solid var(--primary);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
}
.guess-button, .share-button, .button {
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
}
.guess-form.done { opacity: 0.5; }
.suggestions {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
}
.suggestions li { padding: 10px 14px; cursor: pointer; }
.suggestions li.active, .suggestions li:hover { background: var(--primary); color: #fff; }
.suggestions li.empty { color: var(--muted); cursor: default; background: none; }

/* Classic board */
.table-scroll { overflow-x: auto; }
.board { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 480px; }
.board th[scope="col"] { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.cell {
  padding: 10px 6px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  animation: flip 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 0.12s);
}
.cell.name { background: var(--surface); color: var(--text); }
.correct { background: var(--correct); }
.close { background: var(--close); }
.wrong { background: var(--wrong); }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cell { animation: none; } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }

/* Clue board */
.clue-card { padding: 16px; border-radius: 12px; background: var(--surface); text-align: center; }
.clues { margin: 0; padding: 0; list-style: none; }
.clue { margin: 8px 0; font-size: clamp(22px, 6vw, 40px); }
.guess-chips { display: flex; flex-direction: column; gap: 6px; padding: 0; list-style: none; }
.chip { padding: 10px 14px; border-radius: 8px; color: #fff; font-weight: 600; }

/* Result */
.result { margin: 16px 0; padding: 16px; border: 2px solid var(--correct); border-radius: 12px; background: var(--surface); }
.result h2 { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; text-align: center; }
.stat strong { display: block; font-size: 24px; }
.stat span { font-size: 12px; color: var(--muted); }
.share { display: flex; align-items: center; gap: 12px; }
.share-status { color: var(--correct); font-size: 14px; }
.next-links, .other-links, .card-list { display: grid; gap: 8px; padding: 0; list-style: none; }
.next-links a, .other-links a, .card-list a {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--background);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.card-list { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card-list .card-desc { display: block; font-weight: 400; font-size: 14px; color: var(--muted); }
.notice { padding: 16px; border-radius: 10px; background: var(--surface); }

/* Hints and answers pages */
.hint-list details { margin: 8px 0; padding: 12px 14px; border-radius: 10px; background: var(--surface); }
.hint-list summary { cursor: pointer; font-weight: 600; }
.hint-list .reveal-answer { border: 2px solid var(--accent); }
.answers-table { width: 100%; border-collapse: collapse; }
.answers-table th, .answers-table td { padding: 8px; border-bottom: 1px solid var(--surface); text-align: left; }

/* Ads: space reserved so the page does not jump when an ad loads. */
.ad { display: block; margin: 24px auto; text-align: center; min-height: 100px; }
.ad--sidebar { position: sticky; top: 16px; min-height: 600px; }
@media (max-width: 999px) { .ad--sidebar { display: none; } }
.ad-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.site-footer { padding: 24px 16px; text-align: center; font-size: 14px; color: var(--muted); }
.site-footer a { color: var(--muted); margin: 0 8px; }

/* Library panel (modes with "library": true) */
.game-with-library { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.game-main { min-width: 0; }
@media (min-width: 800px) { .game-with-library { grid-template-columns: minmax(0, 1fr) 260px; align-items: start; } }
.library { padding: 12px; border-radius: 12px; background: var(--surface); }
.library-title { margin: 0 0 8px; font-size: 15px; color: var(--muted); }
.library-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
@media (max-width: 799px) { .library-list { max-height: 260px; } }
.library-item { width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: var(--background); color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.library-item:hover:not(:disabled) { background: var(--primary); color: #fff; }

/* Image clues */
.clue-image img { display: block; max-width: min(260px, 70vw); height: auto; margin: 0 auto; border-radius: 12px; transition: filter 0.4s ease; user-select: none; }

/* Lives */
.lives { display: flex; align-items: center; gap: 8px; margin: -6px 0 12px; font-size: 14px; color: var(--muted); }
.lives-hearts { letter-spacing: 2px; font-size: 16px; }
.lives-count { font-variant-numeric: tabular-nums; }
.lives-low .lives-hearts { animation: heartbeat 0.9s ease-in-out infinite; }
@keyframes heartbeat { 50% { transform: scale(1.12); } }

/* In-game hints */
.hint-panel { margin: 20px 0; padding: 12px 16px; border-radius: 12px; background: var(--surface); }
.hint-heading { margin: 0 0 8px; font-size: 16px; }
.hint-slots { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.hint { padding: 8px 10px; border-radius: 8px; background: var(--background); font-size: 15px; }
.hint.locked { color: var(--muted); }
.hint.revealed { border-left: 4px solid var(--accent); }
.hint-button { width: 100%; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; text-align: left; cursor: pointer; }

/* Answer reveal (top of the game when it ends) */
.end-slot:empty { display: none; }
.answer-reveal { margin: 8px 0 16px; padding: 20px 16px; border-radius: 14px; text-align: center; background: var(--surface); border: 2px solid var(--correct); }
.reveal-title { margin: 0; font-family: var(--headingFont, var(--font)); font-size: clamp(22px, 5vw, 32px); font-weight: 700; color: var(--correct); }
.reveal-kicker { margin: 8px 0 0; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; }
.reveal-name { margin: 2px 0 0; font-family: var(--headingFont, var(--font)); font-size: clamp(30px, 8vw, 52px); font-weight: 700; line-height: 1.1; }
.reveal-image { margin: 14px auto 0; max-width: 280px; }
.reveal-image img { display: block; width: 100%; height: auto; border-radius: 10px; }
.reveal-credit { margin-top: 6px; font-size: 11px; color: var(--muted); }
.answer-reveal.lose { border-color: var(--wrong); background: radial-gradient(ellipse at center, color-mix(in srgb, var(--wrong) 28%, var(--surface)), var(--surface)); }
.answer-reveal.lose .reveal-title { color: var(--wrong); }
.answer-reveal.animate.win .reveal-name { animation: reveal-pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.answer-reveal.animate.lose { animation: reveal-shake 0.6s ease both; }
.answer-reveal.animate.lose .reveal-title { animation: reveal-slam 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.answer-reveal.animate.lose .reveal-name { animation: reveal-rise 1.1s 0.35s ease-out both; text-shadow: 0 0 24px var(--wrong); }
.answer-reveal.animate .reveal-image { animation: reveal-rise 0.9s 0.6s ease-out both; }
body.dle-defeat::after { content: ""; position: fixed; inset: 0; z-index: 50; pointer-events: none; background: radial-gradient(circle, transparent 30%, color-mix(in srgb, var(--wrong) 70%, black)); animation: defeat-flash 1.2s ease-out both; }
@keyframes reveal-pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes reveal-slam { from { transform: scale(2.4); opacity: 0; letter-spacing: 0.4em; } }
@keyframes reveal-rise { from { transform: translateY(16px); opacity: 0; filter: blur(6px); } }
@keyframes reveal-shake { 10%, 50%, 90% { transform: translateX(-8px); } 30%, 70% { transform: translateX(8px); } }
@keyframes defeat-flash { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .answer-reveal *, .answer-reveal, body.dle-defeat::after { animation: none !important; } }

/* Thumbnails on guesses (modes with showImages) */
.thumb { display: block; width: 44px; height: 44px; margin: 0 auto 4px; object-fit: cover; border-radius: 50%; }
.chip .thumb { display: inline-block; width: 28px; height: 28px; margin: 0 8px 0 0; vertical-align: middle; }

/* Fourier mode */
.fourier-canvas { display: block; width: min(320px, 80vw); height: auto; aspect-ratio: 1; margin: 0 auto; border-radius: 12px; background: var(--background); }
.fourier-formula { margin: 12px 0 0; font-family: var(--headingFont, monospace); font-size: 13px; overflow-x: auto; white-space: nowrap; }
.fourier-range { margin: 4px 0 0; font-family: var(--headingFont, monospace); font-size: 12px; color: var(--muted); }
.fourier-count { margin: 6px 0 0; font-size: 13px; }

/* Home: search and categories */
.search-box { margin: 16px 0 8px; }
.search-box .guess-input { width: 100%; }
.category-nav { margin: 8px 0 8px; }
.category h2 { margin-bottom: 0; }
.category > .muted { margin-top: 4px; }
[data-search][hidden], .category[hidden] { display: none; }

.page-home .card-list a { background: var(--surface); }

/* Accounts */
.account-link { margin-left: auto; color: var(--text); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 999px; background: var(--background); }
.account { display: grid; gap: 16px; max-width: 520px; }
.account-form { display: grid; gap: 10px; padding: 16px; border-radius: 12px; background: var(--surface); margin-bottom: 16px; }
.account-form h2 { margin: 0; font-size: 20px; }
.account-form.danger { border: 1px solid var(--wrong); }
.field { display: grid; gap: 4px; font-size: 14px; }
.account-status.error { color: var(--wrong); }

/* Win celebration */
.celebration { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; top: -48px; animation-name: confetti-fall; animation-timing-function: cubic-bezier(0.25, 0.6, 0.4, 1); animation-fill-mode: both; }
@keyframes confetti-fall { to { transform: translate(var(--drift, 0), 110vh) rotate(var(--spin, 360deg)); opacity: 0.85; } }
@media (prefers-reduced-motion: reduce) { .celebration { display: none; } }

/* Account page */
.account { display: flex; justify-content: center; }
.account-card { width: 100%; max-width: 440px; padding: 24px 20px; border-radius: 16px; background: var(--surface); box-shadow: 0 10px 40px rgb(0 0 0 / 0.25); }
.account-logo { display: block; margin: 0 auto 8px; border-radius: 14px; }
.account-card .page-title, .account-card .intro { text-align: center; }
.account-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 8px 0 16px; border-radius: 12px; background: var(--background); }
.account-tab { padding: 10px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.account-tab[aria-selected="true"] { background: var(--primary); color: #fff; }
.account-card .account-form { padding: 0; background: none; margin-bottom: 12px; }
.field-input { position: relative; display: flex; }
.field-input .guess-input { width: 100%; }
.reveal-password { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.strength { height: 6px; border-radius: 3px; background: var(--background); overflow: hidden; }
.strength-bar { display: block; height: 100%; width: 0; background: var(--wrong); transition: width 0.2s, background 0.2s; }
.strength-bar[data-level="1"] { width: 25%; }
.strength-bar[data-level="2"] { width: 50%; background: var(--close); }
.strength-bar[data-level="3"] { width: 75%; background: var(--correct); }
.strength-bar[data-level="4"] { width: 100%; background: var(--correct); }
.link-button { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
.switch-line { text-align: center; margin: 4px 0 0; }
.benefits { display: grid; gap: 6px; margin: 16px 0 0; padding: 12px 14px; list-style: none; border-radius: 12px; background: var(--background); font-size: 14px; color: var(--muted); }
.account-hello { display: grid; gap: 10px; text-align: center; margin-bottom: 12px; }
.guess-button.secondary { background: var(--background); color: var(--text); }
.back-to-game { text-align: center; }
.account-section { margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--background); }
.account-section summary { cursor: pointer; font-weight: 700; }
.account-section .account-form { margin-top: 10px; }
.account-section.danger { border: 1px solid var(--wrong); }

/* Listen mode (tunes and sounds) */
.listen-card { display: grid; justify-items: center; gap: 10px; text-align: center; }
.play-button {
  width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 18px; font-weight: 700;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 45%, transparent);
  transition: transform 0.15s;
}
.play-button:hover { transform: scale(1.05); }
.play-button:disabled { opacity: 0.5; cursor: default; }
.listen-card.is-playing .play-button { animation: listen-pulse 1s ease-in-out infinite; }
@keyframes listen-pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 10px color-mix(in srgb, var(--primary) 25%, transparent); } }
.stage-dots { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.stage-dot {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--muted);
  background: transparent; color: var(--muted); font-weight: 700; cursor: pointer;
}
.stage-dot.unlocked { border-color: var(--primary); color: var(--text); }
.stage-dot.current { background: var(--primary); color: #fff; }
.stage-dot:disabled { opacity: 0.4; cursor: default; }
.listen-stage { margin: 0; font-weight: 700; }
.listen-credit:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .listen-card.is-playing .play-button { animation: none; } }

/* Stats dashboard on /account/ (cards take each game's own colours via --c-* variables) */
.account { flex-direction: column; align-items: center; gap: 28px; max-width: none; }
.dashboard { width: 100%; max-width: 980px; }
.dashboard-title { text-align: center; margin: 0; font-size: clamp(26px, 5vw, 34px); }
.dashboard-source { text-align: center; margin: 4px 0 16px; }
.dashboard-empty { text-align: center; font-weight: 700; }
.dashboard-heading { margin: 26px 0 12px; font-size: 20px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-tile {
  display: grid; justify-items: center; gap: 2px; padding: 16px 10px; border-radius: 16px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 22%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  animation: tile-in 0.45s ease-out both;
}
.stat-tile:nth-child(2) { animation-delay: 0.05s; } .stat-tile:nth-child(3) { animation-delay: 0.1s; }
.stat-tile:nth-child(4) { animation-delay: 0.15s; } .stat-tile:nth-child(5) { animation-delay: 0.2s; } .stat-tile:nth-child(6) { animation-delay: 0.25s; }
@keyframes tile-in { from { opacity: 0; transform: translateY(10px); } }
.stat-icon { font-size: 26px; }
.stat-value { font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 13px; text-align: center; }
.stat-tile.is-hot { border-color: #ff8a3d; box-shadow: 0 0 22px #ff8a3d55; }
.stat-tile.is-hot .stat-icon { animation: flame 1.2s ease-in-out infinite; }
@keyframes flame { 50% { transform: scale(1.18) rotate(-6deg); } }
.badges { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { display: grid; justify-items: center; gap: 2px; padding: 12px 8px; border-radius: 14px; background: var(--surface); text-align: center; opacity: 0.45; filter: grayscale(1); font-size: 13px; }
.badge.earned { opacity: 1; filter: none; border: 1px solid var(--accent); box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 30%, transparent); }
.badge-icon { font-size: 30px; }
.dle-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.dle-stat-card {
  display: grid; gap: 12px; padding: 16px; border-radius: 16px; color: var(--c-text);
  background: linear-gradient(150deg, color-mix(in srgb, var(--c-primary) 30%, var(--c-surface)), var(--c-bg) 85%);
  border: 2px solid color-mix(in srgb, var(--c-primary) 60%, transparent);
  box-shadow: 0 8px 26px color-mix(in srgb, var(--c-primary) 22%, transparent);
  animation: tile-in 0.5s ease-out both;
}
.dle-stat-card header { display: flex; align-items: center; gap: 10px; }
.dle-stat-card h3 { margin: 0; font-size: 20px; flex: 1; }
.dle-stat-emoji { font-size: 30px; }
.streak-flame { font-weight: 700; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c-accent) 30%, transparent); }
.dle-stat-summary { display: flex; align-items: center; gap: 16px; }
.dle-stat-summary p { margin: 0; line-height: 1.5; }
.win-ring {
  --size: 76px; width: var(--size); height: var(--size); flex: none; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c-primary) calc(var(--rate) * 1%), color-mix(in srgb, var(--c-text) 15%, transparent) 0);
}
.win-ring span { width: calc(var(--size) - 16px); height: calc(var(--size) - 16px); border-radius: 50%; display: grid; place-items: center; background: var(--c-bg); font-weight: 700; }
.mode-stats { width: 100%; border-collapse: collapse; font-size: 14px; }
.mode-stats th, .mode-stats td { padding: 5px 4px; text-align: right; border-bottom: 1px solid color-mix(in srgb, var(--c-text) 14%, transparent); }
.mode-stats th:first-child { text-align: left; }
.mode-stats thead th { color: color-mix(in srgb, var(--c-text) 65%, transparent); font-weight: 600; font-size: 12px; }
.mode-stats .hot { color: var(--c-accent); font-weight: 700; }
.dle-stat-play { justify-self: start; padding: 8px 14px; border-radius: 999px; background: var(--c-primary); color: var(--c-on-primary); font-weight: 700; text-decoration: none; }
.dle-stat-play:hover { filter: brightness(1.1); }
.try-chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.try-chip { display: inline-block; padding: 8px 14px; border-radius: 999px; text-decoration: none; font-weight: 700; color: var(--c-text); background: var(--c-surface); border: 2px solid var(--c-primary); }
.try-chip:hover { background: var(--c-primary); color: var(--c-on-primary); }
@media (prefers-reduced-motion: reduce) { .stat-tile, .dle-stat-card { animation: none; } .stat-tile.is-hot .stat-icon { animation: none; } }

/* Favourite buttons: the same gold on every page and game (never themed) */
:root { --fav: #ffc83d; --fav-ink: #1a1300; }
.page-fav { display: flex; justify-content: flex-end; margin-bottom: -4px; }
.fav-button {
  border: 2px solid var(--fav); background: var(--fav-ink); color: var(--fav);
  padding: 5px 12px; border-radius: 999px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.fav-button:hover { box-shadow: 0 0 12px color-mix(in srgb, var(--fav) 45%, transparent); }
.fav-button[aria-pressed="true"] { background: var(--fav); color: var(--fav-ink); }
.fav-button.fav-compact { padding: 0; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; line-height: 1; }
.fav-button.fav-pop { animation: fav-pop 0.35s ease-out; }
@keyframes fav-pop { 40% { transform: scale(1.35) rotate(-12deg); } }
.card-list li.has-fav { position: relative; }
.card-list li.has-fav > a { padding-right: 48px; }
.card-list li.has-fav > .fav-button { position: absolute; top: 8px; right: 8px; }
@media (prefers-reduced-motion: reduce) { .fav-button.fav-pop { animation: none; } }
.dle-stat-done { justify-self: start; margin: 0; padding: 8px 14px; border-radius: 999px; font-weight: 700; border: 2px solid var(--c-accent); color: var(--c-accent); }
