/* ============ tokens ============ */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, .10);
  --blue: #2a78d6;
  --blue-dark: #1c5cab;
  --orange: #eb6834;
  --green: #0ca30c;
  --green-text: #006300;
  --red: #d03b3b;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(11, 11, 11, .07);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--page);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.7;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

/* ============ layout ============ */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 42px; flex-shrink: 0; display: flex; align-items: center; }
.topbar-left { margin-right: auto; display: flex; align-items: center; gap: 12px; }
.who { color: var(--ink-2); font-size: 14px; }
.content { max-width: 1060px; margin: 0 auto; padding: 28px 16px 60px; }
.page-title { margin: 0 0 20px; font-size: 24px; }

.tabs { display: flex; gap: 4px; }
.tab {
  border: none; background: none; padding: 8px 16px; border-radius: 10px;
  cursor: pointer; color: var(--ink-2); font-weight: 600; font-size: 14px;
  transition: background .2s, color .2s;
}
.tab:hover { background: rgba(42, 120, 214, .08); }
.tab.active { background: var(--blue); color: #fff; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.card-title { margin: 0 0 16px; font-size: 16px; }

/* ============ buttons & fields ============ */
.btn {
  border: none; border-radius: 12px; padding: 10px 20px; cursor: pointer;
  font-weight: 700; font-size: 14px; transition: transform .15s, box-shadow .15s, background .2s;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); box-shadow: 0 4px 14px rgba(42, 120, 214, .35); }
.btn-success { background: var(--green-text); color: #fff; }
.btn-success:hover { box-shadow: 0 4px 14px rgba(12, 163, 12, .35); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { box-shadow: 0 4px 14px rgba(208, 59, 59, .35); }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--ink-2); }
.btn-ghost:hover { background: rgba(11, 11, 11, .05); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; }
.field span { color: var(--ink-2); font-weight: 600; }
.field input, .field select {
  border: 1.5px solid var(--grid); border-radius: 10px; padding: 10px 12px;
  background: #fff; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42, 120, 214, .15);
}

/* ============ login ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #eaf2fd 0%, var(--page) 55%, #fdf0e9 100%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow);
  padding: 28px 26px; text-align: center;
}
.login-chara { width: 130px; margin: 0 auto 4px; }
.login-title { margin: 0; font-size: 22px; }
.slogan {
  margin: 6px 0 24px; color: var(--blue); font-size: 12px; font-weight: 800;
  letter-spacing: .38em; direction: ltr; text-indent: .38em;
}
.brand-slogan {
  color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .22em;
  direction: ltr; margin-right: 8px;
}
#login-form { text-align: right; }
#login-form input::placeholder { text-align: left; }

.pass-wrap { position: relative; display: block; }
.pass-wrap input { width: 100%; padding-left: 44px; }
.pass-toggle {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; padding: 6px;
  color: var(--muted); border-radius: 8px; display: flex; align-items: center;
  transition: color .15s, background .15s;
}
.pass-toggle:hover { color: var(--ink-2); background: rgba(11, 11, 11, .05); }

/* ============ run page ============ */
.run-hero { text-align: center; padding: 8px 0 24px; position: relative; }
.run-date { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink-2); }
.run-clock { margin: 2px 0 10px; font-size: 13px; color: var(--muted); }
.run-state { animation: fade-up .5s ease both; }
.chara-box { width: min(430px, 100%); margin: 0 auto 14px; }
.run-msg { font-size: 16px; color: var(--ink-2); margin: 8px 0 12px; }
.quote {
  font-size: 15.5px; color: var(--ink-2); line-height: 2.1; max-width: 440px;
  margin: 4px auto 22px; padding: 10px 18px; position: relative;
}
.quote::before, .quote::after {
  content: ''; position: absolute; right: 0; left: 0; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--grid), transparent);
}
.quote::before { top: 0; } .quote::after { bottom: 0; }

.level-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 14px; }
.level-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 14px; font-size: 13px; font-weight: 700; color: var(--ink-2);
  box-shadow: var(--shadow); animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
.level-chip b { color: var(--ink); }
.level-chip .ltr { direction: ltr; font-variant-numeric: tabular-nums; }
.level-chip:nth-child(2) { animation-delay: .08s; }
.level-chip:nth-child(3) { animation-delay: .16s; }
.level-none { color: var(--muted); font-size: 13px; }

.big-btn {
  width: 190px; height: 190px; border-radius: 50%; border: none; cursor: pointer;
  color: #fff; display: inline-flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; transition: transform .2s;
}
.big-btn:hover { transform: scale(1.05); }
.big-btn:active { transform: scale(.95); }
.big-btn-label { font-size: 34px; font-weight: 900; }
.big-btn-sub { font-size: 13px; opacity: .85; }
.big-btn-start {
  background: radial-gradient(circle at 35% 30%, #4b93e8, var(--blue) 60%, var(--blue-dark));
  box-shadow: 0 10px 30px rgba(42, 120, 214, .4);
  animation: pulse-blue 2s ease-in-out infinite;
}
.big-btn-end {
  background: radial-gradient(circle at 35% 30%, #ef8a5f, var(--orange) 60%, #c74a1d);
  box-shadow: 0 10px 30px rgba(235, 104, 52, .4);
  animation: pulse-orange 1.6s ease-in-out infinite;
}
@keyframes pulse-blue {
  0%, 100% { box-shadow: 0 10px 30px rgba(42,120,214,.4), 0 0 0 0 rgba(42,120,214,.35); }
  50% { box-shadow: 0 10px 30px rgba(42,120,214,.4), 0 0 0 22px rgba(42,120,214,0); }
}
@keyframes pulse-orange {
  0%, 100% { box-shadow: 0 10px 30px rgba(235,104,52,.4), 0 0 0 0 rgba(235,104,52,.35); }
  50% { box-shadow: 0 10px 30px rgba(235,104,52,.4), 0 0 0 22px rgba(235,104,52,0); }
}

.timer {
  font-size: 46px; font-weight: 900; letter-spacing: 2px; margin: 0 0 22px;
  font-variant-numeric: tabular-nums; color: var(--ink);
}

.done-title { margin: 6px 0 0; font-size: 26px; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.done-card {
  max-width: 330px; margin: 18px auto 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 20px; text-align: right;
}
.done-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.done-row span { color: var(--ink-2); }
.done-row + .done-row { border-top: 1px solid var(--grid); }
.done-dur b { color: var(--green-text); font-size: 16px; }

.history-card { max-width: 560px; margin: 0 auto; }
.history-list { display: flex; flex-direction: column; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 2px; font-size: 14px;
}
.history-item + .history-item { border-top: 1px solid var(--grid); }
.history-date { font-weight: 600; }
.history-dur { color: var(--green-text); font-weight: 700; font-variant-numeric: tabular-nums; }
.history-meta { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; flex: 1; padding: 0 8px; }
.meta-chip {
  background: rgba(42, 120, 214, .08); color: var(--blue-dark); border-radius: 20px;
  padding: 1px 10px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.meta-none { color: var(--muted); font-size: 11.5px; }
.ltr-inline { direction: ltr; display: inline-block; font-variant-numeric: tabular-nums; }
.history-open { color: var(--orange); font-weight: 700; font-size: 13px; }
.empty-note { color: var(--muted); font-size: 14px; text-align: center; padding: 14px 0; }

/* ============ dashboard ============ */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; animation: fade-up .5s ease both;
}
.tile:nth-child(2) { animation-delay: .06s; } .tile:nth-child(3) { animation-delay: .12s; }
.tile:nth-child(4) { animation-delay: .18s; } .tile:nth-child(5) { animation-delay: .24s; }
.tile-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.tile-value { font-size: 27px; font-weight: 900; margin-top: 2px; }
.tile-sub { font-size: 12px; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) { .dash-grid { grid-template-columns: 1fr; } }

.chart-box svg { display: block; width: 100%; height: auto; }
.chart-bar { transition: opacity .15s; cursor: pointer; }
.chart-bar:hover { opacity: .75; }
.chart-tooltip {
  position: fixed; z-index: 100; background: var(--ink); color: #fff;
  padding: 6px 12px; border-radius: 8px; font-size: 12.5px; pointer-events: none;
  white-space: nowrap; box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}

.leaderboard { display: flex; flex-direction: column; }
.lb-item { display: flex; align-items: center; gap: 12px; padding: 9px 2px; font-size: 14px; }
.lb-item + .lb-item { border-top: 1px solid var(--grid); }
.lb-rank {
  width: 30px; height: 30px; border-radius: 50%; background: rgba(42, 120, 214, .1);
  color: var(--blue-dark); font-weight: 800; display: flex; align-items: center;
  justify-content: center; font-size: 13px; flex-shrink: 0;
}
.lb-item.first .lb-rank { background: #ffe9a8; color: #8a6400; }
.lb-name { font-weight: 700; }
.lb-user { color: var(--muted); font-size: 12px; direction: ltr; }
.lb-stats { margin-right: auto; text-align: left; font-size: 12.5px; color: var(--ink-2); }
.best-badge {
  display: inline-block; background: #ffe9a8; color: #8a6400; border-radius: 20px;
  font-size: 11px; padding: 1px 10px; font-weight: 800; margin-right: 6px;
  animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}

/* ============ tables / users / reports ============ */
.user-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; align-items: end; }
.user-form .btn { margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
.table th {
  text-align: right; color: var(--muted); font-weight: 600; font-size: 12px;
  border-bottom: 1.5px solid var(--baseline); padding: 8px 10px;
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--grid); }
.table tbody tr { transition: background .15s; animation: fade-up .4s ease both; }
.table tbody tr:hover { background: rgba(42, 120, 214, .05); }
.table .num { font-variant-numeric: tabular-nums; }
.username-cell { direction: ltr; text-align: right; font-family: Consolas, monospace; font-size: 13px; }

.badge { border-radius: 20px; font-size: 11.5px; padding: 2px 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-active { background: rgba(12, 163, 12, .12); color: var(--green-text); }
.badge-inactive { background: rgba(208, 59, 59, .12); color: var(--red); }

.row-actions { display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--border); background: none; border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 15px; transition: background .15s, transform .15s;
}
.icon-btn:hover { background: rgba(11, 11, 11, .06); transform: scale(1.08); }
.icon-btn.danger:hover { background: rgba(208, 59, 59, .12); }

.filters { display: flex; flex-wrap: wrap; gap: 0 14px; align-items: end; }
.filters .field { min-width: 150px; }
.filters .btn { margin-bottom: 14px; }
.report-summary { color: var(--ink-2); font-size: 13.5px; margin: 4px 0 12px; }

/* ============ modal & toast ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 11, 11, .45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade-in .2s ease both; backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface); border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  padding: 24px 26px; width: 100%; max-width: 380px; text-align: center;
}
.modal h3 { margin: 4px 0 6px; font-size: 20px; }
.modal p { margin: 0 0 18px; color: var(--ink-2); font-size: 14px; }
.modal-chara { width: 110px; margin: 0 auto; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
#edit-modal, #run-modal { text-align: right; }
#edit-modal h3, #run-modal h3, #run-modal p { text-align: center; }

#toast-box { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; border-radius: 30px; padding: 10px 22px;
  font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  animation: toast-in .35s cubic-bezier(.2, 1.4, .4, 1) both; max-width: 90vw;
}
.toast.success { background: var(--green-text); }
.toast.error { background: var(--red); }
.toast.out { animation: toast-out .3s ease both; }

/* ============ squirrel runner character ============ */
.sq { width: 100%; height: auto; overflow: visible; display: block; }
.sq .eye-lid { animation: blink 3.8s infinite; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96%, 98% { transform: scaleY(.1); } }
.sq .tail { animation: tail-sway 3s ease-in-out infinite; }
@keyframes tail-sway { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(5deg); } }

/* idle (header) */
.sq.idle .whole { animation: bob 2.6s ease-in-out infinite; }

/* wave (login) */
.sq.wave .whole { animation: bob 2.6s ease-in-out infinite; }
.sq.wave .arm-a { animation: sq-wave 1.8s ease-in-out infinite; }
.sq.wave .fore-a { animation: sq-wave-hand 1.8s ease-in-out infinite; }
@keyframes sq-wave { 0%, 100% { transform: rotate(0); } 25%, 80% { transform: rotate(150deg); } }
@keyframes sq-wave-hand {
  0%, 20%, 85%, 100% { transform: rotate(20deg); }
  35% { transform: rotate(65deg); }
  50% { transform: rotate(15deg); }
  65% { transform: rotate(65deg); }
}

/* worried (confirm modal) */
.sq.worried .whole { animation: sq-shiver .3s ease-in-out infinite; }
@keyframes sq-shiver { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }

/* ready: sprinter "set" position
   Character faces LEFT. For a limb hanging from its top pivot, rotate(+θ) swings the free end
   forward (left), rotate(-θ) swings it backward (right). Knees/elbows: knee bends backward (−),
   elbow bends forward (+). */
.sq.ready .whole { animation: sq-ready 1.7s ease-in-out infinite; }
@keyframes sq-ready {
  0%, 100% { transform: rotate(-9deg) translateY(0); }
  14% { transform: rotate(-9deg) translateY(4px); }
  30% { transform: rotate(-10deg) translateY(-7px); }
  44% { transform: rotate(-9deg) translateY(0); }
}
.sq.ready .leg-a { transform: rotate(26deg); }
.sq.ready .shin-a { transform: rotate(-50deg); }
.sq.ready .leg-b { transform: rotate(-36deg); }
.sq.ready .shin-b { transform: rotate(-26deg); }
.sq.ready .arm-a { transform: rotate(-32deg); }
.sq.ready .fore-a { transform: rotate(80deg); }
.sq.ready .arm-b { transform: rotate(40deg); }
.sq.ready .fore-b { transform: rotate(70deg); }

/* running: run cycle. Leg phases (leg-a): 0% heel-strike in front (nearly straight) →
   25% under body → 50% toe-off extended behind → 75% swing-through, heel tucked up.
   leg-b is the same shifted by half a cycle; each arm swings opposite its same-side leg. */
.sq.running .whole { animation: sq-sprint .4s linear infinite; }
@keyframes sq-sprint {
  0%, 100% { transform: rotate(-13deg) translateY(0); }
  25%, 75% { transform: rotate(-12deg) translateY(-6px); }
}
.sq.running .tail { animation-duration: .45s; }
.sq.running .leg-a { animation: sq-hip-a .4s linear infinite; }
.sq.running .shin-a { animation: sq-knee-a .4s linear infinite; }
.sq.running .leg-b { animation: sq-hip-b .4s linear infinite; }
.sq.running .shin-b { animation: sq-knee-b .4s linear infinite; }
@keyframes sq-hip-a {
  0%, 100% { transform: rotate(42deg); }
  25% { transform: rotate(0deg); }
  50% { transform: rotate(-42deg); }
  75% { transform: rotate(-4deg); }
}
@keyframes sq-hip-b {
  0%, 100% { transform: rotate(-42deg); }
  25% { transform: rotate(-4deg); }
  50% { transform: rotate(42deg); }
  75% { transform: rotate(0deg); }
}
@keyframes sq-knee-a {
  0%, 100% { transform: rotate(-12deg); }
  25% { transform: rotate(-18deg); }
  50% { transform: rotate(-28deg); }
  75% { transform: rotate(-95deg); }
}
@keyframes sq-knee-b {
  0%, 100% { transform: rotate(-28deg); }
  25% { transform: rotate(-95deg); }
  50% { transform: rotate(-12deg); }
  75% { transform: rotate(-18deg); }
}
.sq.running .arm-a { animation: sq-pump-a .4s linear infinite; }
.sq.running .arm-b { animation: sq-pump-b .4s linear infinite; }
.sq.running .fore-a, .sq.running .fore-b { transform: rotate(85deg); }
@keyframes sq-pump-a { 0%, 100% { transform: rotate(-36deg); } 50% { transform: rotate(36deg); } }
@keyframes sq-pump-b { 0%, 100% { transform: rotate(36deg); } 50% { transform: rotate(-36deg); } }

/* rest: catching breath */
.sq.rest .whole { animation: sq-breathe 3s ease-in-out infinite; }
@keyframes sq-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03) translateY(-2px); } }
.sq.rest .arm-a { transform: rotate(10deg); }
.sq.rest .arm-b { transform: rotate(-10deg); }
.sq.rest .tail { animation-duration: 4.5s; }

/* character container sizes */
.login-chara { width: 120px; }
.modal-chara { width: 88px; }
.brand-logo { width: 34px; }

/* ============ run scenes (stage) ============ */
.stage {
  position: relative; width: 100%; height: 210px; margin: 0 auto;
  border-radius: 18px; overflow: hidden; border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.stage.ready, .stage.running { background: linear-gradient(#d9edfd 0%, #f2f9ff 70%); }
.stage.rest { background: linear-gradient(#ffe6c9 0%, #fff6e9 70%); }

.stage-label {
  position: absolute; top: 10px; right: 12px; z-index: 6;
  background: rgba(255, 255, 255, .78); border-radius: 20px; padding: 2px 12px;
  font-size: 12px; font-weight: 700; color: var(--ink-2);
  box-shadow: 0 2px 8px rgba(11, 11, 11, .08);
}

.stage .cloud { position: absolute; z-index: 0; font-size: 26px; opacity: .9; }
.stage .c1 { top: 12px; left: 8%; }
.stage .c2 { top: 38px; left: 55%; font-size: 19px; opacity: .7; }
.stage.ready .cloud { animation: cloud-drift 34s linear infinite; }
.stage.ready .c2 { animation-delay: -17s; }
.stage.running .cloud { animation: cloud-drift 5s linear infinite; }
.stage.running .c2 { animation-delay: -2.5s; }
.stage.rest .cloud { animation: cloud-drift 46s linear infinite; }
.stage.rest .c1 { left: 38%; }
@keyframes cloud-drift { from { transform: translateX(-70px); } to { transform: translateX(470px); } }

.stage .ground {
  position: absolute; bottom: 0; left: 0; right: 0; height: 44px; z-index: 1;
  background: #ecd6ae; border-top: 2px solid #dcc294;
}
.stage.rest .ground { background: #cfe6c2; border-top-color: #b9d8a8; }
.stage.rest .lane { display: none; }
.stage .lane {
  position: absolute; top: 18px; left: -60px; right: -60px; height: 4px; border-radius: 2px;
  background: repeating-linear-gradient(90deg, #fff 0 26px, transparent 26px 56px);
  opacity: .85;
}
.stage.running .lane { animation: lane-move .45s linear infinite; }
@keyframes lane-move { from { transform: translateX(0); } to { transform: translateX(56px); } }

.stage .runner {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  width: 86px; z-index: 5;
}
.stage .runner .r-shadow {
  position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  width: 58px; height: 10px; border-radius: 50%; background: rgba(11, 11, 11, .14);
}
.stage.running .r-shadow { animation: shadow-squash .2s ease-in-out infinite; }
@keyframes shadow-squash { 0%, 100% { transform: translateX(-50%) scaleX(1); opacity: 1; } 50% { transform: translateX(-50%) scaleX(.65); opacity: .55; } }

/* ready props */
.stage .flag {
  position: absolute; bottom: 40px; right: 26%; font-size: 30px; z-index: 2;
  transform-origin: 50% 95%; animation: flag-wiggle 2.2s ease-in-out infinite;
}
@keyframes flag-wiggle { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(7deg); } }
.stage .startline {
  position: absolute; bottom: 0; right: 31%; width: 7px; height: 44px; z-index: 2;
  background: repeating-linear-gradient(0deg, #fff 0 6px, #b9b3a4 6px 12px); opacity: .85;
}

/* running props */
.stage .tr { position: absolute; bottom: 36px; left: 0; z-index: 2; }
.stage.running .t1 { font-size: 44px; animation: scene-move 2.1s linear infinite; }
.stage.running .t2 { font-size: 34px; bottom: 38px; animation: scene-move 2.1s linear infinite; animation-delay: -1.05s; }
.stage.running .t3 { font-size: 20px; bottom: 34px; animation: scene-move 1.4s linear infinite; animation-delay: -.5s; }
@keyframes scene-move { from { transform: translateX(-80px); } to { transform: translateX(490px); } }
.stage .dust i {
  position: absolute; bottom: 28px; left: calc(50% + 34px); z-index: 4;
  width: 11px; height: 11px; border-radius: 50%; background: #d9d2c2; opacity: 0;
}
.stage.running .dust i { animation: dust .5s linear infinite; }
.stage.running .dust i:nth-child(2) { animation-delay: .17s; bottom: 33px; }
.stage.running .dust i:nth-child(3) { animation-delay: .34s; bottom: 25px; }
@keyframes dust {
  0% { opacity: .85; transform: translate(0, 0) scale(.5); }
  100% { opacity: 0; transform: translate(30px, -12px) scale(1.7); }
}

/* rest props */
.stage .sun { position: absolute; top: 10px; left: 14px; font-size: 32px; z-index: 0; animation: bob 4s ease-in-out infinite; }
.stage .tree-big { position: absolute; bottom: 36px; right: 10%; font-size: 56px; z-index: 2; }
.stage .drink {
  position: absolute; bottom: 32px; left: calc(50% + 46px); font-size: 24px; z-index: 4;
  transform-origin: 50% 100%; animation: flag-wiggle 3s ease-in-out infinite;
}
.stage .drop { position: absolute; top: 52px; left: calc(50% - 46px); font-size: 15px; z-index: 6; opacity: 0; }
.stage.rest .drop { animation: sweat 2.2s ease-in infinite; }
.stage.rest .d2 { left: calc(50% - 32px); top: 44px; animation-delay: 1.1s; }
@keyframes sweat {
  0% { opacity: 0; transform: translateY(0); }
  25% { opacity: .9; }
  70% { opacity: .6; }
  100% { opacity: 0; transform: translateY(26px); }
}
.stage .spark { position: absolute; font-size: 15px; z-index: 6; opacity: 0; }
.stage.rest .spark { animation: sparkle 2.6s ease-in-out infinite; }
.stage.rest .s1 { top: 58px; left: 24%; }
.stage.rest .s2 { top: 84px; right: 30%; animation-delay: 1.3s; }
@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(.5) translateY(0); }
  50% { opacity: 1; transform: scale(1.1) translateY(-8px); }
}

/* confetti */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px;
  animation: confetti-fall linear both;
}
@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0); opacity: 1; }
  100% { transform: translateY(72vh) rotate(720deg); opacity: 0; }
}

/* ============ shared animations ============ */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.pop-in { animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes fade-up { 0% { opacity: 0; transform: translateY(14px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes toast-in { 0% { opacity: 0; transform: translateY(-24px) scale(.8); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { 0% { opacity: 1; } 100% { opacity: 0; transform: translateY(-16px); } }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px 14px; padding: 10px 14px; }
  .tabs { order: 3; width: 100%; justify-content: center; }
  .big-btn { width: 160px; height: 160px; }
  .timer { font-size: 38px; }
}
