@font-face {
  font-family: "Anton";
  src: url("/fonts/anton.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("/fonts/dm-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("/fonts/dm-sans-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #1e1a17;
  --ink-2: #2a2420;
  --ink-3: #3a332d;
  --cream: #f3efe7;
  --yellow: #e5c110;
  --red: #ff2e12;
  --green: #3ccf7a;
  --muted: #a79f94;
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--cream);
  font: 400 17px/1.5 "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

a {
  color: var(--yellow);
}

h1,
h2,
.count,
.kicker,
.btn,
.ticket-code,
.stats strong {
  font-family: "Anton", "Impact", "Arial Narrow", sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(40px, 12vw, 64px);
  line-height: 0.95;
  margin: 8px 0 16px;
}

h2 {
  font-size: 28px;
  line-height: 1;
  margin: 32px 0 12px;
}

.yellow {
  color: var(--yellow);
}

.kicker {
  margin: 0;
  color: var(--yellow);
  font-size: 14px;
  letter-spacing: 0.25em;
}

.lead {
  font-size: 18px;
  color: #ddd6ca;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14px;
}

.center {
  text-align: center;
}

/* Layout */

.top {
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--ink-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--cream);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.2em;
}

.brand strong {
  color: var(--yellow);
}

.wrap {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

body.admin .wrap {
  max-width: 1000px;
}

.foot {
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ink-3);
  font-size: 14px;
  text-align: center;
}

.foot nav {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.foot nav a {
  color: var(--muted);
}

.foot-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.foot-actions form {
  margin: 0;
}

.hero {
  padding-top: 16px;
}

.stack {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  font-size: 22px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn[disabled] {
  opacity: 0.6;
}

.btn-red {
  background: var(--red);
  color: var(--ink);
}

.btn-yellow {
  background: var(--yellow);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--cream);
  box-shadow: inset 0 0 0 2px var(--ink-3);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  box-shadow: inset 0 0 0 2px var(--red);
}

.btn.big {
  min-height: 72px;
  font-size: 28px;
}

.link {
  background: none;
  border: 0;
  padding: 8px 0;
  color: var(--yellow);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.link.danger {
  color: var(--red);
}

/* Forms */

.form {
  display: grid;
  gap: 16px;
  margin: 20px 0;
}

.form.inline {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.form.inline .btn {
  width: auto;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 15px;
}

input,
textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid var(--ink-3);
  background: var(--ink-2);
  color: var(--cream);
  font: 400 18px/1.3 "DM Sans", system-ui, sans-serif;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--yellow);
}

.code-input {
  font-family: "Anton", sans-serif;
  font-size: 40px;
  letter-spacing: 0.3em;
  text-align: center;
}

.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-weight: 400;
  font-size: 16px;
}

.check input {
  flex: none;
  width: 26px;
  height: 26px;
  margin: 0;
  accent-color: var(--yellow);
}

.check.optional {
  color: #ddd6ca;
}

.follow {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--ink-2);
}

.follow .btn {
  font-size: 18px;
  min-height: 48px;
}

.cf-turnstile {
  min-height: 65px;
}

/* Alerts */

.alert {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink-2);
  border-left: 4px solid var(--yellow);
}

.alert-error {
  border-color: var(--red);
  background: #3a1712;
}

.alert-ok {
  border-color: var(--green);
}

/* Game */

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.count {
  font-size: 88px;
  margin: 0;
  line-height: 1;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--ink-3);
  overflow: hidden;
  margin: 8px 0 20px;
}

.bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--red));
  transition: width 0.6s ease;
}

.w0 { width: 0; }
.w1 { width: 14.28%; }
.w2 { width: 28.57%; }
.w3 { width: 42.85%; }
.w4 { width: 57.14%; }
.w5 { width: 71.42%; }
.w6 { width: 85.71%; }
.w7 { width: 100%; }

.grid {
  list-style: none;
  padding: 0;
  margin: 24px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px 14px;
}

.slot {
  width: calc((100% - 28px) / 3);
  max-width: 130px;
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
}

.slot img,
.missing {
  width: 100%;
  max-width: 104px;
  aspect-ratio: 1;
  height: auto;
}

.missing {
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px dashed var(--ink-3);
  color: var(--ink-3);
  font: 400 40px "Anton", sans-serif;
}

.slot-name {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.2;
}

.slot.found .slot-name {
  color: var(--cream);
  font-weight: 700;
}

.slot.nuovo img {
  animation: pop 0.9s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

@keyframes pop {
  0% {
    transform: scale(0) rotate(-180deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

/* Popup dialetto */

.popup {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 8, 7, 0.82);
  animation: fade 0.25s ease both;
}

.popup[hidden] {
  display: none;
}

.popup-card {
  width: 100%;
  max-width: 420px;
  padding: 28px 24px;
  border-radius: 22px;
  background: var(--yellow);
  color: var(--ink);
  text-align: center;
  transform: rotate(-2deg);
  animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

.popup-card .kicker {
  color: var(--ink);
}

.popup-text {
  font: 400 30px/1.1 "Anton", sans-serif;
  text-transform: uppercase;
  margin: 12px 0 24px;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* Finale */

.finale {
  margin: 16px 0;
  padding: 22px 18px;
  border-radius: 22px;
  background: var(--ink-2);
  text-align: center;
}

.finale h2 {
  margin-top: 6px;
  font-size: 36px;
}

.finale.live {
  position: relative;
  background: var(--red);
  color: var(--ink);
  overflow: hidden;
}

.finale.live .kicker {
  color: var(--ink);
}

/* Bordo animato: uno screenshot non si muove. */
.finale.live::before {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, var(--yellow), var(--red), var(--cream), var(--yellow));
  animation: spin 3s linear infinite;
  z-index: 0;
}

.finale.live::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 18px;
  background: var(--red);
  z-index: 0;
}

.finale.live > * {
  position: relative;
  z-index: 1;
}

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

.finale.redeemed {
  box-shadow: inset 0 0 0 3px var(--green);
}

.ticket {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 18px;
  border-radius: 18px;
  background: var(--cream);
  color: var(--ink);
}

.qr {
  width: min(240px, 70vw);
  line-height: 0;
}

.qr svg {
  width: 100%;
  height: auto;
}

.ticket-code {
  margin: 8px 0 0;
  font-size: 40px;
  letter-spacing: 0.06em;
}

.ticket-name {
  margin: 0;
  font-weight: 700;
}

.clock {
  margin: 4px 0 0;
  font: 700 20px/1 ui-monospace, "SF Mono", Consolas, monospace;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% {
    color: var(--red);
  }
}

/* Staff */

.steps {
  padding-left: 22px;
}

.steps li {
  margin-bottom: 8px;
}

.pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--ink-2);
  font-weight: 700;
}

.pill.ok {
  background: #173a26;
  color: var(--green);
}

.pill.ko {
  background: #3a1712;
  color: var(--red);
}

.verdict {
  display: grid;
  gap: 6px;
  margin: 24px 0;
  padding: 28px 20px;
  border-radius: 22px;
  text-align: center;
}

.verdict strong {
  font: 400 44px/1 "Anton", sans-serif;
}

.verdict.ok {
  background: var(--green);
  color: var(--ink);
}

.verdict.ko {
  background: var(--red);
  color: var(--ink);
}

/* Admin */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stats.two {
  grid-template-columns: 1fr 1fr;
}

.stats > div {
  display: grid;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--ink-2);
}

.stats strong {
  font-size: 44px;
  line-height: 1;
  color: var(--yellow);
}

.stats span {
  font-size: 14px;
  color: var(--muted);
}

.staff-cta {
  margin: 8px 0 6px;
}

.stats.live > div {
  box-shadow: inset 0 0 0 2px var(--ink-3);
}

.stats.live strong {
  color: var(--green);
}

.cp-table td {
  vertical-align: middle;
}

.cp-table img {
  vertical-align: middle;
  margin-right: 6px;
}

.cp-table .recent {
  display: inline-block;
  font: 400 24px/1 "Anton", sans-serif;
  color: var(--green);
}

.bump {
  animation: bump 1.2s ease;
}

@keyframes bump {
  0% {
    color: var(--yellow);
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}

.bars {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 8px;
}

.bars li {
  display: grid;
  grid-template-columns: 140px 1fr 40px;
  gap: 10px;
  align-items: center;
}

meter {
  width: 100%;
  height: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid var(--ink-3);
  text-align: left;
  vertical-align: top;
}

td.actions {
  display: flex;
  gap: 12px;
}

td.actions form {
  margin: 0;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.qr-grid figure {
  margin: 0;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--cream);
  color: var(--ink);
  text-align: center;
}

.qr-grid .qr {
  width: 100%;
}

.qr-grid figcaption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
}

.data {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
}

.data dt {
  color: var(--muted);
}

.data dd {
  margin: 0;
  word-break: break-all;
}

.legal article {
  font-size: 16px;
}

.legal h2 {
  font-size: 24px;
}

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