* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #000;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  height: 100vh;
  overflow: hidden;
}

#screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Message thread ── */

#thread {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1.6rem;
  padding-bottom: 1rem;
  scrollbar-width: none;
}

#thread::-webkit-scrollbar {
  display: none;
}

.msg {
  font-size: 1.05rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  max-width: 85%;
  white-space: pre-wrap;
}

.msg.opponent {
  align-self: flex-start;
  opacity: 1;
}

.msg.user {
  align-self: flex-end;
  text-align: right;
  opacity: 0.6;
}

/* ── Typing cursor ── */

.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: #fff;
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink 700ms step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Input ── */

#input-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0 0.5rem;
  opacity: 0;
  transition: opacity 0.8s ease-in;
}

#input-wrap.show {
  opacity: 1;
}

#response {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.05rem;
  padding: 0.5rem 0;
  outline: none;
}

#response::placeholder {
  color: #444;
}

#send {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
  transition: opacity 0.2s;
}

#send:hover {
  opacity: 0.7;
}

/* ── Reveal trigger ── */

#reveal-trigger {
  display: none;
  text-align: center;
  font-size: 0.85rem;
  color: #fff;
  opacity: 0;
  cursor: pointer;
  padding: 0.8rem 0;
  animation: pulse 3s ease-in-out infinite;
  user-select: none;
}

#reveal-trigger.visible {
  display: block;
  opacity: 0.25;
}

@keyframes pulse {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.35; }
}

/* ── Glitch ── */

@keyframes screenFlicker {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.glitch-flicker {
  animation: screenFlicker 80ms linear;
}

/* ── Reveal stage ── */

#reveal-stage {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
}

#reveal-stage.active {
  display: flex;
}

#letter {
  max-width: 560px;
  width: 100%;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.55rem;
  line-height: 2;
  color: #fff;
  letter-spacing: 0.01em;
  white-space: pre-wrap;
}

#letter .typing-cursor {
  height: 1.4em;
}

#close {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  opacity: 0;
  transition: opacity 2s ease-in;
  pointer-events: none;
  z-index: 110;
}

#close.visible {
  opacity: 1;
}

#names {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.name {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 2.2rem;
  color: #fff;
  letter-spacing: 0.03em;
}

#date {
  margin-top: 2rem;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1rem;
  color: #fff;
  opacity: 0.5;
}

/* ── Dissolution character spans ── */

/* ── Connection error ── */

.retry-link {
  opacity: 0.4;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.retry-link:hover {
  opacity: 0.7;
}

/* ── Dissolution character spans ── */

.dissolve-char {
  transition: opacity 0.15s ease-out;
}

.dissolve-char.gone {
  opacity: 0;
}
