* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0b0712;
  touch-action: none;
  user-select: none;
}
body[data-theme="paper"] { background: #f5f2fa; }

#portrait { position: fixed; inset: 0; display: block; cursor: crosshair; }

#welcome {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  font: 15px/1.6 ui-monospace, Menlo, monospace;
  color: #e9e9e9;
}
#welcome[hidden], #toast[hidden] { display: none; }
#welcome h1 { font-size: 28px; letter-spacing: 0.08em; }
#welcome .small { color: #888; font-size: 13px; }
.button {
  margin-top: 8px;
  padding: 10px 22px;
  border: 1px solid #e9e9e9;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.button:hover { background: #e9e9e9; color: #000; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(640px, 92vw);
  padding: 12px 18px;
  border-radius: 10px;
  background: rgba(20, 20, 20, 0.88);
  color: #eee;
  font: 13px/1.5 ui-monospace, Menlo, monospace;
}
#toast pre { margin-top: 8px; padding: 8px; background: #000; border-radius: 6px; white-space: pre-wrap; user-select: text; }

#quote {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom, 18px));
  transform: translateX(-50%);
  width: min(680px, 92vw);
  padding: 14px 24px;
  border-radius: 16px;
  border: 1px solid rgba(230, 194, 122, 0.34);
  background: linear-gradient(135deg, rgba(28, 17, 44, 0.78), rgba(14, 10, 24, 0.68));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 36px rgba(8, 4, 16, 0.65), inset 0 1px 0 rgba(168, 181, 130, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  text-wrap: balance;
  font: italic 500 clamp(13.5px, 3.5vw, 19px)/1.55 Georgia, "Palatino Linotype", "Book Antiqua", serif;
  letter-spacing: 0.025em;
  color: #f7f0ff;
  text-shadow: 0 2px 14px rgba(10, 5, 20, 0.9);
  pointer-events: none;
  opacity: 0;
  animation: quote-fade 1.6s ease 1.8s forwards;
  transition: opacity 0.9s ease, transform 0.9s ease;
}

#quote .quote-ornament {
  flex: none;
  font-style: normal;
  font-size: 0.85em;
  color: #e6c27a;
  text-shadow: 0 0 12px rgba(230, 194, 122, 0.65);
}

#quote.is-vanishing {
  animation: none;
  opacity: 0 !important;
  transform: translate(-50%, -10px);
}

body[data-theme="paper"] #quote {
  color: #2b1e3d;
  border-color: rgba(114, 124, 78, 0.32);
  background: linear-gradient(135deg, rgba(252, 249, 255, 0.88), rgba(242, 236, 250, 0.8));
  box-shadow: 0 10px 30px rgba(43, 30, 61, 0.12);
  text-shadow: none;
}

body[data-theme="paper"] #quote .quote-ornament {
  color: #a67c2e;
  text-shadow: none;
}

#hint {
  position: fixed;
  left: 50%;
  top: max(16px, env(safe-area-inset-top, 16px));
  transform: translateX(-50%);
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(203, 180, 246, 0.3);
  background: rgba(24, 14, 38, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #e9dcff;
  font: 500 clamp(11.5px, 2.8vw, 13px)/1.3 ui-monospace, Menlo, monospace;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  animation: hint-pulse 2.4s ease-in-out infinite;
}
#hint[hidden] { display: none; }

body[data-theme="paper"] #hint {
  border-color: rgba(110, 82, 158, 0.25);
  background: rgba(250, 246, 255, 0.86);
  color: #412b63;
}

#after-message {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% + 14px));
  width: min(560px, 90vw);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 22px 20px;
  text-align: center;
  text-wrap: balance;
  pointer-events: auto;
  user-select: text;
  touch-action: manipulation;
  opacity: 0;
  transition: opacity 1.4s ease, transform 1.4s ease;
}
#after-message[hidden] { display: none; }
#after-message.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%);
}
#after-message .after-lead {
  font: 400 clamp(14.5px, 3.7vw, 19px)/1.65 Georgia, "Palatino Linotype", serif;
  color: #f3ecff;
  text-shadow: 0 2px 18px rgba(10, 5, 20, 0.85);
  margin-bottom: 14px;
}
#after-message .after-apology {
  font: italic 500 clamp(15.5px, 4vw, 21px)/1.55 Georgia, "Palatino Linotype", serif;
  color: #f2cf88;
  text-shadow: 0 0 22px rgba(230, 194, 122, 0.35);
  margin-bottom: 14px;
}
#after-message .after-note {
  font: 400 clamp(11.5px, 2.9vw, 13px)/1.55 ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: #a9b584;
  max-width: 460px;
  margin: 0 auto 18px;
}

#reply-form {
  max-width: 440px;
  margin: 0 auto;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(169, 181, 132, 0.28);
  background: linear-gradient(155deg, rgba(28, 17, 44, 0.82), rgba(15, 10, 26, 0.78));
  box-shadow: 0 12px 32px rgba(6, 3, 14, 0.55), inset 0 1px 0 rgba(230, 194, 122, 0.14);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: left;
}
#reply-form .reply-label {
  display: block;
  font: 500 clamp(11.5px, 3vw, 13px)/1.45 ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: #ecd092;
  margin-bottom: 9px;
}
#reply-input {
  width: 100%;
  resize: vertical;
  min-height: 68px;
  max-height: 160px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(203, 180, 246, 0.24);
  background: rgba(11, 7, 18, 0.85);
  color: #f5f0ff;
  font: 400 14px/1.45 ui-sans-serif, system-ui, -apple-system, sans-serif;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
#reply-input::placeholder {
  color: rgba(196, 182, 224, 0.45);
}
#reply-input:focus {
  border-color: rgba(203, 180, 246, 0.75);
  box-shadow: 0 0 0 2px rgba(203, 180, 246, 0.15);
}
#reply-form .reply-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}
#reply-send {
  padding: 9px 28px;
  border: 1px solid rgba(230, 194, 122, 0.65);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(230, 194, 122, 0.22), rgba(140, 102, 196, 0.24));
  color: #fff3da;
  font: 600 13px/1.2 ui-sans-serif, system-ui, -apple-system, sans-serif;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
#reply-send:hover:not(:disabled) {
  background: linear-gradient(135deg, #e6c27a, #cbb4f6);
  color: #160e24;
  transform: translateY(-1px);
}
#reply-send:disabled {
  opacity: 0.55;
  cursor: default;
}
#reply-status {
  min-height: 16px;
  font: 400 12px/1.3 ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: #d7c7f5;
  text-align: center;
}
.lavender-question {
  margin-top: 10px;
  text-align: center;
  font: italic 500 clamp(13px, 3.2vw, 15px)/1.45 Georgia, "Palatino Linotype", serif;
  color: #d5baff;
  text-shadow: 0 0 14px rgba(196, 160, 255, 0.45);
}

body[data-theme="paper"] #after-message .after-lead {
  color: #2b1e3d;
  text-shadow: none;
}
body[data-theme="paper"] #after-message .after-apology {
  color: #8f651d;
  text-shadow: none;
}
body[data-theme="paper"] #after-message .after-note {
  color: #5e6b3c;
}
body[data-theme="paper"] #reply-form {
  border-color: rgba(114, 124, 78, 0.28);
  background: rgba(252, 249, 255, 0.9);
  box-shadow: 0 10px 28px rgba(43, 30, 61, 0.1);
}
body[data-theme="paper"] #reply-form .reply-label {
  color: #8f651d;
}
body[data-theme="paper"] #reply-input {
  background: #ffffff;
  border-color: rgba(124, 96, 173, 0.28);
  color: #221830;
}
body[data-theme="paper"] #reply-send {
  border-color: rgba(143, 101, 29, 0.5);
  background: linear-gradient(135deg, rgba(230, 194, 122, 0.24), rgba(169, 134, 224, 0.2));
  color: #4d3510;
}
body[data-theme="paper"] #reply-send:hover:not(:disabled) {
  background: linear-gradient(135deg, #c99d49, #9a79cf);
  color: #fff;
}
body[data-theme="paper"] #reply-status {
  color: #5b4187;
}
body[data-theme="paper"] .lavender-question {
  color: #835ec2;
  text-shadow: none;
}

@keyframes quote-fade {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #quote { opacity: 1; animation: none; }
  #hint { animation: none; }
  #after-message { transition: none; }
}
