:root {
  --parchment: #f2e2c4;
  --ink: #38261e;
  --warm: #ffd39a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #171122;
  color: #f7e9d2;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app, #app canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(10, 6, 18, 0) 38%, rgba(10, 6, 18, 0.42) 100%),
    linear-gradient(to bottom, rgba(11, 8, 24, 0.28), rgba(11, 8, 24, 0) 28%, rgba(11, 8, 24, 0) 72%, rgba(11, 8, 24, 0.3));
}

#title {
  position: fixed;
  top: 24px;
  left: 28px;
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7);
  opacity: 0;
  animation: titleIn 2.4s ease 0.9s forwards;
}

#title h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(20px, 2.5vw, 31px);
  font-weight: 400;
  letter-spacing: 0.09em;
  color: #ffe9c6;
}

#title p {
  margin: 5px 0 0 2px;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 226, 187, 0.62);
}

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

#bubbles {
  position: fixed;
  inset: 0;
  z-index: 6;
  overflow: hidden;
  pointer-events: none;
}

.bubble {
  position: absolute;
  max-width: 220px;
  padding: 9px 13px 10px;
  border: 1px solid #c29a68;
  border-radius: 12px;
  background: linear-gradient(#fff9ea, #f3e2c2);
  color: #33231c;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 8px 24px rgba(5, 2, 12, 0.45), inset 0 1px 0 #fffdf4;
  opacity: 0;
  transform: translate(-50%, calc(-100% + 8px)) scale(0.92);
  transform-origin: 50% 100%;
  transition: opacity 0.22s ease, transform 0.3s cubic-bezier(.2, 1.5, .4, 1);
  will-change: left, top, opacity, transform;
}

.bubble.show {
  opacity: 1;
  transform: translate(-50%, -100%) scale(1);
}

.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 0;
  height: 0;
  margin-left: -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid #f3e2c2;
  filter: drop-shadow(0 1px 0 #c29a68);
}

#prompt {
  position: fixed;
  z-index: 7;
  display: none;
  padding: 8px 14px;
  border: 1px solid rgba(255, 226, 160, 0.85);
  border-radius: 999px;
  background: rgba(255, 214, 130, 0.95);
  color: #3d2510;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.03em;
  white-space: nowrap;
  box-shadow: 0 0 24px rgba(255, 165, 60, 0.4), 0 5px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transform: translate(-50%, -100%);
  animation: promptPulse 1.4s ease-in-out infinite;
}

@keyframes promptPulse {
  0%, 100% { box-shadow: 0 0 18px rgba(255, 165, 60, 0.3), 0 5px 14px rgba(0, 0, 0, 0.35); }
  50%      { box-shadow: 0 0 34px rgba(255, 185, 80, 0.65), 0 5px 14px rgba(0, 0, 0, 0.35); }
}

#prompt.show { display: block; }

#caption {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 6;
  width: min(680px, calc(100vw - 44px));
  padding: 15px 24px 17px;
  border: 1px solid #a77a4a;
  border-radius: 7px;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(255, 255, 255, 0.32), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(120, 74, 34, 0.13), transparent 50%),
    linear-gradient(160deg, #f6e8cd 0%, #eed9b4 55%, #e7cda3 100%);
  color: var(--ink);
  box-shadow: 0 18px 45px rgba(5, 2, 12, 0.55), inset 0 0 0 3px rgba(255, 249, 233, 0.3);
  transform: translate(-50%, 0);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}

#caption.hidden {
  opacity: 0;
  transform: translate(-50%, 14px);
}

#caption .label {
  margin-bottom: 5px;
  color: #96683c;
  font-size: 9.5px;
  font-weight: bold;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

#captionText {
  min-height: 42px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(14px, 1.35vw, 16.5px);
  line-height: 1.5;
}

#caption.typing #captionText::after {
  content: "▌";
  margin-left: 2px;
  color: #a4764a;
  animation: caret 0.9s steps(1) infinite;
}

@keyframes caret {
  50% { opacity: 0; }
}

#hint {
  position: fixed;
  right: 26px;
  bottom: 30px;
  z-index: 5;
  color: rgba(255, 233, 202, 0.55);
  font-size: 10.5px;
  line-height: 1.7;
  letter-spacing: 0.05em;
  text-align: right;
  text-shadow: 0 1px 8px #000;
  pointer-events: none;
}

#error[hidden] { display: none; }

#error {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: #171122;
  text-align: center;
}

#error h2 {
  margin: 0 0 8px;
  font-family: Georgia, serif;
  font-weight: 400;
  color: #ffd9a0;
}

#error p {
  max-width: 520px;
  color: #b8a9c6;
  font-size: 14px;
  line-height: 1.6;
}

#fade {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #120d1c;
  pointer-events: none;
  animation: fadeAway 2.1s ease 0.25s forwards;
}

@keyframes fadeAway {
  to { opacity: 0; }
}

@media (max-width: 620px) {
  #title { top: 16px; left: 18px; }
  #hint { right: 16px; bottom: 20px; font-size: 9.5px; }
  #caption { bottom: 18px; padding: 12px 16px 14px; }
  #captionText { min-height: 54px; font-size: 13.5px; }
  .bubble { max-width: 160px; font-size: 12px; }
}
