/* Daily puzzle page. Green + cream — matches the zine palette. */

.puzzle-page {
  max-width: 900px;
  width: 100%;
  margin: 24px auto;
  padding: 0 16px;
  box-sizing: border-box;
}

.puzzle-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.puzzle-streak {
  text-align: right;
  min-width: 120px;
}

.streak-num {
  font: 700 42px/1 'Fraunces', Georgia, serif;
  color: #2f6f4a;
}

.streak-label {
  color: var(--text-muted, #666);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.puzzle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
  align-items: start;
  min-width: 0;
}

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

.puzzle-layout > *,
.puzzle-board-col {
  min-width: 0;
}

.puzzle-board-col .board-wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  box-sizing: border-box;
}

#board,
#pz-board,
#admin-puzzle-board {
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
}

.puzzle-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

@media (max-width: 480px) {
  .puzzle-page {
    margin-top: 16px;
    padding-inline: 0;
  }

  .puzzle-board-col .board-wrap {
    padding: 6px;
  }
}

.puzzle-side {
  padding: 16px;
  background: #fbf8f2;
  border: 1px solid #e6dfd0;
  border-radius: 10px;
}

.puzzle-status {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed #e6dfd0;
}

.ps-turn {
  font: 600 18px/1.2 'Fraunces', Georgia, serif;
  color: #2f6f4a;
}

.ps-turn-bad  { color: #b3505a; }
.ps-turn-good { color: #2f6f4a; }
.ps-turn-wait { color: #7a6d55; }

.ps-hint { margin-top: 4px; }

.puzzle-meta div { margin-bottom: 6px; }

.themes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.theme-pill {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid #d9d0bd;
  border-radius: 999px;
  color: #7a6d55;
  background: #fff;
}

/* Home-feed Daily Puzzle card */
.daily-puzzle-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fbf8f2 0%, #eef4ea 100%);
  border: 1px solid #d5e4d1;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  margin-bottom: 12px;
}

.daily-puzzle-card:hover { border-color: #2f6f4a; }

.dp-icon {
  font-size: 28px;
  line-height: 1;
}

.dp-body { flex: 1; min-width: 0; }

.dp-title {
  font: 700 16px/1.2 'Fraunces', Georgia, serif;
  color: #2f6f4a;
  margin: 0 0 2px;
}

.dp-sub {
  font-size: 12.5px;
  color: #7a6d55;
}

.dp-streak {
  text-align: right;
  padding-left: 12px;
  border-left: 1px dashed #c8d4c1;
}

.dp-streak .n {
  display: block;
  font: 700 24px/1 'Fraunces', Georgia, serif;
  color: #2f6f4a;
}

.dp-streak .l {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7a6d55;
}

/* ======================================================================
   Puzzle catalog (/puzzles) — LeetCode-style list
   ====================================================================== */
.pzl-page, .lb-page { max-width: 1120px; margin: 24px auto; padding: 0 16px; box-sizing: border-box; }
.pzl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.pzl-head h1 { margin: 0 0 4px; }
.pzl-head p { margin: 0; }
.pzl-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pzl-layout, .lb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .pzl-layout, .lb-layout { grid-template-columns: minmax(0, 1fr); } }

.pzl-progress { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.pzl-progress-card {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  color: inherit; text-decoration: none; box-shadow: var(--shadow-1);
}
.pzl-progress-card:hover { border-color: var(--border-strong); text-decoration: none; }
.pzl-progress-card.is-on { outline: 2px solid currentColor; outline-offset: -2px; }
.pzl-progress-num { font-size: 22px; font-weight: 700; color: var(--text); }
.pzl-diff-label { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.pzl-easy .pzl-diff-label, .pzl-easy.is-on { color: #1f8a5b; }
.pzl-medium .pzl-diff-label, .pzl-medium.is-on { color: #c07a12; }
.pzl-hard .pzl-diff-label, .pzl-hard.is-on { color: #c0392b; }
.pzl-bar { display: block; height: 6px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden; }
.pzl-bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

.pzl-filters { margin-bottom: 10px; }
.pzl-filter-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }

.pzl-table-wrap { overflow-x: auto; padding: 0; }
.pzl-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pzl-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.pzl-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.pzl-table tbody tr:nth-child(even) td { background: var(--bg-elev-2); }
.pzl-table tbody tr:last-child td { border-bottom: 0; }
.pzl-num { text-align: right; white-space: nowrap; }
.pzl-table th.pzl-num { text-align: right; }
.pzl-col-status { width: 28px; text-align: center; }
.pzl-ok { color: #1f8a5b; font-weight: 700; }
.pzl-tried { color: #c07a12; }
.pzl-table tbody tr { position: relative; }
.pzl-title { color: var(--text); font-weight: 500; }
.pzl-title::after { content: ""; position: absolute; inset: 0; }
.pzl-table tbody tr:has(.pzl-title):hover td { background: rgba(0, 0, 0, .04); }
.pzl-table tbody tr:hover .pzl-title { color: var(--accent); }
.pzl-empty { text-align: center; padding: 28px 12px !important; }
@media (max-width: 560px) { .pzl-hide-sm { display: none; } }

.pzl-diff { font-size: 12.5px; font-weight: 600; }
.pzl-diff-easy { color: #1f8a5b; }
.pzl-diff-medium { color: #c07a12; }
.pzl-diff-hard { color: #c0392b; }

.pzl-pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 14px 0; }

.pzl-side, .lb-side { display: flex; flex-direction: column; gap: 12px; }
.pzl-side-card { padding: 14px 16px; }
.pzl-side-card p { margin: 6px 0 0; }
.pzl-side-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pzl-me-stats, .lb-me-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; text-align: center; }
.pzl-me-stats strong, .lb-me-stats strong { display: block; font-size: 20px; }
.pzl-me-stats span, .lb-me-stats span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.pzl-mini-board { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.pzl-mini-board li { display: flex; align-items: center; gap: 8px; }
.pzl-mini-board .rank { min-width: 30px; color: var(--text-muted); }
.pzl-mini-board .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pzl-mini-board .pts { font-weight: 700; }

/* League badges — chess-piece tiers */
.league-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--bg-elev-2); color: var(--text-soft); border: 1px solid var(--border);
}
.league-pawn        { background: #f1efe9; color: #6b6355; border-color: #ddd6c6; }
.league-knight      { background: #f3e6d8; color: #8a5a2b; border-color: #e3c9ab; }
.league-bishop      { background: #e7eef6; color: #3d5f87; border-color: #c7d6e8; }
.league-rook        { background: #e6f3ea; color: #2f6f4a; border-color: #bfdcc9; }
.league-queen       { background: #f3e7f5; color: #7a3d87; border-color: #dcc2e2; }
.league-king        { background: #fdf3d6; color: #8a6a10; border-color: #ecd690; }
.league-grandmaster { background: linear-gradient(135deg, #2b2b2b, #5b4a1a); color: #ffd66b; border-color: #8a6a10; }
.league-dot { font-size: 14px; }

/* ======================================================================
   Single puzzle page (/puzzles/<id>)
   ====================================================================== */
.pzs-page { max-width: 1240px; margin: 16px auto; padding: 0 16px; box-sizing: border-box; }
.pzs-crumbs { display: flex; justify-content: space-between; margin-bottom: 10px; }
.pzs-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .pzs-layout { grid-template-columns: 1fr; } }
.pzs-board-col { min-width: 0; }
.pzs-page [hidden] { display: none !important; }
.pzs-toolbar { display: flex; justify-content: center; align-items: center; gap: 4px; margin-bottom: 8px; }
.pzs-toolbar .btn { min-width: 36px; font-weight: 700; }

/* Default size fits the viewport height so the whole board is visible;
   the +/− buttons set --pz-board-w, still capped by the column width. */
.pzs-board-wrap { --pz-fit: max(260px, calc(100vh - 230px)); }
@supports (height: 100svh) { .pzs-board-wrap { --pz-fit: max(260px, calc(100svh - 230px)); } }
.puzzle-board-col .pzs-board-wrap, .pzs-board-wrap {
  width: min(100%, var(--pz-board-w, var(--pz-fit)));
  max-width: none;
  margin: 0 auto;
  box-sizing: border-box;
}
@media (max-width: 480px) {
  .pzs-page { padding: 0 6px; }
  .pzs-board-wrap { padding: 6px; }
}

#pz-board .pz-hint-sq { box-shadow: inset 0 0 0 4px #e0a800; }
#pz-board .pz-last { box-shadow: inset 0 0 0 999px rgba(155, 199, 0, 0.38); }
.pzs-board-wrap.is-browsing { outline: 2px dashed #c9b98f; outline-offset: 2px; }

/* Move list + step-through controls */
.pz-nav { display: flex; justify-content: center; gap: 4px; margin-top: 10px; }
.pz-nav .btn { min-width: 40px; }
.pz-nav .btn:disabled { opacity: .4; cursor: default; }
.pz-moves-box { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed #e6dfd0; }
.pz-moves-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.pz-moves {
  position: relative; list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto;
  display: grid; grid-template-columns: 2.4em 1fr 1fr; row-gap: 2px;
  font-variant-numeric: tabular-nums;
}
.pz-moves li { display: contents; }
.pz-move-no { color: #9a8f78; padding: 3px 0; }
.pz-move {
  text-align: left; font: inherit; font-weight: 600; padding: 3px 6px; border: 0; border-radius: 4px;
  background: transparent; color: inherit; cursor: pointer;
}
.pz-move:hover { background: #efe8da; }
.pz-move.is-current { background: #2f6f4a; color: #fff; }
.pz-move.is-solution { font-style: italic; color: #b3505a; }
.pz-move.is-solution.is-current { background: #b3505a; color: #fff; }
.pz-move.is-blank { cursor: default; color: #9a8f78; }
.pz-move.is-blank:hover { background: transparent; }
.pz-moves-empty { margin: 0; }

.pzs-title { font-size: 20px; margin: 0 0 8px; line-height: 1.25; }
.pzs-tags { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.pzs-worth { font-weight: 700; color: var(--accent); }
.pzs-me { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed #e6dfd0; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: #b3505a; }
.btn-danger-ghost:hover { background: color-mix(in srgb, #b3505a 10%, transparent); }

/* Solved popup */
.pz-modal {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(20, 30, 20, 0.45);
}
.pz-modal[hidden] { display: none; }
.pz-modal-card {
  width: min(380px, 100%); padding: 26px 22px 20px; text-align: center;
  background: var(--bg-elev); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.pz-modal.is-open .pz-modal-card { animation: pz-pop-in .28s ease-out; }
.pz-thumb { font-size: 64px; line-height: 1; }
.pz-modal.is-open .pz-thumb { animation: pz-thumb .7s cubic-bezier(.2, 1.6, .4, 1) .1s both; }
.pz-modal-card h2 { margin: 10px 0 4px; }
.pz-modal-points { font-size: 30px; font-weight: 800; color: var(--accent); }
.pz-modal.is-open .pz-modal-points { animation: pz-rise .6s ease-out .25s both; }
.pz-modal-total { margin-top: 4px; }
.pz-modal-league { margin-top: 10px; font-weight: 700; color: #8a6a10; }
.pz-modal-note { margin-top: 8px; min-height: 1em; }
.pz-modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
@keyframes pz-pop-in { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pz-thumb { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: none; } }
@keyframes pz-rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .pz-modal.is-open .pz-modal-card, .pz-modal.is-open .pz-thumb, .pz-modal.is-open .pz-modal-points { animation: none; }
}

/* ======================================================================
   Leaderboard (/puzzles/leaderboard)
   ====================================================================== */
.lb-tabs { margin-bottom: 10px; border-radius: var(--radius) var(--radius) 0 0; }
.lb-leagues { margin-bottom: 12px; }
.lb-me { padding: 14px 16px; margin-bottom: 12px; }
.lb-next { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.lb-next .pzl-bar { flex: 1; }
.lb-table tr.is-me td { background: var(--accent-soft) !important; }
.lb-rank { width: 60px; font-size: 16px; }
.lb-player { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lb-player > a, .lb-player > .lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-player > .avatar { flex-shrink: 0; }
.lb-league-icon { display: none; flex-shrink: 0; }
@media (max-width: 560px) {
  .lb-page { margin-top: 16px; padding: 0 12px; }
  .lb-tabs .tab { padding: 10px 6px; }
  .lb-leagues { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 12px; padding: 0 12px 4px; scrollbar-width: none; }
  .lb-leagues::-webkit-scrollbar { display: none; }
  .lb-leagues .chip { flex-shrink: 0; white-space: nowrap; }
  .lb-table { table-layout: fixed; }
  .lb-table th, .lb-table td { padding: 10px 8px; }
  .lb-table th.lb-rank, .lb-table td.lb-rank { width: 48px; }
  .lb-table th.lb-points { width: 64px; }
  .lb-table td.lb-player-cell { overflow: hidden; }
  .lb-league-icon { display: inline; }
  .lb-me-stats strong { font-size: 18px; }
}
.lb-prizes, .lb-league-guide { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.lb-prizes li { display: flex; gap: 10px; }
.lb-prize-rank { min-width: 52px; font-weight: 700; }
.lb-league-guide li { display: flex; justify-content: space-between; align-items: center; }
