/* ============================================================
   SPIN · styles
   PRE-REVEAL: lo stesso formato del biglietto QR (nero #050607,
   viola WALKAWAY #7B61FF, Barlow Condensed 800, etichette mono agli
   angoli, quadrante a tacche, parentesi agli angoli dei tasti).
   REVEAL: design system WALKAWAY v4 (nero + viola).
   ============================================================ */

@font-face { font-family: "Display"; src: url("assets/fonts/display-800.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Brand";   src: url("assets/fonts/brand-900.woff2")   format("woff2"); font-weight: 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Brand";   src: url("assets/fonts/brand-500.woff2")   format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Mono";    src: url("assets/fonts/mono-500.woff2")    format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  /* pre-reveal = biglietto */
  --bg: #050607;
  --ink: #F4F4F2;
  --ink-55: rgba(244,244,242,.55);
  --ink-26: rgba(244,244,242,.26);
  --acc: #7B61FF;               /* il viola WALKAWAY, anche prima del reveal */
  --acc-rgb: 123,97,255;
  --acc-75: rgba(163,146,255,.85); /* etichette: viola chiaro, leggibile su nero */

  /* reveal (WALKAWAY v4) */
  --w-bg: #0A0B0D;
  --w-surface: #14151B;
  --w-surface-2: #191B22;
  --w-line: #23252E;
  --w-white: #F4F5F6;
  --w-mut: #A6A9B3;
  --w-dim: #6C7079;
  --accent: #7B61FF;
  --accent-soft: #A392FF;
  --accent-dim: rgba(123,97,255,.14);

  --display: "Display", "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --brand: "Brand", "Satoshi", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Mono", "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --pad: 22px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.7, 0, .2, 1);
  --pop: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 500;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

.app {
  position: fixed; inset: 0;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}
.app[data-state="reveal"], .app[data-state="map"] { background: var(--w-bg); }

.mono { font-family: var(--mono); font-weight: 500; letter-spacing: .18em; text-transform: uppercase; font-size: 11px; }
.lab { color: var(--ink-55); }
.lab.acc { color: var(--acc-75); }
.labels { display: flex; justify-content: space-between; gap: 12px; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 16px) var(--pad) calc(var(--safe-b) + 18px);
}

/* ---------- MUTE ---------- */
.mute {
  position: absolute; z-index: 40;
  top: calc(var(--safe-t) + 8px); right: 8px;
  width: 40px; height: 40px; border-radius: 999px;
  display: grid; place-items: center;
  color: var(--ink-55); opacity: .8;
  transition: opacity .25s, color .25s;
}
.mute:active { opacity: 1; }
.mute .mute-x { display: none; }
.mute[aria-pressed="true"] .mute-wave { display: none; }
.mute[aria-pressed="true"] .mute-x { display: block; }
.app[data-state="reveal"] .mute, .app[data-state="map"] .mute { color: var(--w-dim); }

/* ---------- GAME: composizione del biglietto ---------- */
.screen-game { justify-content: space-between; z-index: 1; }
.card-head { display: flex; flex-direction: column; padding-right: 40px; }
.headline {
  font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: clamp(64px, 23.5vw, 112px); line-height: .84; letter-spacing: -.005em;
  color: var(--ink); max-width: 6.2ch;
}
.headline .q { color: var(--acc); }
.card-head, .card-foot { opacity: 0; animation: rise .8s var(--ease-out) .15s forwards; }
.card-foot { display: flex; flex-direction: column; align-items: center; padding-bottom: 6px; animation-delay: .35s; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.dial-wrap {
  position: relative; align-self: center;
  width: min(88vw, 52vh, 440px);
  aspect-ratio: 1;
  display: grid; place-items: center;
  opacity: 0; animation: wheel-in 1s var(--ease-out) .1s forwards;
}
@keyframes wheel-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.wheel-glow {
  position: absolute; inset: -22%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(var(--acc-rgb),.09), rgba(var(--acc-rgb),.03) 45%, rgba(var(--acc-rgb),0) 72%);
}
#wheel { width: 100%; height: 100%; display: block; }

/* puntatore: la tacca verde del biglietto, con il punto sopra */
.pointer {
  position: absolute; top: -2.6%; left: 50%;
  width: 4px; height: 13.5%; margin-left: -2px;
  transform-origin: 50% 0;
  will-change: transform;
}
.pointer-dot { position: absolute; left: 50%; top: 0; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 10px rgba(var(--acc-rgb),.7); }
.pointer-tick { position: absolute; left: 50%; top: 20%; width: 3px; height: 80%; margin-left: -1.5px; background: var(--acc); box-shadow: 0 0 8px rgba(var(--acc-rgb),.55); }
.pointer.tick { animation: flap .11s ease-out; }
@keyframes flap { 0% { transform: rotate(0); } 35% { transform: rotate(-9deg); } 100% { transform: rotate(0); } }
.pointer.tick-slow { animation: flap-slow .28s var(--pop); }
@keyframes flap-slow { 0% { transform: rotate(0); } 30% { transform: rotate(-16deg); } 100% { transform: rotate(0); } }

/* ---------- BOTTONI: parentesi verdi agli angoli, testo mono spaziato ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 0 34px;
  font-family: var(--mono); font-weight: 600; font-size: 14px; letter-spacing: .36em; text-indent: .36em; text-transform: uppercase;
  color: var(--acc);
  transition: transform .12s var(--ease-out), opacity .3s;
  -webkit-user-select: none; user-select: none;
}
.btn i { position: absolute; width: 12px; height: 12px; border: 0 solid var(--acc); border-width: 1.5px; transition: transform .15s var(--ease-out); }
.btn i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.btn i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.btn i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.btn i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.btn:active { transform: scale(.97); }
.btn:active i:nth-child(1) { transform: translate(3px, 3px); }
.btn:active i:nth-child(2) { transform: translate(-3px, 3px); }
.btn:active i:nth-child(3) { transform: translate(3px, -3px); }
.btn:active i:nth-child(4) { transform: translate(-3px, -3px); }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btn-br span { position: relative; }
.btn-accent {
  color: #fff; background: var(--accent);
  font-family: var(--brand); font-weight: 900; letter-spacing: .06em; text-indent: 0; font-size: 15px;
  border-radius: 10px; min-height: 52px; padding: 0 18px;
}
.btn-ghost {
  color: var(--w-white); border: 1px solid var(--w-line);
  font-family: var(--brand); font-weight: 900; letter-spacing: .06em; text-indent: 0; font-size: 15px;
  border-radius: 10px; min-height: 52px; padding: 0 18px;
}
.btn-ghost:active { border-color: var(--accent-soft); }
.btn-close { color: var(--w-mut); padding: 10px 6px; min-height: 44px; }

/* ---------- BIG WIN ---------- */
.screen-win { z-index: 10; justify-content: center; align-items: center; pointer-events: none; }
.screen-win.on { pointer-events: auto; }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 45%, #FFFFFF 0%, rgba(var(--acc-rgb),.85) 22%, rgba(var(--acc-rgb),.35) 50%, transparent 78%);
}
.flash.go { animation: flash .46s ease-out forwards; }
@keyframes flash { 0% { opacity: 0; } 8% { opacity: 1; } 100% { opacity: 0; } }

.app[data-state="win"] .dial-wrap, .app[data-state="claim"] .dial-wrap { animation: wheel-out .8s var(--ease-in-out) forwards; }
@keyframes wheel-out { from { opacity: 1; transform: none; filter: none; } to { opacity: 1; transform: scale(.86); filter: blur(2px) brightness(.35); } }
.app[data-state="win"] .card-head, .app[data-state="win"] .card-foot,
.app[data-state="claim"] .card-head, .app[data-state="claim"] .card-foot { animation: fadeout .35s ease-out forwards; }
@keyframes fadeout { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }
.app.shake { animation: shake .5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 1px, 0); }
  20%, 80% { transform: translate3d(4px, -2px, 0); }
  30%, 50%, 70% { transform: translate3d(-7px, 3px, 0); }
  40%, 60% { transform: translate3d(7px, -3px, 0); }
}

.win-content { position: relative; z-index: 2; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 22px; transform: translateY(-3%); }
.bigwin {
  font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: clamp(88px, 36vw, 190px); line-height: .84; letter-spacing: -.005em;
  color: var(--ink);
  display: flex; flex-direction: column; align-items: center;
}
.bigwin .word { display: flex; }
.bigwin .ch { display: inline-block; opacity: 0; transform: translateY(.4em) scale(.6); animation: letter .6s var(--pop) forwards; }
.bigwin .ch.q { color: var(--acc); text-shadow: 0 0 26px rgba(var(--acc-rgb),.75); }
@keyframes letter {
  0%   { opacity: 0; transform: translateY(.4em) scale(.6); }
  60%  { opacity: 1; transform: translateY(-.04em) scale(1.1); }
  100% { opacity: 1; transform: none; }
}

.prize { display: flex; flex-direction: column; align-items: center; gap: 14px; opacity: 0; transform: translateY(18px); }
.prize.on { animation: rise .7s var(--ease-out) forwards; }
.prize-text { font-family: var(--mono); font-weight: 500; font-size: 14px; letter-spacing: .02em; line-height: 1.5; color: var(--ink-55); max-width: 26ch; }
.prize .btn { margin-top: 12px; }

/* ---------- WIPE (transizione al reveal) ---------- */
.wipe {
  position: absolute; inset: 0; z-index: 30; pointer-events: none;
  background: var(--accent); opacity: 0;
  clip-path: circle(0px at var(--wx, 50%) var(--wy, 80%));
}
.wipe.go { opacity: 1; transition: clip-path .62s var(--ease-in-out); clip-path: circle(160vmax at var(--wx, 50%) var(--wy, 80%)); }
.wipe.out { transition: opacity .38s ease-out; opacity: 0; }

/* ---------- REVEAL ---------- */
.screen-reveal {
  z-index: 20; color: var(--w-white); background: var(--w-bg);
  padding-top: calc(var(--safe-t) + 16px); padding-bottom: calc(var(--safe-b) + 16px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background-image:
    linear-gradient(to right, rgba(35,37,46,.35) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(35,37,46,.35) 1px, transparent 1px);
  background-size: 40px 40px; background-position: center top;
}
.reveal-inner { margin: auto 0; width: 100%; max-width: 480px; align-self: center; display: flex; flex-direction: column; gap: 16px; }
.reveal-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.brand { height: 22px; width: auto; display: block; }
.reveal-title { font-family: var(--brand); font-weight: 900; font-size: clamp(34px, 10vw, 46px); line-height: .98; letter-spacing: -.03em; margin-top: 6px; }
.reveal-sub { color: var(--w-mut); font-size: 15px; }

.meet { display: grid; grid-template-columns: 1fr; gap: 1px; background: var(--w-line); border: 1px solid var(--w-line); border-radius: 10px; overflow: hidden; }
.meet-row { background: var(--w-surface); padding: 12px 14px; display: grid; grid-template-columns: 58px 1fr; gap: 12px; align-items: baseline; }
.meet dt { color: var(--accent-soft); font-size: 10px; padding-top: 3px; }
.meet dd strong { display: block; font-weight: 900; font-size: 18px; letter-spacing: -.01em; line-height: 1.15; }
.meet-detail { display: block; color: var(--w-mut); font-size: 12px; line-height: 1.35; margin-top: 3px; }

.map { position: relative; border: 1px solid var(--w-line); border-radius: 10px; overflow: hidden; background: var(--w-surface); }
.map-frame { position: relative; width: 100%; aspect-ratio: var(--map-aspect, 4 / 3); overflow: hidden; }
.map-frame img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: fill; }
.map-frame.rotated img { width: auto; height: auto; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(90deg); }

.pin { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 3; }
.pin-ring { position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--accent-soft); opacity: 0; animation: ring 1.8s ease-out infinite; }
.pin-ring.r2 { animation-delay: .6s; }
@keyframes ring { 0% { transform: scale(.25); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
.pin-dot { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(123,97,255,.25); }
.pin-marker { position: absolute; left: -17px; top: -44px; width: 34px; height: 46px; filter: drop-shadow(0 8px 10px rgba(0,0,0,.6)); transform-origin: 50% 100%; }
.pin-label {
  position: absolute; left: 50%; top: -60px; transform: translate(-50%, -100%);
  white-space: nowrap; background: var(--accent); color: #fff;
  font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  padding: 7px 10px; border-radius: 6px;
}
.pin-label::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; background: var(--accent); transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.pin.drop .pin-marker { animation: drop .75s var(--pop) both; }
.pin.drop .pin-label { animation: labelin .5s var(--ease-out) .45s both; }
.pin.drop .pin-dot, .pin.drop .pin-ring { animation-play-state: paused; opacity: 0; }
.pin.landed .pin-dot { opacity: 1; animation: none; }
.pin.landed .pin-ring { animation-play-state: running; }
@keyframes drop { 0% { transform: translateY(-90px) scale(.6); opacity: 0; } 55% { transform: translateY(6px) scale(1.05); opacity: 1; } 75% { transform: translateY(-4px); } 100% { transform: none; opacity: 1; } }
@keyframes labelin { from { opacity: 0; transform: translate(-50%, -80%); } to { opacity: 1; transform: translate(-50%, -100%); } }
.pin-marker.bounce { animation: bounce 2.4s ease-in-out infinite; }
@keyframes bounce { 0%,100% { transform: none; } 50% { transform: translateY(-5px); } }

.reveal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* reveal: entrata in sequenza */
.screen-reveal .reveal-head, .screen-reveal .meet, .screen-reveal .map, .screen-reveal .reveal-actions { opacity: 0; transform: translateY(16px); }
.screen-reveal.on .reveal-head { animation: rise .7s var(--ease-out) .05s forwards; }
.screen-reveal.on .meet { animation: rise .7s var(--ease-out) .2s forwards; }
.screen-reveal.on .map { animation: rise .8s var(--ease-out) .32s forwards; }
.screen-reveal.on .reveal-actions { animation: rise .7s var(--ease-out) .5s forwards; }
.screen-reveal.on .brand { animation: logo-in .9s var(--ease-out) both; }
@keyframes logo-in { from { opacity: 0; transform: scale(.9); letter-spacing: .2em; } to { opacity: 1; transform: none; } }

/* ---------- MAPPA A SCHERMO INTERO ---------- */
.mapfull {
  position: absolute; inset: 0; z-index: 50; background: var(--w-bg); color: var(--w-white);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 8px) 12px calc(var(--safe-b) + 12px);
  animation: fade .3s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.mapfull-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.mapfull-where { color: var(--w-mut); font-size: 11px; letter-spacing: .14em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapfull-body { flex: 1; min-height: 0; display: grid; place-items: center; }
.mapfull-body .map-frame { width: 100%; border: 1px solid var(--w-line); border-radius: 10px; background: var(--w-surface); }
.mapfull-body .pin-label { font-size: 11px; padding: 8px 12px; }

/* ---------- ACCESSIBILITA' / MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  .app.shake { animation: none; }
  .wheel-glow { animation: none; }
  .bigwin.pulse { animation: none; }
  .prize .btn { animation: none; }
}

/* schermi bassi (iPhone SE, landscape) */
@media (max-height: 640px) {
  .headline { font-size: clamp(26px, 8vw, 34px); margin-top: 8px; }
  .wheel-wrap { width: min(80vw, 54vh, 440px); }
  .btn { min-height: 50px; }
  .reveal-inner { gap: 12px; }
  .reveal-title { font-size: clamp(28px, 8vw, 36px); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .screen-game { flex-direction: row; justify-content: space-around; }
  .wheel-wrap { width: min(80vh, 320px); }
  .game-top, .game-bottom { width: auto; }
  .pointer { top: -12px; }
}
