/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #F8F6F2;
  --surface:   #ECEAE4;
  --border:    #D8D4CC;
  --text:      #1C1C1A;
  --muted:     #9E9488;
  --accent:    #C4856A;
  --correct:   #5B7E62;
  --present:   #C4856A;
  --absent:    #9E9488;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui:      'DM Sans', system-ui, sans-serif;
}

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 580px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
  padding: 40px 16px;
}

/* ─── Header ────────────────────────────────────────────────── */
header {
  padding: 0 0 24px;
  text-align: center;
}

.day-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  cursor: pointer;
}

.day-label:hover { color: var(--text); }

.title {
  font-family: var(--font-display);
  font-size: clamp(32px, 9vw, 44px);
  font-weight: 300;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0 0.25em;
}

.ellipsis {
  color: inherit;
}

.title-dots {
  display: inline-flex;
  align-items: baseline;
  margin-left: -0.25em; /* cancel the flex gap so dots sit right after "på" */
}

/* ─── Archive bar ───────────────────────────────────────────── */
.archive-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
}

.archive-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.archive-back {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.04em;
}

.archive-back:hover { color: var(--text); }

/* ─── Game container ────────────────────────────────────────── */
#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

#game-container.intro-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* ─── Answer reveal (shared) ────────────────────────────────── */
.answer-phrase {
  font-family: var(--font-display);
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 400;
  font-style: italic;
  text-align: center;
  line-height: 1.3;
  color: var(--text);
  padding: 20px 0 8px;
}

/* ─── Status message ────────────────────────────────────────── */
.status-message {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.status-message strong {
  color: var(--text);
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════
   HANGMAN GAME
══════════════════════════════════════════════════════════════ */

.hangman-phrase {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px 20px;
  padding: 8px 0;
  width: 100%;
}

.hangman-word {
  display: flex;
  gap: 4px;
}

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

.hangman-char {
  width: var(--lw, 24px);
  height: 32px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--lf, 26px);
  font-weight: 400;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.hangman-char.revealed {
  opacity: 1;
  transform: translateY(0);
}

.hangman-line {
  width: var(--lw, 24px);
  height: 1px;
  background: var(--border);
}

.hangman-letter.static {
  gap: 0;
}

.hangman-letter.static .hangman-char {
  width: auto;
  min-width: 0;
  padding: 0 2px;
  opacity: 1;
  transform: none;
}

.hangman-letter.static .hangman-line {
  display: none;
}

/* Attempts remaining */
.attempts-display {
  text-align: center;
}

.attempts-track {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}

.attempt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}

.attempt-dot.used {
  background: var(--accent);
  border-color: var(--accent);
}

.attempt-dot.last-two {
  background: #C45A5A;
  border-color: #C45A5A;
}

.attempts-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.06em;
}

/* Hangman alphabet keyboard */
.hangman-keyboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hangman-keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.hangman-key {
  flex: 1;
  max-width: 36px;
  min-width: 0;
  height: 42px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.08s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.hangman-key:active:not(:disabled) { transform: scale(0.9); }

.hangman-key.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.hangman-key.wrong {
  background: transparent;
  border-color: var(--border);
  color: var(--border);
  opacity: 0.4;
  cursor: default;
}

.hangman-key:disabled {
  cursor: default;
}

/* ─── End state ─────────────────────────────────────────────── */
.end-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: center;
  animation: fadeUp 0.5s ease;
}

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

.end-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.end-answer {
  font-family: var(--font-display);
  font-size: clamp(28px, 8vw, 38px);
  font-weight: 300;
  font-style: italic;
  color: var(--text);
  line-height: 1.2;
}

.next-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.divider {
  width: 32px;
  height: 1px;
  background: var(--border);
}

/* ─── Title intro ────────────────────────────────────────────── */
.title-word {
  display: inline-block;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.title-word.visible {
  opacity: 1;
}

.day-label {
  transition: opacity 0.4s ease;
}

.day-label.intro-hidden {
  opacity: 0;
}

/* ─── Game reveal stagger ────────────────────────────────────── */
@keyframes rowReveal {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hangman-phrase.entering,
.attempts-display.entering,
.hangman-keyboard.entering {
  opacity: 0;
  animation: rowReveal 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  animation-delay: var(--enter-delay, 0ms);
}

/* ══════════════════════════════════════════════════════════════
   HISTORY MODAL
══════════════════════════════════════════════════════════════ */

.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 28, 26, 0.35);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.history-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.history-panel {
  background: var(--bg);
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(24px);
  transition: transform 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow: hidden;
}

.history-overlay.open .history-panel {
  transform: translateY(0);
}

.history-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
  flex-shrink: 0;
}

.history-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  font-style: italic;
  color: var(--text);
}

.history-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--surface);
  border-radius: 50%;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.history-close:hover { background: var(--border); }

.history-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ─── Stats row ─────────────────────────────────────────────── */
.history-stats {
  display: flex;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

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

.history-stat + .history-stat {
  border-left: 1px solid var(--border);
}

.history-stat-number {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 300;
  line-height: 1;
  color: var(--text);
}

.history-stat-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─── Section ───────────────────────────────────────────────── */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─── Dot grid ──────────────────────────────────────────────── */
.history-dot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.history-dot {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.history-dot.won  { background: var(--correct); border-color: var(--correct); }
.history-dot.lost { background: var(--accent);  border-color: var(--accent);  }

/* ─── Word list ─────────────────────────────────────────────── */
.history-word-list {
  display: flex;
  flex-direction: column;
}

.history-word-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.history-word-row:last-child { border-bottom: none; }

.history-word-day {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
  line-height: 1;
  transform: translateY(0);
}

.history-word-text {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
  font-style: italic;
  color: var(--text);
  flex: 1;
  line-height: 1;
  transform: translateY(-2px);
}

.history-word-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}

.history-word-dot.won  { background: var(--correct); }
.history-word-dot.lost { background: var(--accent);  }

.history-word-missed {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
  color: var(--border);
  flex: 1;
  line-height: 1;
  transform: translateY(-2px);
}

.history-play-link {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  margin-left: auto;
  flex-shrink: 0;
}

.history-play-link:hover { color: var(--text); }

.history-empty {
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
}
