:root {
  --bg-a: #fff6f5;
  --bg-b: #ffe8dd;
  --bg-c: #f7ecff;
  --card-bg: rgba(255, 255, 255, 0.9);
  --text: #2f1f29;
  --muted: #6f5667;
  --primary: #e14d7a;
  --primary-hover: #ca3d68;
  --line: #f2d8e5;
  --good: #2f8a5f;
  --shadow: 0 20px 40px rgba(96, 36, 61, 0.14);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 15%, rgba(255, 255, 255, 0.85) 0 18%, transparent 19%),
    radial-gradient(circle at 86% 8%, rgba(255, 212, 234, 0.76) 0 20%, transparent 21%),
    radial-gradient(circle at 78% 88%, rgba(216, 222, 255, 0.42) 0 18%, transparent 19%),
    linear-gradient(150deg, var(--bg-a), var(--bg-b) 55%, var(--bg-c));
  padding: 18px;
  display: grid;
  place-items: center;
}

[hidden] {
  display: none !important;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.app-shell {
  width: min(860px, 100%);
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.progress-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #5f4b58;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid #f0d7e4;
  border-radius: 999px;
  padding: 7px 12px;
}

.text-link {
  border: none;
  background: none;
  color: #8d5f76;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 4px;
}

/* ── Global progress bar ─────────────────────────────────────────────────── */

.progress-bar {
  height: 5px;
  background: rgba(240, 215, 228, 0.55);
  border-radius: 3px;
  margin-bottom: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #ff8fa8);
  border-radius: 3px;
  transition: width 0.45s ease;
}

/* ── Card / Screen ───────────────────────────────────────────────────────── */

.card {
  display: none;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  padding: clamp(18px, 4vw, 30px);
}

.screen.is-active {
  display: block;
  animation: screen-in 0.35s ease;
}

.card h1,
.card h2,
.card h3 {
  margin-top: 0;
  margin-bottom: 0.5em;
}

.card p {
  color: var(--muted);
  line-height: 1.58;
}

/* ── Shared components ───────────────────────────────────────────────────── */

.feedback {
  min-height: 1.4em;
  margin-top: 10px;
  font-weight: 600;
  color: #7d4b62;
}

.inline-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-actions .btn {
  flex: 1 1 180px;
}

.btn {
  border: none;
  border-radius: 999px;
  min-height: 46px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #ff6f8f);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover), #f05e82);
}

.btn-outline {
  color: var(--primary);
  background: #fff;
  border: 2px solid #f2b9cd;
}

.btn-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Lock screen ─────────────────────────────────────────────────────────── */

.unlock-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.unlock-form label {
  font-weight: 700;
}

.unlock-form input {
  border: 1px solid #eac8d8;
  border-radius: 12px;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
}

/* ── Vibe choice ─────────────────────────────────────────────────────────── */

.vibe-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.vibe-card {
  border: 2px solid #f2b9cd;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
  width: 100%;
  font-family: inherit;
}

.vibe-card:hover {
  border-color: var(--primary);
  background: #fff7fb;
  transform: translateY(-1px);
}

.vibe-label {
  display: block;
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
}

.vibe-desc {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 3px;
}

/* ── Speedrun checks ─────────────────────────────────────────────────────── */

.speedrun-checks {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.speedrun-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid #f2b9cd;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.18s, background 0.18s;
  width: 100%;
}

.speedrun-toggle.is-checked {
  border-color: var(--good);
  background: #f0faf5;
}

.toggle-check {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: 2px solid #eac8d8;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  transition: background 0.2s, border-color 0.2s;
}

.speedrun-toggle.is-checked .toggle-check {
  background: var(--good);
  border-color: var(--good);
}

#speedrunNextBtn {
  margin-top: 12px;
}

#speedrunSweetText {
  margin-top: 2px;
  margin-bottom: 8px;
  color: #6d4a5c;
  font-weight: 600;
}

/* ── Quiz ────────────────────────────────────────────────────────────────── */

.quiz-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.quiz-progress-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #7b4d64;
  white-space: nowrap;
  flex-shrink: 0;
}

.quiz-progress-bar {
  flex: 1;
  height: 6px;
  background: #f2d8e5;
  border-radius: 3px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.quiz-container {
  display: grid;
  gap: 0;
}

.quiz-question-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 14px;
  line-height: 1.45;
}

.quiz-options {
  display: grid;
  gap: 8px;
}

.quiz-option {
  padding: 12px 14px;
  border: 2px solid #f0d6e4;
  border-radius: 14px;
  background: #fff;
  text-align: left;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  line-height: 1.4;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--primary);
  background: #fff7fb;
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option.is-correct {
  border-color: var(--good);
  background: #f0faf5;
  color: var(--good);
}

.quiz-option.is-wrong {
  border-color: #e85454;
  background: #fff5f5;
  color: #c0392b;
  animation: quiz-shake 0.38s ease;
}

.quiz-feedback {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.45;
}

.quiz-feedback.wrong {
  background: #fff5f5;
  color: #c0392b;
  border: 1px solid #f5c6cb;
}

.quiz-feedback.correct {
  background: #f0faf5;
  color: var(--good);
  border: 1px solid #b8dece;
}

/* ── Letter ──────────────────────────────────────────────────────────────── */

.letter-content {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.letter-line {
  margin: 0;
  background: #fff9fc;
  border: 1px solid #f1dbe6;
  border-radius: 14px;
  padding: 11px 14px;
  opacity: 0;
  transform: translateY(8px);
}

.letter-line.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.38s ease, transform 0.38s ease;
}

/* ── Contract ────────────────────────────────────────────────────────────── */

.contract-list {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.contract-item {
  border: 1px solid #efdbe6;
  border-radius: 16px;
  background: #fffafb;
  padding: 14px;
  transition: border-color 0.3s, background 0.3s;
}

.contract-item.is-sealed {
  border-color: var(--good);
  background: #f0faf5;
}

.contract-promise-text {
  margin: 0 0 10px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.4;
}

.contract-hold-btn {
  position: relative;
  overflow: hidden;
  border: 2px solid #f0d6e4;
  border-radius: 999px;
  background: #fff;
  min-height: 46px;
  width: 100%;
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: border-color 0.2s;
}

.contract-hold-btn:not(:disabled):hover {
  border-color: var(--primary);
}

.hold-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(225, 77, 122, 0.18), rgba(225, 77, 122, 0.35));
  border-radius: 999px;
  pointer-events: none;
}

.hold-label {
  position: relative;
  z-index: 1;
}

.contract-hold-btn.is-sealed {
  border-color: var(--good);
  background: #f0faf5;
  color: var(--good);
  cursor: default;
}

.contract-hold-btn.is-sealed .hold-fill {
  width: 100%;
  background: rgba(47, 138, 95, 0.14);
}

#contractNextBtn {
  margin-top: 12px;
}

/* ── Moodboard ───────────────────────────────────────────────────────────── */

.moodboard-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.moodboard-card {
  background: linear-gradient(135deg, #fff4f8, #ffedf6);
  border: 1px solid #f2c8db;
  border-radius: 16px;
  padding: 16px;
  font-weight: 600;
  color: #4d2c3e;
  line-height: 1.45;
  font-size: 0.97rem;
  opacity: 0;
  animation: moodboard-card-in 0.4s ease forwards;
}

#moodboardNextBtn {
  margin-top: 14px;
}

/* ── Vibe note ───────────────────────────────────────────────────────────── */

.vibe-note-content {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.vibe-note-line {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
  font-size: 1.02rem;
}

.vibe-weiter-btn {
  margin-top: 16px;
}

/* ── Forgiveness ─────────────────────────────────────────────────────────── */

.forgiv-row {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.forgiv-row .btn {
  flex: 1 1 140px;
}

#forgivNotYetBtn:disabled {
  pointer-events: none;
}

/* ── End choices ─────────────────────────────────────────────────────────── */

.end-choices {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.end-choices .btn {
  flex: 1 1 160px;
}

.end-choices .btn.is-selected {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
}

.end-confirm {
  margin-top: 14px;
  font-weight: 600;
  color: var(--good);
  font-size: 1.02rem;
  line-height: 1.55;
}

.end-write-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  text-decoration: none;
}

/* ── End screen ──────────────────────────────────────────────────────────── */

.end-lines {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.end-line {
  margin: 0;
  opacity: 0;
  transform: translateY(7px);
  font-weight: 600;
  color: var(--text);
}

.end-line.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.32s ease, transform 0.32s ease;
}

#endSubtext {
  margin-top: 12px;
  font-weight: 700;
  color: #60354a;
}

.end-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.end-actions .btn {
  flex: 1 1 200px;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(39, 18, 30, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 18px;
  border: 1px solid #efd9e5;
  box-shadow: 0 18px 40px rgba(32, 10, 24, 0.24);
  padding: 18px;
  animation: modal-in 0.2s ease;
}

/* ── Misc ────────────────────────────────────────────────────────────────── */

.noscript-msg {
  max-width: 760px;
  margin: 16px auto 0;
  border-radius: 12px;
  border: 1px solid #edd8e2;
  background: #fff;
  padding: 12px;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}

.is-shaking {
  animation: lock-shake 0.34s ease;
}

/* ── Focus ───────────────────────────────────────────────────────────────── */

.btn:focus-visible,
.text-link:focus-visible,
.unlock-form input:focus-visible,
.vibe-card:focus-visible,
.speedrun-toggle:focus-visible,
.quiz-option:focus-visible,
.contract-hold-btn:focus-visible {
  outline: 3px solid rgba(225, 77, 122, 0.35);
  outline-offset: 2px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 680px) {
  body {
    padding: 12px;
  }

  .card {
    padding: 16px;
    border-radius: 18px;
  }

  .moodboard-grid {
    grid-template-columns: 1fr;
  }

  .end-actions .btn {
    flex-basis: 100%;
  }

  .forgiv-row .btn {
    flex-basis: 100%;
  }
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .moodboard-card {
    opacity: 1;
  }
}

/* ── Keyframes ───────────────────────────────────────────────────────────── */

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes lock-shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-7px); }
  40%  { transform: translateX(7px); }
  60%  { transform: translateX(-5px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

@keyframes quiz-shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-5px); }
  40%  { transform: translateX(5px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

@keyframes moodboard-card-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
