:root {
  --ink: #342426;
  --forest: #7b3038;
  --forest-dark: #481b21;
  --forest-light: #96505a;
  --canvas: #f1e8cf;
  --canvas-dark: #d8c69d;
  --paper: #fffaf0;
  --leather: #6e4028;
  --rust: #b94b2f;
  --gold: #d8a83e;
  --muted: #756366;
  --border: 4px solid var(--leather);
  --shadow: 8px 9px 0 rgba(57, 18, 24, 0.5);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--forest-dark);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  background: var(--forest);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.star-field {
  display: none;
}

.star-field::before,
.star-field::after {
  content: none;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(100% - 32px, 1040px);
  margin: 0 auto;
  padding: 48px 0 70px;
}

.welcome-shell {
  width: min(100% - 32px, 700px);
}

.site-header {
  margin-bottom: 34px;
  color: var(--canvas);
  text-align: center;
}

.brand-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 3vw, 24px);
}

.organization-logo {
  width: clamp(68px, 14vw, 100px);
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(3px 4px 0 rgba(64, 23, 29, 0.75));
}

.eyebrow {
  margin: 0 0 8px;
  color: inherit;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.logo {
  margin: 0;
  color: #ad3c20;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.2rem, 10vw, 6rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.07em;
  text-shadow: 3px 4px 0 #40171d;
}

.logo span,
.mini-logo strong {
  color: #e8dfc7;
}

.tagline {
  max-width: 520px;
  margin: 20px auto 0;
  color: #e8dfc7;
  font-size: 1.02rem;
  line-height: 1.6;
}

.panel {
  position: relative;
  border: var(--border);
  border-radius: 12px;
  background-color: var(--canvas);
  background-image:
    linear-gradient(90deg, rgba(109, 64, 40, 0.035) 50%, transparent 50%),
    linear-gradient(rgba(109, 64, 40, 0.025) 50%, transparent 50%);
  background-size: 5px 5px;
  box-shadow: var(--shadow);
}

.panel::after {
  position: absolute;
  inset: 8px;
  border: 2px dashed rgba(110, 64, 40, 0.42);
  border-radius: 7px;
  content: "";
  pointer-events: none;
}

.token-entry {
  padding: clamp(30px, 7vw, 54px);
}

.panel-pin {
  z-index: 2;
  position: absolute;
  top: -14px;
  width: 25px;
  height: 25px;
  border: 3px solid #704c20;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1a4, var(--gold) 48%, #8e631c);
  box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.35);
}

.pin-left {
  left: 45px;
}

.pin-right {
  right: 45px;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

.token-entry h2,
.badge-heading h2,
.error-panel h1 {
  margin: 0;
  color: var(--forest-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  letter-spacing: -0.03em;
}

.token-entry > p,
.editor-header > p:last-child {
  color: var(--muted);
  line-height: 1.55;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--forest-dark);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

textarea,
input {
  width: 100%;
  border: 2px solid var(--leather);
  border-radius: 5px;
  outline: none;
  color: var(--ink);
  background: var(--paper);
  box-shadow: inset 0 0 0 3px rgba(216, 198, 157, 0.45);
  transition: box-shadow 120ms ease, transform 120ms ease;
}

textarea {
  min-height: 104px;
  padding: 14px;
  resize: vertical;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 24px;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    transparent 0 23px,
    rgba(95, 72, 76, 0.13) 23px 24px
  );
  background-position: 0 14px;
  background-attachment: local;
}

input {
  height: 50px;
  padding: 0 14px;
  font-size: 1rem;
}

textarea:focus,
input:focus {
  box-shadow: inset 0 0 0 3px #e5c66c, 3px 3px 0 rgba(110, 64, 40, 0.3);
  transform: translate(-1px, -1px);
}

.form-message {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--forest);
  font-size: 0.85rem;
  font-weight: 700;
}

.error-message {
  color: #a22f24;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  border: 3px solid var(--forest-dark);
  border-radius: 5px;
  color: #fff8df;
  background: var(--forest);
  box-shadow: 4px 4px 0 var(--leather);
  font-weight: 900;
  letter-spacing: 0.025em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 100ms ease, box-shadow 100ms ease, background 100ms ease;
}

.primary-button:hover {
  background: var(--forest-dark);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--leather);
}

.primary-button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--leather);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 15px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.divider::before,
.divider::after {
  height: 2px;
  flex: 1;
  background: repeating-linear-gradient(90deg, var(--leather) 0 6px, transparent 6px 11px);
  content: "";
  opacity: 0.45;
}

.text-button,
.copy-button {
  border: 0;
  color: var(--forest);
  background: transparent;
  font-weight: 900;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 4px;
  cursor: pointer;
}

.text-button {
  display: block;
  margin: auto;
}

.visitor-counter {
  margin: 30px 0 0;
  color: #ded4b8;
  font-family: "Courier New", monospace;
  font-size: 0.72rem;
  text-align: center;
}

.visitor-counter span {
  padding: 4px 7px;
  border: 1px solid #bcae85;
  color: #f3d477;
  background: #45181f;
  letter-spacing: 0.15em;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.mini-logo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #fff8df;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.06em;
  text-decoration: none;
  text-shadow: 2px 2px 0 #40171d;
}

.mini-organization-logo {
  width: 46px;
  height: 46px;
  filter: drop-shadow(2px 2px 0 rgba(64, 23, 29, 0.75));
}

.mini-logo-text {
  color: inherit;
}

.mini-logo strong {
  font-weight: inherit;
}

.back-link {
  color: #eee5ce;
  font-size: 0.88rem;
  font-weight: 700;
  text-underline-offset: 4px;
}

.editor-panel {
  padding: clamp(28px, 5vw, 56px);
}

.editor-header {
  max-width: 680px;
}

.editor-header .eyebrow,
.badge-heading .eyebrow {
  color: var(--rust);
}

.editor-header h1 {
  margin: 0;
  color: var(--forest-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 8vw, 5rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.editor-header h1 span {
  color: var(--rust);
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 5px;
  text-underline-offset: 7px;
}

.editor-fields {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(300px, 1.5fr);
  gap: 24px;
  margin: 38px 0 48px;
  padding: 25px;
  border: 2px dashed var(--leather);
  border-radius: 8px;
  background: rgba(255, 250, 232, 0.52);
}

.field-group {
  min-width: 0;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.copy-button {
  padding: 0;
  font-size: 0.78rem;
}

.copy-actions {
  display: flex;
  gap: 14px;
}

.badge-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.badge-heading > p {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 13px;
  border: 2px solid var(--leather);
  border-radius: 4px;
  color: #fff8df;
  background: var(--forest);
  box-shadow: 2px 2px 0 var(--leather);
  font-size: 0.82rem;
  font-weight: 900;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px 12px;
  padding: 28px 18px;
  border: 3px solid var(--leather);
  border-radius: 8px;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.05), transparent 40%),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.025) 0 2px,
      transparent 2px 5px
    ),
    #713b44;
  box-shadow: inset 0 0 0 5px #bba878, inset 0 0 0 7px var(--leather);
}

.badge {
  position: relative;
  min-width: 0;
  min-height: 190px;
  padding: 10px 5px;
  border: 0;
  color: #fff8df;
  background: transparent;
  text-align: center;
  cursor: pointer;
  transition: filter 160ms ease, opacity 160ms ease, transform 120ms ease;
}

.badge:hover {
  transform: translateY(-3px) rotate(-1deg);
}

.badge:focus-visible {
  border-radius: 8px;
  outline: 4px solid var(--gold);
  outline-offset: 2px;
}

.badge[aria-pressed="false"] {
  filter: grayscale(1);
  opacity: 0.38;
}

.badge[aria-pressed="false"]:hover {
  opacity: 0.62;
}

.badge-icon {
  position: relative;
  display: grid;
  width: 112px;
  height: 112px;
  margin: 0 auto 12px;
  place-items: center;
  border: 6px solid #eee2bd;
  border-radius: 50%;
  color: var(--ink);
  background: var(--badge-color);
  box-shadow:
    0 0 0 3px var(--leather),
    0 5px 7px rgba(57, 18, 24, 0.45);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.35);
}

.badge-icon::after {
  position: absolute;
  inset: 5px;
  border: 2px dashed rgba(59, 42, 28, 0.58);
  border-radius: 50%;
  content: "";
}

.badge:nth-child(3n + 2) .badge-icon {
  border-radius: 16% 16% 45% 45%;
  transform: rotate(2deg);
}

.badge:nth-child(3n + 2) .badge-icon::after {
  border-radius: 13% 13% 43% 43%;
}

.badge:nth-child(3n) .badge-icon {
  border-radius: 10px;
  transform: rotate(-2deg);
}

.badge:nth-child(3n) .badge-icon::after {
  border-radius: 5px;
}

.badge-name {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.15;
  text-shadow: 1px 2px 0 #481b21;
}

.badge-description {
  display: block;
  max-width: 180px;
  margin: 7px auto 0;
  color: #f0e8d2;
  font-size: 0.72rem;
  line-height: 1.35;
}

.badge-id {
  display: block;
  margin-top: 6px;
  color: #d8ceb3;
  font-family: "Courier New", monospace;
  font-size: 0.62rem;
}

.error-panel {
  max-width: 620px;
  margin: 70px auto 0;
  padding: 48px;
  text-align: center;
}

.error-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.error-icon {
  display: grid;
  width: 78px;
  height: 78px;
  margin: 0 auto 22px;
  place-items: center;
  border: 5px solid #f1e8cf;
  border-radius: 50%;
  color: #fff8df;
  background: var(--rust);
  box-shadow: 0 0 0 3px var(--leather);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.5rem;
  font-weight: 900;
}

.error-panel .primary-button {
  width: auto;
  padding: 0 28px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .page-shell {
    padding-top: 28px;
  }

  .editor-fields {
    grid-template-columns: 1fr;
  }

  .badge-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .badge-grid {
    grid-template-columns: 1fr;
  }

  .badge {
    min-height: 175px;
  }

  .badge-heading {
    align-items: start;
    flex-direction: column;
  }

  .top-nav {
    align-items: start;
    flex-direction: column;
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
