:root {
  --ink: #1f3a2c;
  --muted: #5a7466;
  --line: #d3e8dc;
  --blue: #15a06a;
  --red: #e23b3b;
  --paper: #f4fbf7;
  --gold: #3fd8a0;
  --shadow: 0 22px 50px rgba(6, 40, 26, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(40, 198, 175, 0.24), transparent 60%),
    linear-gradient(180deg, #0b2a1f 0%, #12503a 42%, #082017 100%);
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 auto;
  justify-content: flex-start;
  padding: 28px 16px 16px;
}

.slip {
  position: relative;
  width: min(440px, 100%);
  padding: 32px 26px 40px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, var(--paper) 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.slip-pattern {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='42' viewBox='0 0 72 42'%3E%3Cpath d='M18 21c6 0 6-10 12-10s6 10 12 10 6-10 12-10 6 10 12 10M6 21c-6 0-6-10-12-10M18 21c-6 0-6 10-12 10s-6-10-12-10M54 21c6 0 6 10 12 10s6-10 12-10' fill='none' stroke='%23bfe3cf' stroke-width='1.4'/%3E%3C/svg%3E");
  background-size: 72px 42px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 92%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 92%);
}

.slip > *:not(.slip-pattern) {
  position: relative;
  z-index: 1;
}

.slip-brand {
  display: flex;
  justify-content: center;
  margin: 6px 0 8px;
}

.slip-brand img {
  width: min(300px, 92%);
  height: auto;
  display: block;
}

.slip-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 2px;
  color: var(--blue);
}

.slip-status h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.shield {
  color: #2f9e4f;
  display: inline-flex;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.8));
}

.shield-flip {
  transform: scaleX(-1);
}

.slip-date {
  margin: 2px 0 14px;
  text-align: center;
  color: #3a5546;
  font-size: 14px;
  font-weight: 500;
}

.slip-rows {
  margin: 0;
}

.slip-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 18px 2px;
  border-top: 1px solid var(--line);
}

.slip-row dt {
  margin: 0;
  color: #2b4a3a;
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
}

.slip-row dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.slip-row dd.points {
  color: var(--red);
  font-weight: 800;
}

.slip-wish {
  margin: 26px 0 22px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
}

.field {
  border-radius: 6px;
  outline: none;
  cursor: text;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.slip:not(.is-locked) .field {
  box-shadow: inset 0 0 0 1px transparent;
  background: rgba(21, 160, 106, 0.06);
  border-bottom: 1px dashed rgba(21, 160, 106, 0.55);
  padding: 2px 6px;
  margin: -2px -6px;
}

.slip:not(.is-locked) .slip-wish.field {
  margin: 24px -6px 20px;
}

.slip:not(.is-locked) .field:hover {
  background: rgba(21, 160, 106, 0.1);
}

.slip:not(.is-locked) .field:focus {
  background: #fff;
  box-shadow: 0 0 0 2px #3fd8a0;
  border-bottom-color: transparent;
}

.field:empty::before {
  content: attr(data-placeholder);
  color: #9fb3a8;
  font-weight: 500;
}

.slip.is-locked .field {
  cursor: default;
}

.slip.is-locked .field:empty::before {
  content: "—";
}

.field.is-missing {
  box-shadow: 0 0 0 2px var(--red) !important;
}

.slip-sent {
  margin: -8px 0 12px;
  min-height: 1.3em;
  text-align: center;
  color: #12894f;
  font-weight: 800;
  font-size: 15px;
}

.slip-sent.is-error {
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
}

.slip-close {
  display: block;
  width: min(230px, 78%);
  margin: 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  color: #fff;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.12em;
  cursor: pointer;
  background: linear-gradient(180deg, #3fd89a 0%, #18a866 55%, #12894f 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 8px 16px rgba(18, 137, 79, 0.38);
}

.slip-close:hover {
  filter: brightness(1.05);
}

.slip-close:focus-visible {
  outline: 3px solid #3fd8a0;
  outline-offset: 2px;
}

.slip-close:active {
  transform: translateY(1px);
}

.slip.is-updating {
  animation: slip-pop 280ms ease;
}

@keyframes slip-pop {
  from {
    transform: translateY(6px);
  }
  to {
    transform: none;
  }
}

@media (max-width: 640px) {
  .stage {
    padding: 16px 12px 8px;
  }

  .slip-status h1 {
    font-size: 17px;
  }

  .slip-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .slip-row dd {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slip.is-updating {
    animation: none;
  }
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(900px 400px at 50% -10%, rgba(40, 198, 175, 0.24), transparent 60%),
    linear-gradient(180deg, #0b2a1f 0%, #12503a 50%, #082017 100%);
}

html.unlocked .gate {
  display: none;
}

html:not(.unlocked) body {
  overflow: hidden;
}

.gate-box {
  width: min(340px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 22px 24px;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-logo {
  width: 170px;
  height: auto;
  margin: 0 auto 4px;
}

.gate-box h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.1em;
  color: var(--blue);
}

.gate-box input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
}

.gate-box input:focus-visible,
.gate-btn:focus-visible {
  outline: 3px solid #3fd8a0;
  outline-offset: 2px;
}

.gate-error {
  margin: -4px 0 0;
  min-height: 1.2em;
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
}

.gate-btn {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  color: #fff;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.12em;
  cursor: pointer;
  background: linear-gradient(180deg, #3fd89a 0%, #18a866 55%, #12894f 100%);
}

.icon-fail {
  display: none;
}

.slip.is-failed .icon-ok {
  display: none;
}

.slip.is-failed .icon-fail {
  display: inline;
}

.slip.is-failed .slip-status,
.slip.is-failed .shield {
  color: var(--red);
}

.fail-toggle {
  display: flex;
  justify-content: flex-end;
  width: min(440px, 100%);
  padding: 8px 6px 0;
  opacity: 0.35;
  transition: opacity 0.15s;
}

.fail-toggle:hover,
.fail-toggle:focus-within {
  opacity: 0.9;
}

.fail-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--red);
}
