/* ============================================================
   Палитра:
   --ink:      #241722   глубокий сумеречный фон
   --plum:     #4A2338   средний тон градиента
   --ember:    #E08965   тёплый акцент (свечение, кнопки hover)
   --gold:     #D8B673   акцент, рамки, засечки
   --paper:    #F7EFE6   бумага письма
   --blush:    #EBD3CE   светлый текст на тёмном фоне
   ============================================================ */

:root {
  --ink: #241722;
  --plum: #4A2338;
  --ember: #E08965;
  --gold: #D8B673;
  --paper: #F7EFE6;
  --blush: #EBD3CE;

  --display: 'Cormorant Garamond', serif;
  --hand: 'Caveat', cursive;
  --body: 'Nunito Sans', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at 50% -10%, var(--plum), var(--ink) 65%);
  color: var(--text);
  font-family: var(--body);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.btn, .option-btn, .envelope, .polaroid, .quiz-item, .link-btn, .lightbox-close {
  touch-action: manipulation;
}

@media (prefers-reduced-motion: reduce) {
  /* бесконечные декоративные анимации — просто выключаем, а не ускоряем:
     ускорение infinite-анимации до долей мс превращает её в мерцающий стробоскоп */
  .spark, .glow, .envelope-flap, .envelope-seal, .envelope-body {
    animation: none !important;
  }
  /* остальные (разовые) переходы — можно смело завершать мгновенно */
  .screen, .btn, .option-btn, .card, .polaroid, .dodge-btn, .lightbox, .heart-burst, .feedback, #nextBtn, .question-block, .final-trigger-btn {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.btn-guest {
  display: block;
  margin: 16px auto 0;
  background: none;
  border: none;
  color: var(--text);
  opacity: 0.6;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
  font-family: var(--body);
  padding: 12px;
}
@media (hover: hover) {
  .btn-guest:hover { opacity: 1; }
}

/* ---------- ambient floating light ---------- */
#ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  contain: strict;
}
.spark {
  position: absolute;
  bottom: -10px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.55;
  filter: blur(0.5px);
  animation: rise linear infinite;
  will-change: transform;
  transform: translateZ(0);
}
@keyframes rise {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(-105vh) translateX(var(--drift, 20px)); opacity: 0; }
}

.spark-heart {
  width: auto;
  height: auto;
  background: none;
  border-radius: 0;
  font-size: 13px;
  line-height: 1;
  color: var(--ember);
  filter: none;
}

/* праздничный "взрыв сердечек" в момент правильного ответа на капчу */
.heart-burst {
  position: fixed;
  color: var(--ember);
  pointer-events: none;
  z-index: 200;
  line-height: 1;
  animation: heartBurst 950ms ease-out forwards;
  will-change: transform, opacity;
}
@keyframes heartBurst {
  0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  18%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--bx)), calc(-50% + var(--by))) scale(1); opacity: 0; }
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(36px);
  opacity: 0.22;
  animation: drift ease-in-out infinite alternate;
  will-change: transform;
}
.glow.g1, .glow.g2, .glow.g3 { width: 160px; height: 160px; }
.glow.g1 { top: 8%; left: -80px; animation-duration: 26s; }
.glow.g2 { bottom: 6%; right: -60px; animation-duration: 32s; animation-delay: -8s; }
.glow.g3 { top: 45%; left: 60%; animation-duration: 38s; animation-delay: -14s; }
.glow.g1 { background: var(--ember); }
.glow.g2 { background: var(--gold); }
.glow.g3 { background: var(--plum); }

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(40px, -30px) scale(1.15); }
  100% { transform: translate(-30px, 25px) scale(0.9); }
}

/* ---------- app / screens ---------- */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.screen {
  display: none;
  width: 100%;
  max-width: 620px;
}
.screen.active {
  display: block;
  animation: screenIn 0.5s cubic-bezier(.22,1,.36,1) both;
}
.screen.leaving {
  display: block;
  animation: screenOut 0.28s ease both;
  pointer-events: none;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes screenOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-14px) scale(0.98); }
}

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

/* ---------- envelope screen ---------- */
#screen-envelope { display: none; }
#screen-envelope.active { display: flex; }
#screen-envelope.leaving { display: flex; }
.envelope-wrap {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.envelope {
  position: relative;
  width: 200px;  /* mobile-first: базовый размер под телефон */
  height: 134px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.envelope-shadow {
  position: absolute;
  bottom: -18px;
  left: 10%;
  width: 80%;
  height: 18px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.45), transparent 70%);
  border-radius: 50%;
}

.envelope-body {
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, #f0e2d4, var(--paper));
  border-radius: 6px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
  transition: transform 0.4s ease;
}
.envelope-body::before,
.envelope-body::after {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-top: 67px solid transparent;
}
.envelope-body::before {
  left: 0;
  border-left: 100px solid rgba(0,0,0,0.05);
  border-top-color: transparent;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  transform-origin: top center;
  transition: transform 0.55s cubic-bezier(.6,.1,.3,1.3);
  z-index: 2;
}
.envelope-flap::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 0;
  border-left: 100px solid transparent;
  border-right: 100px solid transparent;
  border-top: 77px solid #e7d5c2;
}

.envelope-seal {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translate(-50%, 0);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d1795c, #a94e3a 70%);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  z-index: 3;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.envelope:active .envelope-seal { transform: translate(-50%,0) scale(0.9); }

.envelope.opening .envelope-flap {
  transform: rotateX(180deg);
}
.envelope.opening .envelope-seal {
  opacity: 0;
  transform: translate(-50%, -30px) scale(0.6);
}
.envelope.opening .envelope-body {
  transform: translateY(-6px) scale(1.03);
}

.hint {
  font-family: var(--hand);
  font-size: 22px;
  color: var(--gold);
  opacity: 0.85;
  letter-spacing: 0.02em;
}

/* ---------- captcha screen ---------- */
.captcha-card { text-align: center; }
.captcha-card h2 {
  font-family: var(--display);
  font-size: 30px;
  color: var(--paper);
  margin: 0 0 16px;
}
.captcha-card > p {
  font-size: 16px;
  line-height: 1.6;
  opacity: 0.85;
  margin: 0 0 26px;
}

.captcha-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.captcha-input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 13px 16px;
  border-radius: 999px;
  border: 1px solid rgba(var(--gold-rgb),0.4);
  background: rgba(var(--surface-rgb),0.06);  
  color: var(--paper);
  font-family: var(--body);
  font-size: 16px; /* >=16px — иначе iOS Safari зумит страницу при фокусе */
  outline: none;
  transition: border-color 0.2s ease;
}
.captcha-input::placeholder { color: var(--blush); opacity: 0.45; }
.captcha-input:focus { border-color: var(--gold); }

.captcha-error {
  margin: 18px 0 0;
  font-size: 14px;
  color: var(--error);
}
.captcha-error.hidden { display: none; }

.captcha-hint {
  margin: 12px 0 0;
  font-family: var(--hand);
  font-size: 18px;
  color: var(--gold);
  opacity: 0.85;
}
.captcha-hint.hidden { display: none; }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(165deg, rgba(var(--surface-rgb),0.06), rgba(var(--surface-rgb),0.02));
  border: 1px solid rgba(var(--gold-rgb),0.25);
  border-radius: 14px;
  padding: 32px 22px;
  backdrop-filter: blur(6px);
}

.letter-card h1, .letter-card h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(30px, 6vw, 40px); /* Адаптивный размер */
  color: var(--heading);
  margin: 0 0 22px;
  line-height: 1.15;
}

.letter-body p {
  font-size: 18px;
  line-height: 1.75;
  color: var(--text);
  margin: 0 0 14px;
}

.signature {
  font-family: var(--hand);
  font-size: 30px;
  color: var(--gold);
  margin: 26px 0 34px;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-family: var(--body);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  padding: 14px 28px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.15s ease;
}
.btn:active { transform: translateY(0); }
.btn.hidden { display: none; }

.link-btn {
  background: none;
  border: none;
  color: var(--blush);
  opacity: 0.7;
  font-size: 14px;
  cursor: pointer;
  font-family: var(--body);
  text-decoration: underline;
  padding: 12px; /* Расширение зоны касания */
  margin: -12px;
}

/* ---------- quiz hub ---------- */
.hub-header { text-align: center; margin-bottom: 30px; }
.hub-header h2 {
  font-family: var(--display);
  font-size: clamp(26px, 5vw, 34px); /* Адаптивный размер */
  color: var(--heading);
  margin: 0 0 8px;
}
.hub-header p { margin: 0; opacity: 0.75; font-size: 15px; }

/* ---------- счётчик "сколько мы вместе" ---------- */
.counter-widget {
  text-align: center;
  margin: 0 0 28px;
  padding: 20px 20px 18px;
  border-radius: 14px;
  border: 1px solid rgba(var(--gold-rgb),0.22);
  background: rgba(var(--surface-rgb),0.04);
}
.counter-widget.hidden { display: none; }

.counter-label {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.65;
}
.counter-days {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  color: var(--heading);
  font-size: clamp(30px, 8vw, 42px);
  line-height: 1.15;
}
.counter-days-word {
  font-size: 15px;
  font-family: var(--body);
  font-weight: 400;
  color: var(--text);
  opacity: 0.75;
}
.counter-time {
  margin: 4px 0 0;
  font-family: var(--hand);
  font-size: 19px;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.notes-link {
  display: block;
  text-align: center;
  margin: 24px auto 0;
  width: fit-content;
}

/* ---------- кнопки-действия хаба (библиотека / заметки) ---------- */
.hub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 0 0 34px;
}
.hub-action-btn {
  flex: 1 1 140px;
  max-width: 220px;
}

/* ---------- раздел с тестами внутри хаба ---------- */
.quiz-section {
  border-top: 1px solid rgba(var(--gold-rgb),0.18);
  padding-top: 26px;
}
.quiz-section h3 {
  font-family: var(--display);
  font-size: clamp(22px, 5vw, 26px);
  color: var(--heading);
  margin: 0 0 6px;
  text-align: center;
}
.quiz-section > p {
  margin: 0 0 22px;
  text-align: center;
  font-size: 14px;
  opacity: 0.7;
}

.final-trigger-btn {
  display: block;
  margin: 22px auto 0;
  background: var(--gold);
  color: var(--accent-contrast);
  animation: softIn 0.4s ease both;
}
.final-trigger-btn:hover { background: var(--ember); border-color: var(--ember); }
.final-trigger-btn.hidden { display: none; }

/* ---------- экран заметок ---------- */
.notes-header { text-align: center; margin-bottom: 30px; }
.notes-header h2 {
  font-family: var(--display);
  font-size: clamp(26px, 5vw, 34px);
  color: var(--heading);
  margin: 0 0 8px;
}
.notes-header p { margin: 0; opacity: 0.75; font-size: 15px; }

.note-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 8px;
}

.note-textarea {
  width: 100%;
  min-height: 160px;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid rgba(var(--gold-rgb),0.3);
  background: rgba(var(--surface-rgb),0.05);  
  color: var(--paper);
  font-family: var(--body);
  font-size: 16px; /* >=16px — иначе iOS Safari зумит страницу при фокусе */
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease;
}
.note-textarea:focus { border-color: var(--gold); }
.note-textarea:disabled { opacity: 0.6; }

.note-editor-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.note-saved-hint {
  font-family: var(--hand);
  font-size: 17px;
  color: var(--gold);
  opacity: 0.9;
}
.note-saved-hint.hidden { display: none; }

.quiz-loading {
  text-align: center;
  padding: 30px 20px;
  opacity: 0.6;
  font-style: italic;
}

.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quiz-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-radius: 12px;
  border: 1px solid rgba(var(--gold-rgb),0.22);
  background: rgba(var(--surface-rgb),0.04);  
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}
.quiz-item.done { opacity: 0.55; }

.quiz-item-text h4 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 22px;
  color: var(--heading);
  font-weight: 600;
}
.quiz-item-text p { margin: 0; font-size: 14px; opacity: 0.7; }
.quiz-item-mark { font-family: var(--hand); font-size: 22px; color: var(--gold); }

/* ---------- quiz screen ---------- */
.quiz-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px 14px;
  margin-bottom: 18px;
}
#exitQuizBtn { flex: 0 0 auto; }

.quiz-top-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  min-width: 0;
  text-align: right;
  flex: 1 1 auto;
}

#quizTitleTag {
  font-size: 13px;
  opacity: 0.6;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-type-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(var(--gold-rgb), 0.35);
  color: var(--gold);
  background: rgba(var(--surface-rgb), 0.05);
  white-space: nowrap;
}
.question-type-badge.type-opinion {
  border-color: rgba(var(--ember-rgb), 0.4);
  color: var(--ember);
}
.question-type-badge.type-text {
  border-color: rgba(var(--gold-rgb), 0.3);
  color: var(--blush);
  opacity: 0.85;
}
.progress-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(247,239,230,0.12);
  margin-bottom: 30px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--ember);
  transition: width 0.4s ease;
}

#questionText {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(21px, 5vw, 26px); /* Адаптивный размер */
  color: var(--heading);
  margin: 0 0 26px;
  line-height: 1.3;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 10px;
}

.question-block.q-leaving {
  animation: qOut 0.2s ease both;
}
.question-block.q-entering {
  animation: qIn 0.35s ease both;
}
@keyframes qOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-16px); }
}
@keyframes qIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.option-btn {
  text-align: left;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid rgba(var(--gold-rgb),0.3);
  background: rgba(var(--surface-rgb),0.03);  
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.option-btn:disabled { cursor: default; }
.option-btn.correct { border-color: var(--correct); background: var(--correct-bg); color: var(--correct-text); }
.option-btn.wrong { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong-text); }


.feedback {
  margin-top: 14px;
  font-size: 14px;
  opacity: 0.85;
  font-style: italic;
}
.feedback.hidden { display: none; }
.feedback:not(.hidden) {
  animation: softIn 0.35s ease both;
}

@keyframes softIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 0.85; transform: translateY(0); }
}

/* ---------- yes/no questions ---------- */
.options-list.yesno-row {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  position: relative;
  min-height: 60px;
}

.yesno-btn {
  flex: 0 0 auto;
  min-width: 100px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 22px;
  border-radius: 999px;
}

/* убегающая кнопка "нет" — визуально ничем не отличается от обычной,
   только имеет плавный переход для координат, которые ей выставляет JS */
.dodge-btn {
  transition: left 0.35s cubic-bezier(.22, 1, .36, 1),
              top 0.35s cubic-bezier(.22, 1, .36, 1),
              transform 0.35s cubic-bezier(.34, 1.56, .64, 1);
  will-change: left, top, transform;
}

#nextBtn { margin-top: 22px; }
#nextBtn:not(.hidden) {
  animation: softIn 0.35s ease both;
}

/* ---------- result screen ---------- */
.result-card { text-align: center; }
.result-card h2 { 
  font-family: var(--display); 
  font-size: clamp(24px, 5vw, 32px); /* Адаптивный размер */
  color: var(--heading); 
  margin: 0 0 10px; 
}
.score { font-family: var(--hand); font-size: 28px; color: var(--gold); margin: 0 0 14px; }
.result-card p:not(.score) { font-size: 16px; opacity: 0.85; margin: 0 0 28px; line-height: 1.6; }

/* ---------- final screen ---------- */
#screen-final .letter-card { text-align: center; }
#screen-final p { font-size: 18px; line-height: 1.7; opacity: 0.9; margin-bottom: 26px; }

/* ---------- gallery screen ---------- */
#screen-gallery { max-width: 940px; }

.gallery-header { text-align: center; margin-bottom: 34px; }
.gallery-header h2 {
  font-family: var(--display);
  font-size: clamp(26px, 5vw, 34px); /* Адаптивный размер */
  color: var(--heading);
  margin: 0 0 8px;
}
.gallery-header p { margin: 0; opacity: 0.75; font-size: 15px; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 22px 16px;
  padding: 10px 4px 6px;
}

.polaroid {
  appearance: none;
  border: none;
  cursor: pointer;
  background: var(--paper);
  padding: 10px 10px 14px;
  border-radius: 3px;
  box-shadow: 0 12px 26px rgba(0,0,0,0.4);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.polaroid:focus-visible {
  transform: rotate(0deg) scale(1.05);
  box-shadow: 0 18px 34px rgba(0,0,0,0.5);
  z-index: 2;
}

.polaroid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 2px;
  display: block;
  background: rgba(0,0,0,0.15);
}

.polaroid-caption {
  font-family: var(--hand);
  font-size: 16px;
  color: #3a2a20;
  text-align: center;
  line-height: 1.2;
}
.polaroid-date {
  font-family: var(--body);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: #8a7864;
  text-align: center;
}

.gallery-empty {
  text-align: center;
  padding: 40px 20px;
  opacity: 0.6;
  font-style: italic;
}
.gallery-empty.hidden { display: none; }

.gallery-continue {
  display: block;
  margin: 40px auto 0;
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(var(--overlay-rgb), 0.88);
  backdrop-filter: blur(4px);  
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeUp 0.25s ease both;
}
.lightbox.hidden { display: none; }

.lightbox-content {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lightbox-content img {
  max-width: min(90vw, 560px);
  max-height: 52vh;
  object-fit: contain;
  border-radius: 4px;
  background: var(--paper);
  padding: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.55);
}

.lightbox-caption {
  font-family: var(--hand);
  font-size: 20px;
  color: var(--paper);
  margin: 4px 0 0;
  text-align: center;
}
.lightbox-date {
  font-family: var(--body);
  font-size: 13px;
  color: var(--gold);
  opacity: 0.85;
  margin: 0;
  letter-spacing: 0.03em;
}

.lightbox-close {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  right: calc(24px + env(safe-area-inset-right, 0px));
  background: none;
  border: none;
  color: var(--paper);
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  padding: 16px; /* Расширение зоны касания */
  margin: -16px;
}

/* ---------- HOVER (только для устройств с мышью) ---------- */
@media (hover: hover) {
  .envelope:hover .envelope-body { transform: translateY(-4px); }
  .btn:hover { background: var(--gold); color: var(--accent-contrast); transform: translateY(-1px); }
  .link-btn:hover { opacity: 1; }
  
  .quiz-item:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
    background: rgba(var(--surface-rgb),0.08);
  }
  
  .option-btn:hover:not(:disabled) {
    border-color: var(--gold);
    background: rgba(var(--surface-rgb),0.07);
  }
  
  .yes-btn:hover:not(:disabled) {
    border-color: var(--correct);
    background: var(--correct-bg);
  }

  .polaroid:hover {
    transform: rotate(0deg) scale(1.05);
    box-shadow: 0 18px 34px rgba(0,0,0,0.5);
    z-index: 2;
  }
  
  .lightbox-close:hover { opacity: 1; }
}

/* ---------- расширение под планшеты/десктоп (mobile-first: тут только "рост") ---------- */
@media (min-width: 641px) {
  .card { padding: 44px 40px; }

  .envelope { width: 240px; height: 160px; }
  .envelope-body::before,
  .envelope-body::after { border-top-width: 80px; }
  .envelope-body::before { border-left-width: 120px; }
  .envelope-flap::before {
    border-left-width: 120px;
    border-right-width: 120px;
    border-top-width: 92px;
  }
  .envelope-seal { top: 66px; width: 40px; height: 40px; font-size: 18px; }

  .yesno-btn { min-width: 120px; padding: 16px 30px; font-size: 16px; }

  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 30px 26px; }
  .lightbox-content img { max-height: 62vh; }
  .lightbox-caption { font-size: 24px; }

  .glow { filter: blur(55px); opacity: 0.32; }
  .glow.g1 { width: 280px; height: 280px; }
  .glow.g2 { width: 220px; height: 220px; }
  .glow.g3 { width: 200px; height: 200px; }
}

/* ---------- focus visibility ---------- */
button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.notes-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding: 4px 4px 4px 0;
}

.note-msg {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(var(--gold-rgb),0.22);
  background: rgba(var(--surface-rgb),0.04);
  max-width: 85%;
  align-self: flex-start;
}
.note-msg.mine {
  align-self: flex-end;
  background: rgba(var(--ember-rgb),0.12);
  border-color: rgba(var(--ember-rgb),0.35);
}

.note-msg-author {
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.03em;
  color: var(--gold);
  margin-bottom: 4px;
  opacity: 0.9;
}
.note-msg-content {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.note-msg-date {
  font-size: 11px;
  opacity: 0.55;
  margin-top: 4px;
  text-align: right;
}

/* ---------- топ-бар (плавающий остров-приветствие + переключатель тем) ---------- */
/* ---------- обёртка: центрирует остров и кнопку логаута вместе ---------- */
.top-bar-row {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;

  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 24px);
}
.top-bar-row.hidden { display: none; }

/* ---------- сам остров (визуальная пилюля) ---------- */
.top-bar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;

  padding: 6px 8px 6px 16px;
  border-radius: 999px;
  background: rgba(36, 23, 34, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(var(--gold-rgb), 0.4);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);

  transition: padding 0.3s cubic-bezier(.22,1,.36,1),
              gap 0.3s cubic-bezier(.22,1,.36,1),
              box-shadow 0.3s ease,
              border-color 0.3s ease;
}

/* ---------- кнопка выхода ---------- */
.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: rgba(36, 23, 34, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(var(--gold-rgb), 0.28);
  color: var(--heading);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.logout-btn:active { transform: scale(0.92); }

@media (hover: hover) {
  .logout-btn:hover {
    border-color: var(--gold);
    background: rgba(var(--ember-rgb), 0.18);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  }
}

@media (min-width: 641px) {
  .logout-btn { width: 40px; height: 40px; }
  .logout-btn svg { width: 18px; height: 18px; }
}
.top-bar.hidden { display: none; }



/* «дышащее» расширение острова при взаимодействии — имитация dynamic island */
@media (hover: hover) and (pointer: fine) {
  .top-bar:hover,
  .top-bar:focus-within {
    padding: 12px 22px;
    gap: 18px;
    border-color: rgba(216, 182, 115, 0.5);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.45);
  }
}

.top-bar-greeting {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
}

.theme-switcher {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  padding-left: 12px;
}

.theme-select {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box; 
  background: rgba(var(--surface-rgb), 0.1);
  border: 1px solid rgba(var(--gold-rgb), 0.4);
  color: var(--text);
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  padding: 7px 26px 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 64px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, width 0.25s cubic-bezier(.22,1,.36,1);
}

.theme-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(var(--gold-rgb), 0.18);
}

@media (min-width: 641px) {
  .top-bar { padding: 14px 28px; }
  .top-bar-greeting { font-size: 20px; }
  .theme-select { font-size: 20px; padding: 9px 34px 9px 16px; }
}

@media (hover: hover) {
  .theme-select:hover {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(var(--gold-rgb), 0.12);
  }
}

.theme-switcher::after {
  content: "▾";
  position: absolute;   
  top: 50%;
  right: 9px;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--gold);
  pointer-events: none; 
}

.theme-select:focus { outline: none; border-color: var(--gold); }
.theme-select option {
  background: var(--ink);
  color: var(--text);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (hover: hover) {
  .theme-select:hover { border-color: var(--gold); }
}

@media (min-width: 641px) {
  .top-bar { padding: 14px 28px; }
  .top-bar-greeting { font-size: 23px; }
  .theme-select { font-size: 14px; max-width: none; padding: 10px 34px 10px 16px; }
}

body.has-top-bar #app {
  padding-top: calc(96px + env(safe-area-inset-top, 0px));
}

.note-editor.hidden { display: none; }

/* ---------- вопрос со свободным вводом текста ---------- */
.text-answer-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.text-answer-input {
  width: 100%;
  min-height: 100px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(var(--gold-rgb),0.3);
  background: rgba(var(--surface-rgb),0.05);
  color: var(--paper);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease;
}
.text-answer-input:focus { border-color: var(--gold); }
.text-answer-input:disabled { opacity: 0.6; }
.text-answer-submit { align-self: flex-start; }

/* ---------- нейтральный выбор для вопросов-опросов без правильного ответа ---------- */
.option-btn.selected {
  border-color: var(--gold);
  background: rgba(var(--gold-rgb),0.12);
}

.date-place-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: rgba(0,0,0,0.15);
  margin-bottom: 14px;
}
.date-place-card { text-align: center; }
.date-place-card h3 {
  font-family: var(--display);
  font-size: 24px;
  color: var(--heading);
  margin: 0 0 6px;
}
.date-place-meta { font-size: 14px; color: var(--gold); margin: 0 0 8px; }
.date-place-desc { font-size: 15px; opacity: 0.8; margin: 0; }

.date-subheading { text-align: center; opacity: 0.75; margin: 0 0 20px; }
.date-carousel { display: flex; align-items: center; gap: 10px; }
.date-nav-btn {
  flex: 0 0 auto;
  background: none;
  border: 1px solid rgba(var(--gold-rgb),0.35);
  color: var(--gold);
  border-radius: 50%;
  width: 38px; height: 38px;
  font-size: 20px;
  cursor: pointer;
}
.date-nav-btn.hidden { display: none; }

.date-dots { display: flex; justify-content: center; gap: 8px; margin: 16px 0; }
.date-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(var(--gold-rgb),0.3); }
.date-dot.active { background: var(--gold); }

.date-accept-btn { display: block; margin: 8px auto 0; }
.date-accepted-view { text-align: center; }
.date-accepted-view h2 { font-family: var(--display); color: var(--heading); margin: 0 0 18px; }
#dateContinueBtn { margin: 20px auto 0; display: block; }
.hidden { display: none !important; }

.date-place-card.d-leaving-next { animation: dOutNext 0.2s ease both; }
.date-place-card.d-leaving-prev { animation: dOutPrev 0.2s ease both; }
.date-place-card.d-entering-next { animation: dInNext 0.35s ease both; }
.date-place-card.d-entering-prev { animation: dInPrev 0.35s ease both; }

@keyframes dOutNext {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-16px); }
}
@keyframes dOutPrev {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(16px); }
}
@keyframes dInNext {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes dInPrev {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .spark, .glow, .envelope-flap, .envelope-seal, .envelope-body {
    animation: none !important;
  }
  .screen, .btn, .option-btn, .card, .polaroid, .dodge-btn, .lightbox, .heart-burst,
  .feedback, #nextBtn, .question-block, .final-trigger-btn,
  .date-place-card { /* <-- add */
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
