:root {
  --bg: #07080b;
  --ink: #e9e2cf;
  --dim: #7d776a;
  --gold: #d9ad5b;
  --red: #c4453a;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#screen {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--dim);
  text-align: center;
  margin: 0;
}

.glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(217, 173, 91, 0.1) 0%, rgba(7, 8, 11, 0) 50%);
  pointer-events: none;
}

.grain {
  position: absolute;
  inset: -50%;
  opacity: 0.06;
  pointer-events: none;
  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='0.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 0.8s steps(4) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-2%, -1%); }
  100% { transform: translate(0, 0); }
}

.stage {
  position: relative;
  z-index: 0;
  width: min(78vw, 360px);
  height: min(78vw, 360px);
}

#coin {
  position: fixed;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.dial {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 165%;
  height: 165%;
  transform: translate(-50%, -50%);
  color: var(--gold);
  opacity: 0.09;
  pointer-events: none;
}

.dial-a,
.dial-b {
  transform-origin: 350px 350px;
}

.dial-a {
  animation: spin 240s linear infinite;
}

.dial-b {
  animation: spin 150s linear infinite reverse;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Luce morbida dall'alto, senza contorni: tre bagliori sovrapposti che respirano a ritmi diversi. */
.beam {
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(70% 60% at 50% -8%, rgba(255, 228, 170, 0.09) 0%, rgba(255, 228, 170, 0.03) 45%, rgba(255, 228, 170, 0) 75%),
    radial-gradient(32% 50% at 50% -4%, rgba(255, 240, 210, 0.07) 0%, rgba(255, 240, 210, 0) 70%);
  animation: breathe 7s ease-in-out infinite;
}

.beam::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(45% 38% at 50% 44%, rgba(217, 173, 91, 0.06) 0%, rgba(217, 173, 91, 0) 70%);
  animation: breathe 11s ease-in-out infinite reverse;
}

@keyframes breathe {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.dust {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.lines {
  position: relative;
  z-index: 2;
  margin-top: 28px;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.headline {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.3em;
  color: var(--ink);
  margin: 0;
}

.headline.granted {
  color: var(--gold);
}

.headline.denied {
  color: var(--red);
}

.hint {
  margin-top: 18px;
  color: var(--gold);
  opacity: 0;
}

.hint.visible {
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}

.footer {
  position: absolute;
  z-index: 2;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
}

.grain {
  z-index: 3;
}

#screen.leaving .lines,
#screen.leaving .footer,
#screen.leaving .dial {
  transition: opacity 0.5s ease;
  opacity: 0;
}

/* ---------- Dossier di arruolamento ---------- */

.dossier {
  position: absolute;
  z-index: 2;
  top: max(12vh, 64px);
  left: 50%;
  transform: translateX(-50%);
  width: min(100% - 40px, 420px);
}

.form-id {
  text-align: left;
  font-size: 10px;
  margin-bottom: 28px;
}

.field-title {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--ink);
  margin: 0 0 10px;
  min-height: 26px;
}

.field-help {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--dim);
  margin: 0 0 26px;
}

.field-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(217, 173, 91, 0.35);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.08em;
  padding: 10px 0;
  caret-color: var(--gold);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color 0.2s ease;
}

.field-input:focus {
  border-bottom-color: var(--gold);
}

.field-input.address {
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  word-break: break-all;
}

.field-error {
  min-height: 20px;
  margin: 12px 0 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.4;
  color: var(--red);
}

.options {
  display: grid;
  gap: 8px;
}

.option {
  text-align: left;
  padding: 14px;
  border: 1px solid rgba(233, 226, 207, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.option.selected {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(217, 173, 91, 0.08);
}

.review dt,
.card-fields dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--dim);
}

.review dd {
  margin: 4px 0 18px;
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--ink);
  word-break: break-all;
}

/* ---------- Tesserino ---------- */

.card {
  position: relative;
  z-index: 2;
  width: min(88vw, 380px);
  padding: 18px 18px 78px;
  border: 1px solid rgba(217, 173, 91, 0.35);
  border-radius: 14px;
  background: linear-gradient(160deg, #16171c 0%, #0d0e12 100%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: card-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

.card.shake {
  animation: card-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both, shake 0.22s ease-out;
}

@keyframes shake {
  0% { transform: translate(0, 0); }
  30% { transform: translate(0, 3px); }
  60% { transform: translate(0, -1px); }
  100% { transform: translate(0, 0); }
}

.card-head {
  display: flex;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(233, 226, 207, 0.1);
}

.card-head .mono {
  font-size: 9px;
}

.card-body {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 16px;
  align-items: start;
}

.card-seal {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(217, 173, 91, 0.4);
}

.card-fields {
  margin: 0;
}

.card-fields dd {
  margin: 3px 0 12px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.card-fields dd.card-codename {
  font-size: 19px;
  color: var(--gold);
  letter-spacing: 0.12em;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.2em;
}

.badge.unverified {
  border: 1px solid rgba(233, 226, 207, 0.22);
  color: var(--dim);
}

.badge.verified {
  border: 1px solid var(--gold);
  color: var(--gold);
}

.stamp {
  position: absolute;
  right: 22px;
  bottom: 18px;
  padding: 4px 10px;
  border: 3px solid var(--red);
  border-radius: 6px;
  color: var(--red);
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.16em;
  opacity: 0;
  transform: rotate(-12deg) scale(2.6);
  pointer-events: none;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='60'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -3 2.4'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='60'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -3 2.4'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  transition: transform 0.33s cubic-bezier(0.55, 0, 1, 0.45), opacity 0.12s linear;
}

.stamp.down {
  opacity: 0.9;
  transform: rotate(-12deg) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .grain,
  .dial-a,
  .dial-b,
  .beam {
    animation: none;
  }
}
