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

:root {
  --bg: #080d1b;
  --surface: #111a2e;
  --surface-light: #192641;
  --orange: #ffae35;
  --orange-light: #ffd078;
  --cyan: #36d9e8;
  --text: #f1f5ff;
  --muted: #9ba9c5;
  --border: rgba(255, 174, 53, 0.3);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Segoe UI", sans-serif;
  font-size: 1rem;
  color: var(--text);
  background:
    radial-gradient(ellipse at 15% 10%, rgba(54, 217, 232, 0.09), transparent 35%),
    radial-gradient(ellipse at 85% 80%, rgba(255, 174, 53, 0.09), transparent 35%),
    var(--bg);
  padding: 30px 16px;
  overflow-x: hidden;
  animation: pageEnter 0.8s ease;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  text-align: center;
  margin: 35px 0;
  line-height: 1.2;
  letter-spacing: -1.5px;
  background: linear-gradient(100deg, #fff, var(--orange), var(--cyan));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  animation: titleReveal 1s ease both;
}

h2 {
  font-size: 1.3rem;
  text-align: center;
  margin: 28px 0 18px;
  color: var(--cyan);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.input-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
  align-items: stretch;
  width: clamp(320px, 90vw, 480px);
  padding: 25px;
  margin: 10px auto;
  background: rgba(17, 26, 46, 0.85);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  box-shadow: 0 15px 45px rgba(0,0,0,0.3);
  backdrop-filter: blur(15px);
  animation: slideUp 0.8s ease both;
}

.input-container label {
  color: var(--muted);
  font-size: 0.95rem;
}

.number-input {
  width: 100%;
  padding: 14px;
  font: inherit;
  color: white;
  background: var(--bg);
  border: 1px solid #34425d;
  border-radius: 9px;
  outline: none;
  transition: 0.3s ease;
}

.number-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(54,217,232,0.12),
              0 0 18px rgba(54,217,232,0.12);
}

.convert-btn {
  width: 100%;
  padding: 13px;
  font: inherit;
  font-weight: 700;
  color: #17121a;
  background: linear-gradient(110deg, var(--orange), var(--orange-light));
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.convert-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(255,174,53,0.3);
}

.convert-btn:active {
  transform: scale(0.97);
}

.output-container {
  width: clamp(320px, 90vw, 480px);
  margin: 15px auto;
  animation: slideUp 1s ease both;
}

#result {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 85px;
  padding: 18px;
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
  color: var(--orange-light);
  background: linear-gradient(135deg, #111a2e, #18243b);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 0 25px rgba(255,174,53,0.06);
  transition: 0.3s ease;
}

#result:not(:empty) {
  animation: resultPop 0.45s ease;
}

#animation-container {
  display: flex;
  flex-direction: column-reverse;
  justify-content: end;
  gap: 12px;
  min-height: 40vh;
  padding: 18px;
  margin-bottom: 25px;
  background: rgba(17,26,46,0.65);
  border: 1px dashed rgba(54,217,232,0.4);
  border-radius: 14px;
}

.animation-frame {
  padding: 17px;
  color: var(--text);
  font-family: "Segoe UI", sans-serif;
  font-size: 1rem;
  text-align: center;
  background: linear-gradient(110deg, #192641, #202d48);
  border: 1px solid rgba(54,217,232,0.35);
  border-left: 4px solid var(--orange);
  border-radius: 9px;
  box-shadow: 0 5px 18px rgba(0,0,0,0.2);
  animation: frameAppear 0.45s cubic-bezier(.2,.8,.2,1) both;
  transition: border-color 0.3s ease, transform 0.3s ease;
}

.animation-frame:hover {
  transform: translateX(5px);
  border-left-color: var(--cyan);
}

@keyframes pageEnter {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes resultPop {
  0% { transform: scale(0.95); opacity: 0.5; }
  70% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes frameAppear {
  from {
    opacity: 0;
    transform: translateX(-25px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@media screen and (min-width: 36em) {
  .input-container {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .input-container label {
    width: 100%;
  }

  .number-input {
    flex: 1;
    min-width: 0;
  }

  .convert-btn {
    width: auto;
    min-width: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Recursive call returning animation */
.frame-returning {
  border-color: var(--cyan);
  border-left-color: var(--cyan);
  background: linear-gradient(
    110deg,
    #123447,
    #192d48
  );
  animation: returnPulse 0.7s ease;
}

/* Stack frame removal */
.frame-exit {
  animation: frameExit 0.35s ease forwards;
}

@keyframes returnPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 transparent;
  }

  50% {
    transform: scale(1.03);
    box-shadow: 0 0 22px rgba(54, 217, 232, 0.35);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes frameExit {
  from {
    opacity: 1;
    transform: translateX(0);
    max-height: 200px;
  }

  to {
    opacity: 0;
    transform: translateX(40px);
    max-height: 0;
    padding: 0;
    margin: 0;
  }
}

.result-ready {
  color: var(--cyan) !important;
  border-color: var(--cyan) !important;
  box-shadow: 0 0 25px rgba(54, 217, 232, 0.2) !important;
}
.footer {
  margin-top: 30px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
.footer-link {
  color: var(--cyan);
  text-decoration: none;
  transition: color 0.3s ease;
}
.footer-link:hover {
  color: var(--orange);
}