/* FEED THE TYDE — stile. Brand: nero/bianco + arancione #FF4B00. Font Montserrat. Mobile-first. */
@font-face {
  font-family: 'Montserrat';
  src: url('../assets/montserrat.ttf') format('truetype');
  font-weight: 100 900; font-style: normal; font-display: swap;
}
:root {
  --orange: #FF4B00;
  --bg: #000; --ink: #fff; --muted: rgba(255,255,255,0.5);
  --faint: rgba(255,255,255,0.3); --hair: rgba(255,255,255,0.12);
  --card-bg: #0b0b0b; --card-border: rgba(255,255,255,0.12);
  --btn-ghost-border: rgba(255,255,255,0.26);
}
:root[data-theme="light"] {
  --bg: #fff; --ink: #0a0a0a; --muted: rgba(0,0,0,0.45);
  --faint: rgba(0,0,0,0.3); --hair: rgba(0,0,0,0.1);
  --card-bg: #fff; --card-border: rgba(0,0,0,0.1);
  --btn-ghost-border: rgba(0,0,0,0.22);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; -moz-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* gli input restano digitabili/selezionabili (il nome utente) */
input { -webkit-user-select: text; -moz-user-select: text; user-select: text; -webkit-touch-callout: default; }
html, body {
  overflow: hidden; position: fixed; inset: 0;
  overscroll-behavior: none; touch-action: manipulation;
  background: var(--bg);
}
body {
  font-family: 'Montserrat', system-ui, sans-serif; color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* toggle tema */
.theme-toggle {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 20px); right: 16px; z-index: 30;
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--hair);
  background: transparent; color: var(--ink); font-size: 20px; cursor: pointer; display: grid; place-items: center;
}

/* ---- START ---- */
#screen-start { align-items: center; justify-content: center; text-align: center; padding: 32px; gap: 22px; }
.mast { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: 6px; font-size: clamp(13px,3.6vw,17px); }
.mast .glyph { width: 14px; height: 14px; background: var(--orange); clip-path: polygon(50% 0,100% 25%,100% 75%,50% 100%,0 75%,0 25%); }
.hero-title { font-weight: 900; letter-spacing: -1px; line-height: 0.92; font-size: clamp(48px,16vw,110px); }
.hero-title .y { color: var(--orange); }
.oneliner { font-weight: 500; font-size: clamp(15px,4.2vw,21px); color: var(--muted); max-width: 22ch; }
.btn-play {
  margin-top: 8px; border: none; background: var(--orange); color: #000; font-family: inherit; font-weight: 800;
  font-size: clamp(20px,5.6vw,26px); letter-spacing: 3px; padding: 20px 64px; border-radius: 16px; cursor: pointer;
}
.start-hint { font-weight: 700; font-size: 13px; letter-spacing: 2px; color: var(--muted); }
.name-input { width: min(80vw, 300px); text-align: center; background: transparent; border: 2px solid var(--btn-ghost-border);
  border-radius: 12px; padding: 13px 16px; font-family: inherit; font-weight: 700; font-size: 15px; letter-spacing: 2px;
  color: var(--ink); text-transform: uppercase; }
.name-input::placeholder { color: var(--muted); letter-spacing: 1px; font-weight: 600; text-transform: none; }
.name-input:focus { outline: none; border-color: var(--orange); }
.start-bg { position: absolute; inset: 0; display: grid; place-items: center; z-index: 0; opacity: .05; pointer-events: none; }
.start-bg svg { width: min(128vw, 560px); height: auto; animation: spin 60s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.start-scrim { position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 72% 54% at 50% 52%, rgba(0,0,0,.68) 0%, rgba(0,0,0,.36) 46%, transparent 66%); }
:root[data-theme="light"] .start-scrim {
  background: radial-gradient(ellipse 74% 56% at 50% 52%, rgba(250,249,247,.86) 0%, rgba(250,249,247,.5) 46%, transparent 66%); }
:root[data-theme="light"] .start-bg { opacity: .06; }
#screen-start > *:not(.start-bg):not(.start-scrim) { position: relative; z-index: 1; }
.best { font-weight: 700; font-size: 13px; letter-spacing: 3px; color: var(--muted); }
.btn-install { margin-top: 2px; background: transparent; border: 2px solid var(--btn-ghost-border); color: var(--ink);
  font-family: inherit; font-weight: 700; font-size: 13px; letter-spacing: 1px; padding: 12px 22px; border-radius: 12px; cursor: pointer; }
.ios-hint { font-weight: 600; font-size: 12px; letter-spacing: .3px; color: var(--muted); max-width: 28ch; text-align: center; line-height: 1.5; }
.ios-hint b { color: var(--ink); }

/* ---- GAME ---- */
#screen-game { }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.hud { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 26px); left: 20px; right: 20px; z-index: 10;
       display: flex; justify-content: space-between; pointer-events: none; }
.hud .lab { font-weight: 700; font-size: 12px; letter-spacing: 4px; color: var(--muted); }
.hud .val { font-weight: 900; font-size: clamp(38px,11vw,64px); line-height: 1; font-variant-numeric: tabular-nums; }
.hud .right { text-align: right; }
.hud .streak { color: var(--orange); font-weight: 800; font-size: clamp(22px,6vw,36px); }
.game-credit { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 10px) + 8px);
  text-align: center; z-index: 8; pointer-events: none; font-weight: 700; font-size: 10px; letter-spacing: 2px;
  color: var(--muted); opacity: 0.55; }

/* ---- GAME OVER / FUNNEL ---- */
#screen-over { align-items: center; justify-content: safe center; padding: 24px 20px 28px; overflow-y: auto; }
.over-head { font-weight: 700; font-size: 13px; letter-spacing: 7px; color: var(--muted); margin: 6px 0 16px; }
.share-quick { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--orange);
  background: transparent; cursor: pointer; display: grid; place-items: center; }
.card .cmast { align-items: flex-start; }
.card .cmleft { min-width: 0; }
.card .cid { margin-top: 6px; }
.card {
  position: relative; width: 100%; max-width: 460px; background: var(--card-bg); border: 2px solid var(--card-border);
  border-radius: 24px; padding: 22px 24px 18px; box-shadow: 0 30px 70px rgba(0,0,0,.5);
}
/* cornice certificato: hairline arancione tenue inset */
.card::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(255,75,0,.22); border-radius: 18px; pointer-events: none; }
.card .cmast { display: flex; align-items: center; justify-content: space-between; }
.card .cmrow { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 2.5px; font-size: 11px; white-space: nowrap; }
.card .cmrow .glyph { width: 10px; height: 10px; flex: 0 0 auto; background: var(--orange); clip-path: polygon(50% 0,100% 25%,100% 75%,50% 100%,0 75%,0 25%); }
.card .cid { font-weight: 700; font-size: 10px; letter-spacing: 1.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .csig { display: flex; justify-content: center; margin: 4px 0 2px; }
.card .csig svg { width: min(66vw, 300px); height: auto; }
.card .clabel { text-align: center; font-weight: 700; letter-spacing: 5px; font-size: 13px; }
.card .csub { text-align: center; font-weight: 500; font-size: 12px; color: var(--muted); margin-top: 5px; }
.card .cstats { display: flex; align-items: flex-end; gap: 14px; margin-top: 16px; }
.card .cnum { font-weight: 900; font-size: 42px; line-height: 0.9; font-variant-numeric: tabular-nums; }
.card .cnlab { font-weight: 600; font-size: 10px; letter-spacing: 2px; color: var(--muted); margin-top: 6px; }
.card .cvr { width: 2px; align-self: stretch; background: var(--hair); }
.card .ctier { flex: 1; min-width: 0; text-align: right; }
.card .ctname { font-weight: 800; font-size: clamp(20px, 6vw, 26px); line-height: 0.95; letter-spacing: -0.3px; }
.card .ctname.brand { color: var(--orange); }
.card .ctsub { font-weight: 600; font-size: 12px; letter-spacing: 1px; color: var(--muted); margin-top: 4px; }
.card .cfoot { display: flex; align-items: center; justify-content: space-between; border-top: 2px solid var(--hair); margin-top: 16px; padding-top: 14px; }
.card .cfoot img { height: 20px; }
.card .curl { font-weight: 700; font-size: 14px; letter-spacing: 1px; }

.over-actions { width: 100%; max-width: 460px; }
/* RIGIOCA = primario (arancione), CONDIVIDI = secondario forte (bordo ink + icona arancione) */
.btn-replay { margin-top: 22px; width: 100%; border: none; background: var(--orange); color: #000; font-family: inherit;
  font-weight: 800; font-size: 19px; letter-spacing: 4px; padding: 20px; border-radius: 16px; cursor: pointer;
  transition: transform .08s ease; }
.btn-replay:active { transform: scale(0.98); }
.btn-share { margin-top: 12px; width: 100%; background: transparent; color: var(--ink); border: 2px solid var(--btn-ghost-border);
  font-family: inherit; font-weight: 700; font-size: 16px; letter-spacing: 1px; padding: 16px; border-radius: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px; white-space: nowrap; transition: border-color .15s ease; }
.btn-share:active { border-color: var(--orange); }
.sep { width: 100%; max-width: 460px; height: 2px; background: var(--hair); margin: 26px 0 20px; }
.cta-wa { width: 100%; max-width: 460px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  border: 2px solid var(--btn-ghost-border); border-radius: 16px; padding: 16px 20px; text-decoration: none; color: var(--ink); }
.cta-wa b { font-weight: 700; font-size: 17px; }
.cta-wa i { display: block; font-style: normal; font-weight: 500; font-size: 13px; color: var(--muted); margin-top: 5px; }
.cta-wa .arr { color: var(--orange); font-size: 24px; }
.lead { width: 100%; max-width: 460px; display: flex; flex-direction: column; align-items: center; margin-top: 22px; gap: 12px; }
.lead .ltx { font-weight: 500; font-size: 14px; color: var(--muted); text-align: center; }
.lead .lrow { display: flex; gap: 10px; width: 100%; }
.lead input { flex: 1; background: transparent; border: 2px solid var(--hair); border-radius: 12px; padding: 14px 16px;
  font-family: inherit; font-weight: 500; font-size: 15px; color: var(--ink); }
.lead .lbtn { background: var(--hair); border: none; border-radius: 12px; padding: 14px 24px; font-family: inherit;
  font-weight: 700; font-size: 15px; letter-spacing: 1px; color: var(--ink); cursor: pointer; }
.lead .lno { background: none; border: none; font-family: inherit; font-weight: 600; font-size: 14px; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.lead .lok { font-weight: 600; font-size: 14px; color: var(--orange); }

/* record pill + meter nella card (parità con l'export) */
.card .crec { display: none; align-items: center; justify-content: center; gap: 8px; width: max-content; margin: 12px auto 2px;
  border: 2px solid var(--orange); border-radius: 999px; padding: 6px 15px; color: var(--orange); font-weight: 700; font-size: 10.5px; letter-spacing: 2.5px; }
.card .crec .dia { width: 8px; height: 8px; flex: 0 0 auto; background: var(--orange); transform: rotate(45deg); }
.card .cmeter { display: flex; justify-content: flex-end; margin-bottom: 5px; }
.card .cmeter svg { height: 18px; width: auto; }

/* HUD stile strumento */
.hud .left { position: relative; }
.hud .left::before, .hud .left::after { content: ""; position: absolute; width: 12px; height: 12px; border: 2px solid var(--faint); }
.hud .left::before { top: -8px; left: -10px; border-right: 0; border-bottom: 0; }
.hud .left::after { bottom: -8px; left: -10px; border-right: 0; border-top: 0; }
.hud-meter { display: flex; justify-content: flex-end; margin-top: 8px; }
.hud-meter svg { height: 13px; width: auto; }
