:root {
  color-scheme: dark;
  --night: #050f1d;
  --night-2: #06192e;
  --panel: rgba(12, 39, 66, .62);
  --panel-solid: #0c2742;
  --panel-2: #11304f;
  --line: rgba(246, 243, 236, .12);
  --line-2: rgba(246, 243, 236, .22);
  --cream: #f6f3ec;
  --cream-2: rgba(246, 243, 236, .76);
  --cream-3: rgba(246, 243, 236, .52);
  --lime: #a7c507;
  --lime-2: #c6e324;
  --lime-soft: rgba(167, 197, 7, .14);
  --gold: #d9b56a;
  --cyan: #00ace9;
  --navy: #0065a9;
  --danger: #ef7b6c;
  --f-display: "Fraunces", "Iowan Old Style", "Times New Roman", serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-label: "Outfit", "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--night);
  color: var(--cream);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: var(--f-display);
  font-weight: 420;
  font-variation-settings: "opsz" 144;
  letter-spacing: -.02em;
  margin: 0;
  text-wrap: balance;
}
em { font-style: italic; font-weight: 330; color: var(--lime); }
p { margin: 0; }

/* ---------- ambient background (aurora + grain) ---------- */
.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--night); }
.ambient::before, .ambient::after {
  content: "";
  position: absolute;
  width: 70vmax; height: 70vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .55;
  animation: drift 26s ease-in-out infinite alternate;
}
.ambient::before { background: radial-gradient(circle, rgba(0, 101, 169, .55), transparent 65%); top: -30vmax; right: -20vmax; }
.ambient::after { background: radial-gradient(circle, rgba(167, 197, 7, .22), transparent 65%); bottom: -35vmax; left: -25vmax; animation-delay: -13s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-6vmax, 4vmax) scale(1.08); }
  100% { transform: translate(4vmax, -3vmax) scale(.96); }
}
.grain {
  position: fixed; inset: -50%; z-index: 90; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

/* ---------- typography helpers ---------- */
.eyebrow {
  font-family: var(--f-label);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--lime);
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before { content: ""; width: 24px; height: 1.5px; background: linear-gradient(90deg, transparent, var(--lime)); }
.label {
  font-family: var(--f-label);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--cream-3);
}
.muted { color: var(--cream-3); }

/* word reveal */
.w { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: .08em; margin-bottom: -.08em; }
.w > span { display: inline-block; animation: wordIn 1s var(--ease) both; }
@keyframes wordIn {
  from { transform: translateY(105%) rotate(4deg); opacity: 0; filter: blur(8px); }
  to { transform: none; opacity: 1; filter: none; }
}

/* ---------- avatar ---------- */
.av {
  --s: 48px;
  position: relative;
  width: var(--s);
  height: var(--s);
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: inline-block;
  background: var(--panel-solid);
  box-shadow: 0 0 0 1.5px rgba(246, 243, 236, .22), 0 8px 22px rgba(0, 0, 0, .35);
  user-select: none;
}
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.ring { box-shadow: 0 0 0 2px var(--night), 0 0 0 4px var(--lime), 0 0 30px rgba(167, 197, 7, .45); }
.av.pop { animation: pop .8s var(--spring) both; }
@keyframes pop {
  from { transform: scale(.2) translateY(20px); opacity: 0; filter: blur(6px); }
  to { transform: none; opacity: 1; filter: none; }
}

/* ---------- buttons ---------- */
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 17px 28px;
  font-family: var(--f-label);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .04em;
  background: linear-gradient(180deg, var(--lime-2), var(--lime));
  color: #0a1a05;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .45) inset, 0 14px 34px rgba(167, 197, 7, .32);
  transition: transform .25s var(--ease), box-shadow .25s, opacity .2s;
}
.btn::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .55) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: sheen 3.6s var(--ease) infinite;
}
@keyframes sheen { 0%, 55% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.btn:hover { box-shadow: 0 1px 0 rgba(255, 255, 255, .45) inset, 0 18px 44px rgba(167, 197, 7, .45); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn:disabled::after { display: none; }
.btn.ghost {
  background: rgba(12, 39, 66, .55);
  color: var(--cream-2);
  border: 1px solid var(--line);
  box-shadow: none;
  backdrop-filter: blur(12px);
}
.btn.ghost::after { display: none; }
.btn.ghost:hover { color: var(--cream); border-color: rgba(167, 197, 7, .6); }
.btn:focus-visible, .opt:focus-visible, .pick:focus-visible, .link:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}
.link {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--cream-3);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- glass ---------- */
.glass {
  background: linear-gradient(180deg, rgba(17, 48, 79, .55), rgba(8, 28, 50, .55));
  border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

/* ---------- partner lockup ---------- */
.partners { display: flex; align-items: center; gap: 14px; }
.partners .mw {
  width: 52px; height: 52px; border-radius: 50%; overflow: hidden; flex: none;
  box-shadow: 0 0 0 1.5px rgba(217, 181, 106, .55), 0 8px 24px rgba(0, 0, 0, .45);
}
.partners .mw img { width: 100%; height: 100%; object-fit: cover; }
.partners .bo {
  height: 52px; padding: 0 16px; border-radius: 14px; background: #fbfaf6; display: flex; align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.partners .bo img { height: 30px; width: auto; }
.partners .x { font-family: var(--f-display); font-style: italic; font-size: 20px; color: var(--cream-3); }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.input {
  width: 100%;
  background: rgba(8, 28, 50, .65);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 17px;
  font-size: 17px;
  color: var(--cream);
  outline: none;
  transition: border-color .25s, background .25s, box-shadow .25s;
  backdrop-filter: blur(10px);
}
.input::placeholder { color: rgba(246, 243, 236, .32); }
.input:focus { border-color: var(--lime); background: rgba(8, 28, 50, .9); box-shadow: 0 0 0 4px rgba(167, 197, 7, .12); }
textarea.input { resize: none; min-height: 100px; line-height: 1.45; }

/* ---------- option cards ---------- */
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 42px 1fr 24px;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 15px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 48, 79, .6), rgba(8, 28, 50, .6));
  color: var(--cream);
  font-size: 17px;
  line-height: 1.35;
  backdrop-filter: blur(10px);
  transition: border-color .3s, background .3s, transform .3s var(--ease), box-shadow .3s;
  animation: optIn .7s var(--ease) both;
}
@keyframes optIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.opt:active { transform: scale(.975); }
.opt .k {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 22px;
  color: var(--lime);
  background: var(--lime-soft);
  border: 1px solid rgba(167, 197, 7, .25);
  transition: background .3s, color .3s, transform .4s var(--spring);
}
.opt .tick { width: 24px; height: 24px; color: var(--lime); }
.opt .tick path { stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .5s var(--ease) .1s; }
.opt.on {
  border-color: rgba(167, 197, 7, .8);
  background: linear-gradient(100deg, rgba(167, 197, 7, .24), rgba(167, 197, 7, .06));
  box-shadow: 0 0 0 1px rgba(167, 197, 7, .4), 0 14px 40px rgba(167, 197, 7, .16);
}
.opt.on .k { background: var(--lime); color: var(--night); transform: rotate(-8deg) scale(1.06); }
.opt.on .tick path { stroke-dashoffset: 0; }
.opt.custom { border-style: dashed; }
.opt.custom.on { border-style: solid; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(198, 227, 36, .45), transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple .8s var(--ease) forwards;
}
@keyframes ripple { to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

/* ---------- result bars ---------- */
.bars { display: flex; flex-direction: column; gap: 16px; }
.bar .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.bar .row span { font-size: 15px; color: var(--cream-2); line-height: 1.3; }
.bar .row b { font-family: var(--f-display); font-weight: 400; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.bar .track { height: 10px; background: rgba(246, 243, 236, .07); border-radius: 999px; overflow: hidden; }
.bar .fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--navy), var(--cyan) 55%, var(--lime));
  transition: width 1.6s var(--ease);
  opacity: .6;
}
.bar.top .fill { opacity: 1; box-shadow: 0 0 18px rgba(167, 197, 7, .5); }
.bar.top .row span { color: var(--cream); font-weight: 600; }
.bar.mine .row span::after { content: "  · Twój wybór"; color: var(--lime); font-weight: 500; }

.dot-live {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--lime);
  animation: live 1.8s infinite;
}
@keyframes live {
  0% { box-shadow: 0 0 0 0 rgba(167, 197, 7, .55); }
  70% { box-shadow: 0 0 0 12px rgba(167, 197, 7, 0); }
  100% { box-shadow: 0 0 0 0 rgba(167, 197, 7, 0); }
}

.fade-in { animation: fadeUp .8s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.screen-in { animation: screenIn .9s var(--ease) both; }
@keyframes screenIn { from { opacity: 0; transform: scale(.985); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  padding: 13px 18px;
  border-radius: 14px;
  font-size: 15px;
  z-index: 85;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
  max-width: calc(100vw - 32px);
  animation: toastIn .5s var(--spring) both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px) scale(.9); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.err { border-color: rgba(239, 123, 108, .6); }

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