:root {
  --bg: #f5f1eb;
  --surface: rgba(255, 255, 255, 0.76);
  --paper: rgba(255, 252, 247, 0.97);
  --text: #24211f;
  --muted: #7a716a;
  --line: rgba(36, 33, 31, 0.12);
  --red: #a91f34;
  --red-deep: #7f1526;
  --shadow: 0 22px 60px rgba(56, 41, 30, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,0.8), transparent 35%),
    radial-gradient(circle at 85% 90%, rgba(218, 198, 185, 0.16), transparent 35%),
    var(--bg);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100vh;
  min-height: 100svh;
}

.screen {
  min-height: 100vh;
  min-height: 100svh;
  display: none;
  opacity: 0;
  transform: translateY(10px);
}

.screen.active {
  display: flex;
  animation: screenIn 520ms ease forwards;
}

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

/* ---------- Entry ---------- */

.screen-entry {
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
}

.entry-wrap {
  width: min(100%, 420px);
}

.small-mark {
  width: 30px;
  height: 30px;
  margin: 0 auto 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  background: rgba(255,255,255,0.4);
}

.entry-wrap h1 {
  margin: 0;
  text-align: center;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(3rem, 11vw, 4.2rem);
  line-height: 0.95;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.entry-subtitle {
  margin: 14px 0 34px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.name-form {
  display: grid;
  gap: 10px;
}

.name-form label {
  margin-top: 7px;
  color: #5e5751;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.name-form input {
  width: 100%;
  height: 52px;
  border: 1px solid rgba(36,33,31,0.16);
  border-radius: 14px;
  outline: none;
  padding: 0 15px;
  color: var(--text);
  background: rgba(255,255,255,0.66);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.name-form input:focus {
  border-color: rgba(127, 21, 38, 0.45);
  background: rgba(255,255,255,0.92);
  box-shadow: 0 0 0 4px rgba(169, 31, 52, 0.08);
}

.field-message {
  min-height: 20px;
  margin: 4px 0 0;
  color: var(--red-deep);
  font-size: 0.78rem;
}

/* ---------- Buttons ---------- */

.btn {
  min-height: 50px;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  font-weight: 600;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  box-shadow: 0 12px 26px rgba(127, 21, 38, 0.18);
}

.btn-primary:hover {
  box-shadow: 0 15px 30px rgba(127, 21, 38, 0.25);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255,255,255,0.65);
  border-color: rgba(36,33,31,0.12);
}

/* ---------- Warning ---------- */

.screen-warning {
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
}

.warning-card {
  width: min(100%, 650px);
  padding: clamp(26px, 6vw, 46px);
  border: 1px solid rgba(36,33,31,0.1);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.warning-symbol {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  margin-bottom: 24px;
  display: grid;
  place-items: center;
  color: var(--red-deep);
  border: 1px solid rgba(169,31,52,0.2);
  background: rgba(169,31,52,0.06);
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red-deep);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.warning-card h2 {
  margin: 0 0 24px;
  max-width: 12ch;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-weight: 600;
}

.warning-copy {
  color: #4f4842;
  font-size: 0.96rem;
  line-height: 1.8;
}

.warning-copy p {
  margin: 0 0 16px;
}

.warning-strong {
  color: var(--text);
  font-weight: 600;
}

.warning-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 30px;
}

/* ---------- Letter ---------- */

.screen-letter {
  position: relative;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px 70px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,0.9), transparent 30%),
    radial-gradient(circle at 80% 100%, rgba(189, 42, 61, 0.06), transparent 34%),
    #f2ece4;
}

.letter-shell {
  position: relative;
  z-index: 2;
  width: min(100%, 820px);
}

.letter-paper {
  position: relative;
  padding: clamp(30px, 7vw, 72px) clamp(22px, 7vw, 76px) clamp(36px, 8vw, 78px);
  border: 1px solid rgba(80, 44, 30, 0.08);
  border-radius: 20px;
  background:
    linear-gradient(rgba(255,255,255,0.12), rgba(255,255,255,0.12)),
    var(--paper);
  box-shadow:
    0 24px 80px rgba(73, 45, 32, 0.12),
    0 3px 8px rgba(73, 45, 32, 0.04);
}

.letter-topline {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 54px;
  color: #8f8278;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.letter-heading-wrap h2 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2.8rem, 9vw, 5rem);
  line-height: 0.95;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.letter-body {
  margin-top: 38px;
  color: #37312d;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  font-size: clamp(1.3rem, 2.8vw, 1.65rem);
  line-height: 1.68;
}

.letter-body p {
  margin: 0 0 1.35em;
}

.letter-signoff {
  margin-top: 2.1em !important;
}

.letter-signoff span {
  font-style: italic;
}

.letter-end {
  margin-top: 42px;
  text-align: center;
  color: #72675f;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  font-size: 1.25rem;
  line-height: 1.5;
}

.letter-end p {
  margin: 7px 0;
}

.end-line {
  width: 70px;
  height: 1px;
  margin: 0 auto 20px;
  background: rgba(127, 21, 38, 0.28);
}

/* ---------- Floating heart bubbles ---------- */

.heart-field {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.heart {
  position: absolute;
  top: -12vh;
  left: 0;
  width: var(--size);
  height: var(--size);
  opacity: var(--opacity);
  transform: translate3d(0, -20px, 0) rotate(var(--rotation));
  animation: driftDown var(--duration) linear var(--delay) forwards;
  filter: blur(var(--blur));
}

.heart::before {
  content: "♥";
  display: block;
  color: rgba(169, 31, 52, 0.28);
  font-size: var(--size);
  line-height: 1;
  text-shadow: 0 1px 10px rgba(169, 31, 52, 0.07);
}

@keyframes driftDown {
  0% {
    transform: translate3d(var(--start-x), -15vh, 0) rotate(var(--rotation));
  }
  50% {
    transform: translate3d(calc(var(--start-x) + var(--sway)), 50vh, 0) rotate(calc(var(--rotation) + 10deg));
  }
  100% {
    transform: translate3d(calc(var(--start-x) - var(--sway2)), 115vh, 0) rotate(calc(var(--rotation) - 8deg));
  }
}

@media (min-width: 640px) {
  .warning-actions {
    grid-template-columns: 0.8fr 1.2fr;
  }

  .screen-entry {
    padding-inline: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen.active {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .heart {
    animation: none;
    display: none;
  }
}


/* ---------- Owner settings ---------- */

.settings-button {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 20;
  border: 1px solid rgba(36,33,31,0.12);
  border-radius: 12px;
  padding: 9px 13px;
  color: #4f4842;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(10px);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
}

.owner-panel {
  position: fixed;
  right: 18px;
  top: 62px;
  z-index: 30;
  width: min(360px, calc(100vw - 36px));
  padding: 22px;
  border: 1px solid rgba(36,33,31,0.1);
  border-radius: 20px;
  background: rgba(255,252,247,0.96);
  box-shadow: 0 24px 70px rgba(45, 30, 22, 0.18);
  backdrop-filter: blur(18px);
}

.owner-panel h3 {
  margin: 0 0 16px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 2rem;
}

.owner-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: transparent;
  color: #766c65;
  font-size: 1.5rem;
  cursor: pointer;
}

.owner-status {
  padding: 12px;
  border-radius: 14px;
  background: rgba(169,31,52,0.05);
  margin-bottom: 12px;
}

.owner-status p,
.owner-note {
  margin: 7px 0 0;
  color: #7a716a;
  font-size: 0.74rem;
  line-height: 1.5;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #8f2436;
}

.activity-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 2px;
  border-bottom: 1px solid rgba(36,33,31,0.08);
  font-size: 0.82rem;
}

.activity-row strong {
  color: #8f2436;
  text-align: right;
}

.owner-panel .btn {
  width: 100%;
  margin-top: 16px;
}

.reply-waiting {
  margin-top: 20px !important;
  color: #8f2436;
  font-style: italic;
  font-weight: 600;
}

/* ---------- Pre-letter message modal ---------- */

body.modal-open {
  overflow: hidden;
}

.message-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.message-modal.visible {
  display: flex;
  animation: modalFadeIn 320ms ease forwards;
}

.message-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 25, 20, 0.28);
  backdrop-filter: blur(8px);
}

.message-modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  padding: clamp(30px, 7vw, 52px);
  border: 1px solid rgba(80, 44, 30, 0.10);
  border-radius: 26px;
  background: rgba(255, 252, 247, 0.97);
  box-shadow: 0 28px 90px rgba(45, 30, 22, 0.22);
  text-align: center;
}

.message-modal-card h2 {
  margin: 0 auto 18px;
  max-width: 13ch;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2.25rem, 9vw, 3.8rem);
  line-height: 0.98;
  font-weight: 600;
  letter-spacing: -0.035em;
}

.message-modal-copy {
  margin: 0 auto 28px;
  max-width: 38ch;
  color: #5d544e;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.15rem, 3.5vw, 1.45rem);
  line-height: 1.55;
}

.message-modal-card .btn {
  width: 100%;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.exit-letter-btn {
  min-width: 130px;
  margin-top: 22px;
}

@media (prefers-reduced-motion: reduce) {
  .message-modal.visible {
    animation: none;
  }
}
