@font-face { font-family: "Nunito"; src: url("fonts/Nunito-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-Bold.ttf") format("truetype"); font-weight: 600 900; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("fonts/Montserrat-Black.ttf") format("truetype"); font-weight: 900; font-display: swap; }

:root {
  --ink: #1e2b40;
  --paper: #f7fbff;
  --bg1: #9cc3e6;
  --bg2: #3c5f8f;
  --accent: #f28c28;
  --accent-dark: #c56a12;
  --font: "Nunito", "Segoe UI", system-ui, 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(--paper);
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.screen {
  position: fixed; inset: 0;
  height: 100%; height: 100dvh;
  max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 12px calc(env(safe-area-inset-bottom) + 12px);
}

.bar { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; }
.icon-btn {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; border: none;
  background: rgba(0,0,0,0.18); color: #fff; font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(0.94); }
.coins {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.2); padding: 6px 12px 6px 8px; border-radius: 999px;
  font-weight: 800; font-size: 18px;
}
.coin-icon { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe08a, #f2b32a 60%, #c98a12); }
.coins.bump { animation: bump 380ms cubic-bezier(.2,.9,.3,1.4); }

/* ---------- Главный экран ---------- */
#home { justify-content: space-between; text-align: center; }
.logo { margin-top: 3vh; }
.logo-tiles { display: flex; justify-content: center; gap: 5px; }
.tile {
  width: min(11vw, 54px); aspect-ratio: 1; border-radius: 30%;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); color: var(--ink);
  font-family: "Montserrat", var(--font); font-weight: 900; font-size: min(6.6vw, 32px);
  box-shadow: 0 5px 0 rgba(0,0,0,0.18);
  animation: tile-in 520ms cubic-bezier(.2,.9,.3,1.3) both; animation-delay: calc(var(--i) * 55ms);
}
.tile:nth-child(odd) { transform: rotate(-4deg); }
.tile:nth-child(even) { transform: rotate(3deg); }
.tile.alt { background: var(--accent); color: #fff; }
.tile { position: relative; }
.tile::before { content: ""; position: absolute; left: 8%; right: 8%; top: -14%; height: 26%; background: #fff; border-radius: 999px 999px 40% 40%; box-shadow: 0 2px 0 rgba(0,0,0,0.06); }
.logo-sub { margin-top: 12px; font-size: 18px; font-weight: 700; opacity: 0.95; }
.mascot { width: min(80vw, 320px); 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 { font-size: 12px; opacity: 0.6; letter-spacing: 0.1em; padding-top: 6px; }

.btn {
  border: none; border-radius: 16px; padding: 14px 18px;
  font-size: 18px; font-weight: 800; background: var(--accent); color: #fff;
}
.btn.big { font-size: 22px; padding: 18px; box-shadow: 0 6px 0 var(--accent-dark); }
.btn.big:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--accent-dark); }
.btn.secondary { background: rgba(255,250,240,0.92); color: var(--ink); }
.btn.ghost { background: none; color: #7a7290; font-size: 15px; font-weight: 700; padding: 8px; text-decoration: underline; text-underline-offset: 3px; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; }

/* ---------- Списки: уровни и Буквоеды ---------- */
.panel { overflow-y: auto; touch-action: pan-y; }
.panel-bar { display: flex; align-items: center; gap: 12px; padding: 12px 0 8px; }
.panel-bar h2 { margin: 0; font-size: 22px; flex: 1; }
.stars-total { font-weight: 800; }
.level-list { display: flex; flex-direction: column; gap: 14px; padding-bottom: 24px; }
.theme { background: rgba(255,255,255,0.14); border-radius: 18px; padding: 12px; }
.theme h3 { margin: 0 0 10px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.theme h3 i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lvl {
  aspect-ratio: 1; border-radius: 14px; border: none;
  background: var(--paper); color: var(--ink);
  font-weight: 900; font-size: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.lvl small { font-size: 11px; letter-spacing: 1px; color: #e7a41f; }
.lvl.locked { background: rgba(255,255,255,0.25); color: rgba(255,255,255,0.7); }
.lvl.current { background: var(--accent); color: #fff; box-shadow: 0 0 0 3px #fff; }
.lvl.current small { color: #fff3c4; }

.skin-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 24px; }
.skin {
  background: var(--paper); color: var(--ink); border-radius: 18px; padding: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; border: 3px solid transparent;
}
.skin.on { border-color: var(--accent); }
.skin canvas { width: 100%; height: auto; }
.skin b { font-size: 17px; }
.skin .btn { width: 100%; padding: 10px; font-size: 16px; }

/* ---------- Игра ---------- */
.hud { display: flex; align-items: center; gap: 10px; padding: 10px 0 6px; }
.hud-mid { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.hud-level { font-weight: 800; font-size: 18px; }
.hearts { font-size: 16px; letter-spacing: 2px; }
.word-bar { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-bottom: 8px; }
.word-count { font-size: 14px; font-weight: 700; opacity: 0.9; }
.word-tiles { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.wt {
  width: 38px; height: 42px; border-radius: 10px;
  background: rgba(255,255,255,0.3); color: rgba(42,36,64,0.45);
  display: flex; align-items: center; justify-content: center;
  font-family: "Montserrat", var(--font); font-weight: 900; font-size: 22px;
}
.wt.done { background: var(--paper); color: var(--ink); }
.wt.next { background: var(--accent); color: #fff; animation: pulse 900ms ease-in-out infinite; }
.word-tiles.win .wt { animation: hop 500ms ease both; }
.field-wrap { position: relative; flex: 1 1 auto; min-height: 0; border-radius: 22px; overflow: hidden; }
#field { display: block; width: 100%; height: 100%; touch-action: none; }
.toast {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  background: rgba(0,0,0,0.5); padding: 6px 14px; border-radius: 999px;
  font-weight: 700; font-size: 15px; white-space: nowrap;
  opacity: 0; transition: opacity 200ms ease; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---------- Окна ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20,24,40,0.55); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 10; }
.card { width: min(420px, 100%); background: var(--paper); color: var(--ink); border-radius: 22px; padding: 24px 22px 20px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.35); animation: rise 260ms cubic-bezier(.2,.9,.3,1); }
.card h2 { margin: 0 0 10px; font-size: 24px; }
.ov-text { margin: 0 0 18px; font-size: 17px; line-height: 1.45; }
.ov-text p { margin: 0 0 10px; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .btn.secondary { background: #ece5d8; }
.big-stars { font-size: 44px; letter-spacing: 6px; color: #f2b32a; margin: 4px 0 8px; }
.big-stars .off { color: #ddd3c2; }
.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(--accent); height: 28px; }
.sep { border-top: 1px solid #e9e0cf; margin: 16px 0 10px; }

.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 tile-in { from { transform: translateY(-16px) scale(0.5); opacity: 0; } to { opacity: 1; } }
@keyframes bump { 40% { transform: scale(1.15); } }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes hop { 40% { transform: translateY(-10px); } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* снимки для витрины: без анимаций появления */
.no-anim *, .no-anim *::before, .no-anim *::after { animation: none !important; transition: none !important; }

/* шапка списков остаётся на месте при прокрутке */
.panel-bar { position: sticky; top: 0; z-index: 2; background: linear-gradient(180deg, #9cc3e6 70%, rgba(156,195,230,0)); margin: 0 -12px; padding-left: 12px; padding-right: 12px; }

/* ---------- Зимник ---------- */
.hud-stats { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 15px; }
.daybar { flex: 1; height: 10px; border-radius: 999px; background: rgba(0,0,0,0.25); overflow: hidden; }
.daybar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffcf5a, #ffe9a8); border-radius: inherit; transition: background 400ms; }
.daybar.late i { background: linear-gradient(90deg, #ff7a4a, #ffb36b); }
.goal { white-space: nowrap; }
.garage-list { display: flex; flex-direction: column; gap: 12px; padding-bottom: 24px; }
.upg { background: var(--paper); color: var(--ink); border-radius: 18px; padding: 14px; display: flex; gap: 14px; align-items: center; }
.upg canvas { width: 96px; height: 72px; flex: 0 0 auto; }
.upg-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.upg-body b { font-size: 18px; }
.upg-body span { font-size: 14px; color: #5a6578; }
.pips { display: flex; gap: 5px; }
.pips i { width: 22px; height: 8px; border-radius: 4px; background: #dbe3ee; }
.pips i.on { background: var(--accent); }
.upg .btn { padding: 10px 12px; font-size: 15px; }
.lvl small.route { font-size: 10px; color: #7c8aa0; letter-spacing: 0; }

.toast { white-space: normal; text-align: center; max-width: 92%; width: max-content; line-height: 1.3; }

.hud .hearts { color: #ff6b6b; font-size: 15px; letter-spacing: 1px; white-space: nowrap; }
.hud .hearts.bump { animation: bump 400ms ease; }

.daytime { font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 4.2em; }
.daytime.late { color: #ffd0c4; animation: pulse 700ms ease-in-out infinite; }

/* подпись студии с логотипом */
.credit { display: flex; align-items: center; justify-content: center; gap: 7px; opacity: 0.8; font-weight: 700; }
.credit img { width: 24px; height: 24px; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

/* ---------- Машины в гараже ---------- */
.garage-h { margin: 6px 4px 0; font-size: 18px; color: #fff; text-shadow: 0 1px 3px rgba(20,40,70,0.35); }
.garage-note { margin: -6px 4px 0; font-size: 14px; color: rgba(255,255,255,0.9); }
.upg.machine.current { box-shadow: 0 0 0 3px var(--accent); }
.upg.machine.locked { opacity: 0.6; }
.upg.machine.locked canvas { filter: grayscale(0.8); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 2px 0; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #5a6578; }
.stat span { width: 58px; flex: 0 0 auto; }
.stat i { flex: 1; height: 7px; border-radius: 4px; background: #dbe3ee; overflow: hidden; }
.stat i b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5aa3e8, #2f74c9); }

/* спасибо посёлка после рейса */
.thanks { font-style: italic; color: #3d5a80; }

/* карта района на экране рейсов */
.region { background: var(--paper); border-radius: 18px; padding: 8px; margin-bottom: 12px; }
.region canvas { display: block; width: 100%; height: auto; border-radius: 12px; }
.region-note { text-align: center; font-weight: 800; font-size: 15px; color: var(--ink); padding: 6px 0 2px; }
.btn.endless { width: 100%; margin-bottom: 12px; }
