@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 {
  --bg-top: #2b4a6f;
  --bg-bottom: #e7a56b;
  --ink: #1d2433;
  --paper: #fffaf2;
  --cell-empty: rgba(255, 250, 242, 0.28);
  --cell-border: rgba(255, 255, 255, 0.55);
  --accent: #f0803c;
  --accent-dark: #c85f22;
  --good: #3f9b6b;
  --wheel-bg: rgba(255, 250, 242, 0.9);
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, 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(--bg-top) 0%, #6d6f8f 55%, var(--bg-bottom) 100%);
}

button { font: inherit; color: inherit; cursor: pointer; }

.screen {
  position: fixed; inset: 0;
  height: 100%;
  height: 100dvh;
  max-width: 560px;
  max-width: max(560px, 50vh); /* на высоких мониторах поле не уже половины высоты (требование 1.6.2.2) */
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 12px calc(env(safe-area-inset-bottom) + 12px);
}

/* ---------- Верхняя панель ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 4px;
}
.place {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  background: none; border: none; padding: 2px 4px; text-align: left;
  line-height: 1.15;
}
.place-row { display: flex; align-items: baseline; gap: 8px; max-width: 100%; }
#place-name { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tiny { font-size: 12px; }
.muted { opacity: 0.75; font-size: 14px; }
.coins {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  font-weight: 700; font-size: 18px;
}
.coin-icon {
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe08a, #f2b32a 60%, #c98a12);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}
.coins.bump { animation: bump 380ms cubic-bezier(.2,.9,.3,1.4); }

/* ---------- Кроссворд ---------- */
.board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}
.grid { display: grid; gap: var(--gap, 4px); --cell: 48px; }
.cell {
  width: var(--cell); height: var(--cell);
  border-radius: calc(var(--cell) * 0.18);
  background: var(--cell-empty);
  border: 1.5px solid var(--cell-border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: calc(var(--cell) * 0.56);
  color: var(--ink);
  transition: background-color 200ms ease;
}
.cell.open { background: var(--paper); border-color: var(--paper); }
.cell.open.pop { animation: pop 320ms cubic-bezier(.2,.9,.3,1.3); }
.cell.hinted { color: var(--accent-dark); }
.cell.flash { animation: flash 600ms ease; }

/* ---------- Текущее слово и подсказки ---------- */
.preview-row { position: relative; height: 52px; display: flex; align-items: center; justify-content: center; }
.preview {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  background: transparent;
  font-size: 28px; font-weight: 800; letter-spacing: 0.12em;
  display: flex; align-items: center;
}
.preview.filled { background: var(--accent); }
.preview.shake { animation: shake 360ms ease; background: #b8474a; }
.preview.ok { background: var(--good); }
.toast {
  position: absolute; top: -6px; left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 15px; font-weight: 600;
  background: rgba(0,0,0,0.45);
  padding: 4px 12px; border-radius: 999px;
  opacity: 0; transition: opacity 200ms ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---------- Колесо букв ---------- */
.controls {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding-bottom: 8px;
}
.wheel {
  position: relative;
  width: min(68vw, 300px, 38dvh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--wheel-bg);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  flex: 0 0 auto;
}
.wheel-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.wheel-line polyline { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.letter {
  position: absolute;
  width: var(--letter, 26%); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(24px, 8vw, 40px); font-weight: 800;
  color: var(--ink);
  transition: background-color 120ms ease, color 120ms ease, left 300ms ease, top 300ms ease;
}
.letter.on { background: var(--accent); color: #fff; }

.side-col { display: flex; flex-direction: column; gap: 14px; }
.side-btn {
  position: relative;
  width: 54px; height: 54px; border-radius: 50%;
  flex: 0 0 auto;
  border: none;
  background: rgba(255, 250, 242, 0.9);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  transition: transform 120ms ease;
}
.side-btn:active { transform: scale(0.94); }
.side-icon { font-size: 26px; font-weight: 800; line-height: 1; }
.badge {
  position: absolute; right: -6px; bottom: -4px;
  min-width: 24px; padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 700;
}

/* ---------- Окна ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 20, 34, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 10;
}
.overlay.hidden { display: none; }
.card {
  width: min(420px, 100%);
  background: var(--paper); color: var(--ink);
  border-radius: 20px;
  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; }
.card p { margin: 0 0 18px; font-size: 17px; line-height: 1.45; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
  border: none; border-radius: 14px;
  padding: 14px 18px;
  font-size: 18px; font-weight: 700;
  background: var(--accent); color: #fff;
}
.btn.secondary { background: #e9e2d6; color: var(--ink); }
.btn:active { transform: scale(0.98); }
.bonus-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.bonus-list span { background: #efe6d8; padding: 4px 10px; border-radius: 8px; font-weight: 600; }

.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 pop { 0% { transform: scale(0.6); } 100% { transform: scale(1); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes flash { 0%,100% { background: var(--paper); } 40% { background: #ffe1c7; } }
@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; }
}

/* ---------- Общие элементы навигации ---------- */
.hidden { display: none !important; }
.icon-btn {
  flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 14px;
  border: none;
  background: rgba(0, 0, 0, 0.22);
  color: var(--paper);
  font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(0.94); }
.loc-progress {
  width: 100%; height: 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden; display: block;
}
.loc-progress.small { height: 5px; max-width: 220px; }
.loc-progress-fill { display: block; height: 100%; width: 0; background: #ffd27a; border-radius: inherit; transition: width 400ms ease; }

/* ---------- Главный экран ---------- */
#home { justify-content: space-between; text-align: center; }
.home-bar { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; }
.logo { margin-top: 4vh; }
.logo-tiles { display: flex; justify-content: center; gap: 4px; flex-wrap: nowrap; }
.tile {
  width: min(9vw, 46px); aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 22%;
  background: var(--paper); color: var(--ink);
  font-family: "Montserrat", var(--font);
  font-weight: 900; font-size: min(5.6vw, 28px);
  box-shadow: 0 4px 0 rgba(0,0,0,0.18);
  animation: tile-in 500ms cubic-bezier(.2,.9,.3,1.3) both;
  animation-delay: calc(var(--i) * 45ms);
}
.tile.alt { background: var(--accent); color: #fff; }
.logo-sub { margin-top: 10px; font-size: 17px; opacity: 0.9; letter-spacing: 0.04em; }
.home-where {
  margin: 0 auto; width: min(100%, 360px);
  background: rgba(0, 0, 0, 0.2); border-radius: 18px; padding: 16px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.home-where-label { font-size: 13px; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.08em; }
.home-where-place { font-size: 26px; font-weight: 800; }
.home-where-sub { font-size: 14px; opacity: 0.85; }
.home-actions { display: flex; flex-direction: column; gap: 10px; width: min(100%, 360px); margin: 0 auto; }
.btn.big { font-size: 21px; padding: 18px; box-shadow: 0 6px 0 var(--accent-dark); }
.btn.big:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--accent-dark); }
.home-actions .btn.secondary { background: rgba(255, 250, 242, 0.9); }
.home-credit { font-size: 12px; opacity: 0.6; padding: 8px 0 4px; letter-spacing: 0.1em; }

/* ---------- Подсказка на первом уровне ---------- */
.preview.tip { font-size: 16px; font-weight: 600; letter-spacing: 0; background: rgba(0,0,0,0.3); animation: breathe 2s ease-in-out infinite; }

/* ---------- Карта ---------- */
.panel { background: linear-gradient(180deg, var(--bg-top), #3a3f58); overflow-y: auto; touch-action: pan-y; }
.panel-bar { display: flex; align-items: center; gap: 12px; padding: 12px 0 6px; }
.panel-bar h2 { margin: 0; font-size: 21px; }
.panel-lead { margin: 4px 2px 14px; opacity: 0.85; line-height: 1.4; font-size: 15px; }
.map-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 24px; }
.map-item { display: flex; gap: 14px; align-items: flex-start; background: rgba(255,255,255,0.1); border-radius: 16px; padding: 14px; }
.map-item.now { background: rgba(255,250,242,0.95); color: var(--ink); }
.map-item.now .loc-progress { background: #e7dccb; }
.map-item.now .loc-progress-fill { background: var(--accent); }
.map-item.locked { opacity: 0.55; }
.map-dot {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 18px;
  border: 2px solid rgba(255,255,255,0.7);
}
.map-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.map-name { font-size: 18px; font-weight: 800; }
.map-meta { font-size: 13px; opacity: 0.8; }
.map-facts {
  align-self: flex-start; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; padding: 7px 12px;
}
.fact-list { text-align: left; margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 16px; line-height: 1.45; }

/* ---------- Окна: текст, настройки, сложность ---------- */
.ov-text { margin: 0 0 18px; font-size: 17px; line-height: 1.45; }
.ov-text p { margin: 0 0 10px; }
.ov-text .fact { font-size: 18px; font-weight: 600; }
.muted-dark { color: #7a7266; font-size: 14px; }
.slider-row { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; font-weight: 700; text-align: left; }
.slider-row span { width: 80px; }
.slider-row input { flex: 1; accent-color: var(--accent); height: 28px; }
.settings-note { font-size: 14px; color: #7a7266; text-align: left; }
.mode-list { display: flex; flex-direction: column; gap: 8px; }
.mode-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  border: 2px solid #e2d8c8; background: #fff; border-radius: 14px; padding: 12px 14px;
}
.mode-btn b { font-size: 18px; }
.mode-btn span { font-size: 14px; color: #5c554b; }
.mode-btn small { font-size: 12px; color: #8b8378; }
.mode-btn.on { border-color: var(--accent); background: #fff3e8; }

@keyframes tile-in { from { transform: translateY(-14px) scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes breathe { 0%,100% { opacity: 0.75; } 50% { opacity: 1; } }

@media (min-width: 700px) and (min-height: 600px) {
  .screen { max-width: max(620px, 50vh); }
}

.ring-tag {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
  padding: 2px 8px; border-radius: 999px;
  background: #e8b84a; color: #3a2a08;
}

.danger-zone { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-top: 18px; padding-top: 14px; border-top: 1px solid #e7dccb; }
.btn.danger { background: #e9e2d6; color: var(--ink); font-size: 16px; padding: 12px 16px; }
.btn.danger.ghost { background: none; color: #7a7266; font-size: 15px; font-weight: 600; padding: 8px; text-decoration: underline; text-underline-offset: 3px; }

/* снимки для витрины: без анимаций появления */
.no-anim *, .no-anim *::before, .no-anim *::after { animation: none !important; transition: none !important; }

/* подпись студии с логотипом */
.home-credit { display: flex; align-items: center; justify-content: center; gap: 7px; opacity: 0.8; font-weight: 700; }
.home-credit img { width: 24px; height: 24px; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

/* ---------- Подарок дня и таблица лидеров ---------- */
.bar-right { display: flex; gap: 8px; }
.daily-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 4px 0 14px; }
.daily-day {
  border-radius: 10px; padding: 6px 2px; background: #efe8dc; color: #8a8174;
  font-size: 11px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.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; }
.lb-note { font-size: 14px; color: #6d665c; margin: 0 0 12px; }
.lb-code { font-size: 12px; color: #a39b8f; margin: -6px 0 12px; }

/* узкие телефоны (360–400 px): колесо и боковые кнопки помещаются по ширине, название города не обрезается */
.wheel { width: min(calc(100vw - 152px), 300px, 38dvh); }
#level-label { white-space: nowrap; }
@media (max-width: 400px) {
  .controls { gap: 8px; }
  .side-col { gap: 10px; }
  .side-btn { width: 48px; height: 48px; }
  .side-icon { font-size: 23px; }
  .wheel { width: min(calc(100vw - 132px), 38dvh); }
  .topbar { gap: 6px; }
  #place-name { font-size: 17px; }
  .place-row { gap: 5px; }
  .topbar .coins { padding: 4px 10px 4px 6px; }
}
