/* WolskiDev Timer — stile "Neon Arena" */
@font-face { font-family: Anton; src: url(fonts/anton.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: Inter; src: url(fonts/inter.woff2) format('woff2'); font-weight: 400 800; font-display: swap; }

:root {
  --bg: #07070A;
  --card: #121218;
  --line: #22222B;
  --line2: #2A2A33;
  --fg: #FFFFFF;
  --muted: #9A9AA6;
  --lime: #C6FF3D;
  --pink: #FF3D9A;
  --orange: #FF8A1F;
  --cyan: #3DE0FF;
  --yellow: #FFE14D;
  --display: Anton, Impact, 'Arial Narrow', sans-serif;
  font-family: Inter, -apple-system, system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; touch-action: manipulation; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
body.running { overflow: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
svg { display: block; }

@keyframes rise { from { opacity: 0; transform: translateY(22px); } }
@keyframes bye { to { opacity: 0; transform: scale(.9); } }

/* Pulsante tondo a contorno */
.o-btn { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 2px solid var(--line2); display: grid; place-items: center; color: inherit; transition: transform .2s; }
.o-btn svg { width: 20px; height: 20px; }
.o-btn:active { transform: scale(.9); }
.o-btn.md { width: 64px; height: 64px; }
.o-btn.md svg { width: 24px; height: 24px; }
.o-btn.txt { font-weight: 800; font-size: 13px; letter-spacing: .04em; }
.o-btn:disabled { opacity: .3; }

/* Pulsanti a pillola */
.btn { flex: 1; height: 58px; border-radius: 29px; font-weight: 800; font-size: 17px; transition: transform .2s; }
.btn:active { transform: scale(.96); }
.btn.lime { background: var(--lime); color: var(--bg); }
.btn.pink { background: var(--pink); color: var(--bg); }
.btn.line { border: 2px solid var(--line2); color: var(--fg); }
.btn.wide { width: 100%; flex: none; }
button:disabled { opacity: .35; pointer-events: none; }

/* ---------- Home ---------- */
.home { padding: calc(env(safe-area-inset-top) + 28px) 20px 0; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; }
.brand { margin: 0; font-family: var(--display); font-weight: 400; font-size: 64px; line-height: .88; letter-spacing: .01em; text-transform: uppercase; animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; }
.brand .dot { color: var(--lime); }
@media (max-width: 370px) { .brand { font-size: 50px; } }

.quick { position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; text-align: left;
  min-height: 132px; padding: 18px 20px; border-radius: 22px; background: var(--lime); color: var(--bg);
  animation: rise .6s .05s cubic-bezier(.2, .8, .2, 1) both; transition: transform .25s; }
.quick:active { transform: scale(.97); }
.quick-stripes { position: absolute; right: -20px; top: -10px; width: 180px; height: 180px; border-radius: 50%;
  background: repeating-linear-gradient(135deg, rgba(7,7,10,.12) 0 10px, transparent 10px 22px); animation: turn 30s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
.quick-tx { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.quick-k { font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.quick-n { font-family: var(--display); font-size: 40px; line-height: 1; text-transform: uppercase; overflow-wrap: anywhere; }
.quick-n.long { font-size: 32px; }
.quick-m { font-size: 13px; font-weight: 600; }
.quick-play { position: relative; flex: none; width: 64px; height: 64px; border-radius: 50%; background: var(--bg); color: var(--lime); display: grid; place-items: center; }
.quick-play svg { width: 26px; height: 26px; transform: translateX(2px); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 22px; padding: 14px 12px; border-radius: 18px; text-align: left;
  background: var(--c); color: var(--bg); animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(.1s + var(--i) * 50ms); transition: transform .2s; }
.tile:active { transform: scale(.94); }
.tile svg { width: 22px; height: 22px; }
.tile span { font-family: var(--display); font-size: 22px; text-transform: uppercase; line-height: 1; }
.tile small { position: absolute; top: 14px; right: 12px; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile small:not(:empty)::before { content: "● "; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.sec-h { display: flex; justify-content: space-between; align-items: baseline; padding-top: 4px; margin-bottom: -8px; }
.sec-h h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 26px; text-transform: uppercase; }
.sec-h span { font-size: 13px; color: var(--muted); }

.wlist { display: flex; flex-direction: column; gap: 8px; }
.wcard { display: flex; flex-direction: column; gap: 10px; width: 100%; text-align: left; padding: 14px 16px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); color: var(--fg);
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(.15s + var(--i) * 40ms); transition: transform .2s, border-color .2s; }
.wcard:active { transform: scale(.98); border-color: var(--line2); }
.wcard.bye { animation: bye .3s ease-in forwards; }
.w-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.w-l { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.w-tag { font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.w-tag.round { color: var(--pink); }
.w-tag.tabata { color: var(--orange); }
.w-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-tot { font-family: var(--display); font-size: 30px; line-height: 1; flex: none; }
.pbar { display: flex; gap: 2px; height: 4px; }
.pbar i { display: block; min-width: 1px; border-radius: 2px; background: var(--c); }
.w-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.w-sum { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-act { display: flex; gap: 6px; flex: none; }
.w-act span { width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--line2); display: grid; place-items: center; color: var(--muted); }
.w-act svg { width: 14px; height: 14px; }
.empty { margin: 0; padding: 18px 16px; border-radius: 18px; border: 1.5px dashed var(--line2); color: var(--muted); font-size: 14px; line-height: 1.5; text-align: center; }
.empty b { color: var(--fg); }
.bottom-space { height: calc(30px + env(safe-area-inset-bottom)); }

.banner { position: fixed; z-index: 60; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%);
  padding: 12px 20px; border-radius: 30px; font-weight: 800; font-size: 15px; white-space: nowrap; background: var(--bg); color: var(--lime); border: 2px solid var(--lime);
  box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.toast { position: fixed; z-index: 70; left: 50%; bottom: calc(40px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  padding: 12px 18px; border-radius: 16px; background: var(--card); border: 1px solid var(--line2); font-weight: 600; font-size: 15px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .4s cubic-bezier(.2, .9, .2, 1.3); width: max-content; max-width: 88vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Allenamento / cronometro ---------- */
.run { --ph: var(--cyan); --ink: #07070A; --lineInk: rgba(7,7,10,.25);
  position: fixed; inset: 0; z-index: 10; overflow: hidden; color: var(--ink); background: var(--ph);
  display: flex; flex-direction: column; gap: 16px; transition: color .3s;
  padding: calc(env(safe-area-inset-top) + 16px) calc(env(safe-area-inset-right) + 20px) calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 20px); }
.wipes, .wipes > div { position: absolute; inset: 0; }
.wipes > div { background: repeating-linear-gradient(135deg, rgba(0,0,0,.05) 0 14px, transparent 14px 34px), var(--c); }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.run > :not(.wipes):not(.flash):not(#burst):not(.confirm) { position: relative; }
.run .o-btn { border-color: var(--lineInk); }

.r-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.r-title { flex: 1; min-width: 0; text-align: center; font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-tot { display: flex; flex-direction: column; align-items: flex-end; min-width: 48px; line-height: 1; }
.r-tot b { font-family: var(--display); font-weight: 400; font-size: 22px; font-variant-numeric: tabular-nums; }
.r-tot span { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .6; margin-top: 3px; }

.r-head { display: flex; flex-direction: column; padding-top: 12px; }
.r-label { font-family: var(--display); font-size: clamp(56px, 18vw, 120px); line-height: .95; text-transform: uppercase; transform-origin: left center; }
.r-sub { font-size: 15px; font-weight: 600; margin-top: 4px; }
.r-stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.digits { display: flex; font-family: var(--display); line-height: .8; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.digits .d { position: relative; display: inline-block; width: .5em; height: .82em; overflow: visible; }
.digits .d.c { width: .24em; }
.digits .d > span { position: absolute; left: 0; right: 0; top: 0; text-align: center; }
.digits .d > span.in { animation: rollIn .4s cubic-bezier(.2, .9, .25, 1.1) both; }
.digits .d > span.out { animation: rollOut .3s cubic-bezier(.5, 0, .75, 0) both; }
@keyframes rollIn { from { transform: translateY(40%); opacity: 0; } }
@keyframes rollOut { to { transform: translateY(-40%); opacity: 0; } }

.r-foot { display: flex; flex-direction: column; gap: 16px; }
.pills { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 6px; }
.pills:empty { display: none; }
.pills i { height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--ink) 18%, transparent); transition: background .3s; }
.pills i.on { background: var(--ink); }
.pills i.cur { background: color-mix(in srgb, var(--ink) 55%, transparent); }
.pills.bar { display: block; height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--ink) 18%, transparent); overflow: hidden; }
.pills.bar i { display: block; height: 100%; width: 0; border-radius: 5px; background: var(--ink); }
.controls { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; }
.ctl-big { width: 120px; height: 120px; border-radius: 50%; background: var(--ink); color: var(--ph); display: grid; place-items: center; transition: transform .2s, background .3s, color .3s; }
.ctl-big svg { width: 40px; height: 40px; }
.ctl-big:active { transform: scale(.93); }
.done-actions { display: none; gap: 10px; }
#burst { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

/* Stati */
.run.paused .digits { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .3; } }
.run.done { --ink: #fff; --lineInk: rgba(255,255,255,.25); }
.run.done .r-label { color: var(--lime); }
.run.done .controls, .run.done .pills { display: none; }
.run.done .done-actions { display: flex; }
.run.done .btn.line { border-color: rgba(255,255,255,.25); }

.confirm { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 24px; color: var(--fg);
  background: rgba(7,7,10,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.confirm-box { width: min(100%, 360px); padding: 24px 20px 20px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); text-align: center; animation: rise .3s both; }
.confirm-box b { font-family: var(--display); font-weight: 400; font-size: 28px; text-transform: uppercase; line-height: 1.05; display: block; }
.confirm-act { display: flex; gap: 10px; margin-top: 20px; }

/* Entrata */
.run.enter .r-head { animation: rise .6s .15s cubic-bezier(.2, .9, .2, 1) both; }
.run.enter .r-stage { animation: pop .7s .2s cubic-bezier(.2, .9, .2, 1.15) both; }
.run.enter .r-foot { animation: rise .6s .3s cubic-bezier(.2, .9, .2, 1) both; }
@keyframes pop { from { opacity: 0; transform: scale(.7); } }

/* Cronometro */
.watch { --ph: var(--cyan); }
.w-read { display: flex; flex-direction: column; align-items: center; }
.cs { font-family: var(--display); font-size: 44px; line-height: 1; opacity: .6; margin-top: 4px; font-variant-numeric: tabular-nums; }
.laps { max-height: 22vh; overflow-y: auto; border-radius: 16px; background: rgba(7,7,10,.08); -webkit-overflow-scrolling: touch; }
.laps:empty { display: none; }
.lap { display: flex; align-items: baseline; gap: 10px; padding: 9px 14px; font-weight: 700; font-variant-numeric: tabular-nums; border-bottom: 1px solid rgba(7,7,10,.1); }
.lap:last-child { border-bottom: 0; }
.lap .ln { flex: 1; min-width: 0; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lap .ls { font-family: var(--display); font-weight: 400; font-size: 22px; }
.lap .lt { min-width: 80px; text-align: right; font-size: 13px; opacity: .6; }
.lap.live .ls { opacity: .65; }
.lap.best .ln::after { content: " · migliore"; }
.lap.worst .ln::after { content: " · più lento"; }
.lap.best { background: rgba(7,7,10,.1); }

/* Orizzontale */
@media (orientation: landscape) and (max-height: 600px) {
  .run { display: grid; grid-template-columns: 1fr minmax(280px, 40%); grid-template-rows: auto auto 1fr auto; column-gap: 28px; row-gap: 8px; padding-top: calc(env(safe-area-inset-top) + 10px); padding-bottom: calc(env(safe-area-inset-bottom) + 14px); }
  .r-top { grid-column: 1 / -1; }
  .r-head { grid-column: 2; grid-row: 2; padding-top: 0; }
  .r-label { font-size: clamp(40px, 8vw, 80px); }
  .r-stage { grid-column: 1; grid-row: 2 / 5; }
  .r-foot { grid-column: 2; grid-row: 4; }
  .ctl-big { width: 96px; height: 96px; }
  .laps { max-height: 30vh; }
}

/* ---------- Pannelli dal basso ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(7,7,10,.7); opacity: 0; transition: opacity .3s; }
.sheet-bg.show { opacity: 1; }
.sheet { position: fixed; z-index: 21; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 94vh; overflow-y: auto;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; background: var(--card); border-top: 1px solid var(--line);
  transform: translateY(105%); transition: transform .45s cubic-bezier(.2, .95, .2, 1); }
.sheet.show { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line2); margin: 0 auto 14px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Editor */
.seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 30px; border: 2px solid var(--line2); margin-bottom: 12px; }
.seg button { position: relative; z-index: 1; height: 44px; border-radius: 24px; font-family: var(--display); font-size: 20px; text-transform: uppercase; color: var(--muted); transition: color .3s; }
.seg button.sel { color: var(--bg); }
.seg-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 24px; background: var(--pink); transition: transform .4s cubic-bezier(.2, .9, .2, 1.1), background .3s; }
.seg.tabata .seg-pill { transform: translateX(100%); background: var(--orange); }
#kName { width: 100%; height: 50px; border-radius: 16px; margin-bottom: 10px; padding: 0 16px; outline: none;
  background: var(--bg); border: 1px solid var(--line); color: var(--fg); font: inherit; font-size: 17px; -webkit-user-select: text; user-select: text; }
#kName:focus { border-color: var(--lime); }
.fields { display: flex; flex-direction: column; gap: 8px; }
.frow { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line);
  box-shadow: inset 4px 0 0 var(--c, var(--line2)); animation: rise .3s cubic-bezier(.2, .8, .2, 1) both; }
.frow .fl { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; }
.frow .fl small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.step { display: flex; align-items: center; gap: 4px; }
.step button { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--line2); font-size: 22px; font-weight: 600; line-height: 1; touch-action: none; display: grid; place-items: center; }
.step button:active { background: var(--line2); }
.step .val { width: auto; min-width: 78px; height: 42px; padding: 0 6px; border: 0; border-radius: 10px; border-bottom: 2px dashed var(--line2);
  font-family: var(--display); font-size: 28px; font-weight: 400; font-variant-numeric: tabular-nums; }
.k-total { margin: 14px 2px 8px; }
.k-total .pbar { height: 6px; }
.k-total-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; font-weight: 700; color: var(--muted); font-size: 14px; }
.k-total-row b { font-family: var(--display); font-weight: 400; font-size: 32px; color: var(--fg); font-variant-numeric: tabular-nums; }

/* Rotella */
#pickBg { z-index: 40; }
.picker { z-index: 41; }
.pk-title { text-align: center; font-family: var(--display); font-size: 26px; text-transform: uppercase; margin-bottom: 6px; }
.pk-wheels { position: relative; display: flex; justify-content: center; align-items: center; gap: 4px; height: 220px; margin-bottom: 14px;
  -webkit-mask-image: linear-gradient(transparent, #000 28%, #000 72%, transparent); mask-image: linear-gradient(transparent, #000 28%, #000 72%, transparent); }
.pk-wheels::before { content: ""; position: absolute; left: 10px; right: 10px; top: 88px; height: 44px; border-radius: 22px; border: 2px solid var(--lime); pointer-events: none; }
.wheel { position: relative; width: 92px; height: 220px; padding: 88px 0; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; perspective: 600px; overscroll-behavior: contain; }
.wheel::-webkit-scrollbar { display: none; }
.wheel > div { height: 44px; line-height: 44px; text-align: center; font-family: var(--display); font-size: 32px; font-variant-numeric: tabular-nums;
  scroll-snap-align: center; cursor: pointer; will-change: transform, opacity; }
.pk-unit { font-size: 15px; font-weight: 700; color: var(--muted); margin-right: 12px; }

/* Suono */
#sndBg { z-index: 30; }
.snd-sheet { z-index: 31; }
.snd-h { margin: 0 2px 4px; font-family: var(--display); font-weight: 400; font-size: 34px; text-transform: uppercase; }
.snd-p { margin: 0 2px 14px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.snd-list { display: flex; flex-direction: column; gap: 8px; }
.snd { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px; border-radius: 16px; background: var(--bg); border: 2px solid var(--line); transition: border-color .2s; }
.snd.sel { border-color: var(--lime); }
.snd-ic { font-size: 26px; flex: none; }
.snd-tx { flex: 1; min-width: 0; }
.snd-tx b { display: block; font-size: 16px; }
.snd-tx small { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.snd-play { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 2px solid var(--line2); display: grid; place-items: center; font-size: 12px; }
.snd.sel .snd-play { background: var(--lime); border-color: var(--lime); color: var(--bg); }
.snd-voice { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; margin-top: 10px; padding: 14px; border-radius: 16px; background: var(--bg); border: 2px solid var(--line); }
.switch { position: relative; flex: none; width: 52px; height: 32px; border-radius: 16px; background: var(--line2); transition: background .25s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .3s cubic-bezier(.2, .9, .2, 1.3); }
.snd-voice.on .switch { background: var(--lime); }
.snd-voice.on .switch::after { transform: translateX(20px); background: var(--bg); }
.snd-note { margin: 14px 2px; color: var(--muted); font-size: 13px; text-align: center; }
.snd-note b { color: var(--fg); }

@media (prefers-reduced-motion: reduce) {
  .quick-stripes, .tile small::before { animation: none; }
}
