/* Nunito 3.602 (SIL OFL 1.1) с кириллицей, переменная толщина 200–1000, урезан до латиницы, кириллицы и знаков */
@font-face { font-family: "Nunito"; src: url("fonts/Nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("fonts/Montserrat-Black.ttf") format("truetype"); font-weight: 900; font-display: swap; }

:root {
  --ink: #2d3139;
  --ink-soft: #8a8f98;
  --paper: #f5f2eb;
  --card: #ffffff;
  --line: #e4dfd4;
  --blue: #2f6fdf;
  --red: #e5383b;
  --font: "Nunito", "Segoe UI", system-ui, sans-serif;
  --num: "Montserrat", "Nunito", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  font-family: var(--font); color: var(--ink);
  background: var(--paper);
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.screen {
  position: fixed; inset: 0;
  height: 100%; height: 100dvh;
  max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 14px);
}

.bar { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; }
.icon-btn {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; border: none;
  background: var(--card); color: var(--ink); font-size: 15px; font-weight: 900; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(45,49,57,0.12), 0 0 0 1px rgba(45,49,57,0.06);
}
.icon-btn:active { transform: scale(0.94); }
.stars-chip { font-family: var(--num); font-weight: 900; font-size: 16px; color: #d99a00; }
.coin-icon { width: 15px; height: 15px; border-radius: 50%; background: #f2b32a; box-shadow: inset 0 0 0 2.5px #e09b12; flex: 0 0 auto; }

/* ---------- Главный экран ---------- */
#home { justify-content: space-between; text-align: center; }
.logo { margin-top: 5vh; display: flex; justify-content: center; }
.sign { display: flex; align-items: center; gap: 14px; animation: rise 500ms cubic-bezier(.2,.9,.3,1.2) both; }
.sign-plate {
  width: 74px; height: 74px; border-radius: 16px; background: var(--blue); border: 4px solid #fff; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(47,111,223,0.25), 0 0 0 1px rgba(45,49,57,0.06);
}
.sign-bus { width: 44px; height: 30px; border-radius: 8px 9px 4px 4px; background: #fff; position: relative; margin-top: -4px; }
.sign-bus::before { content: ""; position: absolute; left: 5px; right: 5px; top: 5px; height: 10px; border-radius: 3px; background: var(--blue); }
.sign-bus::after { content: ""; position: absolute; left: 5px; right: 5px; bottom: -6px; height: 10px; background: radial-gradient(circle at 6px 5px, #fff 4.5px, transparent 5px) 0 0 / 34px 10px no-repeat, radial-gradient(circle at 28px 5px, #fff 4.5px, transparent 5px) 0 0 / 34px 10px no-repeat; }
.sign-text { text-align: left; }
.logo-main { font-family: var(--num); font-weight: 900; font-size: min(10.5vw, 46px); line-height: 1; letter-spacing: -0.02em; }
.logo-sub { display: inline-block; margin-top: 8px; background: #f7c531; color: var(--ink); font-weight: 900; font-size: min(4.8vw, 20px); padding: 3px 11px; border-radius: 9px; transform: rotate(-2deg); box-shadow: 0 2px 0 rgba(45,49,57,0.12); }
.mascot { width: min(100%, 380px); height: auto; margin: 0 auto; display: block; }
.home-actions { display: flex; flex-direction: column; gap: 10px; width: min(100%, 360px); margin: 0 auto; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
.credit { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 12px; color: var(--ink-soft); letter-spacing: 0.1em; font-weight: 700; padding-top: 10px; }

.btn {
  border: none; border-radius: 14px; padding: 14px 16px;
  font-size: 17px; font-weight: 800; background: var(--ink); color: #fff;
}
.btn.big { font-size: 20px; padding: 17px; }
.btn.secondary { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1.5px var(--line) inset; }
.btn.ghost { background: none; color: var(--ink-soft); font-size: 15px; font-weight: 700; padding: 6px; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.4; }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger-text { color: #c62f32; }
.btn .ad { display: block; font-size: 12px; font-weight: 700; opacity: 0.7; margin-top: 2px; }

/* ---------- Список дней ---------- */
.panel { overflow-y: auto; touch-action: pan-y; }
.panel-bar { display: flex; align-items: center; gap: 12px; padding: 14px 0 10px; position: sticky; top: 0; z-index: 2; background: var(--paper); }
.panel-bar h2 { margin: 0; font-size: 22px; flex: 1; font-family: var(--num); font-weight: 900; }
.day-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; }
.day {
  display: flex; align-items: center; gap: 14px; text-align: left;
  border: none; border-radius: 16px; padding: 12px 14px; background: var(--card); color: var(--ink);
  box-shadow: 0 0 0 1.5px var(--line) inset;
}
.day .num { width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: #fff; font-family: var(--num); font-weight: 900; font-size: 15px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.day .body { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.day b { font-size: 16px; }
.day small { color: var(--ink-soft); font-size: 13px; }
.day .st { color: #f2b32a; font-size: 16px; letter-spacing: 1px; white-space: nowrap; }
.day .st .off { color: #e4dfd4; }
.day.locked { background: transparent; color: var(--ink-soft); }
.day.locked .num { background: var(--line); color: var(--ink-soft); font-size: 13px; }
.day.current { box-shadow: 0 0 0 2.5px var(--ink) inset; }
.btn.endless { margin-bottom: 18px; }

/* ---------- Игра ---------- */
#game { position: fixed; inset: 0; }
#field { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 0; pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-left { display: flex; flex-direction: column; gap: 2px; min-width: 80px; }
.hud-score { display: flex; align-items: center; gap: 6px; font-family: var(--num); font-weight: 900; font-size: 26px; line-height: 1; }
.hud-score .person { width: 11px; height: 20px; background: radial-gradient(circle at 50% 4.5px, var(--ink) 4.5px, transparent 5px), linear-gradient(var(--ink), var(--ink)) 50% 100% / 11px 11px no-repeat; border-radius: 0 0 3px 3px; }
.hud-score.bump { animation: bump 280ms ease; }
.hud-day { font-size: 13px; font-weight: 800; color: var(--ink-soft); white-space: nowrap; }
.hud-mid { display: flex; flex-direction: column; align-items: center; gap: 5px; padding-top: 2px; }
.clock { font-family: var(--num); font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1; }
.daybar { width: 86px; height: 4px; border-radius: 999px; background: rgba(45,49,57,0.12); overflow: hidden; }
.daybar i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: inherit; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud-buttons { display: flex; gap: 8px; }
.hud-mail { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding-right: 2px; }
.mail-row { display: flex; gap: 3px; }
.hud-mail i { display: block; width: 18px; height: 13px; }
.hud-mail svg { width: 100%; height: 100%; fill: none; stroke: rgba(45,49,57,0.32); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.hud-mail i.on svg { fill: var(--red); stroke: #fff; }
.hud-mail i.on svg rect { stroke: var(--red); }
.hud-mail small { font-size: 11px; font-weight: 800; color: var(--ink-soft); white-space: nowrap; }
.hud-mail.warn small { color: var(--red); }
.hud-mail.bump { animation: shake 400ms ease; }
.speed.fast { background: var(--ink); color: #fff; }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 76px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 9px 15px; border-radius: 14px;
  font-weight: 700; font-size: 15px; line-height: 1.3; text-align: center;
  width: max-content; max-width: min(92%, 440px);
  opacity: 0; transition: opacity 200ms ease; pointer-events: none; z-index: 12;   /* поверх окон: сообщение может прийти, пока открыты итоги */
}
.toast.show { opacity: 1; }

.routes-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 0 14px calc(env(safe-area-inset-bottom) + 14px); pointer-events: none;
}
.routes-bar > * { pointer-events: auto; }
.chips { display: flex; gap: 10px; align-items: center; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; padding: 12px 10px; margin: -6px 0; }
.chip {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; border: none; padding: 0;
  display: flex; align-items: center; justify-content: center; position: relative;
  font-family: var(--num); font-weight: 900; font-size: 17px; color: #fff;
  transition: transform 150ms ease;
}
.chip small { position: absolute; right: -4px; bottom: -3px; min-width: 19px; height: 19px; padding: 0 4px; border-radius: 999px; background: var(--card); color: var(--ink); font-size: 11px; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 1.5px var(--line); }
.chip.empty { background: transparent; box-shadow: inset 0 0 0 2.5px rgba(45,49,57,0.2); color: rgba(45,49,57,0.35); font-size: 22px; font-family: var(--font); }
.chip.buy { background: var(--card); color: var(--ink); font-size: 24px; font-family: var(--font); box-shadow: 0 1px 3px rgba(45,49,57,0.12), 0 0 0 1px rgba(45,49,57,0.06); }
.chip.buy small { gap: 3px; right: -10px; padding: 0 5px 0 3px; }
.chip.buy .coin-icon { width: 11px; height: 11px; box-shadow: inset 0 0 0 2px #e09b12; }
.chip.sel { transform: scale(1.12); box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.cash { display: flex; align-items: center; gap: 6px; font-family: var(--num); font-weight: 900; font-size: 17px; padding: 0 4px; }

.popover {
  z-index: 4;
  position: absolute; left: 50%; transform: translateX(-50%); width: min(94%, 420px);
  bottom: calc(env(safe-area-inset-bottom) + 80px);
  background: var(--card); color: var(--ink); border-radius: 18px; padding: 14px;
  box-shadow: 0 10px 32px rgba(45,49,57,0.18), 0 0 0 1px rgba(45,49,57,0.05);
  animation: pop 180ms ease;
}
.popover h3 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.popover h3 i { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-style: normal; font-family: var(--num); font-size: 13px; display: flex; align-items: center; justify-content: center; }
.popover .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.popover .btn { font-size: 15px; padding: 11px 8px; }
.popover .btn small { display: block; font-size: 12px; font-weight: 700; opacity: 0.7; }
.popover .btn.danger { background: #fdecec; color: #c62f32; }
.popover .note { font-size: 14px; color: var(--ink-soft); margin: 0 0 10px; }

/* ---------- Монеты, подарок, автопарк, городки ---------- */
.bar-left, .bar-right { display: flex; align-items: center; gap: 12px; }
.coins { display: flex; align-items: center; gap: 6px; font-family: var(--num); font-weight: 900; font-size: 16px; }
.icon-btn.gift { position: relative; font-size: 19px; }
.icon-btn.gift.ready::after { content: ""; position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--paper); }
.icon-btn.gift.ready { animation: wiggle 2.4s ease-in-out infinite; }
.gift-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 4px 0 14px; }
.gift-day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0; border-radius: 10px; background: var(--paper); font-family: var(--num); font-weight: 900; font-size: 12px; color: var(--ink-soft); }
.gift-day b { font-size: 10px; font-family: var(--font); }
.gift-day.got { background: #fff4d6; color: #b07d00; }
.gift-day.now { background: var(--ink); color: #fff; }
.earned { display: flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--num); font-weight: 900; font-size: 17px; margin: 4px 0 0; }
.town { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 4px 2px; }
.town b { font-family: var(--num); font-weight: 900; font-size: 18px; }
.town span { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.garage-note { margin: 0 0 12px; font-size: 14px; color: var(--ink-soft); line-height: 1.4; }
.garage-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 24px; }
.upg { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; padding: 14px; box-shadow: 0 0 0 1.5px var(--line) inset; }
.upg-body { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.upg-body b { font-size: 16px; }
.upg-body span { font-size: 13px; color: var(--ink-soft); }
.upg-body .upg-val { color: var(--ink); font-weight: 800; }
.pips { display: flex; gap: 4px; margin-top: 4px; }
.pips i { width: 22px; height: 5px; border-radius: 3px; background: var(--line); }
.pips i.on { background: var(--ink); }
.upg .btn { display: flex; align-items: center; gap: 6px; padding: 11px 14px; font-size: 15px; font-family: var(--num); font-weight: 900; }
@keyframes wiggle { 0%, 80%, 100% { transform: none; } 85% { transform: rotate(-10deg); } 90% { transform: rotate(9deg); } 95% { transform: rotate(-5deg); } }

/* ---------- Пополнение и запас в парке ---------- */
.daybar { position: relative; overflow: visible; }
.daybar .mark { position: absolute; top: -3px; width: 3px; height: 10px; margin-left: -1.5px; border-radius: 2px; background: var(--ink); opacity: 0.35; }
.inv { position: absolute; right: 14px; bottom: calc(env(safe-area-inset-bottom) + 78px); display: flex; flex-direction: column; gap: 10px; pointer-events: auto; }
.inv-item { position: relative; width: 44px; height: 44px; border: none; border-radius: 12px; padding: 7px; background: var(--card); color: var(--ink); display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(45,49,57,0.12), 0 0 0 1px rgba(45,49,57,0.06); }
.inv-item svg { width: 100%; height: 100%; }
.inv-item small { position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--ink); color: #fff; font-family: var(--num); font-weight: 900; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.inv-item.empty { opacity: 0.4; }
.inv-item.empty small { background: var(--ink-soft); }
.inv-item.on { box-shadow: 0 0 0 3px var(--ink); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.card-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; border: none; border-radius: 16px; padding: 16px 10px 14px; background: var(--paper); color: var(--ink); box-shadow: 0 0 0 1.5px var(--line) inset; }
.card-opt:active { transform: scale(0.97); }
.card-opt .card-ico { width: 64px; height: 40px; color: var(--blue); display: flex; align-items: center; justify-content: center; }
.card-opt .card-ico svg { max-width: 100%; max-height: 100%; }
.card-opt b { font-size: 17px; }
.card-opt small { font-size: 13px; color: var(--ink-soft); line-height: 1.3; }

/* ---------- Переключатель языка ---------- */
.segs { flex: 1; display: flex; gap: 4px; background: var(--paper); border-radius: 12px; padding: 3px; }
.seg { flex: 1; border: none; border-radius: 9px; padding: 8px 4px; background: none; font-size: 14px; font-weight: 800; color: var(--ink-soft); }
.seg.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(45,49,57,0.15); }
.slider-row .segs + * { display: none; }

.tut {
  z-index: 3;
  position: absolute; left: 50%; top: calc(env(safe-area-inset-top) + 124px); transform: translateX(-50%);
  width: min(90%, 420px); background: var(--card); color: var(--ink); border-radius: 16px; padding: 12px 16px;
  font-weight: 800; font-size: 16px; line-height: 1.35; text-align: center; pointer-events: none;
  box-shadow: 0 8px 24px rgba(45,49,57,0.16), 0 0 0 1.5px var(--line);
}
.tut.pop { animation: pop 260ms ease; }
.tut.interactive { pointer-events: auto; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.tut .btn { padding: 9px 22px; font-size: 15px; }
.tut-spot {
  position: fixed; border-radius: 18px; pointer-events: none; z-index: 2;
  box-shadow: 0 0 0 3px var(--blue), 0 0 0 9999px rgba(245,242,235,0.55);
  animation: spot 1.2s ease-in-out infinite; transition: left 200ms, top 200ms, width 200ms, height 200ms;
}
@keyframes spot { 50% { box-shadow: 0 0 0 6px var(--blue), 0 0 0 9999px rgba(245,242,235,0.55); } }

.lang-select { flex: 1; height: 42px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-weight: 800; padding: 0 10px; }

/* ---------- Окна ---------- */
.overlay { position: fixed; inset: 0; background: rgba(245,242,235,0.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 22px; z-index: 10; }
.card { width: min(400px, 100%); background: var(--card); color: var(--ink); border-radius: 22px; padding: 24px 20px 18px; text-align: center; box-shadow: 0 16px 48px rgba(45,49,57,0.18), 0 0 0 1px rgba(45,49,57,0.05); animation: rise 240ms cubic-bezier(.2,.9,.3,1); }
.card h2 { margin: 0 0 10px; font-size: 22px; font-family: var(--num); font-weight: 900; }
.ov-text { margin: 0 0 16px; font-size: 16px; line-height: 1.45; }
.ov-text p { margin: 0 0 10px; }
.ov-text .muted { font-size: 14px; color: var(--ink-soft); }
.actions { display: flex; flex-direction: column; gap: 8px; }
.big-stars { font-size: 38px; letter-spacing: 6px; color: #f2b32a; margin: 2px 0 4px; }
.big-stars .off { color: #ebe6dc; }
.result-num { font-family: var(--num); font-weight: 900; font-size: 46px; line-height: 1.1; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; text-align: left; font-size: 15px; margin: 8px 0 14px; padding: 12px; border-radius: 14px; background: var(--paper); }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 18px; height: 18px; border-radius: 50%; flex: 0 0 auto; }
.legend i.ring { background: #fff !important; box-shadow: inset 0 0 0 3.5px var(--ink); }
.slider-row { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; font-weight: 800; text-align: left; }
.slider-row span { width: 80px; }
.slider-row input { flex: 1; accent-color: var(--ink); height: 28px; }

.mock-ad { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: #111; color: #fff; font-size: 20px; }

@keyframes bump { 40% { transform: scale(1.12); } }
@keyframes shake { 20% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 80% { transform: translateX(-2px); } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: translateX(-50%) translateY(10px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
.no-anim *, .no-anim *::before, .no-anim *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
