* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #1c2a1e;
  color: #f2efe6;
  font-family: "Courier New", Courier, monospace;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.stage {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

h1 {
  font-size: 1.4rem;
  margin: 0;
  letter-spacing: 0.05em;
}

.controls {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

#text-input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 1rem;
  background: #f2efe6;
  color: #1c2a1e;
  border: 3px solid #0f180f;
  border-radius: 6px;
  outline: none;
}

#text-input:focus {
  border-color: #6cbf3f;
}

#go {
  padding: 0.7rem 1.4rem;
  font: inherit;
  font-weight: bold;
  font-size: 1rem;
  letter-spacing: 0.1em;
  background: #6cbf3f;
  color: #0f180f;
  border: 3px solid #0f180f;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.08s ease;
}

#go:hover:not(:disabled) {
  transform: translateY(-2px);
}

#go:active:not(:disabled) {
  transform: translateY(1px);
}

#go:disabled {
  opacity: 0.5;
  cursor: wait;
}

.gif-wrap {
  position: relative;
  width: 100%;
  border: 4px solid #0f180f;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.gif-wrap.hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

.gif-wrap img {
  display: block;
  width: 100%;
}

.output {
  width: 100%;
  min-height: 6rem;
  padding: 1rem;
  background: #f7f3e8;
  color: #262014;
  border: 3px solid #0f180f;
  border-radius: 8px;
  font-size: 1.3rem;
  line-height: 1.7;
  word-break: break-word;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
}

.output-placeholder {
  color: #b3a98e;
  font-size: 0.95rem;
  font-style: italic;
}

/* letter slot reserved in the output while its twin is mid-flight */
.output .slot {
  display: inline-block;
  white-space: pre;
  visibility: hidden;
}

.output .slot.landed {
  visibility: visible;
  animation: stamp 0.18s ease-out;
}

@keyframes stamp {
  0% {
    transform: scale(1.6);
  }
  60% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

/* the letter that flies through the air */
.flying-letter {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10;
  font-family: "Courier New", Courier, monospace;
  font-size: 1.3rem;
  font-weight: bold;
  color: #f2efe6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  will-change: transform;
}
