/* Всё крупное, как в остальном ParaAbu: кнопки от 60 px, поле 3×3 — самый
   крупный квадрат, который позволяет экран в обеих ориентациях (disposicion.js).
   Вид — базовый скин исходника X_O_kids: бежевая бумага в клетку, белые клетки
   в рамке, синий крестик и розовый нолик. HUD — одна кнопка звука — поверх. */
:root {
  --violeta: #3b1e5e;
  --papel: #f4f0e8;                  /* фон исходника */
  --rejilla: rgba(60, 50, 35, 0.06); /* его тонкая клетка */
  --marco: #b9a883;                  /* рамка поля исходника */
  --azul: #1e9bff;                   /* под спрайт крестика */
  --rosa: #ff4f98;                   /* под спрайт нолика */
}

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

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--papel);
  color: var(--violeta);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 20px;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; /* долгое нажатие на крестик — без меню «Сохранить картинку» на iOS */
  touch-action: manipulation;
}

.pantalla { position: relative; height: 100%; height: 100dvh; }
/* Экран скрыт, пока main.js не убедится, что сертификат активирован, и не
   загрузит крестик и нолик: иначе первая метка появилась бы пустым местом. */
.pantalla[hidden] { display: none; }

#escenario {
  position: absolute; inset: 0; overflow: hidden;
  background-color: var(--papel);
  background-image:
    linear-gradient(to right, var(--rejilla) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rejilla) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* Щуп safe-area: невидимый блок с отступами env(). main.js читает их и не
   кладёт поле под «чёлку» и полоску жестов. */
#seguro {
  position: absolute; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* HUD поверх поля: одна кнопка звука справа. Плашка не ловит касания —
   только кнопка настоящая. */
.hud {
  position: absolute; z-index: 20;
  top: max(0.5rem, env(safe-area-inset-top));
  left: max(0.6rem, env(safe-area-inset-left));
  right: max(0.6rem, env(safe-area-inset-right));
  display: flex; align-items: center; gap: 0.5rem;
  pointer-events: none;
}

.accion {
  width: 60px; height: 60px; flex: 0 0 60px; aspect-ratio: 1; margin-left: auto;
  display: grid; place-items: center; padding: 0;
  color: var(--violeta); background: #fff; border: 0; border-radius: 50%;
  cursor: pointer; box-shadow: 0 3px 0 rgba(59, 30, 94, 0.18);
  pointer-events: auto;
}
.accion svg { width: 32px; height: 32px; display: block; }
.accion:active { transform: translateY(2px); box-shadow: none; }
.accion .apagado { display: none; }
.accion[aria-pressed="true"] .encendido { display: none; }
.accion[aria-pressed="true"] .apagado { display: block; }

/* Поле: место, сторону и зазор (--hueco) задаёт main.js. Рамка и зазоры —
   фон самого поля, клетки белые, как в исходнике. */
#tablero {
  position: absolute; left: 0; top: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: var(--hueco, 6px); padding: var(--hueco, 6px);
  background: var(--marco);
  border-radius: calc(var(--hueco, 6px) * 4 / 3);
}
.celda { position: relative; background: #fff; }

/* Метка — 72 % клетки, как в исходнике; только что поставленная «выпрыгивает». */
.ficha {
  position: absolute; left: 14%; top: 14%; width: 72%; height: 72%;
  object-fit: contain; pointer-events: none; -webkit-user-drag: none;
}
.ficha.nueva { animation: aparecer 400ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes aparecer {
  from { transform: scale(0.2); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Конец партии. Тройка крестика голубая, тройка бота розовая — под цвета
   спрайтов; при победе поле ещё мягко светится. Без color-mix: его нет в
   старом Safari. */
.celda.ganadora { background: #d6ecff; box-shadow: inset 0 0 0 calc(var(--hueco, 6px) * 0.6) var(--azul); }
.celda.perdedora { background: #ffdcea; box-shadow: inset 0 0 0 calc(var(--hueco, 6px) * 0.6) var(--rosa); }
#tablero.ganado { animation: brillo 1s ease-in-out infinite alternate; }
@keyframes brillo {
  from { box-shadow: 0 0 0 0 rgba(30, 155, 255, 0); }
  to   { box-shadow: 0 0 16px 4px rgba(30, 155, 255, 0.6); }
}
/* Рука обучения (hand.png, 58×85) — та же, что в остальных играх, и «тычет»,
   как в маджонге. Кончик пальца на картинке — 22.4% ширины и 1.2% высоты: на
   столько же и сдвигаем, чтобы JS задавал просто место кончика. */
.mano {
  position: absolute; z-index: 70; pointer-events: none;
  transform-origin: 22% 2%;
  animation: tocar 1.6s ease-in-out infinite;
}
.mano[hidden] { display: none; }
.mano img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 3px 5px rgba(59, 30, 94, 0.45)); }
@keyframes tocar {
  0%, 100% { transform: translate(-22.4%, -1.2%) scale(1); }
  40%      { transform: translate(-22.4%, 15%) scale(0.94); }
  58%      { transform: translate(-22.4%, -1.2%) scale(1); }
}

/* Конец партии: смайл по центру (ширину задаёт main.js — треть короткой
   стороны) и надпись под ним. Поверх поля и HUD, но ниже конфетти. */
.resultado {
  position: absolute; inset: 0; z-index: 75;
  display: grid; place-items: center; align-content: center; gap: 0.8rem;
  padding: 1rem;
  pointer-events: none;
}
.resultado[hidden] { display: none; }
.resultado img {
  display: block; height: auto;
  filter: drop-shadow(0 8px 16px rgba(59, 30, 94, 0.35));
}
.resultado p {
  margin: 0; max-width: 90%; padding: 0.6rem 1.2rem;
  background: rgba(255, 253, 247, 0.95); border-radius: 999px;
  font-size: 1.4rem; font-weight: 800; line-height: 1.25; text-align: center;
  box-shadow: 0 3px 0 rgba(59, 30, 94, 0.18);
}

/* Конфетти на победу (confeti.js) — то же, что в «найди отличия»: полоски
   сыплются сверху. Поверх поля, руки и HUD. */
.confeti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 80; }
.confeti i { position: absolute; top: 0; width: 10px; height: 16px; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  .ficha.nueva { animation: none; }
  #tablero.ganado { animation: none; box-shadow: 0 0 16px 4px rgba(30, 155, 255, 0.6); }
}
