/* ── Stile retrò anni '90/2000: arcade a 8 bit + finestre di Windows 98 + CRT ── */
:root {
  --w98: #c0c0c0;
  --w98-dark: #808080;
  --w98-light: #dfdfdf;
  --navy: #000080;
  --navy2: #1084d0;
  --yel: #ffff00;
  --cyan: #00ffff;
  --lime: #00ff66;
  --red: #ff2a2a;
  --sky1: #4fb2ff;
  --sky2: #bfe4ff;
  --sky3: #d9eeff;
  --pixel: "Press Start 2P", "Courier New", monospace;
  --term: "VT323", "Courier New", monospace;
  --win: Tahoma, Verdana, "Segoe UI", Geneva, sans-serif;
  --bevel-out: inset -1px -1px #0a0a0a, inset 1px 1px #ffffff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
  --bevel-in: inset -1px -1px #ffffff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px #808080;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--sky3); color: #000;
  font-family: var(--win);
  touch-action: none; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
button { font-family: inherit; cursor: pointer; color: inherit; }

/* ── cielo ── */
#sky { position: fixed; inset: 0; background: linear-gradient(180deg, var(--sky1) 0%, #8fd0ff 38%, var(--sky2) 62%, var(--sky3) 78%); overflow: hidden; }
#sky .sun {
  position: absolute; top: 9%; right: 12%; width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle, #fffbe0 0 45%, #ffe36a 46% 100%); border: 5px solid #ffb627;
  box-shadow: 0 0 60px 20px rgba(255, 240, 160, 0.6);
}
.cloud { position: absolute; width: 130px; height: 44px; background: #fff; border-radius: 30px; animation: drift 60s linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 60px; height: 60px; top: -30px; left: 18px; }
.cloud::after { width: 46px; height: 46px; top: -20px; left: 64px; }
.cloud.c1 { top: 9%; left: -20%; }
.cloud.c2 { top: 20%; left: -40%; transform: scale(0.7); animation-duration: 85s; animation-delay: -30s; }
.cloud.c3 { top: 4%; left: -30%; transform: scale(1.2); animation-duration: 110s; animation-delay: -70s; }
@keyframes drift { to { left: 120%; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }

/* ── effetto tubo catodico ── */
#crt {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.38) 100%);
  animation: flicker 0.15s infinite;
}
body[data-screen="none"] #crt { opacity: 0.5; }
@keyframes flicker { 50% { opacity: 0.94; } }

/* ── modalità Tempi d'oro: look da videocassetta ── */
#vhs { display: none; position: fixed; inset: 0; pointer-events: none; z-index: 12; font-family: var(--term); color: #fff; text-shadow: 2px 2px 0 #000, 0 0 6px rgba(255, 255, 255, 0.6); font-size: 26px; }
#vhs .play { position: absolute; top: calc(110px + var(--safe-top)); left: 14px; }
#vhs .date { position: absolute; bottom: calc(14px + var(--safe-bottom)); left: 14px; }
body.mode-oro #vhs { display: block; }
body.mode-oro #vhs .play { animation: blink 1.2s steps(1) infinite; }
body.mode-oro #game { filter: sepia(0.35) saturate(1.25) contrast(1.06) hue-rotate(-8deg); }
body.mode-oro[data-screen="scr-loading"] #vhs { display: none; }

/* ── schermate ── */
.screen {
  position: fixed; inset: 0; display: none; z-index: 20;
  flex-direction: column; align-items: center; justify-content: center;
  padding: calc(14px + var(--safe-top)) 12px calc(14px + var(--safe-bottom));
  overflow: hidden;
}
.screen.on { display: flex; }
.screen.desk { background: rgba(0, 128, 128, 0.86); padding-bottom: calc(52px + var(--safe-bottom)); }

/* ── BIOS ── */
#scr-loading { background: #000; align-items: stretch; justify-content: flex-start; z-index: 40; }
.bios { font-family: var(--term); color: #c8c8c8; font-size: 21px; line-height: 1.15; padding: 8px 4px; }
.bios-head { display: flex; justify-content: space-between; gap: 8px; color: #fff; }
.bios-head .star { color: #4cf; }
#bios-lines .ok { color: #5f5; }
.bios-bar { margin-top: 10px; color: #fff; white-space: pre; }
#load-text::after { content: "_"; animation: blink 0.8s steps(1) infinite; }

/* ── titolo arcade ── */
#scr-title { justify-content: space-between; }
.hiscore {
  font-family: var(--pixel); font-size: 10px; color: #fff; text-shadow: 2px 2px 0 #000;
  background: rgba(0, 0, 0, 0.6); padding: 7px 10px; letter-spacing: 1px;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hiscore .lbl { color: var(--red); }
.hiscore b { color: var(--yel); font-weight: 400; }
.logo { text-align: center; margin: 1vh 0 auto; } /* in alto, lascia libera la bici al centro */
.edition { font-family: var(--pixel); font-size: 9px; color: var(--yel); text-shadow: 2px 2px 0 #000; letter-spacing: 1px; animation: blink 1.6s steps(1) infinite; }
.wordart {
  position: relative; isolation: isolate; margin: 6px 0 0;
  font-family: "Arial Black", Impact, "Luckiest Guy", sans-serif; font-weight: 900; font-style: italic;
  font-size: clamp(50px, 16vw, 112px); line-height: 1.05; letter-spacing: -1px; padding: 0 10px;
  transform: perspective(320px) rotateX(18deg) skewX(-6deg);
  animation: wave 3s ease-in-out infinite;
}
.wordart span {
  position: relative; z-index: 1; display: inline-block;
  background: linear-gradient(180deg, #ff1e1e 0%, #ff8c00 22%, #ffef00 42%, #2ee62e 60%, #1e90ff 80%, #b026ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px #1a0030;
}
.wordart::before {
  content: attr(data-text); position: absolute; inset: 0; padding: 0 10px; z-index: 0;
  color: #3a0a52; -webkit-text-stroke: 2px #1a0030;
  text-shadow: 1px 1px #3a0a52, 2px 2px #3a0a52, 3px 3px #3a0a52, 4px 4px #3a0a52, 5px 5px #3a0a52, 6px 6px #2a0640, 7px 7px #2a0640, 8px 8px 6px rgba(0, 0, 0, 0.5);
  transform: translate(3px, 4px);
}
.wordart.amp { font-size: clamp(34px, 11vw, 76px); margin-top: -4px; }
@keyframes wave { 50% { transform: perspective(320px) rotateX(10deg) skewX(-10deg) translateY(-4px); } }
.subtitle {
  display: inline-block; margin-top: 10px; font-family: var(--pixel); font-size: clamp(12px, 4.2vw, 22px); color: #fff;
  background: linear-gradient(180deg, #ff2a6a, #b0004a); padding: 8px 10px 6px; border: 3px solid #fff; outline: 3px solid #000;
  text-shadow: 3px 3px 0 #000; transform: rotate(-2deg);
}
.title-bottom { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; max-width: 400px; }
.arcade-menu {
  width: 100%; background: rgba(0, 0, 20, 0.84); border: 4px double var(--cyan); padding: 8px 6px;
  display: flex; flex-direction: column; box-shadow: 0 0 0 3px #000, 0 0 18px rgba(0, 255, 255, 0.45);
}
.mi {
  position: relative; text-align: left; background: none; border: 0; padding: 12px 10px 12px 38px; min-height: 46px;
  font-family: var(--pixel); font-size: 14px; color: #fff; text-shadow: 2px 2px 0 #303; line-height: 1.3;
}
.mi b { font-weight: 400; color: var(--cyan); }
.mi::before { content: "▶"; position: absolute; left: 12px; color: var(--yel); opacity: 0; }
.mi.sel, .mi:hover, .mi:focus-visible { color: var(--yel); outline: none; }
.mi.sel::before, .mi:hover::before, .mi:focus-visible::before { opacity: 1; animation: blink 0.6s steps(1) infinite; }
.mi:active { transform: translateX(4px); }
.press-start { font-family: var(--pixel); font-size: 8px; color: #fff; text-shadow: 2px 2px 0 #000; animation: blink 1s steps(1) infinite; text-align: center; line-height: 1.6; }
.player-chip { font-family: var(--term); font-size: 20px; background: #000; color: var(--lime); border: 2px solid var(--lime); padding: 2px 12px; }
.player-chip:empty { display: none; }
.player-chip .edit { color: var(--yel); }
.title-bottom footer { font-family: var(--pixel); font-size: 8px; color: #fff; text-shadow: 2px 2px 0 #000; }
.heart { color: var(--red); display: inline-block; animation: blink 0.8s steps(1) infinite; }

/* ── finestre Windows 98 ── */
.win {
  width: 100%; max-width: 420px; max-height: 100%; display: flex; flex-direction: column;
  background: var(--w98); padding: 3px; box-shadow: var(--bevel-out), 6px 6px 0 rgba(0, 0, 0, 0.35);
  animation: winopen 0.18s steps(3);
}
.win.small { max-width: 330px; }
@keyframes winopen { from { transform: scale(0.3); opacity: 0.2; } }
.win-title {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-shrink: 0;
  background: linear-gradient(90deg, var(--navy), var(--navy2)); color: #fff;
  font-weight: 700; font-size: 14px; padding: 3px 3px 3px 6px; min-height: 28px;
}
.win-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-x { width: 26px; height: 22px; padding: 0; border: 0; background: var(--w98); color: #000; font-weight: 700; font-size: 12px; box-shadow: var(--bevel-out); flex-shrink: 0; }
.win-x:active { box-shadow: var(--bevel-in); }
.win-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow: auto; font-size: 15px; touch-action: pan-y; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg p { margin: 0; line-height: 1.35; }
.big-ico { font-size: 34px; line-height: 1; }
.win label { display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.in98 {
  font: 18px var(--win); padding: 8px; border: 0; background: #fff; color: #000; box-shadow: var(--bevel-in);
  user-select: text; -webkit-user-select: text; touch-action: manipulation; border-radius: 0;
}
.in98:focus { outline: 1px dotted #000; outline-offset: -5px; }
.row { display: flex; gap: 8px; width: 100%; }
.row.end { justify-content: flex-end; }
.row.pad { padding: 8px; }
.b98 { min-width: 92px; min-height: 42px; padding: 6px 14px; border: 0; background: var(--w98); color: #000; font: 700 15px var(--win); box-shadow: var(--bevel-out); }
.b98.def { box-shadow: var(--bevel-out), 0 0 0 1px #000; }
.b98:active { box-shadow: var(--bevel-in); padding: 7px 13px 5px 15px; }
.b98.grow { flex: 1; }
.b98.sq { min-width: 0; width: 44px; height: 44px; padding: 0; font-size: 16px; }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* Blocco note */
.notepad .menubar { font-size: 13px; padding: 3px 6px; display: flex; gap: 12px; flex-shrink: 0; }
.notepad .paper { background: #fff; box-shadow: var(--bevel-in); margin: 0 2px; padding: 8px; flex: 1; min-height: 0; }
.notepad pre { margin: 0; font-family: var(--term); font-size: 20px; line-height: 1.05; white-space: pre-wrap; color: #000; user-select: none; }

/* risultato */
.pixel-title { margin: 0; text-align: center; font-family: var(--pixel); font-weight: 400; font-size: 15px; line-height: 1.4; color: var(--navy); text-shadow: 2px 2px 0 #fff; }
.result #res-text { margin: 0; text-align: center; font-size: 14px; }
.lcd { background: #0b1a0b; box-shadow: var(--bevel-in); padding: 8px 10px 4px; text-align: center; font-family: var(--term); color: #3dff6a; text-shadow: 0 0 8px rgba(61, 255, 106, 0.7); }
.lcd small { display: block; font-size: 16px; letter-spacing: 2px; color: #1fae45; }
.lcd span { font-size: 64px; line-height: 0.95; }
.breakdown { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; box-shadow: var(--bevel-in); }
.breakdown td { padding: 5px 7px; border-bottom: 1px dotted #999; }
.breakdown td:nth-child(2) { color: #555; font-size: 12px; }
.breakdown td:last-child { text-align: right; font-weight: 700; }
#res-rank { text-align: center; font-size: 15px; min-height: 24px; }
#res-rank .big { font-family: var(--pixel); font-size: 20px; color: #c00000; }
.badge { display: inline-block; margin-top: 6px; font-family: var(--pixel); font-size: 10px; color: var(--yel); background: #000; padding: 6px 8px; animation: blink 0.7s steps(1) infinite; }
.small { font-size: 12px !important; color: #333; }
.spin { display: inline-block; animation: spin 1s steps(8) infinite; }

/* ── HIGH SCORES ── */
#scr-board.arcade { background: #000; justify-content: flex-start; gap: 10px; }
.hs-title { margin: 6px 0 0; font-family: var(--pixel); font-weight: 400; font-size: 22px; animation: rainbow 1.2s steps(6) infinite; text-shadow: 3px 3px 0 #300; }
@keyframes rainbow { 0% { color: #ff2a2a; } 17% { color: #ff9900; } 33% { color: #ffff00; } 50% { color: #00ff66; } 67% { color: #00ffff; } 83% { color: #ff00ff; } }
.hs-head, #board-list li { display: grid; grid-template-columns: 48px 1fr auto; gap: 8px; width: 100%; max-width: 440px; align-items: center; }
.hs-head { font-family: var(--pixel); font-size: 9px; color: #888; padding: 0 6px; }
#board-list { list-style: none; margin: 0; padding: 0 0 6px; width: 100%; max-width: 440px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; touch-action: pan-y; }
#board-list li { font-family: var(--pixel); font-size: 11px; padding: 4px 6px; color: var(--c, #fff); }
#board-list li:nth-child(7n+1) { --c: #ff4040; }
#board-list li:nth-child(7n+2) { --c: #ff9900; }
#board-list li:nth-child(7n+3) { --c: #ffff00; }
#board-list li:nth-child(7n+4) { --c: #00ff66; }
#board-list li:nth-child(7n+5) { --c: #00ffff; }
#board-list li:nth-child(7n+6) { --c: #5f8bff; }
#board-list li:nth-child(7n+7) { --c: #ff55ff; }
#board-list li.me { background: #222; outline: 2px solid #fff; }
#board-list li.me .nm::after { content: " ◀"; animation: blink 0.6s steps(1) infinite; }
#board-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.5; }
#board-list .nm small { display: block; font-family: var(--term); font-size: 16px; color: #aaa; }
#board-list .tm { text-align: right; }
#board-list .empty, #board-list .loading { display: block; text-align: center; color: #fff; line-height: 1.8; }
#board-foot { font-family: var(--term); font-size: 19px; color: #aaa; text-align: center; }
#board-foot b { color: var(--yel); font-weight: 400; }
.pix-btn { font-family: var(--pixel); font-size: 12px; color: #000; background: var(--yel); border: 0; padding: 14px 18px; box-shadow: 4px 4px 0 #f0f; }
.pix-btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #f0f; }

/* ── barra delle applicazioni ── */
.taskbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; height: calc(42px + var(--safe-bottom));
  padding: 5px 4px calc(5px + var(--safe-bottom)); background: var(--w98); box-shadow: inset 0 1px #fff, inset 0 2px var(--w98-light);
  align-items: center; gap: 6px; font-size: 13px;
}
body[data-screen="scr-name"] .taskbar, body[data-screen="scr-howto"] .taskbar, body[data-screen="scr-team"] .taskbar, body[data-screen="scr-crop"] .taskbar,
body[data-screen="scr-pause"] .taskbar, body[data-screen="scr-result"] .taskbar { display: flex; }
.taskbar .start { height: 32px; border: 0; background: var(--w98); box-shadow: var(--bevel-out); padding: 0 8px; font-size: 14px; }
.taskbar .start:active { box-shadow: var(--bevel-in); }
.taskbar .task { flex: 1; height: 32px; display: flex; align-items: center; padding: 0 8px; box-shadow: var(--bevel-in); background: #e8e8e8; font-weight: 700; white-space: nowrap; overflow: hidden; }
.taskbar .tray { height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 8px; box-shadow: inset 1px 1px var(--w98-dark), inset -1px -1px #fff; }

/* ── HUD ── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; display: none; }
#hud.on { display: block; }
.hud-top { position: absolute; top: calc(10px + var(--safe-top)); left: 10px; right: 64px; display: flex; gap: 8px; }
.hud-box { background: rgba(0, 0, 0, 0.72); border: 3px solid #fff; outline: 2px solid #000; padding: 6px 8px 5px; font-family: var(--pixel); color: #fff; line-height: 1; }
.hud-box small { display: block; font-size: 8px; margin-bottom: 5px; color: var(--red); }
.hud-time span { font-size: 15px; color: var(--yel); }
.hud-rings small { color: var(--cyan); }
.hud-rings span { font-size: 13px; }
.hud-rings .ico { font-style: normal; font-size: 12px; }
.hud-rings b { font-weight: 400; }
.hud-rings.bump { animation: bump 0.2s steps(2); }
@keyframes bump { 50% { transform: scale(1.15); } }
.hud-progress { position: absolute; top: calc(68px + var(--safe-top)); left: 14px; right: 72px; }
.hud-progress .track { position: relative; height: 12px; border: 2px solid #fff; outline: 2px solid #000; background: repeating-linear-gradient(90deg, #1e3a8a 0 6px, #000 6px 8px); }
.hud-progress .tick { position: absolute; top: -4px; width: 2px; height: 16px; background: #fff; }
.hud-progress .tick::after { content: attr(data-l); position: absolute; top: 18px; left: -6px; font: 8px var(--pixel); color: #fff; text-shadow: 1px 1px 0 #000; }
.hud-progress .goal { position: absolute; right: -14px; top: -12px; font-size: 22px; }
#hud-bike { position: absolute; top: -14px; left: 0; font-size: 22px; transform: translateX(-50%) scaleX(-1); }
#hud-power { height: 8px; margin-top: 22px; width: 60%; background: #000; border: 2px solid #fff; outline: 2px solid #000; opacity: 0; }
#hud-power i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); }
#hud-power[data-kind="turbo"], #hud-power[data-kind="brillo"] { opacity: 1; }
#hud-power[data-kind="turbo"] i { background: repeating-linear-gradient(90deg, #ffcc00 0 6px, #ff6600 6px 8px); }
#hud-power[data-kind="brillo"] i { background: repeating-linear-gradient(90deg, #ff66cc 0 6px, #ff9900 6px 8px); }
#btn-pause { position: absolute; pointer-events: auto; right: 10px; top: calc(10px + var(--safe-top)); }
#bell-ico { position: absolute; left: 50%; bottom: calc(18px + var(--safe-bottom)); font-size: 34px; opacity: 0; transform: translateX(-50%); }
#bell-ico.ring { animation: bell 0.5s steps(5); }
@keyframes bell { 0% { opacity: 1; transform: translateX(-50%) rotate(0) scale(1.3); } 25% { transform: translateX(-50%) rotate(25deg) scale(1.3); } 50% { transform: translateX(-50%) rotate(-25deg) scale(1.2); } 100% { opacity: 0; transform: translateX(-50%) rotate(0) scale(1); } }

#btn-mute { position: fixed; z-index: 30; right: 10px; bottom: calc(10px + var(--safe-bottom)); }
body[data-screen="none"] #btn-mute { bottom: auto; top: calc(60px + var(--safe-top)); }
body[data-screen="scr-loading"] #btn-mute { display: none; }
body[data-screen="scr-name"] #btn-mute, body[data-screen="scr-howto"] #btn-mute, body[data-screen="scr-team"] #btn-mute, body[data-screen="scr-crop"] #btn-mute,
body[data-screen="scr-pause"] #btn-mute, body[data-screen="scr-result"] #btn-mute { display: none; }

/* ── banner di tappa ── */
#stage {
  position: fixed; left: 0; right: 0; top: 30%; z-index: 14; pointer-events: none; text-align: center; opacity: 0;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 80, 0.85) 20%, rgba(0, 0, 80, 0.85) 80%, transparent);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
#stage small { font-family: var(--pixel); font-size: 12px; color: var(--yel); text-shadow: 2px 2px 0 #000; }
#stage b { font-family: var(--pixel); font-weight: 400; font-size: clamp(14px, 5vw, 26px); color: #fff; text-shadow: 3px 3px 0 #f0f; line-height: 1.4; }
#stage span { font-family: var(--term); font-size: 22px; color: var(--cyan); }
#stage.on { animation: stage 2.8s steps(28) forwards; }
@keyframes stage { 0% { opacity: 0; transform: translateX(100%); } 12% { opacity: 1; transform: none; } 85% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateX(-100%); } }

/* ── scritte comiche a pixel ── */
#popups { position: fixed; inset: 0; pointer-events: none; z-index: 15; overflow: hidden; }
.pop {
  position: absolute; left: 50%; top: 36%; font-family: var(--pixel); font-size: clamp(20px, 7.5vw, 40px); color: #fff; white-space: nowrap;
  text-shadow: 3px 0 #000, -3px 0 #000, 0 3px #000, 0 -3px #000, 3px 3px #000, -3px -3px #000, 3px -3px #000, -3px 3px #000, 6px 6px 0 var(--sh, #f0f);
  transform: translate(-50%, -50%) rotate(var(--rot));
  animation: pop 1.1s steps(11) forwards;
}
.pop.crash { color: var(--red); --sh: #600; }
.pop.cow { color: #fff; --sh: #555; top: 28%; }
.pop.smash { color: var(--yel); --sh: #f60; }
.pop.turbo { color: #ffcc00; --sh: #a40; font-size: clamp(14px, 5.2vw, 30px); }
.pop.brillo { color: #ff66cc; --sh: #f90; font-size: clamp(14px, 5.2vw, 30px); }
.pop.bouquet { color: #ffb3d9; --sh: #c06; font-size: clamp(16px, 6vw, 34px); }
.pop.finish { color: var(--yel); --sh: #f0f; top: 22%; font-size: clamp(24px, 8.5vw, 52px); }
@keyframes pop {
  0% { transform: translate(-50%, -50%) rotate(var(--rot)) scale(0.2); opacity: 0; }
  20% { transform: translate(-50%, -50%) rotate(var(--rot)) scale(1.15); opacity: 1; }
  75% { transform: translate(-50%, -60%) rotate(var(--rot)) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -80%) rotate(var(--rot)) scale(0.9); opacity: 0; }
}
.ringpop { position: absolute; top: 54%; font-family: var(--pixel); font-size: 12px; color: var(--yel); text-shadow: 2px 2px 0 #000; animation: rise 0.7s steps(7) forwards; }
@keyframes rise { to { transform: translateY(-70px); opacity: 0; } }

#countdown {
  position: fixed; left: 50%; top: 40%; z-index: 16; pointer-events: none; opacity: 0;
  font-family: var(--pixel); font-size: 72px; color: var(--yel);
  text-shadow: 5px 0 #000, -5px 0 #000, 0 5px #000, 0 -5px #000, 9px 9px 0 #f0f;
  transform: translate(-50%, -50%);
}
#countdown.on { animation: count 0.9s steps(9) forwards; }
#countdown.go { color: var(--lime); font-size: 56px; }
@keyframes count { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2.4); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); } }

#toast {
  position: fixed; left: 50%; bottom: 18%; z-index: 30; pointer-events: none; opacity: 0; transform: translateX(-50%);
  background: #ffffe1; color: #000; border: 1px solid #000; padding: 6px 10px; font: 15px var(--win); box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.4); white-space: nowrap;
}
#toast.on { animation: toast 1.8s steps(1, end) forwards; }
@keyframes toast { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }

/* fumetto di Sara: dialogo da gioco di ruolo */
#bubble {
  position: fixed; z-index: 16; pointer-events: none; display: none; transform: translate(-50%, -100%);
  background: var(--navy); color: #fff; border: 3px solid #fff; outline: 3px solid #000; padding: 8px 14px 8px 12px;
  font-family: var(--term); font-size: 24px; line-height: 1; max-width: 240px; text-align: left;
}
#bubble b { color: var(--yel); font-weight: 400; }
#bubble i { font-style: normal; position: absolute; right: 4px; bottom: 1px; font-size: 14px; animation: blink 0.6s steps(1) infinite; }
#bubble.on { display: block; }

/* ── effetti speciali ── */
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 9; opacity: 0; }
#flash.on.crash { animation: flash 0.3s steps(3); background: rgba(255, 0, 0, 0.35); }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
#fx-speed {
  position: fixed; inset: -20%; pointer-events: none; z-index: 8; opacity: 0;
  background: repeating-conic-gradient(from 0deg at 50% 45%, rgba(255, 255, 255, 0.55) 0 1.2deg, transparent 1.2deg 7deg);
  mask-image: radial-gradient(circle at 50% 45%, transparent 0 28%, #000 60%);
  -webkit-mask-image: radial-gradient(circle at 50% 45%, transparent 0 28%, #000 60%);
}
.fx-turbo #fx-speed { opacity: 1; animation: speedlines 0.18s steps(2) infinite; }
@keyframes speedlines { 50% { transform: rotate(2.5deg); } }
#fx-brillo { position: fixed; inset: 0; pointer-events: none; z-index: 8; opacity: 0; background: radial-gradient(circle, transparent 40%, rgba(255, 60, 200, 0.3)); overflow: hidden; }
.fx-brillo #fx-brillo { opacity: 1; }
#fx-brillo i { position: absolute; bottom: -40px; width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.85); animation: bubble 2.4s steps(24) infinite; }
#fx-brillo i:nth-child(1) { left: 8%; animation-delay: 0s; }
#fx-brillo i:nth-child(2) { left: 22%; animation-delay: 0.7s; width: 12px; height: 12px; }
#fx-brillo i:nth-child(3) { left: 48%; animation-delay: 1.3s; }
#fx-brillo i:nth-child(4) { left: 70%; animation-delay: 0.3s; width: 28px; height: 28px; }
#fx-brillo i:nth-child(5) { left: 86%; animation-delay: 1.8s; width: 14px; height: 14px; }
#fx-brillo i:nth-child(6) { left: 94%; animation-delay: 1.0s; }
@keyframes bubble { to { transform: translateY(-110vh) translateX(20px); } }

@media (min-width: 700px) and (min-height: 700px) {
  .hud-time span { font-size: 20px; }
  .mi { font-size: 16px; }
}
@media (max-height: 640px) {
  .press-start, .title-bottom footer { display: none; }
  .mi { min-height: 40px; padding-top: 9px; padding-bottom: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  #crt, .wordart, .edition, .press-start, .heart, .cloud { animation: none !important; }
}
body[data-screen="scr-title"] #vhs .date, body[data-screen="scr-board"] #vhs { display: none; }

/* ── squadra personalizzata ── */
.slot {
  margin: 0; padding: 8px 8px 10px; border: 0; box-shadow: inset -1px -1px #fff, inset 1px 1px #808080, inset -2px -2px #808080, inset 2px 2px #fff;
  display: grid; grid-template-columns: 88px 1fr; gap: 6px 10px; align-items: center;
}
.slot legend { font-weight: 700; font-size: 13px; padding: 0 4px; background: var(--w98); }
.slot .face { width: 88px; height: 104px; display: flex; align-items: center; justify-content: center; background: #008080; box-shadow: var(--bevel-in); }
.slot .face img { max-width: 82px; max-height: 98px; }
.slot-side { display: flex; flex-direction: column; gap: 6px; }
.slot .who { font-size: 12px; color: #333; }
.slot .b98 { min-height: 38px; display: flex; align-items: center; justify-content: center; }
.slot .file { position: relative; overflow: hidden; cursor: pointer; }
.slot .file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.swatches { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; }
.sw { width: 25px; height: 25px; border: 0; padding: 0; background: var(--c); box-shadow: var(--bevel-out); }
.sw.on { outline: 2px dotted #000; outline-offset: 2px; }
#crop-canvas { width: 100%; max-width: 300px; aspect-ratio: 300 / 360; align-self: center; box-shadow: var(--bevel-in); touch-action: none; cursor: grab; }
.zoom { flex-direction: row !important; align-items: center; gap: 8px !important; }
.zoom input { flex: 1; }
