:root {
  color-scheme: dark;
  --ink: rgba(229, 237, 248, .94);
  --muted: rgba(158, 178, 212, .64);
  --dim: rgba(123, 148, 190, .42);
  --line: rgba(168, 197, 235, .14);
  --panel: rgba(5, 9, 17, .44);
  --panel-strong: rgba(4, 7, 14, .58);
  --blue: #84b7ff;
  --amber: #e6c67b;
  --rose: #d89bb3;
  --serif: "IM Fell English", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #05070b;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 12% 16%, rgba(88, 120, 180, .24), transparent 29rem),
    radial-gradient(circle at 88% 80%, rgba(141, 113, 86, .16), transparent 26rem),
    #05070b;
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

.poster {
  width: min(100%, 430px);
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: #07090e;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .36);
  touch-action: manipulation;
}

.backdrop,
.grain,
.burn {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.backdrop {
  z-index: -4;
  background-image: url("assets/bg.png");
  background-position: center 15%;
  background-size: cover;
  transform: scale(1.01);
  filter: saturate(.98) contrast(1.08) brightness(1.08);
}

.grain {
  z-index: -2;
  opacity: .34;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.36'/%3E%3C/svg%3E");
}

.burn {
  z-index: -3;
  background:
    linear-gradient(180deg, rgba(3, 5, 10, .54) 0%, rgba(3, 5, 10, .04) 27%, rgba(3, 5, 10, .08) 56%, rgba(3, 5, 10, .78) 100%),
    linear-gradient(90deg, rgba(5, 9, 18, .24), transparent 34%, transparent 72%, rgba(5, 9, 18, .26));
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(9px, 1.55vh, 15px);
  padding: max(18px, env(safe-area-inset-top)) 20px max(12px, env(safe-area-inset-bottom));
}

.top-bar,
.footer,
.pair-strip,
.swap-row {
  display: flex;
  align-items: center;
}

.top-bar {
  position: relative;
  justify-content: center;
  width: min(100%, 356px);
  justify-self: center;
  text-align: center;
}

.kicker,
.field span,
.pair-strip,
.rate-line,
.footer {
  margin: 0;
  color: var(--dim);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  color: rgba(226, 235, 251, .95);
  font-family: var(--serif);
  font-size: clamp(32px, 9.6vw, 43px);
  font-weight: 400;
  line-height: .95;
  letter-spacing: .13em;
  text-transform: uppercase;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .88);
}

.converter {
  align-self: center;
  justify-self: center;
  width: min(100%, 334px);
  position: relative;
  margin: clamp(6px, 1.2vh, 14px) 0;
  padding: 13px 14px 12px;
  border: 1px solid rgba(174, 203, 240, .10);
  background:
    linear-gradient(180deg, rgba(10, 16, 28, .38), rgba(4, 7, 13, .27)),
    var(--panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .055),
    0 18px 52px rgba(0, 0, 0, .24);
  backdrop-filter: blur(7px) saturate(1.08);
  overflow: hidden;
}

.converter-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, transparent 0%, rgba(132, 183, 255, .08) 44%, transparent 62%),
    radial-gradient(circle at 78% 10%, rgba(144, 243, 194, .055), transparent 14rem);
  opacity: .58;
}

.pair-strip {
  position: relative;
  justify-content: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 0;
  text-align: center;
}

.pair-strip span:last-child {
  position: absolute;
  right: 0;
  text-align: right;
  color: rgba(171, 190, 225, .74);
  letter-spacing: .08em;
  text-shadow: 0 0 14px rgba(132, 183, 255, .20);
}

.field-grid {
  position: relative;
  display: grid;
  grid-template-columns: .92fr 1.08fr;
  gap: 12px;
  padding-top: 11px;
}

.bottom-grid {
  grid-template-columns: .72fr 1.28fr;
  padding-top: 0;
}

.field {
  min-width: 0;
  display: grid;
  gap: 4px;
  text-align: center;
}

.field span {
  display: block;
}

input,
output {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: rgba(228, 237, 252, .94);
  font-family: var(--serif);
  line-height: 1.05;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .82);
  transition: border-color .2s ease, color .2s ease, transform .2s ease;
}

input {
  height: 34px;
  padding: 0;
  min-height: 34px;
  font-size: clamp(21px, 6.4vw, 28px);
  text-align: center;
  appearance: textfield;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

output {
  display: block;
  height: 34px;
  padding: 0;
  font-size: clamp(20px, 5.9vw, 27px);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-field.is-compact output {
  font-size: clamp(18px, 5.1vw, 23px);
}

.result-field.is-tiny output {
  font-size: clamp(16px, 4.5vw, 20px);
}

input:focus,
.currency-trigger:focus-visible,
.currency-code:focus {
  border-color: rgba(144, 243, 194, .62);
  color: #f2f7ff;
}

.native-select {
  display: none;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.currency-control {
  width: 100%;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.currency-code {
  width: 54px;
  height: 31px;
  border: 0;
  outline: none;
  background: transparent;
  color: rgba(228, 237, 252, .94);
  font-family: var(--serif);
  font-size: clamp(18px, 5.4vw, 24px);
  line-height: 1;
  text-align: right;
  text-transform: uppercase;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .82);
}

.currency-code.is-invalid {
  color: rgba(174, 192, 222, .44);
}

.currency-trigger {
  width: 26px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 0;
  outline: none;
  background: transparent;
  color: rgba(228, 237, 252, .94);
  cursor: pointer;
  transition: color .18s ease, transform .18s ease;
}

.currency-trigger:hover,
.currency-trigger[aria-expanded="true"] {
  color: #f5f8ff;
}

.currency-trigger:active {
  transform: translateY(1px);
}

.currency-trigger svg {
  width: 9px;
  height: 6px;
  margin-top: 2px;
  fill: none;
  stroke: rgba(178, 204, 238, .70);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s ease, stroke .18s ease;
}

.currency-trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
  stroke: rgba(144, 243, 194, .72);
}

.currency-popover {
  position: absolute;
  z-index: 8;
  width: 132px;
  max-height: 210px;
  display: none;
  padding: 7px;
  border: 1px solid rgba(170, 199, 238, .20);
  background:
    linear-gradient(180deg, rgba(10, 15, 25, .84), rgba(3, 6, 12, .76)),
    rgba(5, 8, 15, .82);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .06),
    inset 0 -18px 38px rgba(4, 7, 14, .45),
    0 18px 44px rgba(0, 0, 0, .44);
  backdrop-filter: blur(14px) saturate(1.15);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  isolation: isolate;
}

.currency-popover::before,
.currency-popover::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: -1;
}

.currency-popover::before {
  inset: -42% -30%;
  background:
    radial-gradient(ellipse at 34% 82%, rgba(61, 132, 211, .36) 0%, rgba(61, 132, 211, .12) 21%, transparent 45%),
    radial-gradient(ellipse at 72% 82%, rgba(118, 178, 238, .30) 0%, rgba(118, 178, 238, .10) 24%, transparent 48%),
    radial-gradient(ellipse at 52% 102%, rgba(183, 213, 247, .16), transparent 42%);
  filter: blur(10px);
  opacity: .78;
  animation: menuFlame 4.8s ease-in-out infinite alternate;
}

.currency-popover::after {
  inset: 0;
  background:
    linear-gradient(180deg, transparent, rgba(132, 183, 255, .08) 48%, transparent 50%),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, .022) 0 1px, transparent 1px 5px);
  mix-blend-mode: screen;
  opacity: .5;
}

.currency-popover.is-open {
  display: grid;
  gap: 3px;
  animation: menuIn .22s cubic-bezier(.2, .8, .2, 1) both;
}

.currency-popover::-webkit-scrollbar {
  width: 5px;
}

.currency-popover::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, .03);
}

.currency-popover::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(161, 201, 247, .46), rgba(62, 130, 211, .34));
}

.currency-option {
  position: relative;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  background: rgba(8, 13, 24, .28);
  color: rgba(218, 229, 247, .86);
  font-family: Inter, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-align: left;
  cursor: pointer;
  padding: 0 10px;
  text-transform: uppercase;
  overflow: hidden;
  transition: color .16s ease, background .16s ease, transform .16s ease;
}

.currency-option::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(132, 183, 255, .20), transparent);
  opacity: 0;
  transform: translateX(-80%);
  transition: opacity .18s ease;
}

.currency-option:hover,
.currency-option.is-active {
  background:
    linear-gradient(90deg, rgba(111, 159, 224, .16), rgba(191, 218, 250, .06)),
    rgba(12, 20, 35, .62);
  color: rgba(243, 248, 255, .96);
  transform: translateX(2px);
}

.currency-option:hover::before,
.currency-option.is-active::before {
  opacity: 1;
  animation: optionSheen 1.3s ease infinite;
}

.currency-option.is-active::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(132, 183, 255, .92);
  box-shadow:
    0 0 10px rgba(132, 183, 255, .66),
    0 0 18px rgba(191, 218, 250, .28);
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-7px) scale(.97); filter: blur(3px); }
}

@keyframes menuFlame {
  0% { transform: translate3d(-4px, 8px, 0) scale(1); }
  50% { transform: translate3d(5px, -2px, 0) scale(1.08); }
  100% { transform: translate3d(-1px, -8px, 0) scale(1.03); }
}

@keyframes optionSheen {
  from { transform: translateX(-95%); }
  to { transform: translateX(95%); }
}

.swap-row {
  gap: 10px;
  margin: 7px 0 9px;
  justify-content: center;
}

.swap-row span {
  display: none;
}

.swap-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(137, 183, 255, .22);
  border-radius: 50%;
  background: rgba(7, 13, 25, .30);
  color: rgba(203, 223, 252, .82);
  cursor: pointer;
  box-shadow: 0 7px 20px rgba(0, 0, 0, .18);
  transition: transform .2s ease, border-color .2s ease, color .2s ease, background .2s ease;
}

.swap-btn:hover,
.swap-btn:focus-visible {
  border-color: rgba(144, 243, 194, .64);
  background: rgba(11, 22, 38, .92);
  color: #fff;
}

.swap-btn:active {
  transform: scale(.92);
}

.swap-btn.is-spinning svg {
  animation: spinSwap .42s cubic-bezier(.2, .8, .2, 1);
}

.swap-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes spinSwap {
  to { transform: rotate(180deg); }
}

.rate-line {
  min-height: 14px;
  margin-top: 8px;
  text-align: center;
  letter-spacing: .08em;
  text-transform: none;
  color: var(--muted);
}

.result-field.is-changing output {
  animation: resultLift .3s ease;
}

@keyframes resultLift {
  0% { opacity: .35; transform: translateY(7px); }
}

.footer {
  width: min(100%, 334px);
  justify-self: center;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  padding-top: 4px;
  font-size: 9px;
  color: rgba(123, 148, 190, .30);
}

.footer-left {
  display: grid;
  gap: 2px;
}

.credit {
  color: rgba(171, 190, 225, .16);
  font-size: 8px;
  letter-spacing: .14em;
  text-transform: lowercase;
}

@media (max-width: 360px) {
  .shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .converter {
    padding: 13px;
  }

  .field-grid,
  .bottom-grid {
    gap: 9px;
  }

  .field-grid {
    grid-template-columns: .9fr 1.1fr;
  }

  .bottom-grid {
    grid-template-columns: .66fr 1.34fr;
  }

  h1 {
    font-size: 31px;
  }

  .converter,
  .footer {
    width: min(100%, 324px);
  }
}

@media (display-mode: standalone) {
  body {
    background: #07090e;
  }

  .poster {
    width: 100%;
    box-shadow: none;
  }
}

@media (min-width: 760px) {
  .poster {
    border: 1px solid rgba(188, 209, 240, .12);
    border-radius: 28px;
    min-height: min(820px, 96vh);
  }

  .shell {
    min-height: min(820px, 96vh);
  }
}

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