* { margin: 0; padding: 0; box-sizing: border-box; }

/* --k — шаг пикселя чашки на экране, ставит js/main.js. Кнопки считают от
   него всё: кегль, рамку, отступы — и живут в той же сетке, что чашка. */
:root { --k: 2; --dpr: 1; }

/* Растровый MS Sans Serif из Windows 95 (FontStruction «lou», CC BY-SA 3.0,
   конвертация из 98.css). Нарисован под 11 px: любой другой кегль плывёт,
   поэтому кегль везде один и тот же, а сглаживание выключено. */
@font-face {
  font-family: "Pixelated MS Sans Serif";
  src: url("../assets/fonts/ms_sans_serif.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: "Pixelated MS Sans Serif";
  src: url("../assets/fonts/ms_sans_serif_bold.woff2") format("woff2");
  font-weight: bold;
  font-style: normal;
}

html, body {
  /* обычной стрелки в кадре не бывает: везде прицел, над чашкой — пинцет */
  cursor: crosshair;
  background: #000;
  color: #8c8c8c;
  font: 11px/1.5 "Pixelated MS Sans Serif", "MS Sans Serif",
        "Microsoft Sans Serif", Arial, sans-serif;
  -webkit-font-smoothing: none;
  letter-spacing: 2px;
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

#stage {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* пока расставляют споры, роль курсора играет крупный пинцет (js/cursor.js) */
#stage.has-tool { cursor: none; }
body.running #stage.has-tool { cursor: crosshair; }

#tool {
  position: fixed;
  z-index: 25;
  display: none;
  pointer-events: none;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, .85));
}
body.running #stage { cursor: default; }

#wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 78px 200px 24px 8px;
}

#bar { display: flex; gap: 28px; justify-content: center; }

/* Сводка вверху: сколько видов растёт и какие именно. Внизу остаётся
   чистое чёрное поле с чашкой. */
#status {
  position: fixed;
  top: 14px;
  left: 130px;
  right: 250px;
  z-index: 14;
  text-align: center;
  pointer-events: none;
}
#phase { color: #8c8c8c; }
#species {
  margin-top: 4px;
  color: #4d4d4d;
  line-height: 1.5;
}

/* ---------- палитра штаммов ---------- */

#strains {
  position: fixed;
  top: 0; right: 0;
  z-index: 16;
  width: 188px;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #070707;
  border-left: 1px solid #191919;
  padding: 14px 12px 20px;
}

#brushes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 6px;
}

/* Плитка — образец плесени и подпись, без плашки. Выбор — подпись ярче
   и те же четыре уголка, что у кнопок. */
.tile {
  position: relative;
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 4px 3px 5px;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 11px;
  overflow: hidden;
  /* квадрат, образец по центру — как на телефоне */
  aspect-ratio: 1;
  grid-template-rows: 1fr auto;
}
.tile:hover:not(:disabled) .corner { display: none; }
.tile.on .corner, .tile.on:hover:not(:disabled) .corner { display: block; }
.tile canvas {
  width: 48px;
  height: auto;
  display: block;
  align-self: center;
  image-rendering: pixelated;
}
.tile .cap {
  line-height: 1.2;
  color: #5a5a5a;
  text-align: center;
  word-break: break-all;
}
.tile:hover .cap { color: #8c8c8c; }
.tile.on .cap { color: #f2f2f2; }

#strain-info {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #191919;
  color: #5a5a5a;
  line-height: 1.45;
}
#strain-info b { color: #b3b3b3; font-weight: 400; }
/* у растрового шрифта нет курсива, а синтетический наклон рвёт пиксели */
em { font-style: normal; }

/* ---------- кнопка панели ---------- */

#save, #sound-toggle {
  position: fixed;
  z-index: 30;
  width: 40px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
}
#sound-toggle svg { fill: #d9d9d9; display: block; }
#sound-toggle:hover svg { fill: #fff; }
#sound-toggle .off { display: none; }
#sound-toggle.off .on { display: none; }
#sound-toggle.off .off { display: block; }
#sound-toggle.off svg { fill: #6a6a6a; }
#sound-toggle.off .off { fill: #f2f2f2; }
#save { left: 12px; bottom: 12px; }
#sound-toggle { left: 12px; top: 12px; }
#fire-overlay {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
  image-rendering: pixelated;
}
#bar { position: relative; z-index: 15; }
/* плитка «случайно»: на всю ширину, в центре пятно-«?» */
/* плитка «случайно» — квадрат в две ячейки, знак по центру */
.tile-random {
  grid-column: 1 / -1;
  aspect-ratio: 1;
  grid-template-rows: 1fr auto;
}
.tile-random canvas { width: 88px; height: 88px; align-self: center; }
button:focus-visible { outline: 1px solid #ddd; outline-offset: 3px; }

h2 {
  color: #3d3d3d;
  font-weight: 400;
  margin: 6px 0 5px;
}
#strains h2 { margin: 0 0 8px; }

button {
  cursor: crosshair;
}

/* Кнопка — только надпись. Наведение рисует четыре тонких уголка: один
   псевдоэлемент с рамкой в 1 px, из которого маска оставляет только углы.
   Рамка, а не картинка: браузер сажает её на пиксель экрана при любом
   масштабе, картинка на дробной позиции размывалась. Нажатие (.pressed,
   держит js/skin.js 220 мс) сдвигает уголки на пиксель внутрь. */
button {
  position: relative;
  background: transparent;
  color: #d9d9d9;
  border: 0;
  font: inherit;
  font-size: 11px;
  line-height: 1.4;
  padding: 9px 12px;
  border-radius: 0;
}
/* Уголки: четыре спана (js/ui.js corners) с рамкой в один пиксель экрана.
   Толщина задана в пикселях экрана (1px / dpr): css-пиксель на дробном
   dpr сажался то в один, то в два пикселя, и плечи выходили разной толщины. */
button .corner {
  position: absolute;
  width: 7px;
  height: 7px;
  border: 0 solid #f2f2f2;
  pointer-events: none;
  display: none;
}
button .c0 { top: 0; left: 0; border-top-width: calc(1px / var(--dpr)); border-left-width: calc(1px / var(--dpr)); }
button .c1 { top: 0; right: 0; border-top-width: calc(1px / var(--dpr)); border-right-width: calc(1px / var(--dpr)); }
button .c2 { bottom: 0; left: 0; border-bottom-width: calc(1px / var(--dpr)); border-left-width: calc(1px / var(--dpr)); }
button .c3 { bottom: 0; right: 0; border-bottom-width: calc(1px / var(--dpr)); border-right-width: calc(1px / var(--dpr)); }
button:hover:not(:disabled) { color: #ffffff; }
button:hover:not(:disabled) .corner { display: block; }
button.pressed:not(:disabled) .corner { display: block; border-color: #b3b3b3; }
button.pressed:not(:disabled) .c0 { top: 1px; left: 1px; }
button.pressed:not(:disabled) .c1 { top: 1px; right: 1px; }
button.pressed:not(:disabled) .c2 { bottom: 1px; left: 1px; }
button.pressed:not(:disabled) .c3 { bottom: 1px; right: 1px; }
button:disabled { color: #3a3a3a; }




/* ---------- телефон ---------- */

@media (max-width: 760px), (pointer: coarse) {

  #wrap { padding: 76px 6px 232px; gap: 12px; }

  #status { left: 8px; right: 8px; top: 66px; }

  /* палитра уезжает вниз и листается горизонтально */
  #strains {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%;
    height: auto;
    max-height: 166px;
    overflow-x: auto;
    overflow-y: hidden;
    border-left: 0;
    border-top: 1px solid #191919;
    padding: 8px 10px;
  }
  #strains h2, #strain-info { display: none; }
  #brushes {
    display: grid;
    grid-template-rows: repeat(2, 72px);
    grid-auto-columns: 72px;
    grid-template-columns: none;
    grid-auto-flow: column;
    gap: 6px;
    width: max-content;
  }
  .tile { width: 72px; }
  .tile canvas { width: 48px; }
  .tile-random { width: 150px; grid-row: 1 / 3; grid-column: 1 / 3; aspect-ratio: auto; }
  .tile-random canvas { width: 88px; }


  /* три кнопки одной ширины, прижатые к нижнему краю над палитрой */
  #bar {
    position: fixed;
    left: 6px; right: 6px;
    bottom: 174px;
    gap: 8px;
    z-index: 15;
  }
  #bar button { flex: 1 1 0; min-width: 0; min-height: 46px; }

  #sound-toggle, #save { width: 48px; height: 44px; }
  /* PNG — в правом верхнем углу, напротив звука; низ целиком под палитру */
  #save { left: auto; right: 12px; top: 12px; bottom: auto; }

}

@media (max-height: 620px) and (pointer: coarse) {
  #species { display: none; }
}
