:root {
  --green: rgb(0, 255, 0);
  --green-dim: rgba(0, 255, 0, 0.18);
  --green-ink: #0a5c0a;
  --ink: #0d1a0d;
  --muted: #5a6b5a;
  --line: rgba(0, 80, 0, 0.12);
  --white: #ffffff;
  --surface: rgba(255, 255, 255, 0.88);
  --danger: #c62828;
  --radius: 18px;
  --font-display: "Syne", sans-serif;
  --font-ui: "Outfit", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--white);
  overflow-x: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

body.is-loaded {
  opacity: 1;
  transform: none;
}

body.merchant-pulse .merchant-select-wrap {
  animation: pulse-ring 0.55s ease;
}

.preview-ribbon {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: #0d1a0d;
  color: #f4fff4;
  font-size: 0.82rem;
  line-height: 1.35;
}

.preview-ribbon p {
  margin: 0;
}

.preview-ribbon strong {
  color: var(--green);
  font-weight: 800;
}

.preview-dismiss {
  flex-shrink: 0;
  border: 1px solid rgba(0, 255, 0, 0.45);
  background: transparent;
  color: var(--green);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.preview-dismiss:hover {
  background: rgba(0, 255, 0, 0.12);
}

body.is-preview .top {
  padding-top: 16px;
}

body.is-preview .ad-slot::before {
  content: "Ad slot";
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px 2px;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 100% -10%, var(--green-dim), transparent 55%),
    radial-gradient(90% 60% at -10% 100%, rgba(0, 255, 0, 0.12), transparent 50%),
    linear-gradient(180deg, #f7fff7 0%, var(--white) 42%, #f3fff3 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    -18deg,
    transparent,
    transparent 22px,
    rgba(0, 255, 0, 0.03) 22px,
    rgba(0, 255, 0, 0.03) 23px
  );
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 70%);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 20px 8px;
  max-width: 560px;
  margin: 0 auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 10vw, 3.4rem);
  letter-spacing: -0.04em;
  position: relative;
  display: inline-block;
  background: linear-gradient(90deg, var(--green-ink) 0%, var(--ink) 55%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brand-in 0.7s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0.08em;
  width: 100%;
  height: 0.12em;
  background: var(--green);
  border-radius: 999px;
  transform-origin: left;
  animation: underline-grow 0.8s 0.2s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.brand-name {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.35rem;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  background: var(--green);
  border-color: var(--green);
  transform: rotate(28deg);
}

.shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 20px calc(28px + var(--safe-bottom));
}

.merchant-bar {
  margin: 12px 0 28px;
  animation: rise 0.55s 0.1s ease both;
}

.merchant-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.merchant-select-wrap {
  position: relative;
  border-radius: var(--radius);
  background: var(--green);
  padding: 2px;
  box-shadow: 0 10px 30px rgba(0, 180, 0, 0.18);
}

.merchant-select {
  width: 100%;
  appearance: none;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%230d1a0d'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 14px center;
  font-family: var(--font-ui);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 16px 42px 16px 16px;
  color: var(--ink);
  cursor: pointer;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.field-block {
  animation: rise 0.55s ease both;
}

.field-block:nth-child(1) { animation-delay: 0.15s; }
.field-block:nth-child(2) { animation-delay: 0.22s; }
.field-block:nth-child(3) { animation-delay: 0.3s; }

.row {
  display: grid;
  grid-template-columns: 1fr minmax(108px, 34%);
  gap: 10px;
  align-items: stretch;
}

.amount,
.currency {
  font-family: var(--font-ui);
  font-size: clamp(1.35rem, 5vw, 1.7rem);
  font-weight: 700;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 14px 14px;
  min-height: 64px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.amount:focus,
.currency:focus,
.merchant-select:focus,
.settings select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
}

.currency {
  appearance: none;
  font-size: 1rem;
  font-weight: 700;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%230d1a0d'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.change-out {
  display: flex;
  align-items: center;
  border-style: solid;
  border-width: 2px;
  border-color: var(--green);
  background: linear-gradient(180deg, rgba(0, 255, 0, 0.12), var(--white));
  letter-spacing: -0.02em;
}

.change-out.is-ready {
  animation: settle 0.35s ease;
}

.change-out.is-negative {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff5f5;
}

.bilingual {
  margin: 8px 4px 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.status {
  margin: 4px 4px 0;
  min-height: 1.2em;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--danger);
}

/* —— Ad slots (G-rated travel) —— */
.ad-slot {
  margin: 0 0 14px;
  min-height: 56px;
  animation: rise 0.5s 0.05s ease both;
}

.ad-slot-bottom {
  margin: 22px 0 0;
  min-height: 120px;
  animation-delay: 0.35s;
}

.ad-house {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.ad-house:hover {
  border-color: rgba(0, 180, 0, 0.45);
  background: #f4fff4;
}

.ad-badge {
  grid-column: 1 / -1;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ad-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ad-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.25;
}

.ad-sub {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.3;
}

.ad-cta {
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--green);
  color: var(--ink);
}

.ad-banner {
  min-height: 56px;
}

.ad-rect {
  min-height: 110px;
  padding: 14px 14px;
}

.ad-rect .ad-title {
  font-size: 1.05rem;
}

.ad-rect .ad-sub {
  font-size: 0.85rem;
}

.ad-slot .adsbygoogle {
  display: block;
  min-height: 50px;
  overflow: hidden;
  border-radius: 14px;
}

.rate-badge {
  margin: 16px 4px 0;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.rate-badge.is-warn {
  color: #9a6b00;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 24, 8, 0.35);
  opacity: 0;
  transition: opacity 0.22s ease;
  z-index: 40;
}

.backdrop.is-open {
  opacity: 1;
}

.settings {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 24px);
  width: min(100%, 560px);
  max-height: min(88vh, 640px);
  overflow: auto;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 24px 22px calc(22px + var(--safe-bottom));
  z-index: 50;
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  border-top: 4px solid var(--green);
}

.settings.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}

.settings h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0 0 18px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 0.9rem;
}

.settings select {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--white);
}

.muted {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--green);
  color: var(--ink);
}

.btn.ghost {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
}

@keyframes brand-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes underline-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@keyframes settle {
  0% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.55); }
  100% { box-shadow: 0 10px 30px rgba(0, 180, 0, 0.18); }
}

@media (min-width: 720px) {
  .shell {
    padding-top: 12px;
  }

  .settings {
    bottom: auto;
    top: 50%;
    border-radius: 24px;
    transform: translate(-50%, calc(-50% + 16px));
  }

  .settings.is-open {
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 380px) {
  .row {
    grid-template-columns: 1fr;
  }

  .currency {
    min-height: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  body {
    opacity: 1;
    transform: none;
  }
}
