:root {
  /* Colors and type here deliberately mirror the approved brand standard
     (Montserrat/Lato, navy/teal/orange/gray palette) so this site could be
     folded into that brand later without a redesign — it isn't officially
     tied to it today, just built compatible on purpose. */
  --bg: #FFFFFF;
  --bg-raised: #F4FAFC;
  --pale: #D4EDF4;
  --brand: #345C72;
  --slate: #89A2B2;
  --light-gray: #DAD9D6;
  --gray: #888888;
  --line: #DAD9D6;
  --caught: #4E8989;
  --smolder: #E0582E;
  --ash: #888888;
  --radius: 4px;
  --font-display: 'Montserrat', sans-serif;
  --font-body: 'Lato', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-hand: 'Caveat', cursive;
}

* { box-sizing: border-box; }

/* Guarantees the hidden attribute always works, even on elements that set
   their own display (flex, grid, etc.) elsewhere in this file — without
   this, an element's own "display: flex" silently overrides [hidden] and
   it never actually disappears. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--brand);
  font-family: var(--font-body);
  min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.brand-tab {
  display: inline-block;
  margin: 20px 0 0 24px;
  padding: 8px 16px;
  background: var(--brand);
  color: #FFFFFF;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  border-radius: 6px;
}

.masthead {
  text-align: center;
  padding: 18px 24px 20px;
  border-bottom: 1px solid var(--line);
}

.masthead-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 7vw, 3rem);
  letter-spacing: 0.01em;
  margin: 0 0 6px;
  color: var(--brand);
}

.masthead-sub {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--gray);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#theme-label, #puzzle-number { color: var(--smolder); font-weight: 600; }

.masthead-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--gray);
}

.link-btn {
  background: none;
  border: none;
  color: var(--gray);
  text-decoration: underline;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0;
}

.link-btn:hover { color: var(--brand); }

.info-modal {
  position: fixed;
  inset: 0;
  z-index: 46;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.info-modal-card {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(52,92,114,0.15);
}

.info-modal-card p { font-size: 0.9rem; line-height: 1.55; color: var(--brand); }
.info-modal-card .drawer-header { margin-bottom: 10px; }

.rules-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.rules-list li { font-size: 0.85rem; display: flex; align-items: center; gap: 8px; color: var(--brand); }

.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 3px; }
.swatch.caught { background: var(--caught); }
.swatch.smolder { background: var(--smolder); }
.swatch.ash { background: var(--ash); }

.game-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 340px;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.tile {
  aspect-ratio: 1;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.1rem, 5vw, 1.6rem);
  color: var(--brand);
  text-transform: uppercase;
  transition: transform 0.15s ease;
}

.tile.filled { border-color: var(--slate); transform: scale(1.03); }
.tile.flip { animation: flip 0.5s ease forwards; }

.board-row.shake { animation: shake 0.4s ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

@keyframes flip {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(90deg); }
  51%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

.tile.correct { background: var(--caught); border-color: var(--caught); color: #FFFFFF; }
.tile.present { background: var(--smolder); border-color: var(--smolder); color: #FFFFFF; }
.tile.absent  { background: var(--ash);  border-color: var(--ash);  color: #FFFFFF; }

.message {
  min-height: 1.2em;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--smolder);
  text-align: center;
  margin: 0;
}

.keyboard { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 480px; }
.keyboard-row { display: flex; justify-content: center; gap: 5px; }

.key {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--brand);
  border-radius: var(--radius);
  padding: 12px 0;
  flex: 1;
  min-width: 26px;
  max-width: 42px;
  cursor: pointer;
  text-transform: uppercase;
}

.key:active { transform: scale(0.95); }
.key.wide { max-width: 62px; font-size: 0.65rem; }
.key.correct { background: var(--caught); border-color: var(--caught); color: #FFFFFF; }
.key.present { background: var(--smolder); border-color: var(--smolder); color: #FFFFFF; }
.key.absent  { background: var(--ash);   border-color: var(--ash);  color: #FFFFFF; opacity: 0.75; }

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

.guess-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}

.btn-wide {
  flex: 1;
  padding: 14px 10px;
  font-size: 0.85rem;
}

.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--brand);
  background: transparent;
  color: var(--brand);
}

.btn-ghost:hover { background: var(--pale); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--caught); color: #FFFFFF; border-color: var(--caught); }
.btn-icon { border: none; background: none; font-size: 1.4rem; line-height: 1; color: var(--brand); padding: 0 6px; }

/* Spark Board */
.board-wall-section {
  max-width: 640px;
  margin: 10px auto 30px;
  padding: 20px 16px 0;
  border-top: 1px solid var(--line);
}

.add-spark-wrap {
  max-width: 420px;
  margin: 0 auto 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.spark-celebrate {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--brand);
  margin: 20px 0 0;
}

.spark-count-line {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--smolder);
  margin: 0 0 10px;
  min-height: 1.2em;
}

.wall-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--brand);
  margin: 0 0 4px;
}

.spark-sub {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--gray);
  margin: 0 0 10px;
}

.add-spark-wrap textarea {
  font-family: var(--font-body);
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #FFFFFF;
  color: var(--brand);
  resize: vertical;
  min-height: 60px;
  text-align: left;
}

.note-form-row { display: flex; gap: 8px; }
.note-form-row input {
  flex: 1;
  font-family: var(--font-body);
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #FFFFFF;
  color: var(--brand);
}

.consent-note { font-size: 0.7rem; color: var(--gray); margin: 0; }
.no-pressure { font-size: 0.75rem; color: var(--gray); font-style: italic; margin: 2px 0 0; }

.board-header { text-align: center; margin: 8px 0 16px; }
.board-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--brand);
  margin: 0 0 4px;
}
.board-counter {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--smolder);
  margin: 0;
}

.cork-board {
  background: #E8DCC8;
  background-image: radial-gradient(rgba(52,92,114,0.08) 1px, transparent 1px);
  background-size: 12px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 24px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px 14px;
  min-height: 100px;
  justify-content: center;
}

.sticky-note {
  width: 140px;
  min-height: 100px;
  color: #2A2410;
  padding: 12px 10px 10px;
  font-family: var(--font-hand);
  font-size: 1.15rem;
  line-height: 1.25;
  border-radius: 2px;
  box-shadow: 2px 4px 8px rgba(52,92,114,0.25);
  position: relative;
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.15s ease;
}

.sticky-note:hover { transform: rotate(var(--rot, 0deg)) scale(1.04); z-index: 2; }

.sticky-note .pin {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--smolder);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.pin-badge {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--brand);
  margin-bottom: 6px;
}

.sticky-note .note-name {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  margin-top: 8px;
  opacity: 0.7;
}

.cork-empty { color: var(--gray); font-family: var(--font-body); font-size: 0.85rem; }

.site-footer {
  display: flex;
  justify-content: space-between;
  max-width: 480px;
  margin: 10px auto 40px;
  padding: 0 24px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--gray);
  letter-spacing: 0.03em;
}

/* Stamp overlay */
.stamp-overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; pointer-events: none; z-index: 50; }
.stamp-overlay.show { display: flex; }

.stamp {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 8vw, 3rem);
  letter-spacing: 0.03em;
  padding: 14px 28px;
  border: 6px solid var(--gray);
  color: var(--gray);
  text-transform: uppercase;
  border-radius: 8px;
  opacity: 0;
  background: #FFFFFF;
  transform: scale(2.2) rotate(-6deg);
}

.stamp.win { border-color: var(--caught); color: var(--caught); }
.stamp.animate { animation: stampdown 0.35s cubic-bezier(.2,1.4,.5,1) forwards; }

@keyframes stampdown {
  0%   { opacity: 0; transform: scale(2.6) rotate(-6deg); }
  60%  { opacity: 1; transform: scale(0.92) rotate(-6deg); }
  100% { opacity: 1; transform: scale(1) rotate(-6deg); }
}

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(52,92,114,0.35); z-index: 40; }

.drawer {
  position: fixed; top: 0; right: -340px; width: 320px; max-width: 88vw; height: 100%;
  background: #FFFFFF; border-left: 1px solid var(--line); padding: 22px 20px;
  z-index: 45; transition: right 0.25s ease; overflow-y: auto;
  box-shadow: -8px 0 24px rgba(52,92,114,0.12);
}

.drawer.open { right: 0; }

.drawer-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.drawer-header h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; margin: 0; color: var(--brand); }
.drawer-sub { font-family: var(--font-body); font-size: 0.75rem; color: var(--gray); margin: 6px 0 16px; text-transform: uppercase; letter-spacing: 0.03em; }

.leaderboard-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.leaderboard-list li { display: flex; justify-content: space-between; font-family: var(--font-body); font-weight: 700; font-size: 0.85rem; padding: 8px 10px; background: var(--bg-raised); border-radius: var(--radius); border: 1px solid var(--line); color: var(--brand); }
.leaderboard-empty { justify-content: center !important; color: var(--gray); font-weight: 400 !important; }

.submit-form { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.submit-form label { font-family: var(--font-body); font-size: 0.75rem; color: var(--gray); text-transform: uppercase; letter-spacing: 0.03em; }
.submit-form input { font-family: var(--font-body); padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #FFFFFF; color: var(--brand); }
