@import url("../numbrix/styles.css");

.pasture-page .game-panel {
  grid-template-columns: minmax(240px, 290px) minmax(0, 1fr);
}

.pasture-page .play-sidebar {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
}

.pasture-page .difficulty-row {
  grid-template-columns: repeat(3, 1fr);
}

.mark-tools {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  min-width: 0;
}

.mark-button {
  min-height: 42px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.mark-button span {
  display: inline-block;
  margin-right: 5px;
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

.mark-button.is-active {
  border-color: rgba(107, 127, 232, 0.55);
  background: rgba(107, 127, 232, 0.22);
  color: var(--ink);
}

.pasture-board {
  --size: 8;
  display: grid;
  grid-template-columns: repeat(var(--size), minmax(0, 1fr));
  grid-template-rows: repeat(var(--size), minmax(0, 1fr));
  gap: clamp(3px, 0.7dvh, 7px);
  width: min(100%, calc(100dvh - 120px), 700px);
  max-width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  padding: clamp(7px, 1.2dvh, 12px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.pasture-cell {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  place-items: center;
  border: 0;
  border-radius: clamp(4px, 0.8dvh, 8px);
  background: var(--pasture);
  color: #fff;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16), 0 2px 4px rgba(0,0,0,0.18);
  transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

.pasture-cell:hover {
  z-index: 1;
  transform: scale(1.06);
  filter: brightness(1.08);
}

.cow-face {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  width: min(72%, 40px);
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: #fff1d5;
  color: #313950;
  font-size: clamp(17px, 3.2vw, 36px);
  font-weight: 900;
  box-shadow: 0 2px 7px rgba(0,0,0,0.2);
  transform: translate(-50%, -50%);
}

.cross-mark {
  position: absolute;
  inset: 50% auto auto 50%;
  color: rgba(255,255,255,0.92);
  font-size: clamp(18px, 4vw, 38px);
  font-weight: 900;
  line-height: 0.8;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transform: translate(-50%, -50%);
}

.auto-cross .cross-mark {
  opacity: 0.66;
}

.pasture-cell.conflict {
  animation: shake 230ms ease-in-out 2;
  box-shadow: inset 0 0 0 3px #ff456c, 0 0 18px rgba(255,69,108,0.65);
}

.pasture-cell.hint {
  animation: pulse 680ms ease-in-out 2;
  box-shadow: inset 0 0 0 3px #ffe491, 0 0 22px rgba(245,194,107,0.8);
}

.modal.is-celebration #victoryNewButton {
  animation: record-button-pulse 1100ms ease-in-out 2;
}

@media (max-width: 760px) {
  .pasture-page .game-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "top"
      "difficulty"
      "status"
      "board"
      "info"
      "marks"
      "controls";
  }

  .pasture-page .topbar,
  .pasture-page .difficulty-row,
  .pasture-page .status-strip,
  .pasture-page .board-wrap,
  .pasture-page .info-row,
  .pasture-page .mark-tools,
  .pasture-page .controls {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .pasture-page .info-row {
    overflow: hidden;
  }

  .pasture-page .message {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pasture-page .seed {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pasture-page .title-block h1 { font-size: 16px; }
  .pasture-page .game-title-logo { width: 30px; height: 30px; }
  .pasture-board {
    width: min(100%, calc(100vw - 30px), calc(100dvh - 315px));
    gap: 3px;
    padding: 5px;
  }
  .mark-tools { grid-area: marks; margin-bottom: 6px; }
  .mark-button { min-height: 34px; font-size: 12px; }
  .mark-button span { font-size: 17px; }
}

@media (max-width: 380px) {
  .pasture-page .game-shell {
    padding: 4px;
  }

  .pasture-page .game-panel {
    padding: 7px;
  }

  .pasture-page .topbar {
    gap: 4px;
  }

  .pasture-page .small-button {
    padding: 0 8px;
  }

  .pasture-page .level-chip {
    min-width: 64px;
    padding: 0 9px;
  }

  .pasture-board {
    width: min(100%, calc(100vw - 22px), calc(100dvh - 303px));
  }
}

@media (max-height: 700px) {
  .pasture-board {
    width: min(100%, calc(100vw - 30px), calc(100dvh - 265px));
  }
}
