/* ============================================================================
 * style.css — «Сетка 5×5», Telegram Mini App
 *
 * Цвета страницы берутся из темы Telegram: app.js выставляет CSS-переменные
 * из Telegram.WebApp.themeParams. Цвета ячеек фиксированы механикой игры:
 * белая ⇄ зелёная, поэтому они не зависят от темы (по ТЗ).
 * ==========================================================================*/

:root {
  --bg: #17212b;            /* фон страницы (тёмная тема Telegram) */
  --surface: #232e3c;       /* плашки статистики */
  --text: #f2f5f7;
  --muted: #7d8b99;
  --accent: #2ea6ff;        /* кнопка «Сбросить» */
  --accent-text: #ffffff;
  --green: #34c759;         /* зелёная ячейка — по механике */
  --green-dark: #23b14d;
  --radius-cell: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.app {
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- шапка ---------- */

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .2px;
}

.subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  max-width: 300px;
}

.save {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  white-space: nowrap;
}

.save-label { font-size: 12px; color: var(--muted); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .5;
  flex: 0 0 auto;
  transition: background-color .2s ease;
}
.dot.saving  { background: #f5a623; opacity: 1; animation: pulse 1s ease-in-out infinite; }
.dot.saved   { background: var(--green); opacity: 1; }
.dot.retry   { background: #ff9500; opacity: 1; }
.dot.offline { background: #8e8e93; opacity: 1; }

@keyframes pulse { 50% { opacity: .35; } }

/* ---------- статистика ---------- */

.stats { display: flex; gap: 10px; }

.stat {
  flex: 1;
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value { font-size: 20px; font-weight: 700; line-height: 1.2; }

.stat-value .frac {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 2px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
}

/* ---------- сетка 5×5 ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(6px, 1.8vw, 10px);
  width: 100%;
}

.cell {
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(127, 127, 127, .28);
  border-radius: var(--radius-cell);
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
  cursor: pointer;
  padding: 0;
  font: inherit;
  transition: background-color .12s ease, box-shadow .12s ease, border-color .12s ease;
  touch-action: manipulation;
}

.cell:active { transform: scale(.94); }

.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cell.green {
  background: linear-gradient(150deg, #3fd26e, var(--green-dark));
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(52, 199, 89, .35);
}

.cell.pop { animation: pop .18s ease-out; }

@keyframes pop {
  0%   { transform: scale(.86); }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ---------- кнопка сброса ---------- */

.reset {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
  touch-action: manipulation;
}

.reset:active { transform: scale(.98); filter: brightness(.92); }

.reset:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

/* ---------- подвал ---------- */

.foot {
  min-height: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  max-width: min(88vw, 360px);
  background: rgba(15, 20, 26, .88);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
