/* Layout: home = un foglio di adesivi (6 card personaggio) su arancione a retino;
   arena = faccia a faccia a schermo diviso, G1 a sinistra e G2 a destra, pad BEAT lungo il bordo basso.
   Look unico e volutamente "meme": stesso aspetto con tema chiaro o scuro. */
:root {
  --ink: #14101f;
  --paper: #fff8ef;
  --home: #ff6b1a;
  --home-dot: #ff8b4a;
  --stick: #ffd400;
  --p1: #ff3d7f;
  --p1-deep: #9c0f4c;
  --p2: #22b8ff;
  --p2-deep: #0b4c92;
  --warn: #ff2d2d;
  --veil: rgba(20, 16, 31, .6);

  --font-display: 'Bungee', 'Arial Black', Impact, sans-serif;
  --font-body: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;

  --radius: 22px;
  --bounce: cubic-bezier(.3, 1.6, .5, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--home);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible { outline: 4px solid var(--paper); outline-offset: 3px; box-shadow: 0 0 0 9px var(--ink); }
kbd {
  font-family: var(--font-display);
  font-size: .9em;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-bottom-width: 4px;
  border-radius: 7px;
  padding: 0 .4em;
}
[hidden] { display: none !important; }

/* Testo "adesivo": riempimento chiaro con contorno scuro spesso. */
.logo, .char-name, .hud-num, .beat-label, .countdown span, .pop, .result-title {
  -webkit-text-stroke: var(--stroke, 3px) var(--ink);
  paint-order: stroke fill;
}

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* ================================================================ HOME */

.screen-home {
  min-height: 100%;
  padding: clamp(16px, 3vh, 32px) 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2.4vh, 26px);
  background:
    radial-gradient(var(--home-dot) 20%, transparent 22%) 0 0 / 16px 16px,
    var(--home);
}

.home-head { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.logo {
  --stroke: 4px;
  margin: 0;
  display: flex;
  gap: .22em;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 5.6rem);
  line-height: .95;
  color: var(--paper);
  text-shadow: 0 6px 0 var(--ink);
  transform: rotate(-3deg);
}
.logo span:last-child { color: var(--stick); }

.tagline {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: clamp(.95rem, 2.2vw, 1.2rem);
  letter-spacing: .02em;
  padding: .3em 1em;
  border-radius: 999px;
  transform: rotate(1.5deg);
}

/* --- Scelta: G1 VS G2 --- */
.pick-bar {
  width: min(100%, 640px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(8px, 2vw, 16px);
}
.slot {
  --c: var(--p1);
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform .15s var(--bounce), box-shadow .15s;
}
.slot-p2 { --c: var(--p2); justify-content: flex-end; padding: 6px 8px 6px 12px; }
.slot.is-active {
  background: var(--c);
  color: var(--paper);
  animation: slot-turn .7s ease-in-out infinite alternate;
}
.slot.is-filled:hover { transform: translateY(-2px); }
.slot .chip { font-size: clamp(.8rem, 2vw, 1rem); }
.slot-art {
  flex: none;
  width: clamp(38px, 7vw, 52px);
  aspect-ratio: 200 / 240;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
}
.slot-art .char-svg { display: block; width: 100%; height: auto; }
.slot-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: clamp(.75rem, 2.2vw, 1.05rem);
}
.pick-vs {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  background: var(--stick);
  border: 4px solid var(--ink);
  border-radius: 12px;
  padding: .05em .4em;
  transform: rotate(-6deg);
  box-shadow: 0 4px 0 var(--ink);
}
.pick-prompt {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.8vw, 1.5rem);
  text-align: center;
  color: var(--paper);
  background: var(--ink);
  border-radius: 14px;
  padding: .2em .8em;
}
.pick-prompt[data-turn="p1"] { color: var(--p1); }
.pick-prompt[data-turn="p2"] { color: var(--p2); }
.pick-prompt[data-turn="done"] { color: var(--stick); }

.char-grid {
  --turn: var(--p1);
  width: min(100%, 1040px, max(560px, calc((100svh - 420px) * 1.5)));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 24px);
}

.char-card {
  --p: 0;
  position: relative;
  aspect-ratio: 1;
  max-width: 100%;
  container-type: inline-size;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  justify-items: center;
  padding: 6% 6% 8%;
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  background:
    radial-gradient(rgba(255, 255, 255, .22) 18%, transparent 20%) 0 0 / 14px 14px,
    var(--card);
  box-shadow: 0 8px 0 var(--ink);
  overflow: hidden;
  transition: transform .18s var(--bounce), box-shadow .18s;
  animation: card-in .5s var(--bounce) both;
  animation-delay: calc(var(--i) * 60ms);
}
.char-card:hover, .char-card:focus-visible {
  --p: .35;
  transform: translateY(-5px) rotate(-1.5deg);
  box-shadow: 0 13px 0 var(--ink);
}
.char-card:nth-child(even):hover, .char-card:nth-child(even):focus-visible { transform: translateY(-5px) rotate(1.5deg); }
.char-card:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--ink); }
.char-card.is-featured { outline: 4px dashed var(--paper); outline-offset: 5px; }

/* Bordo colorato del giocatore che sta scegliendo. */
.char-grid[data-turn="p2"] { --turn: var(--p2); }
.char-grid:not([data-turn="done"]) .char-card:hover,
.char-grid:not([data-turn="done"]) .char-card:focus-visible {
  box-shadow: 0 13px 0 var(--ink), inset 0 0 0 6px var(--turn);
}
.char-grid[data-turn="done"] .char-card { cursor: default; }

/* Etichette G1/G2 sulle card scelte. */
.char-marks {
  position: absolute;
  top: 6%;
  right: 6%;
  z-index: 1;
  display: flex;
  gap: 4px;
}
.char-marks .chip {
  font-size: clamp(.8rem, 7cqi, 1.2rem);
  box-shadow: 0 3px 0 var(--ink);
  animation: mark-in .35s var(--bounce) both;
}

.char-art {
  width: 100%;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
.char-art .char-svg { height: 100%; width: auto; max-width: 100%; }

.char-name {
  --stroke: 2.5px;
  margin-top: 2%;
  font-family: var(--font-display);
  font-size: clamp(.95rem, 10.5cqi, 2rem);
  line-height: 1.05;
  color: var(--paper);
  text-shadow: 0 3px 0 var(--ink);
  text-align: center;
  text-wrap: balance;
}
.char-tag {
  margin-top: 3%;
  max-width: 100%;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: .1em .7em;
  font-weight: 600;
  font-size: clamp(.72rem, 5.4cqi, 1rem);
  white-space: nowrap;
}
.char-badge {
  position: absolute;
  top: 6%;
  left: 6%;
  z-index: 1;
  font-family: var(--font-display);
  font-size: clamp(.8rem, 7cqi, 1.2rem);
  background: var(--stick);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: .1em .45em;
  transform: rotate(-8deg);
}

.settings {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 22px;
}
.setting { display: flex; align-items: center; gap: 10px; }
.setting-label {
  font-weight: 700;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.seg {
  display: flex;
  gap: 4px;
  padding: 5px;
  background: var(--ink);
  border-radius: 999px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--paper);
  font-weight: 700;
  padding: .45em 1em;
  border-radius: 999px;
  white-space: nowrap;
}
.seg button.is-on { background: var(--stick); color: var(--ink); }
.seg button:not(.is-on):hover { background: rgba(255, 255, 255, .14); }

.hint {
  margin: 0;
  max-width: 60ch;
  text-align: center;
  font-weight: 600;
}

/* ================================================================ ARENA */

.screen-arena {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: clamp(6px, 1.4vh, 14px);
  padding:
    calc(env(safe-area-inset-top, 0px) + clamp(8px, 1.6vh, 16px))
    max(16px, env(safe-area-inset-right, 0px))
    calc(env(safe-area-inset-bottom, 0px) + clamp(14px, 2.4vh, 24px))
    max(16px, env(safe-area-inset-left, 0px));
  background: var(--ink);
  color: var(--paper);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Sfondo diviso in diagonale + retino + riflettore centrale. */
.arena-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 45% 40% at 50% 78%, rgba(255, 212, 0, .28), transparent 70%),
    radial-gradient(rgba(255, 255, 255, .09) 20%, transparent 22%) 0 0 / 18px 18px,
    linear-gradient(100deg, var(--p1-deep) 0 49.6%, var(--ink) 49.6% 50.4%, var(--p2-deep) 50.4%);
}

/* --- HUD --- */
.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}
.hud-player { display: flex; flex-direction: column; min-width: 0; }
.hud-p2 { align-items: flex-end; text-align: right; }

.hud-tag {
  display: flex;
  align-items: center;
  gap: .45em;
  font-family: var(--font-display);
  font-size: clamp(.8rem, 1.8vw, 1.15rem);
  min-width: 0;
  max-width: 100%;
}
.hud-tag > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  flex: none;
  font-family: var(--font-display);
  font-weight: 400;
  border: 3px solid var(--ink);
  border-radius: 9px;
  padding: 0 .35em;
  color: var(--paper);
}
.chip-p1 { background: var(--p1); }
.chip-p2 { background: var(--p2); }

.hud-score { display: flex; align-items: baseline; gap: .15em; }
.hud-num {
  --stroke: 4px;
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 5.4rem);
  line-height: 1;
  color: var(--paper);
  text-shadow: 0 5px 0 var(--ink);
  font-variant-numeric: tabular-nums;
}
.hud-score small { font-family: var(--font-display); font-size: clamp(.8rem, 2vw, 1.3rem); opacity: .8; }
.hud-bpm { font-weight: 600; font-size: clamp(.78rem, 1.7vw, 1rem); opacity: .9; }
.hud-bpm b { font-variant-numeric: tabular-nums; }

.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.timer-label { font-weight: 700; font-size: .72rem; letter-spacing: .14em; opacity: .85; }
.timer {
  min-width: 4.2ch;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4.6vw, 3rem);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  background: var(--paper);
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: .05em .4em;
  box-shadow: 0 5px 0 var(--ink);
}
.timer.is-warn { background: var(--warn); color: var(--paper); animation: warn .5s ease-in-out infinite alternate; }
.series { font-weight: 700; font-size: clamp(.75rem, 1.6vw, .95rem); white-space: nowrap; }
.hud-tools { display: flex; gap: 6px; }
.tool {
  border: 2px solid var(--paper);
  background: rgba(20, 16, 31, .55);
  color: var(--paper);
  font-weight: 600;
  font-size: .78rem;
  padding: .2em .7em;
  border-radius: 999px;
  white-space: nowrap;
}
.tool:hover { background: var(--ink); }

/* --- Barra tiro alla fune: quanto sta dominando G1 rispetto a G2 --- */
.tug {
  --share: .5;
  position: relative;
  height: clamp(16px, 2.6vh, 24px);
  margin-inline: 6px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
}
.tug-track { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; background: var(--p2); }
.tug-fill { height: 100%; width: calc(var(--share) * 100%); background: var(--p1); transition: width .15s ease-out; }
.tug-vs {
  position: absolute;
  top: 50%;
  left: calc(var(--share) * 100%);
  transform: translate(-50%, -50%) rotate(-6deg);
  font-family: var(--font-display);
  font-size: clamp(.8rem, 2vw, 1.1rem);
  background: var(--stick);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: .05em .45em;
  transition: left .15s ease-out;
}

/* --- Palco con i due personaggi faccia a faccia --- */
.stage {
  position: relative;
  container-type: size;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6cqw;
}
.stage::before {
  content: '';
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: -3%;
  height: 18%;
  border-radius: 50%;
  background: rgba(20, 16, 31, .35);
  border: 3px solid rgba(255, 248, 239, .15);
}

.fighter {
  --p: 0;
  position: relative;
  width: min(43cqw, 80cqh);
  transition: filter .2s;
}
.fighter-body { transform-origin: 50% 100%; }
.fighter.is-hyped .fighter-body {
  filter: drop-shadow(0 0 10px var(--tint)) drop-shadow(0 0 3px var(--stick));
  animation: hype .25s ease-in-out infinite alternate;
}

/* Colore e verso di ogni giocatore (usati anche nella schermata risultato). */
.fighter-p1 { --tint: var(--p1); }
.fighter-p2 { --tint: var(--p2); }
.fighter-p2 .fighter-flip { transform: scaleX(-1); }
.fighter-p2 .unflip { transform: scaleX(-1); }

.fighter-flip .char-svg { display: block; width: 100%; height: auto; }

/* Parti dell'SVG dei personaggi */
.char-svg { overflow: visible; }
.char-svg .tint { fill: var(--tint, #ffffff); }
.char-svg .grow {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scale(calc(1 + var(--p, 0) * var(--g, .5)));
  transition: transform .25s var(--bounce), opacity .25s;
}
.char-svg .prop { transform-box: fill-box; transform-origin: 50% 100%; }
.char-svg .unflip { transform-box: fill-box; transform-origin: center; }

/* --- Pulsanti BEAT --- */
.beat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 3vw, 40px);
}
.beat {
  --c: var(--p1);
  position: relative;
  height: clamp(110px, 25vh, 250px);
  height: clamp(110px, 25svh, 250px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 5px solid var(--ink);
  border-radius: 28px;
  background:
    radial-gradient(rgba(255, 255, 255, .25) 18%, transparent 20%) 0 0 / 16px 16px,
    var(--c);
  color: var(--paper);
  box-shadow: 0 10px 0 var(--ink), inset 0 -10px 0 rgba(0, 0, 0, .18);
  transition: transform .05s, box-shadow .05s, filter .2s;
  touch-action: none;
}
.beat-p2 { --c: var(--p2); }
.beat.is-down {
  transform: translateY(8px);
  box-shadow: 0 2px 0 var(--ink), inset 0 -4px 0 rgba(0, 0, 0, .18);
}
.beat-label {
  --stroke: 5px;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 8vw, 6rem);
  line-height: 1;
  text-shadow: 0 6px 0 var(--ink);
  pointer-events: none;
}
.beat-key {
  pointer-events: none;
  font-weight: 700;
  font-size: clamp(.75rem, 1.6vw, 1rem);
  background: rgba(20, 16, 31, .75);
  padding: .1em .8em;
  border-radius: 999px;
}
.screen-arena:not(.is-live) .beat { filter: saturate(.5) brightness(.85); }
@media (hover: none) and (pointer: coarse) { .key-hint { display: none; } }

/* --- Conto alla rovescia / STOP --- */
.countdown {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.countdown span {
  --stroke: 10px;
  font-family: var(--font-display);
  font-size: clamp(4rem, min(26vw, 38vh), 16rem);
  line-height: 1;
  color: var(--paper);
  text-shadow: 0 12px 0 var(--ink);
}
.countdown .is-go { color: var(--stick); }
.countdown .is-stop { color: var(--warn); }

/* --- Scritte volanti --- */
.pop {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  white-space: nowrap;
  font-family: var(--font-display);
  color: var(--paper);
  transform: translate(-50%, -50%);
  animation: pop-up .7s ease-out forwards;
}
.pop-plus { font-size: clamp(1.2rem, 3vw, 2rem); }
.pop-p1 { color: var(--p1); }
.pop-p2 { color: var(--p2); }
.pop-phrase {
  --stroke: 4px;
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  color: var(--stick);
  text-shadow: 0 4px 0 var(--ink);
  animation: pop-phrase 1.1s var(--bounce) forwards;
}
.pop-warn { color: var(--warn); }
.pop-milestone {
  --stroke: 6px;
  font-size: clamp(3rem, 12vw, 8rem);
  text-shadow: 0 8px 0 var(--ink);
  animation: pop-milestone .9s var(--bounce) forwards;
}

/* --- Overlay (pronti / risultato) --- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  padding: 16px;
  overflow: auto;
  background: var(--veil);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  touch-action: pan-y;
}
.panel {
  margin: auto;
  width: min(100%, 560px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: clamp(18px, 3vw, 32px);
  text-align: center;
  background: var(--paper);
  color: var(--ink);
  border: 5px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 10px 0 var(--ink);
  animation: panel-in .45s var(--bounce) both;
}
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.6rem, 5vw, 2.8rem);
  line-height: 1.05;
  text-wrap: balance;
}
.kicker {
  margin: 0;
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  padding: .2em .9em;
  border-radius: 999px;
}
.panel-intro { margin: 0; font-size: 1.1rem; font-weight: 600; max-width: 40ch; }
.panel-rule { margin: 0; font-size: 1rem; max-width: 40ch; }

.key-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.key-chip {
  font-weight: 700;
  color: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: .25em .8em;
}

.btn-big {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3.6vw, 2rem);
  background: var(--stick);
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 18px;
  padding: .4em 1.4em;
  box-shadow: 0 6px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn-big:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink); }
.btn-big:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.btn-ghost {
  background: transparent;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: .5em 1.1em;
  font-weight: 700;
}
.btn-ghost:hover:not(:disabled) { background: var(--ink); color: var(--paper); }

/* --- Risultato --- */
.result-title {
  --stroke: 5px;
  color: var(--stick);
  text-shadow: 0 5px 0 var(--ink);
}
[data-winner="p1"] .result-title { color: var(--p1); }
[data-winner="p2"] .result-title { color: var(--p2); }

.result-hero {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  padding-top: 18px;
}
.hero { position: relative; width: clamp(90px, 22vh, 170px); }
.hero:not(.is-winner) { width: clamp(70px, 16vh, 120px); }
.hero.is-winner { animation: winner 1s ease-in-out infinite alternate; }
.crown {
  position: absolute;
  top: -16%;
  left: 50%;
  width: 46%;
  transform: translateX(-50%) rotate(-8deg);
}

.roast { margin: 0; font-weight: 600; font-size: 1.05rem; max-width: 40ch; }

.result-stats {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  color: var(--paper);
}
.stat-p1, .key-chip.chip-p1 { background: var(--p1); }
.stat-p2, .key-chip.chip-p2 { background: var(--p2); }
.stat.is-winner { box-shadow: 0 0 0 4px var(--stick), 0 0 0 7px var(--ink); }
.stat-who { font-family: var(--font-display); font-size: .9rem; }
.stat b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
}
.stat-meta { font-size: .8rem; font-weight: 600; }

.record { margin: 0; font-size: .9rem; font-weight: 600; opacity: .8; }
.record.is-new { opacity: 1; background: var(--stick); padding: .15em .7em; border-radius: 8px; border: 2px solid var(--ink); }

.result-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 14px; }

/* ================================================================ ANIMAZIONI */

@keyframes card-in {
  from { transform: scale(.88) rotate(-4deg); }
  to { transform: none; }
}
@keyframes slot-turn {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}
@keyframes mark-in {
  from { transform: scale(0) rotate(-30deg); }
  to { transform: none; }
}
@keyframes panel-in {
  from { transform: scale(.85) translateY(20px); }
  to { transform: none; }
}
@keyframes warn {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}
@keyframes hype {
  from { transform: translateY(0); }
  to { transform: translateY(-2%); }
}
@keyframes winner {
  from { transform: rotate(-3deg) translateY(0); }
  to { transform: rotate(3deg) translateY(-6px); }
}
@keyframes pop-up {
  0% { transform: translate(-50%, -50%) scale(.6); opacity: 1; }
  25% { transform: translate(-50%, -90%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -240%) scale(.9); opacity: 0; }
}
@keyframes pop-phrase {
  0% { transform: translate(-50%, -50%) scale(.3) rotate(var(--r)); opacity: 1; }
  30% { transform: translate(-50%, -80%) scale(1.15) rotate(var(--r)); opacity: 1; }
  75% { transform: translate(-50%, -120%) scale(1) rotate(var(--r)); opacity: 1; }
  100% { transform: translate(-50%, -160%) scale(.9) rotate(var(--r)); opacity: 0; }
}
@keyframes pop-milestone {
  0% { transform: translate(-50%, -50%) scale(2.5) rotate(-12deg); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(.95) rotate(4deg); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(1.1); opacity: 0; }
}

/* ================================================================ RESPONSIVE */

@media (max-width: 640px) {
  .char-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setting { flex-direction: column; gap: 4px; }
  .hud { gap: 6px; }
  .hud-tools .tool { font-size: .7rem; padding: .15em .55em; }
}

/* Schermi bassi (telefono in orizzontale): HUD più compatto per lasciare spazio ai personaggi. */
@media (max-height: 520px) {
  .hud-num { font-size: clamp(1.8rem, 9vh, 3rem); }
  .timer { font-size: 1.3rem; }
  .series, .timer-label { display: none; }
  .beat { height: clamp(90px, 30svh, 160px); border-radius: 22px; }
  .beat-label { font-size: clamp(1.8rem, 12vh, 3.4rem); }
  .tug { height: 14px; border-width: 3px; }
  .hero { width: clamp(70px, 26vh, 120px); }
  .panel { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .char-card, .panel, .hero.is-winner, .slot.is-active, .char-marks .chip, .timer.is-warn, .fighter.is-hyped .fighter-body { animation: none; }
  .pop { animation-duration: .45s; }
  .char-svg .grow { transition: none; }
}
