*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: #f7f7f7;
  color: #222;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Header ── */
header {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 2px solid #222;
  background: #fff;
}

.title-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

#header-date {
  font-size: 0.85rem;
  font-weight: 400;
  color: #888;
  white-space: nowrap;
}

.puzzle-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  color: #aaa;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}

/* ── Timer ── */
.timer-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 20px;
  padding: 3px 6px;
  transition: background 0.3s, color 0.3s;
}

.timer-wrap.completed {
  background: #2e9e56;
  padding: 3px 10px;
}

.timer-wrap.completed #timer-btn { display: none; }

.timer-wrap.completed #timer {
  color: #fff;
  font-weight: 700;
}

#timer {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  min-width: 3.5ch;
}

#timer-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}

#header-share-btn {
  background: #2e9e56;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

#header-share-btn:hover { background: #257d45; }

/* ── Previous puzzles link ── */
.prev-link {
  font-size: 0.78rem;
  font-weight: 600;
  color: #555;
  text-decoration: none;
  white-space: nowrap;
  padding: 4px 0;
}
.prev-link:hover { color: #222; text-decoration: underline; }

/* ── Help ── */
.help-wrap {
  position: relative;
}

#help-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #222;
  background: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1.5px solid #222;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-width: 150px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.dropdown button {
  background: none;
  border: none;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
}

.dropdown button:hover { background: #f0f0f0; }
.dropdown button:first-child { border-radius: 6px 6px 0 0; }
.dropdown button:last-child  { border-radius: 0 0 6px 6px; }

/* ── Main layout ── */
main {
  width: 100%;
  max-width: 600px;
  padding: 12px 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ── Active clue banner ── */
#active-clue-banner {
  width: 100%;
  min-height: 2.4em;
  padding: 8px 12px;
  background: #fff;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #333;
}

/* ── Grid ── */
#grid-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  width: min(320px, 90vw);
}

.cell {
  position: relative;
  aspect-ratio: 1;
  background: #fff;
  border: 1.5px solid #999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell.black {
  background: #222;
  border-color: #222;
  pointer-events: none;
}

.cell .num {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  color: #444;
  pointer-events: none;
  user-select: none;
}

.cell input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #222;
  caret-color: transparent;
  cursor: pointer;
  outline: none;
  padding-top: 8px;
}

/* States */
.cell.selected   { background: #ffd966; }
.cell.highlighted { background: #a8d4f5; }
.cell.incorrect  { background: #f8b4b4; }
.cell.revealed   { background: #d4d4d4; }

/* ── Check All button ── */
#check-all-wrap {
  width: 100%;
  display: flex;
  justify-content: flex-end;
}

#check-all-btn {
  padding: 6px 16px;
  border: 1.5px solid #222;
  border-radius: 20px;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

#check-all-btn:hover { background: #f0f0f0; }

/* ── Completion banner (inline) ── */
#completion-banner {
  width: 100%;
  background: #fff;
  border: 2px solid #2e9e56;
  border-radius: 10px;
  padding: 20px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}


#completion-banner h2 { font-size: 1.3rem; }
#modal-time { font-size: 2rem; font-weight: 900; }
#modal-assisted { font-size: 0.82rem; color: #888; }

#player-name {
  padding: 8px 12px;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  text-align: center;
  width: 100%;
  max-width: 260px;
}

#share-btn {
  padding: 10px 20px;
  background: #2e9e56;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

#share-btn:hover { background: #257d45; }
#share-confirm { font-size: 0.82rem; color: #555; }

/* ── Clue panel ── */
#clue-panel {
  width: 100%;
  display: flex;
  gap: 16px;
}

.clue-col {
  flex: 1;
  min-width: 0;
}

.clue-col h2 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1.5px solid #222;
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.clue-col ul {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
}

.clue-col li {
  padding: 5px 6px;
  font-size: 0.85rem;
  line-height: 1.4;
  border-radius: 4px;
  cursor: pointer;
}

.clue-col li:hover { background: #f0f0f0; }
.clue-col li.active-clue { background: #ffd966; font-weight: 600; }
.clue-col li span.clue-num { font-weight: 700; margin-right: 4px; }

/* ── Attempt badge ── */
#attempt-badge {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
}
#attempt-badge.gold   { background: #d4edda; color: #155724; }
#attempt-badge.silver { background: #fff3cd; color: #856404; }
#attempt-badge.clown  { background: #f8d7da; color: #721c24; }

/* ── Reset confirm modal ── */
#reset-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

#reset-modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px 20px;
  max-width: 300px;
  width: 88%;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#reset-modal p { font-size: 0.95rem; line-height: 1.4; }

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

#reset-cancel {
  padding: 8px 20px;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}

#reset-confirm {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: #d33;
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
}

#reset-confirm:hover { background: #b22; }

/* ── Result card (from share URL) ── */
#result-card {
  width: 100%;
  background: #fff;
  border: 2px solid #222;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

#result-card h3 { font-size: 1.1rem; margin-bottom: 6px; }
#result-card .rc-time { font-size: 2.2rem; font-weight: 900; }
#result-card .rc-name { font-size: 1rem; color: #555; margin-top: 4px; }

/* ── Nick footer ── */
.nick-footer {
  text-align: center;
  padding: 40px 0 24px;
  color: #666;
  font-style: italic;
  font-size: 0.9rem;
}
.nick-emblem {
  width: 48px;
  height: 48px;
  opacity: 0.75;
  display: block;
  margin: 0 auto 8px;
}
.nick-footer p { margin: 0; }
.nick-footer a { color: inherit; }

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Mobile tweaks ── */
@media (max-width: 420px) {
  header h1 { font-size: 1.1rem; }
  #header-date { font-size: 0.75rem; }
  .cell input { font-size: 1.1rem; }
  .clue-col li { font-size: 0.8rem; }
}
