/* Cool Club Connections — cozy library aesthetic */

:root {
  --parchment: #f4ead5;
  --parchment-dark: #ede0c2;
  --tile-bg: #fbf6e8;
  --tile-bg-hover: #f3eada;
  --ink: #3a2f24;
  --ink-soft: #6a5847;
  --accent: #7a2c2c;
  --accent-soft: #b06868;
  --gold: #c08a3a;

  --yellow: #f4d03f;
  --yellow-dark: #c9a93b;
  --green: #a3c585;
  --green-dark: #6f9356;
  --blue: #6fa8dc;
  --blue-dark: #3f7fb1;
  --purple: #b889c9;
  --purple-dark: #875a99;

  --shadow-sm: 0 1px 2px rgba(58, 47, 36, 0.12);
  --shadow-md: 0 3px 10px rgba(58, 47, 36, 0.15);
  --shadow-lg: 0 8px 30px rgba(58, 47, 36, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 18px;
}

h1 {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.tagline {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 14px;
  line-height: 1.4;
}

.puzzle-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.puzzle-title-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.puzzle-label { font-style: italic; }

#puzzle-title {
  color: var(--ink);
  font-weight: 700;
}

.puzzle-sep { color: var(--gold); }

.meta-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-soft);
  font-size: 1rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.meta-btn:hover {
  background: var(--parchment-dark);
  color: var(--ink);
}

/* Solved rows */
.solved-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.solved-row {
  border-radius: 8px;
  padding: 12px 14px;
  text-align: center;
  font-weight: 700;
  color: var(--ink);
  animation: slide-down 0.4s ease-out;
  box-shadow: var(--shadow-sm);
}

.solved-row .row-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.solved-row .row-items {
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.solved-row.yellow  { background: var(--yellow); }
.solved-row.green   { background: var(--green); }
.solved-row.blue    { background: var(--blue); color: #fff; }
.solved-row.purple  { background: var(--purple); color: #fff; }

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.tile {
  aspect-ratio: 1 / 1;
  background: var(--tile-bg);
  border: 1.5px solid rgba(58, 47, 36, 0.12);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  line-height: 1.15;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  word-break: break-word;
  hyphens: auto;
  box-shadow: var(--shadow-sm);
}

.tile:hover:not(.selected):not(.disabled) {
  background: var(--tile-bg-hover);
  transform: translateY(-1px);
}

.tile.selected {
  background: var(--ink);
  color: var(--parchment);
  border-color: var(--ink);
  transform: translateY(-2px);
}

.tile.disabled {
  pointer-events: none;
  opacity: 0.4;
}

.tile.shake {
  animation: shake 0.45s ease-in-out;
}

.tile.bounce {
  animation: bounce 0.32s ease-in-out;
}

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

@keyframes bounce {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

/* Status row */
.status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  min-height: 28px;
}

.mistakes {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mistakes-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.mistake-dots {
  display: inline-flex;
  gap: 6px;
}

.mistake-dots .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  transition: all 0.3s ease;
}

.mistake-dots .dot.spent {
  background: transparent;
  border: 2px solid rgba(122, 44, 44, 0.25);
  transform: scale(0.85);
}

.hint {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--gold);
  min-height: 1.2em;
  text-align: right;
  transition: opacity 0.3s ease;
}

.hint.show {
  animation: pulse 0.4s ease-out;
}

@keyframes pulse {
  0%   { opacity: 0; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

/* Controls */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
}

.btn:hover:not(:disabled) {
  background: var(--ink);
  color: var(--parchment);
}

.btn-primary {
  background: var(--ink);
  color: var(--parchment);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:disabled {
  background: transparent;
  color: var(--ink-soft);
  border-color: rgba(58, 47, 36, 0.2);
  cursor: not-allowed;
}

.btn-secondary { font-weight: 600; }

/* Footer */
.footer {
  margin-top: 32px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.link-btn {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(58, 47, 36, 0.3);
  text-underline-offset: 3px;
  padding: 4px 2px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.dot-sep {
  margin: 0 4px;
  color: var(--gold);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(58, 47, 36, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fade-in 0.2s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  background: var(--parchment);
  border-radius: 14px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: pop-in 0.25s ease-out;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}

.modal-close:hover { color: var(--accent); }

.modal h2 {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1.4rem;
  margin: 0 0 16px;
  color: var(--accent);
  text-align: center;
}

.modal-body {
  font-size: 0.95rem;
  line-height: 1.55;
}

.modal-body p { margin: 0 0 12px; }

.modal-body ul {
  margin: 8px 0 12px;
  padding-left: 22px;
}

.modal-body li { margin-bottom: 4px; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* Victory share grid */
.share-block {
  background: var(--tile-bg);
  border: 1.5px dashed rgba(58, 47, 36, 0.25);
  border-radius: 10px;
  padding: 14px;
  font-family: 'Source Sans 3', monospace;
  font-size: 1.4rem;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-align: center;
  margin: 12px 0;
  white-space: pre;
  user-select: all;
}

.victory-stats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
}

.stat-value {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Puzzle picker */
.puzzle-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.puzzle-list li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s ease;
  border-bottom: 1px solid rgba(58, 47, 36, 0.08);
}

.puzzle-list li:hover { background: var(--parchment-dark); }
.puzzle-list li:last-child { border-bottom: none; }

.puzzle-list .puzzle-num {
  font-family: 'Libre Baskerville', Georgia, serif;
  color: var(--gold);
  margin-right: 8px;
  font-weight: 700;
}

.puzzle-list .puzzle-status {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.puzzle-list .puzzle-status.solved { color: var(--green-dark); font-weight: 700; }
.puzzle-list .puzzle-status.failed { color: var(--accent); }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Responsive */
@media (max-width: 480px) {
  .page { padding: 16px 10px 30px; }
  h1 { font-size: 1.5rem; }
  .tagline { font-size: 0.85rem; }
  .grid { gap: 6px; }
  .tile { font-size: 0.7rem; padding: 3px; }
  .btn { padding: 9px 18px; font-size: 0.9rem; }
  .solved-row { padding: 10px 12px; }
  .solved-row .row-items { font-size: 0.82rem; }
}

@media (max-width: 360px) {
  .tile { font-size: 0.62rem; }
  .controls { gap: 6px; }
  .btn { padding: 8px 14px; font-size: 0.85rem; }
}

/* ===== Weekly rotation additions ===== */

/* Week chip — sits above the puzzle title */
.week-chip {
  display: inline-block;
  background: var(--parchment-dark);
  color: var(--ink-soft);
  border: 1px solid rgba(58, 47, 36, 0.15);
  border-radius: 999px;
  padding: 5px 14px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s ease;
  margin: 4px 0 2px;
}

.week-chip:hover {
  background: var(--parchment);
  color: var(--ink);
  border-color: var(--gold);
}

.week-chip.active {
  background: var(--gold);
  color: var(--parchment);
  border-color: var(--gold);
}

.week-chip.active:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.week-chip .chip-label {
  font-weight: 700;
}

.week-chip .chip-date {
  font-weight: 700;
  font-style: italic;
}

/* Locked-week placeholder */
.locked-placeholder {
  background: var(--tile-bg);
  border: 2px dashed rgba(58, 47, 36, 0.2);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  margin-bottom: 16px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.locked-placeholder.hidden { display: none; }

.lock-icon {
  font-size: 3rem;
  line-height: 1;
}

.lock-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

.lock-sub {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

/* Hidden game UI when locked */
.controls.hidden,
.status.hidden { display: none; }

/* Puzzle picker — three-section layout */
.puzzle-section {
  margin-bottom: 18px;
}

.puzzle-section:last-child { margin-bottom: 0; }

.section-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(192, 138, 58, 0.25);
}

.puzzle-list li.locked {
  opacity: 0.55;
  cursor: default;
}

.puzzle-list li.locked:hover {
  background: transparent;
}

.puzzle-list li.this-week {
  background: rgba(192, 138, 58, 0.12);
  border-left: 3px solid var(--gold);
  padding-left: 9px;
}

.puzzle-status.locked {
  color: var(--ink-soft);
  font-weight: 600;
}

.puzzle-status.this-week {
  color: var(--gold);
  font-weight: 700;
}

