:root {
  --red: #c8102e;
  --red-dark: #8e0b20;
  --gold: #c8972c;
  --ink: #0b0b0d;
  --paper: #f4f1ec;
  --muted: #5c6570;
  --line: rgba(15, 23, 42, 0.12);
  --calc-shadow: 0 24px 60px rgba(11, 11, 13, 0.28);
}
body {
  margin: 0;
  background: #0b0b0d;
  color: #1a1a1a;
  font-family: Georgia, "Times New Roman", Times, serif;
}
.page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(200, 16, 46, 0.35), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(200, 151, 44, 0.18), transparent 50%),
    linear-gradient(180deg, #0b0b0d 0%, #14161a 42%, #1a1c22 100%);
}
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.5rem 1.15rem 3.5rem;
}
.intro {
  color: #f3f4f6;
  margin: 0 auto 1.25rem;
  max-width: 36rem;
  text-align: center;
}
.intro .brand {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 .35rem;
  line-height: 1.15;
}
.intro .brand span { color: var(--gold); }
.intro p {
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .95rem;
  color: #c5cad3;
  line-height: 1.5;
  max-width: 34rem;
}
.calc {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  min-height: 0;
  border-radius: 22px;
  /* Must stay visible so the country dropdown is not clipped */
  overflow: visible;
  box-shadow: var(--calc-shadow);
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--paper);
  /* Never use animation-fill-mode:both with opacity:0 — first paint can stay invisible */
  opacity: 1;
  animation: calc-rise .45s ease;
}
@keyframes calc-rise {
  from { transform: translateY(14px); }
  to { transform: none; }
}
@media (max-width: 820px) {
  .calc { grid-template-columns: 1fr; }
  .scene { min-height: 0; }
}
.scene {
  position: relative;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 22px 0 0 22px;
}
.scene.is-country { background: #12141a; }
.scene-media {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #ffffff;
}
.scene.is-country .scene-media {
  background: #12141a;
  aspect-ratio: 4 / 5;
  min-height: 280px;
}
.scene-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  opacity: 0;
  transition: opacity .55s ease;
  will-change: opacity;
  pointer-events: none;
}
.scene.is-country .scene-bg { background: #12141a; }
.scene-bg.visible { opacity: 1; }
.scene-bg img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}
.scene-bg img.is-cover {
  object-fit: cover;
}
.scene-media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  /* no dark veil over the product artwork */
  background: none;
  pointer-events: none;
}
.scene.is-country .scene-media::after {
  background: linear-gradient(180deg, rgba(11,11,13,.12) 30%, rgba(11,11,13,.72) 100%);
}
.scene-inner {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 1.1rem 1.2rem 1rem;
  color: #fff;
  pointer-events: none;
  text-align: left;
}
/* Product shot already has branding — hide duplicate caption overlay */
.scene:not(.is-country) .scene-inner {
  display: none;
}
.flag-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .45rem;
  min-height: 36px;
}
.flag {
  width: 54px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.35);
  background: #333;
  transition: transform .35s ease, opacity .35s ease;
}
.flag.is-swap { transform: scale(.92); opacity: .4; }
.flag.is-hidden { display: none; }
.scene-country {
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 16px rgba(0,0,0,.45);
}
.scene-meta {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .82rem;
  color: rgba(255,255,255,.82);
  margin-top: .2rem;
}
.panel {
  padding: 1.35rem 1.4rem 1.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  z-index: 5;
  overflow: visible;
  border-radius: 0 22px 22px 0;
  background: var(--paper);
}
.panel h2 {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 1.35rem;
  margin: 0;
  color: var(--ink);
  text-align: center;
}
.packs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .45rem;
}
@media (max-width: 520px) {
  .packs { grid-template-columns: repeat(2, 1fr); }
}
.pack {
  appearance: none;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: .65rem .4rem;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.pack:hover { border-color: rgba(200,16,46,.45); transform: translateY(-1px); }
.pack.active {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200,16,46,.15);
  background: #fff8f8;
}
.pack img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
  margin: 0 auto .25rem;
}
.pack .n { display: block; font-weight: 800; font-size: .92rem; color: var(--ink); }
.pack .w { display: block; font-size: .68rem; color: var(--muted); margin-top: .1rem; }
.fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: .55rem;
}
label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .3rem;
}

/* Custom searchable country field — type in the field itself */
.country-picker { position: relative; }
.country-field {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: .55rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: .55rem .7rem .55rem .75rem;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.country-field:hover { border-color: rgba(200,16,46,.35); }
.country-picker.open .country-field,
.country-field:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200,16,46,.12);
}
.country-field-flag {
  width: 22px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}
.country-field-flag.is-hidden { display: none; }
.country-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink);
  padding: .2rem 0;
}
.country-input::placeholder {
  color: var(--muted);
  font-weight: 500;
}
.country-chevron-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: .2rem;
  cursor: pointer;
  color: var(--ink);
  opacity: .45;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: transform .2s, opacity .15s;
}
.country-picker.open .country-chevron-btn { transform: rotate(180deg); opacity: .85; }
.country-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(11,11,13,.18), 0 0 0 1px rgba(15,23,42,.04);
  padding: .4rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(.98);
  transition: opacity .16s, transform .16s, visibility .16s;
  pointer-events: none;
}
.country-picker.open .country-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.country-list {
  max-height: min(280px, 48vh);
  overflow-y: auto;
  padding: .1rem;
}
.country-option {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .58rem .65rem;
  border: none;
  background: transparent;
  border-radius: 9px;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background .12s;
}
.country-option:hover,
.country-option.is-active {
  background: rgba(200,16,46,.08);
}
.country-option.is-selected {
  background: rgba(200,16,46,.14);
  color: var(--red-dark);
}
.country-option img {
  width: 22px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}
.country-empty {
  padding: .9rem .65rem;
  font-size: .84rem;
  color: var(--muted);
  text-align: center;
}

.dims {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.45;
  min-height: 2.4em;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  justify-content: stretch;
}
.actions .btn-primary {
  flex: 1 1 100%;
  width: 100%;
  justify-content: center;
}
.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: .78rem 1.15rem;
  font: inherit;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  transition: transform .12s, filter .12s;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  color: #fff;
  box-shadow: 0 8px 20px rgba(200,16,46,.28);
}
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.result {
  border-radius: 14px;
  padding: 1rem 1.05rem;
  background: #fff;
  border: 1.5px solid var(--line);
  min-height: 5.5rem;
}
.result .price {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: clamp(1.8rem, 4vw, 2.35rem);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.03em;
  margin: 0;
}
.result .price span { color: var(--red); }
.result .sub {
  margin: .25rem 0 0;
  font-size: .82rem;
  color: var(--muted);
}
.result .err { color: var(--red-dark); font-weight: 600; font-size: .9rem; margin: 0; }
.result.pending .price { opacity: .35; }
.cta-shop {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-top: .65rem;
  color: var(--red-dark);
  font-weight: 700;
  font-size: .86rem;
  text-decoration: none;
}
.cta-shop:hover { text-decoration: underline; }
.note {
  margin-top: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .78rem;
  color: #9ca3af;
  line-height: 1.45;
}

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .wrap {
    padding: 1rem .85rem calc(2.25rem + env(safe-area-inset-bottom, 0px));
  }
  .intro {
    margin: 0 auto .95rem;
    max-width: none;
    text-align: center;
  }
  .intro .brand { font-size: clamp(1.45rem, 7vw, 1.9rem); }
  .intro p { font-size: .88rem; }

  .calc {
    grid-template-columns: 1fr;
    min-height: 0;
    /* allow country dropdown to escape the card */
    overflow: visible;
    border-radius: 18px;
  }
  .panel {
    order: 1;
    padding: 1.15rem 1rem 1.25rem;
    gap: .85rem;
    border-radius: 18px 18px 0 0;
    background: var(--paper);
    overflow: visible;
    z-index: 5;
  }
  .scene {
    order: 2;
    min-height: 0;
    border-radius: 0 0 18px 18px;
    overflow: hidden;
  }
  .scene-media {
    min-height: 0;
    aspect-ratio: 1 / 1;
    max-height: min(420px, 70vw);
  }
  .scene.is-country .scene-media {
    aspect-ratio: 16 / 10;
    max-height: min(280px, 55vw);
  }
  .scene-inner { padding: .9rem 1rem .85rem; }
  .scene-country { font-size: 1.35rem; }

  .panel h2 { font-size: 1.2rem; }
  .packs {
    grid-template-columns: repeat(2, 1fr);
    gap: .5rem;
  }
  .pack {
    min-height: 72px;
    padding: .7rem .45rem;
    -webkit-tap-highlight-color: transparent;
  }
  .pack:hover { transform: none; }
  .pack img { width: 48px; height: 48px; }

  .country-field {
    min-height: 48px;
    padding: .55rem .7rem;
  }
  /* 16px prevents iOS auto-zoom on focus */
  .country-input { font-size: 16px; }

  .country-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    bottom: auto;
    max-height: min(50vh, 320px);
    z-index: 50;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(11,11,13,.22);
    transform: translateY(-6px) scale(.98);
  }
  .country-picker.open .country-menu {
    transform: translateY(0) scale(1);
  }
  .country-list {
    max-height: min(44vh, 280px);
    -webkit-overflow-scrolling: touch;
  }
  .country-option {
    min-height: 44px;
    padding: .7rem .75rem;
    font-size: .95rem;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .actions .btn {
    width: 100%;
    min-height: 48px;
    text-align: center;
    box-sizing: border-box;
  }
  .result { padding: .9rem 1rem; }
  .result .price { font-size: clamp(1.65rem, 8vw, 2.1rem); }
  .cta-shop {
    justify-content: center;
    text-align: center;
    padding: .35rem 0;
    font-size: .9rem;
  }
  .note {
    text-align: center;
    padding: 0 .25rem;
  }
  .dims { font-size: .8rem; }
}

@media (max-width: 380px) {
  .pack .w { font-size: .62rem; }
  .panel { padding: 1rem .85rem 1.1rem; }
  .wrap { padding-left: .7rem; padding-right: .7rem; }
}
