/* Worek na monety — ciemny teal, złoto i pocztówki lotnicze */

:root {
  color-scheme: dark;
  --bg: #0b2430;
  --panel: #12384a;
  --panel-edge: rgba(255, 255, 255, 0.1);
  --paper: #f6f1e4;
  --ink: #1c2433;
  --muted: rgba(255, 255, 255, 0.72);
  --air-red: #e0483e;
  --air-blue: #2f6fd0;

  --btn-top: #ffe27a;
  --btn-bottom: #f5b82e;
  --btn-edge: #b97d0d;
  --btn-ink: #3b2600;

  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: clamp(1.25rem, 4vw, 3rem) 1.25rem 3rem;
  color: #fff;
  background:
    radial-gradient(50rem 28rem at 50% 0%, rgba(255, 210, 63, 0.14), transparent 70%),
    var(--bg);
}

.wrap {
  width: min(52rem, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ---------- Nagłówek ---------- */

.top { text-align: center; }

.top h1 {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.top p {
  max-width: 30rem;
  margin: 0.8rem auto 0;
  font-size: clamp(1rem, 2.6vw, 1.15rem);
  line-height: 1.45;
  color: var(--muted);
}

/* ---------- Scena: worek + przycisk + maskotka ---------- */

.stage {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 1rem 2rem;
  padding: 2rem 2.5rem;
  border: 1px solid var(--panel-edge);
  border-radius: 2rem;
  background:
    radial-gradient(18rem 18rem at 24% 50%, rgba(255, 210, 63, 0.22), transparent 70%),
    linear-gradient(160deg, #164559, var(--panel) 60%);
  box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.35);
}

.bag {
  width: min(100%, 19rem);
  height: auto;
  justify-self: center;
  filter: drop-shadow(0 1.2rem 1rem rgba(0, 0, 0, 0.4));
}

.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* ---------- Przycisk ---------- */

button {
  min-width: min(100%, 15rem);
  padding: 1.1rem 2.2rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(var(--btn-top), var(--btn-bottom));
  color: var(--btn-ink);
  box-shadow:
    inset 0 0.15rem 0 rgba(255, 255, 255, 0.55),
    0 0.45rem 0 var(--btn-edge),
    0 1.2rem 1.6rem rgba(0, 0, 0, 0.35);
  cursor: pointer;
  font: inherit;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 160ms ease;
}

#thing-state {
  display: block;
  font-size: clamp(1.25rem, 4.5vw, 1.6rem);
  font-weight: 850;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

button:hover:not(:disabled) { filter: brightness(1.06); }

button:active:not(:disabled) {
  transform: translateY(0.35rem);
  box-shadow:
    inset 0 0.15rem 0 rgba(255, 255, 255, 0.55),
    0 0.1rem 0 var(--btn-edge),
    0 0.4rem 0.8rem rgba(0, 0, 0, 0.35);
}

button:focus-visible {
  outline: 0.25rem solid #fff;
  outline-offset: 0.3rem;
}

button:disabled { cursor: progress; }

/* stany przycisku */

button[data-state="success-pair"],
button[data-state="success-exchange"] {
  --btn-top: #b6f2cf;
  --btn-bottom: #4fd08a;
  --btn-edge: #25975c;
  --btn-ink: #06301b;
}

button[data-state="failure"] {
  --btn-top: #ffc2c2;
  --btn-bottom: #ff6b6b;
  --btn-edge: #c63c48;
  --btn-ink: #3d0a10;
}

button[data-state="unsupported"] {
  --btn-top: #6c7388;
  --btn-bottom: #4a5062;
  --btn-edge: #2e3340;
  --btn-ink: rgba(255, 255, 255, 0.8);
  cursor: not-allowed;
}

/* ---------- Opis stanu ---------- */

.detail {
  max-width: 22rem;
  min-height: 2.9rem;
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.45;
  text-align: center;
  color: var(--muted);
  overflow-wrap: anywhere;
}

button[data-state="failure"] + .detail { color: #ffb3b3; }

button[data-state="success-pair"] + .detail,
button[data-state="success-exchange"] + .detail { color: #b6f2cf; }

/* ---------- Maskotka nad przyciskiem ---------- */

.mascot {
  order: -1;
  position: relative;
  width: 100%;
  height: 10.5rem;
}

.mascot img {
  position: absolute;
  bottom: -0.2rem;
  left: 50%;
  height: auto;
  translate: -50% 0;
  filter: drop-shadow(0 0.6rem 0.6rem rgba(0, 0, 0, 0.35));
}

.m-idle { width: 10rem; }

.m-win {
  display: none;
  width: 4.9rem;
  height: auto;
}

button:is([data-state="success-pair"], [data-state="success-exchange"]) ~ .mascot .m-idle { display: none; }
button:is([data-state="success-pair"], [data-state="success-exchange"]) ~ .mascot .m-win {
  display: block;
  width: auto;
  height: 10.7rem;
  animation: pop-in 520ms cubic-bezier(0.3, 1.6, 0.5, 1);
}

button[data-state="unsupported"] ~ .mascot .m-idle,
button[data-state="failure"] ~ .mascot .m-idle {
  filter: grayscale(0.7) drop-shadow(0 0.6rem 0.6rem rgba(0, 0, 0, 0.35));
}

button:is([data-state="requesting-device"], [data-state="connecting"], [data-state="reading-device"], [data-state="pairing"], [data-state="exchanging"]) ~ .mascot .m-idle {
  animation: hop 700ms ease-in-out infinite;
}

@keyframes hop {
  50% { transform: translateY(-0.9rem); }
}

@keyframes pop-in {
  from { transform: scale(0.5) translateY(1rem); opacity: 0; }
}

/* ---------- Instrukcje: pocztówki ---------- */

.instructions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.step {
  position: relative;
  padding: 2.1rem 1.4rem 1.4rem;
  border-radius: 0.3rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.3);
}

.step::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 0.6rem;
  border-radius: 0.3rem 0.3rem 0 0;
  background: repeating-linear-gradient(
    135deg,
    var(--air-red) 0 0.9rem,
    var(--paper) 0.9rem 1.4rem,
    var(--air-blue) 1.4rem 2.3rem,
    var(--paper) 2.3rem 2.8rem
  );
}

.step:nth-of-type(1) { transform: rotate(-0.5deg); }
.step:nth-of-type(2) { transform: rotate(0.5deg); }

.step h2 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
  font-weight: 800;
}

.step p {
  margin: 0.45rem 0 0;
  font-size: 0.95rem;
  line-height: 1.55;
}

.step p + p {
  padding-top: 0.55rem;
  border-top: 1px dashed rgba(28, 36, 51, 0.3);
  font-weight: 650;
}

.note {
  grid-column: 1 / -1;
  max-width: 38rem;
  margin: 0.25rem auto 0;
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

/* ---------- Telefon ---------- */

@media (max-width: 42rem) {
  .stage {
    grid-template-columns: 1fr;
    padding: 1.5rem 1.25rem 1.75rem;
    gap: 0.5rem;
  }

  .bag { width: min(70%, 14rem); }
  .instructions { grid-template-columns: 1fr; }
  .step:nth-of-type(1), .step:nth-of-type(2) { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mascot img, button { animation: none !important; transition: none; }
}
