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

:root {
  --gold:       #C9962A;
  --gold-light: #F0C96A;
  --gold-glow:  rgba(201, 150, 42, 0.18);
  --cream:      #1A1610;
  --deep:       #0D0B08;
  --panel:      #1E1A12;
  --panel2:     #252019;
  --border:     rgba(201, 150, 42, 0.25);
  --muted:      #7A6E58;
  --light:      #EDE8DC;
  --white:      #FAF7F0;
  --green:      #4CAF7D;
  --red:        #E05A3A;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:    'DM Mono', monospace;
}

html {
  background: var(--deep);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--deep);
  color: var(--light);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-bottom: 3rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── SHELL ── */
.shell {
  width: 100%;
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 20px 20px;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(201, 150, 42, 0.08);
}

/* ── HEADER ── */
.header {
  background: var(--deep);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem 1rem;
  text-align: center;
  position: relative;
}

.header-eyebrow {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.35rem;
  opacity: 0.85;
}

.header-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--white);
  letter-spacing: -0.01em;
  line-height: 1;
}

.header-title span {
  color: var(--gold-light);
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.4rem;
  letter-spacing: 0.04em;
}

.header-meta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.9rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.meta-label {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--gold-light);
}

/* ── SCORE BAR ── */
.score-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
}

.score-display {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.score-num {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1;
  transition: color 0.3s;
}

.score-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ── TIMER ── */
.timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}

.timer {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--light);
  transition: color 0.3s;
}

.timer.urgent { color: var(--red); }
.timer.warning { color: #E09A2A; }

.timer-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ── PUZZLE AREA ── */
.puzzle-area {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.puzzle-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.puzzle-date {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.puzzle-badge {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--gold);
}

.puzzle-badge.Easy { color: var(--green); border-color: rgba(76, 175, 125, 0.4); }
.puzzle-badge.Medium { color: var(--gold-light); border-color: rgba(240, 201, 106, 0.4); }
.puzzle-badge.Hard { color: var(--red); border-color: rgba(224, 90, 58, 0.4); }

.cross-deco {
  text-align: center;
  font-size: 1.1rem;
  color: var(--gold);
  opacity: 0.4;
  margin-bottom: 0.5rem;
  letter-spacing: 0.5em;
}

.puzzle-display {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: 0.14em;
  color: var(--white);
  text-align: center;
  line-height: 2.2;
  padding: 1.1rem 1rem 0.6rem;
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 76px;
  word-break: break-word;
  user-select: none;
}

/* ── HINTS ── */
.hints-section {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.hints-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.hints-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.hints-cost {
  font-size: 0.65rem;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.hints-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.hint-btn {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  color: var(--light);
  font-family: var(--font-body);
  font-size: 0.8rem;
  position: relative;
  overflow: hidden;
  min-height: 52px;
}

.hint-btn:hover:not(:disabled):not(.revealed) {
  border-color: var(--gold);
  background: var(--gold-glow);
}

.hint-btn.revealed {
  border-color: rgba(201,150,42,0.5);
  background: rgba(201,150,42,0.07);
  cursor: default;
}

.hint-btn:disabled:not(.revealed) {
  opacity: 0.4;
  cursor: not-allowed;
}

.hint-num {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.hint-text {
  color: var(--muted);
  font-size: 0.75rem;
}

.hint-btn.revealed .hint-text {
  color: var(--light);
}

.hint-tap {
  font-size: 0.7rem;
  color: var(--muted);
  font-style: italic;
}

/* ── INPUT AREA ── */
.input-area {
  padding: 1rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.input-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 0.5rem;
  display: block;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.guess-input {
  flex: 1;
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--white);
  font-family: var(--font-body);
  font-size: 1rem; /* 16px to prevent iOS auto-zoom */
  outline: none;
  transition: border-color 0.2s;
}

.guess-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-glow);
}

.guess-input::placeholder {
  color: var(--muted);
}

.guess-btn {
  background: var(--gold);
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  color: var(--deep);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
  touch-action: manipulation;
}

.guess-btn:hover { background: var(--gold-light); }
.guess-btn:active { transform: scale(0.97); }

.feedback {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  min-height: 1.2rem;
  text-align: center;
  font-weight: 500;
}

.feedback.wrong { color: var(--red); }
.feedback.right { color: var(--green); }

/* ── GUESSES REMAINING ── */
.guesses-row {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.guess-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  transition: background 0.2s, border-color 0.2s;
}

.guess-dot.used { background: var(--panel2); border: 1px solid var(--border); }

/* ── RESULT CARD ── */
.result-card {
  display: none;
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-card.show { display: block; }

.result-emoji { font-size: 2.5rem; margin-bottom: 0.5rem; }

.result-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--white);
  margin-bottom: 0.25rem;
}

.result-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.final-score {
  font-family: var(--font-display);
  font-size: 3.2rem;
  color: var(--gold-light);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.final-score-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

/* ── CHURCH CHALLENGE CARD ── */
.church-challenge-card {
  background: linear-gradient(135deg, rgba(201, 150, 42, 0.12), rgba(240, 201, 106, 0.05));
  border: 1px solid rgba(201, 150, 42, 0.35);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin: 0 auto 1.25rem;
  text-align: center;
}

.challenge-title {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}

.challenge-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ── SHARE ACTIONS ── */
.share-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.25rem;
}

@media (min-width: 440px) {
  .share-actions {
    flex-direction: row;
    justify-content: center;
  }
}

.share-btn {
  border-radius: 8px;
  padding: 0.75rem 1.2rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  touch-action: manipulation;
  text-decoration: none;
}

.fb-share-btn {
  background: #1877F2;
  border: 1px solid #1877F2;
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(24, 119, 242, 0.3);
}

.fb-share-btn:hover {
  background: #166FE5;
  border-color: #166FE5;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(24, 119, 242, 0.4);
}

.fb-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.copy-share-btn {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--light);
}

.copy-share-btn:hover {
  border-color: var(--gold);
  color: var(--gold-light);
  background: var(--gold-glow);
  transform: translateY(-1px);
}

.share-copied {
  font-size: 0.8rem;
  color: var(--green);
  margin-top: 0.5rem;
  margin-bottom: 0.8rem;
  min-height: 1.2rem;
  font-weight: 500;
}

.fb-follow-nudge {
  background: rgba(24, 119, 242, 0.08);
  border: 1px solid rgba(24, 119, 242, 0.22);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: #92BFFF;
  line-height: 1.5;
  margin-top: 0.5rem;
}

/* ── HOW TO PLAY ── */
.how-section {
  padding: 0.35rem 0 0.15rem;
}

.how-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0;
  letter-spacing: 0.05em;
  transition: color 0.2s;
  width: 100%;
  justify-content: center;
}

.how-toggle:hover { color: var(--gold); }

.how-body {
  display: none;
  margin-top: 0.6rem;
  padding: 1rem;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.7;
}

.how-body.open { display: block; }

.how-body strong { color: var(--light); }

/* ── WELCOME MODAL ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.4s;
  padding: 1.5rem;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  padding: 2rem 1.75rem 1.5rem;
  box-shadow: 0 24px 64px rgba(0,0,0,0.8);
  text-align: center;
}

.modal-cross {
  font-size: 1.5rem;
  color: var(--gold);
  opacity: 0.6;
  letter-spacing: 0.4em;
  margin-bottom: 0.75rem;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--white);
  margin-bottom: 0.2rem;
}

.modal-title span { color: var(--gold-light); }

.modal-subtitle {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.modal-steps {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.modal-step {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.step-icon {
  font-size: 1.3rem;
  line-height: 1.3;
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
}

.step-text {
  font-size: 0.85rem;
  color: var(--light);
  line-height: 1.5;
}

.step-text strong {
  color: var(--white);
  display: block;
  margin-bottom: 0.1rem;
}

.step-text em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.78rem;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.modal-play-btn {
  width: 100%;
  background: var(--gold);
  border: none;
  border-radius: 10px;
  padding: 0.9rem;
  color: var(--deep);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.2s, transform 0.1s;
  touch-action: manipulation;
}

.modal-play-btn:hover { background: var(--gold-light); }
.modal-play-btn:active { transform: scale(0.98); }

.modal-note {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.65rem;
}

/* ── COUNTDOWN OVERLAY ── */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: var(--deep);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99;
  transition: opacity 0.5s;
}

.countdown-overlay.active { display: flex; }
.countdown-overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-cross {
  font-size: 2rem;
  color: var(--gold);
  opacity: 0.5;
  margin-bottom: 1rem;
  letter-spacing: 0.5em;
}

.overlay-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--white);
  margin-bottom: 0.25rem;
}

.overlay-sub {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-bottom: 2rem;
}

.overlay-count {
  font-family: var(--font-display);
  font-size: 6rem;
  font-weight: 900;
  color: var(--gold-light);
  line-height: 1;
}

/* ── FOOTER ── */
.app-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--deep);
}

.app-footer a {
  color: var(--gold);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* ── RESPONSIVE MOBILE TWEAKS ── */
@media (max-width: 480px) {
  body {
    padding-bottom: 1rem;
  }
  .shell {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .header-title {
    font-size: 1.8rem;
  }
  .puzzle-display {
    font-size: 1rem;
    letter-spacing: 0.1em;
    padding: 0.85rem 0.6rem 0.5rem;
  }
  .hints-grid {
    grid-template-columns: 1fr;
  }
  .input-row {
    flex-direction: row;
  }
}
