/* Минута — тёмный экран, чтобы кроме рисунка ничего не отвлекало. */

:root {
  --bg: #0a0a0b;
  --paper: #121214;
  --text: #f2f2f4;
  --dim: #7a7a85;
  --line: #26262c;
  --accent: #ffcf5c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* Чтобы палец не таскал страницу, когда человек рисует. */
  overscroll-behavior: none;
}

body { overflow: hidden; }

/* ---------- экраны ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
}

.screen.is-visible { display: flex; }

.screen--scroll { overflow-y: auto; display: none; }
.screen--scroll.is-visible { display: block; }

.center {
  margin: auto;
  width: 100%;
  max-width: 460px;
  text-align: center;
}

/* ---------- главная ---------- */

.logo {
  font-size: 44px;
  font-weight: 300;
  letter-spacing: 0.22em;
  margin: 0 0 22px;
  text-transform: lowercase;
}

.lead {
  color: var(--dim);
  font-size: 16px;
  line-height: 1.65;
  margin: 0 0 32px;
}

.stats {
  color: var(--dim);
  font-size: 13px;
  margin: 16px 0 0;
  min-height: 18px;
}

.big-button {
  background: var(--text);
  color: #0a0a0b;
  border: 0;
  border-radius: 999px;
  padding: 15px 34px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.big-button:active { transform: scale(0.98); }

.link {
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 14px;
  cursor: pointer;
  margin-top: 26px;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.link:hover { color: var(--text); }

.button-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 22px;
}

/* ---------- результат: повтор ---------- */

/* Тумблер «быстро / как было»: появляется вместе со «Стоп» и живёт, пока
   идёт повтор. Активная половина залита, как big-button. */
.replay-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.replay-toggle__option {
  background: none;
  border: 0;
  color: var(--dim);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.replay-toggle__option.is-active {
  background: var(--text);
  color: #0a0a0b;
}

/* ---------- ожидание ---------- */

.pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 auto 28px;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.15); }
}

/* ---------- минута ---------- */

.timebar {
  height: 2px;
  background: var(--line);
  flex: none;
  margin-top: 8px;
}

.timebar-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  /* Ширину пишет js каждый кадр, поэтому transition тут не нужен. */
}

/* Свободное место между таймером и инструментами. Отступы именно margin,
   а не padding: js меряет это место через getBoundingClientRect, а он
   padding считает своим. */
.paper-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0;
}

/* Размер живому холсту задаёт js — он делает квадрат по меньшей стороне
   свободного места. Через css надёжно не выходит: на узком экране браузер
   зажмёт ширину, а высоту оставит, и квадрат станет прямоугольником —
   линии партнёра приехали бы растянутыми. */
.paper-wrap {
  position: relative;
  border-radius: 14px;
  background: var(--paper);
  overflow: hidden;
  touch-action: none;
}

.paper-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Верхний холст с точками лежит поверх нижнего, с которого мы слушаем палец.
   Без этой строки он перехватывает все нажатия и рисовать нельзя. */
#overlay { pointer-events: none; }

/* Картинка на экране результата: тут квадрат делает css. */
.paper-wrap--small {
  flex: none;
  width: min(100%, 46vh);
  aspect-ratio: 1 / 1;
  margin: 18px auto;
}

/* ---------- инструменты ---------- */

.tools {
  flex: none;
  padding-bottom: 12px;
}

.swatches {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s;
}

.swatch.is-active {
  border-color: var(--text);
  transform: scale(1.18);
}

.tool-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.tool {
  background: none;
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.tool.is-active {
  border-color: var(--text);
  color: var(--text);
}

.sizes { display: flex; gap: 8px; align-items: center; }

.size-dot {
  background: var(--dim);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  opacity: 0.45;
}

.size-dot.is-active { opacity: 1; background: var(--text); }

.seconds {
  color: var(--dim);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
}

/* ---------- результат ---------- */

.result-title {
  font-size: 20px;
  font-weight: 400;
  margin: 0;
}

/* ---------- коллекция ---------- */

.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 0 8px;
}

.gallery-head .link { margin-top: 0; }
.gallery-head .stats { margin-top: 0; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.card {
  background: var(--paper);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid transparent;
}

.card:hover { border-color: var(--line); }

.card canvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
}

.card-label {
  color: var(--dim);
  font-size: 11px;
  padding: 7px 9px 9px;
  line-height: 1.4;
}

.empty {
  color: var(--dim);
  text-align: center;
  font-size: 14px;
  margin-top: 60px;
  display: none;
}

.empty.is-visible { display: block; }
