@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: #2a2440;
  --paper: #fffaf0;
  --bg1: #8fd3a8;
  --bg2: #4fa8b8;
  --accent: #ff8a3d;
  --accent-dark: #d0641c;
  --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; }
.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, #8fd3a8 70%, rgba(143,211,168,0)); margin: 0 -12px; padding-left: 12px; padding-right: 12px; }

/* подпись студии с логотипом */
.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); }

/* ---------- Оформление 2.0: фон с пузырями, рамка поля, плитки-конфеты ---------- */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 10% 16%, rgba(255,255,255,0.2) 0 52px, transparent 53px),
    radial-gradient(circle at 90% 30%, rgba(255,255,255,0.13) 0 84px, transparent 85px),
    radial-gradient(circle at 16% 78%, rgba(255,255,255,0.1) 0 110px, transparent 111px),
    radial-gradient(ellipse 130% 36% at 50% 112%, rgba(255,255,255,0.2) 0 60%, transparent 61%);
}
.field-wrap { margin: 4px 4px 0; box-shadow: 0 0 0 4px rgba(255,255,255,0.92), 0 12px 28px rgba(0,0,0,0.22); }
.wt {
  background: rgba(255,255,255,0.18); color: rgba(255,255,255,0.8);
  border: 2px dashed rgba(255,255,255,0.6);
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.wt.done {
  border: none; color: var(--ink); text-shadow: none;
  background: linear-gradient(180deg, #fffdf7, #efe3cc);
  box-shadow: 0 3px 0 rgba(0,0,0,0.16), inset 0 2px 0 #fff;
}
.wt.next {
  border: none;
  background: radial-gradient(circle at 35% 30%, #ffc48f, var(--accent) 55%, var(--accent-dark));
  box-shadow: 0 3px 0 var(--accent-dark), 0 0 0 3px rgba(255,255,255,0.75);
}
.btn.big { background: linear-gradient(180deg, #ffa060, var(--accent)); }
.logo-tiles .tile { background: linear-gradient(180deg, #fffdf7, #efe3cc); }
.logo-tiles .tile.alt { background: radial-gradient(circle at 35% 30%, #ffc48f, var(--accent) 55%, var(--accent-dark)); }
.skin { box-shadow: 0 4px 0 rgba(0,0,0,0.12); }
.skin canvas { background: radial-gradient(circle at 50% 45%, #f4fbe9, #e2f1d4); border-radius: 12px; }

/* ---------- Сложности, подарок дня, таблица лидеров, награды ---------- */
.bar-right { display: flex; gap: 8px; }
.mode-pill { align-self: center; padding: 8px 16px; font-size: 15px; background: rgba(255,255,255,0.22); color: #fff; border-radius: 999px; }
.ov-note { font-size: 14px; color: #6d665c; margin: -4px 0 12px; }
.mode-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.mode-btn { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 14px; border: 2px solid #e9e0cf; background: #fffdf8; }
.mode-btn b { font-size: 18px; }
.mode-btn span { font-size: 14px; color: #5c554b; line-height: 1.35; }
.mode-btn small { font-size: 12px; color: #8b8378; margin-top: 2px; }
.mode-btn.on { border-color: var(--accent); background: #fff3e8; }
.daily-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 4px 0 14px; }
.daily-day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; background: #f1ece2; font-size: 11px; font-weight: 700; color: #8a8174; }
.daily-day b { font-size: 14px; color: var(--ink); }
.daily-day.done { background: #d9ead7; color: #3f7a4a; }
.daily-day.done b { color: #3f7a4a; }
.daily-day.today { background: var(--accent); color: #fff; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.daily-day.today b { color: #fff; }
.lb-list { list-style: none; margin: 0 0 12px; padding: 0; text-align: left; max-height: 46vh; overflow-y: auto; }
.lb-list li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; font-weight: 700; }
.lb-list li:nth-child(odd) { background: #f3eee5; }
.lb-list li.me { background: #ffe2c4; }
.lb-rank { width: 2.2em; color: #8a8174; font-variant-numeric: tabular-nums; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-variant-numeric: tabular-nums; color: #c98a12; }
.lb-note { font-size: 14px; color: #6d665c; margin: 0 0 12px; }
.lb-code { font-size: 12px; color: #a39b8f; margin: -6px 0 12px; }
.new-skin { background: #fff3d6; border-radius: 12px; padding: 8px 10px; font-size: 15px; }
.panel-bar h2 small { font-size: 14px; font-weight: 700; opacity: 0.8; }
.skin.prize { background: #f4efe6; }
.skin-cond { font-size: 13px; font-weight: 700; color: #7a705f; line-height: 1.3; text-align: center; min-height: 40px; display: flex; align-items: center; }
