/* ============================================
   Epha — Biblical Wordle
   Visual: deep blue-night + warm gold accents
   ============================================ */

:root {
  --bg-deep: #0a0f1e;
  --bg-surface: #111827;
  --bg-card: #1a2236;
  --bg-input: #1e293b;
  --gold: #c9a84c;
  --gold-dim: #a08838;
  --gold-bright: #e0c060;
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.15);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.1);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #1e293b;
  --border-light: #334155;
  --radius: 8px;
  --radius-lg: 12px;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Lora', Georgia, 'Times New Roman', serif;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-deep);
  z-index: 100;
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.02em;
}

.header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.lang-btn {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 32px;
  height: 32px;
}

/* ---- Views ---- */

.view {
  display: none;
  flex-direction: column;
  flex: 1;
}

.view.active {
  display: flex;
}

/* ---- Cartouche ---- */

.cartouche {
  text-align: center;
  padding: 16px 16px 8px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.cartouche strong {
  color: var(--gold);
  font-weight: 600;
}

.cartouche .separator {
  margin: 0 6px;
  color: var(--text-muted);
}

/* ---- Progress ---- */

.progress-container {
  margin: 0 16px 12px;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-text {
  position: absolute;
  right: 0;
  top: -18px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---- Passage ---- */

.passage-container {
  flex: 1;
  padding: 8px 16px 16px;
  overflow-y: auto;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text-primary);
  font-weight: 400;
}

.verse-number {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  color: var(--gold-dim);
  vertical-align: super;
  margin-right: 2px;
  font-weight: 600;
}

.word {
  display: inline;
}

.word-hidden {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  min-width: 1.5em;
  height: 1.4em;
  vertical-align: baseline;
  margin: 1px 0;
  transition: all 0.35s ease;
}

.word-revealed {
  display: inline;
  color: var(--green);
  animation: revealFade 0.5s ease;
}

.word-hint {
  display: inline;
  color: var(--gold-bright);
  animation: revealFade 0.5s ease;
}

.word-visible {
  display: inline;
  color: var(--text-secondary);
}

.punctuation {
  color: var(--text-muted);
}

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

/* ---- Controls ---- */

.controls {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--bg-surface);
}

.stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

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

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.stars {
  display: flex;
  gap: 4px;
  font-size: 1.2rem;
}

.star {
  transition: opacity 0.3s;
}

.star.lost {
  opacity: 0.3;
  filter: grayscale(1);
}

.input-row {
  display: flex;
  gap: 8px;
}

#guess-input {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#guess-input:focus {
  border-color: var(--gold);
}

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

.btn-primary {
  height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--gold);
  color: var(--bg-deep);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--gold-bright);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  height: 44px;
  padding: 0 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-secondary:hover {
  border-color: var(--gold-dim);
  color: var(--text-primary);
}

.btn-hint {
  height: 44px;
  min-width: 44px;
  padding: 0 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  transition: border-color 0.15s, color 0.15s;
}

.btn-hint:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.btn-hint:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---- Synonym feedback ---- */

.synonym-feedback {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid rgba(201, 168, 76, 0.25);
  font-size: 0.85rem;
  color: var(--gold);
  text-align: center;
  animation: revealFade 0.3s ease;
}

/* ---- Failed guesses ---- */

.failed-guesses {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-height: 60px;
  overflow-y: auto;
}

.failed-guess {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--red-dim);
  color: var(--red);
  font-family: var(--font-ui);
  animation: revealFade 0.3s ease;
}

/* ---- Victory ---- */

.victory-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  gap: 16px;
}

.victory-icon {
  font-size: 3rem;
  animation: victoryBounce 0.6s ease;
}

@keyframes victoryBounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.victory-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--gold);
  font-weight: 700;
}

.victory-ref {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.victory-stars {
  font-size: 2rem;
  display: flex;
  gap: 8px;
}

.victory-stats {
  display: flex;
  gap: 32px;
  margin: 8px 0;
}

.victory-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.victory-stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.victory-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.victory-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-share {
  min-width: 140px;
}

.share-toast {
  margin-top: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--green-dim);
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 500;
  animation: revealFade 0.3s ease;
}

/* ---- Archives ---- */

.archives-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.archives-header h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--gold);
  font-weight: 600;
}

.archives-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}

.archive-item:hover {
  opacity: 0.8;
}

.archive-item-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.archive-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.archive-ref {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

.archive-theme {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.archive-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.archive-stars {
  font-size: 0.85rem;
}

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

.archive-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.archive-badge.completed {
  background: var(--green-dim);
  color: var(--green);
}

.archive-badge.today {
  background: rgba(201, 168, 76, 0.15);
  color: var(--gold);
}

.archive-badge.playable {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.archives-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Modal ---- */

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

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  font-family: var(--font-serif);
  color: var(--gold);
  font-size: 1.3rem;
  margin-bottom: 16px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.help-body {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.help-body h3 {
  color: var(--text-primary);
  font-size: 0.9rem;
  margin-top: 16px;
  margin-bottom: 6px;
}

.help-body p {
  margin-bottom: 8px;
}

.help-body .help-block {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  width: 3em;
  height: 1.2em;
  vertical-align: middle;
}

.help-body .help-revealed {
  color: var(--green);
  font-weight: 600;
}

.help-body .help-hint-color {
  color: var(--gold-bright);
  font-weight: 600;
}

/* ---- Utilities ---- */

.hidden {
  display: none !important;
}

/* ---- Responsive ---- */

@media (max-width: 400px) {
  .passage-container {
    font-size: 0.95rem;
    line-height: 1.75;
  }

  .victory-stats {
    gap: 20px;
  }
}

@media (min-width: 641px) {
  .passage-container {
    font-size: 1.1rem;
  }
}
